From affafafe37375997288a9a254c204885272de157 Mon Sep 17 00:00:00 2001 From: Jason Benedetti Date: Thu, 22 Aug 2019 14:49:16 +0200 Subject: [PATCH] Dispatch JS events at crucial display steps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FR : Ajout d'évènements JS à différents moments du cycle de vie de tarteaucitron. Permet d'ajouter de la logique métier personnalisée à différentes étapes. EN : Add JS events to many moments of tarteaucitron life cycle. Allow to add personalized business logic to different steps. --- tarteaucitron.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tarteaucitron.js b/tarteaucitron.js index e480c63..b2284c2 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -417,6 +417,9 @@ var tarteaucitron = { body.appendChild(div, body); div.innerHTML = html; + var tacRootAvailableEvent = new Event("tac.root_available"); + window.dispatchEvent(tacRootAvailableEvent); + if (tarteaucitron.job !== undefined) { tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job); for (index = 0; index < tarteaucitron.job.length; index += 1) { @@ -762,6 +765,9 @@ var tarteaucitron = { document.getElementsByTagName('body')[0].classList.add('modal-open'); tarteaucitron.userInterface.focusTrap(); tarteaucitron.userInterface.jsSizing('main'); + + var tacOpenPanelEvent = new Event("tac.open_panel"); + window.dispatchEvent(tacOpenPanelEvent); }, "closePanel": function () { "use strict"; @@ -787,6 +793,8 @@ var tarteaucitron = { //document.getElementById('contentWrapper').setAttribute("aria-hidden", "false"); document.getElementsByTagName('body')[0].classList.remove('modal-open'); + var tacClosePanelEvent = new Event("tac.close_panel"); + window.dispatchEvent(tacClosePanelEvent); }, "focusTrap": function() { "use strict"; @@ -834,6 +842,9 @@ var tarteaucitron = { tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block'); tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none'); tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block'); + + var tacOpenAlertEvent = new Event("tac.open_alert"); + window.dispatchEvent(tacOpenAlertEvent); }, "closeAlert": function () { "use strict"; @@ -842,6 +853,9 @@ var tarteaucitron = { tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block'); tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none'); tarteaucitron.userInterface.jsSizing('box'); + + var tacCloseAlertEvent = new Event("tac.close_alert"); + window.dispatchEvent(tacCloseAlertEvent); }, "toggleCookiesList": function () { "use strict";