From 363808ff4ebdee8459dba6593fe7cee709eafe37 Mon Sep 17 00:00:00 2001 From: MewenLeHo Date: Mon, 18 Oct 2021 17:02:36 +0200 Subject: [PATCH] fix(#831): checkboxes display when user accept or deny cookies --- site/assets/js/tac.js | 47 +++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/site/assets/js/tac.js b/site/assets/js/tac.js index 0b55eed6f4..bd9677b59c 100644 --- a/site/assets/js/tac.js +++ b/site/assets/js/tac.js @@ -45,49 +45,44 @@ }, { once: true }) document.addEventListener( - "googletagmanager_added", + 'googletagmanager_added', function () { var ask = document.querySelector( '#googletagmanagerLine .tarteaucitronAsk' - ); + ) var choiceEvent = - 'tarteaucitron.userInterface.respond(document.getElementById("googletagmanagerAllowed"),document.getElementById("googletagmanagerAllowed").checked);'; + 'tarteaucitron.userInterface.respond(document.getElementById("googletagmanagerAllowed"),document.getElementById("googletagmanagerAllowed").checked);' var toggle = document .createRange() .createContextualFragment( '
' - ); - ask.innerHTML = ""; - ask.append(toggle); + ) + ask.innerHTML = '' + ask.append(toggle) - var allowConsentButton = document.querySelector('.tarteaucitronAllow') - var denyConsentButton = document.querySelector('.tarteaucitronDeny') + var allowConsentButton = document.querySelector('#tarteaucitronAllAllowed') + var denyConsentButton = document.querySelector('#tarteaucitronAllDenied') var checkboxes = document.querySelectorAll('.form-check-input') - [allowConsentButton].forEach(function (button) { - button.addEventListener('click', function () { - for (var i = 0; i < checkboxes.length; i++) { - if (!checkboxes.checked) { - checkboxes[i].checked = true; - } + allowConsentButton.addEventListener('click', function () { + for (var i = 0; i < checkboxes.length; i++) { + if (!checkboxes.checked) { + checkboxes[i].checked = true } - }) - }); - - [denyConsentButton].forEach(function (button) { - button.addEventListener('click', function () { - for (var i = 0; i < checkboxes.length; i++) { - if (checkboxes.checked !== true) { - checkboxes[i].checked = false; - } + } + }) + denyConsentButton.addEventListener('click', function () { + for (var i = 0; i < checkboxes.length; i++) { + if (checkboxes.checked !== true) { + checkboxes[i].checked = false } - }); - }); + } + }) }, { once: true } - ); + ) })() if (typeof tarteaucitron !== 'undefined') {