Skip to content

Commit

Permalink
Add a timeout to avoid be sure elem are available
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauriC committed Mar 1, 2024
1 parent 32ba59c commit 6b651fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions tarteaucitron.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,25 +851,29 @@ var tarteaucitron = {

// add info about the services on the main banner
if (tarteaucitron.parameters.partnersList === true && (tarteaucitron.parameters.orientation === "middle" || tarteaucitron.parameters.orientation === "popup")) {
var liPartners = "";
var tarteaucitronPartnersCat = [];
tarteaucitron.job.forEach(function(id) {
if (tarteaucitronPartnersCat[tarteaucitron.services[id].type] === undefined) {
tarteaucitronPartnersCat[tarteaucitron.services[id].type] = true;
liPartners += "<li>" + tarteaucitron.lang[tarteaucitron.services[id].type].title + "</li>";
setTimeout(function() {
var liPartners = "";
var tarteaucitronPartnersCat = [];
tarteaucitron.job.forEach(function (id) {
if (tarteaucitronPartnersCat[tarteaucitron.services[id].type] === undefined) {
tarteaucitronPartnersCat[tarteaucitron.services[id].type] = true;
liPartners += "<li>" + tarteaucitron.lang[tarteaucitron.services[id].type].title + "</li>";
}
});
var tacPartnersInfoParent = document.getElementById('tarteaucitronDisclaimerAlert');
if (tacPartnersInfoParent !== null) {
tacPartnersInfoParent.insertAdjacentHTML('beforeend', '<div class="tarteaucitronPartnersList"><b>' + tarteaucitron.lang.ourpartners + ' (' + tarteaucitron.job.length + ')</b> <ul>' + liPartners + '</ul></div>');
}
});
var tacPartnersInfoParent = document.getElementById('tarteaucitronDisclaimerAlert');
if (tacPartnersInfoParent !== null) {
tacPartnersInfoParent.insertAdjacentHTML('beforeend', '<div class="tarteaucitronPartnersList"><b>' + tarteaucitron.lang.ourpartners + ' (' + tarteaucitron.job.length + ')</b> <ul>' + liPartners + '</ul></div>');
}
}, 100);
}

// add a save button
var tacSaveButtonParent = document.getElementById('tarteaucitronServices');
if (tacSaveButtonParent !== null) {
tacSaveButtonParent.insertAdjacentHTML('beforeend', '<div id="tarteaucitronSave"><button class="tarteaucitronAllow" id="tarteaucitronSaveButton">' + tarteaucitron.lang.save + '</button></div>');
}
setTimeout(function() {
var tacSaveButtonParent = document.getElementById('tarteaucitronServices');
if (tacSaveButtonParent !== null) {
tacSaveButtonParent.insertAdjacentHTML('beforeend', '<div id="tarteaucitronSave"><button class="tarteaucitronAllow" id="tarteaucitronSaveButton">' + tarteaucitron.lang.save + '</button></div>');
}
}, 100);

tarteaucitron.userInterface.color("", true);

Expand Down
2 changes: 1 addition & 1 deletion tarteaucitron.min.js

Large diffs are not rendered by default.

0 comments on commit 6b651fb

Please sign in to comment.