From e58a6ab8d235f8518bcf74c60a4628146370acfd Mon Sep 17 00:00:00 2001 From: nstCactus Date: Wed, 29 Jan 2020 19:57:06 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Dispatch=20an=20event=20when=20a=20?= =?UTF-8?q?service=20is=20added.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tarteaucitron.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index d1547c6..baa60f9 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -226,11 +226,11 @@ var tarteaucitron = { }, params = tarteaucitron.parameters; - // Step -1 - if (typeof tarteaucitronCustomPremium !== 'undefined') { - tarteaucitronCustomPremium(); + // Step -1 + if (typeof tarteaucitronCustomPremium !== 'undefined') { + tarteaucitronCustomPremium(); } - + // Step 0: get params if (params !== undefined) { @@ -364,7 +364,7 @@ var tarteaucitron = { html += ' ' + tarteaucitron.lang.privacyUrl; html += ' '; } - + //html += ' '; //html += ''; html += ''; @@ -384,15 +384,15 @@ var tarteaucitron = { html += ' '; - - + + if (tarteaucitron.parameters.orientation === 'middle') { html += ' '; html += '

'; } - + html += ' '; @@ -454,7 +454,7 @@ var tarteaucitron = { div.id = 'tarteaucitronRoot'; body.appendChild(div, body); div.innerHTML = html; - + //ie compatibility var tacRootAvailableEvent; if(typeof(Event) === 'function') { @@ -464,7 +464,7 @@ var tarteaucitron = { tacRootAvailableEvent.initEvent("tac.root_available", true, true); } //end ie compatibility - + window.dispatchEvent(tacRootAvailableEvent); if (tarteaucitron.job !== undefined) { @@ -641,6 +641,7 @@ var tarteaucitron = { } tarteaucitron.cookie.checkCount(service.key); + tarteaucitron.sendEvent(service.key + '_added') }, "sendEvent" : function(event_key) { if(event_key !== undefined) { @@ -838,7 +839,7 @@ var tarteaucitron = { document.getElementsByTagName('body')[0].classList.add('modal-open'); tarteaucitron.userInterface.focusTrap(); tarteaucitron.userInterface.jsSizing('main'); - + //ie compatibility var tacOpenPanelEvent; if(typeof(Event) === 'function') { @@ -848,7 +849,7 @@ var tarteaucitron = { tacOpenPanelEvent.initEvent("tac.open_panel", true, true); } //end ie compatibility - + window.dispatchEvent(tacOpenPanelEvent); }, "closePanel": function () { @@ -877,7 +878,7 @@ var tarteaucitron = { document.getElementById('tarteaucitronCloseAlert').focus(); } document.getElementsByTagName('body')[0].classList.remove('modal-open'); - + //ie compatibility var tacClosePanelEvent; if(typeof(Event) === 'function') { @@ -887,7 +888,7 @@ var tarteaucitron = { tacClosePanelEvent.initEvent("tac.close_panel", true, true); } //end ie compatibility - + window.dispatchEvent(tacClosePanelEvent); }, "focusTrap": function() { @@ -947,7 +948,7 @@ var tarteaucitron = { tacOpenAlertEvent.initEvent("tac.open_alert", true, true); } //end ie compatibility - + window.dispatchEvent(tacOpenAlertEvent); }, "closeAlert": function () { @@ -958,7 +959,7 @@ var tarteaucitron = { tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none'); tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible'); tarteaucitron.userInterface.jsSizing('box'); - + //ie compatibility var tacCloseAlertEvent; if(typeof(Event) === 'function') { @@ -968,7 +969,7 @@ var tarteaucitron = { tacCloseAlertEvent.initEvent("tac.close_alert", true, true); } //end ie compatibility - + window.dispatchEvent(tacCloseAlertEvent); }, "toggleCookiesList": function () { @@ -1361,15 +1362,15 @@ var tarteaucitron = { var availableLanguages = 'cs,de,en,es,fr,it,nl,pl,pt,ru,el,ro,bg,ja,cn', defaultLanguage = 'en'; - + if (tarteaucitronForceLanguage !== '') { if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) { return tarteaucitronForceLanguage; } } - + if (!navigator) { return 'en'; } - + var lang = navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLang || null, userLanguage = lang ? lang.substr(0, 2) : null;