From 7ddd28b0632bba37f3a20f5ee64d28568b12c490 Mon Sep 17 00:00:00 2001 From: MewenLeHo Date: Wed, 20 Oct 2021 14:43:14 +0200 Subject: [PATCH] fix(#831): checkboxes display when user accept or deny cookies --- site/assets/js/tac.js | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/site/assets/js/tac.js b/site/assets/js/tac.js index bd9677b59c..1f24970019 100644 --- a/site/assets/js/tac.js +++ b/site/assets/js/tac.js @@ -38,30 +38,11 @@ alert.querySelector('.tarteaucitronDeny').innerHTML = tarteaucitron.lang.denyAll }, { once: true }) - window.addEventListener('tac.open_panel', function () { - document.querySelectorAll('#tarteaucitronServices_api button').forEach(function (button) { - button.classList.add('btn', 'btn-sm', 'ms-2') - }) - }, { once: true }) - - document.addEventListener( - 'googletagmanager_added', + window.addEventListener('tac.open_panel', function () { - var ask = document.querySelector( - '#googletagmanagerLine .tarteaucitronAsk' - ) - var choiceEvent = - 'tarteaucitron.userInterface.respond(document.getElementById("googletagmanagerAllowed"),document.getElementById("googletagmanagerAllowed").checked);' - var toggle = document - .createRange() - .createContextualFragment( - '
' - ) - ask.innerHTML = '' - ask.append(toggle) - + document.querySelectorAll('#tarteaucitronServices_api button').forEach(function (button) { + button.classList.add('btn', 'btn-sm', 'ms-2') + }) var allowConsentButton = document.querySelector('#tarteaucitronAllAllowed') var denyConsentButton = document.querySelector('#tarteaucitronAllDenied') var checkboxes = document.querySelectorAll('.form-check-input') @@ -83,6 +64,29 @@ }, { once: true } ) + + document.addEventListener( + 'googletagmanager_added', + function () { + var ask = document.querySelector( + '#googletagmanagerLine .tarteaucitronAsk' + ) + var choiceEvent = + 'tarteaucitron.userInterface.respond(document.getElementById(\'googletagmanagerAllowed\'),document.getElementById(\'googletagmanagerAllowed\').checked);' + var toggle = document + .createRange() + .createContextualFragment( + '
' + ) + ask.innerHTML = '' + ask.append(toggle) + }, + { once: true } + ) })() if (typeof tarteaucitron !== 'undefined') {