Merge pull request #401 from nstCactus/patch-3

 Dispatch an event when a service is added.
This commit is contained in:
Amauri CHAMPEAUX 2020-02-05 11:32:07 +01:00 committed by GitHub
commit 4d870d731d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 20 deletions

View File

@ -226,11 +226,11 @@ var tarteaucitron = {
}, },
params = tarteaucitron.parameters; params = tarteaucitron.parameters;
// Step -1 // Step -1
if (typeof tarteaucitronCustomPremium !== 'undefined') { if (typeof tarteaucitronCustomPremium !== 'undefined') {
tarteaucitronCustomPremium(); tarteaucitronCustomPremium();
} }
// Step 0: get params // Step 0: get params
if (params !== undefined) { if (params !== undefined) {
@ -364,7 +364,7 @@ var tarteaucitron = {
html += ' ' + tarteaucitron.lang.privacyUrl; html += ' ' + tarteaucitron.lang.privacyUrl;
html += ' </button>'; html += ' </button>';
} }
//html += ' </span>'; //html += ' </span>';
//html += '</div>'; //html += '</div>';
html += '</div>'; html += '</div>';
@ -384,15 +384,15 @@ var tarteaucitron = {
html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">'; html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
html += ' &#10003; ' + tarteaucitron.lang.acceptAll; html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
html += ' </button>'; html += ' </button>';
if (tarteaucitron.parameters.orientation === 'middle') { if (tarteaucitron.parameters.orientation === 'middle') {
html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">'; html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
html += ' &#10007; ' + tarteaucitron.lang.denyAll; html += ' &#10007; ' + tarteaucitron.lang.denyAll;
html += ' </button>'; html += ' </button>';
html += ' <br/><br/>'; html += ' <br/><br/>';
} }
html += ' <button type="button" id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">'; html += ' <button type="button" id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
html += ' ' + tarteaucitron.lang.personalize; html += ' ' + tarteaucitron.lang.personalize;
html += ' </button>'; html += ' </button>';
@ -454,7 +454,7 @@ var tarteaucitron = {
div.id = 'tarteaucitronRoot'; div.id = 'tarteaucitronRoot';
body.appendChild(div, body); body.appendChild(div, body);
div.innerHTML = html; div.innerHTML = html;
//ie compatibility //ie compatibility
var tacRootAvailableEvent; var tacRootAvailableEvent;
if(typeof(Event) === 'function') { if(typeof(Event) === 'function') {
@ -464,7 +464,7 @@ var tarteaucitron = {
tacRootAvailableEvent.initEvent("tac.root_available", true, true); tacRootAvailableEvent.initEvent("tac.root_available", true, true);
} }
//end ie compatibility //end ie compatibility
window.dispatchEvent(tacRootAvailableEvent); window.dispatchEvent(tacRootAvailableEvent);
if (tarteaucitron.job !== undefined) { if (tarteaucitron.job !== undefined) {
@ -641,6 +641,7 @@ var tarteaucitron = {
} }
tarteaucitron.cookie.checkCount(service.key); tarteaucitron.cookie.checkCount(service.key);
tarteaucitron.sendEvent(service.key + '_added')
}, },
"sendEvent" : function(event_key) { "sendEvent" : function(event_key) {
if(event_key !== undefined) { if(event_key !== undefined) {
@ -839,7 +840,7 @@ var tarteaucitron = {
document.getElementsByTagName('body')[0].classList.add('modal-open'); document.getElementsByTagName('body')[0].classList.add('modal-open');
tarteaucitron.userInterface.focusTrap(); tarteaucitron.userInterface.focusTrap();
tarteaucitron.userInterface.jsSizing('main'); tarteaucitron.userInterface.jsSizing('main');
//ie compatibility //ie compatibility
var tacOpenPanelEvent; var tacOpenPanelEvent;
if(typeof(Event) === 'function') { if(typeof(Event) === 'function') {
@ -849,7 +850,7 @@ var tarteaucitron = {
tacOpenPanelEvent.initEvent("tac.open_panel", true, true); tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
} }
//end ie compatibility //end ie compatibility
window.dispatchEvent(tacOpenPanelEvent); window.dispatchEvent(tacOpenPanelEvent);
}, },
"closePanel": function () { "closePanel": function () {
@ -878,7 +879,7 @@ var tarteaucitron = {
document.getElementById('tarteaucitronCloseAlert').focus(); document.getElementById('tarteaucitronCloseAlert').focus();
} }
document.getElementsByTagName('body')[0].classList.remove('modal-open'); document.getElementsByTagName('body')[0].classList.remove('modal-open');
//ie compatibility //ie compatibility
var tacClosePanelEvent; var tacClosePanelEvent;
if(typeof(Event) === 'function') { if(typeof(Event) === 'function') {
@ -888,7 +889,7 @@ var tarteaucitron = {
tacClosePanelEvent.initEvent("tac.close_panel", true, true); tacClosePanelEvent.initEvent("tac.close_panel", true, true);
} }
//end ie compatibility //end ie compatibility
window.dispatchEvent(tacClosePanelEvent); window.dispatchEvent(tacClosePanelEvent);
}, },
"focusTrap": function() { "focusTrap": function() {
@ -948,7 +949,7 @@ var tarteaucitron = {
tacOpenAlertEvent.initEvent("tac.open_alert", true, true); tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
} }
//end ie compatibility //end ie compatibility
window.dispatchEvent(tacOpenAlertEvent); window.dispatchEvent(tacOpenAlertEvent);
}, },
"closeAlert": function () { "closeAlert": function () {
@ -959,7 +960,7 @@ var tarteaucitron = {
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none'); tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible'); tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
tarteaucitron.userInterface.jsSizing('box'); tarteaucitron.userInterface.jsSizing('box');
//ie compatibility //ie compatibility
var tacCloseAlertEvent; var tacCloseAlertEvent;
if(typeof(Event) === 'function') { if(typeof(Event) === 'function') {
@ -969,7 +970,7 @@ var tarteaucitron = {
tacCloseAlertEvent.initEvent("tac.close_alert", true, true); tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
} }
//end ie compatibility //end ie compatibility
window.dispatchEvent(tacCloseAlertEvent); window.dispatchEvent(tacCloseAlertEvent);
}, },
"toggleCookiesList": function () { "toggleCookiesList": function () {
@ -1362,15 +1363,15 @@ var tarteaucitron = {
var availableLanguages = 'cs,de,en,es,fr,it,nl,pl,pt,ru,el,ro,bg,ja,cn', var availableLanguages = 'cs,de,en,es,fr,it,nl,pl,pt,ru,el,ro,bg,ja,cn',
defaultLanguage = 'en'; defaultLanguage = 'en';
if (tarteaucitronForceLanguage !== '') { if (tarteaucitronForceLanguage !== '') {
if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) { if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
return tarteaucitronForceLanguage; return tarteaucitronForceLanguage;
} }
} }
if (!navigator) { return 'en'; } if (!navigator) { return 'en'; }
var lang = navigator.language || navigator.browserLanguage || var lang = navigator.language || navigator.browserLanguage ||
navigator.systemLanguage || navigator.userLang || null, navigator.systemLanguage || navigator.userLang || null,
userLanguage = lang ? lang.substr(0, 2) : null; userLanguage = lang ? lang.substr(0, 2) : null;