From c75862884a71dd3c6b254b4acc5d3cb7f4d9859e Mon Sep 17 00:00:00 2001 From: Nicolas Zerr Date: Wed, 4 Oct 2023 14:27:08 +0200 Subject: [PATCH 1/3] A11Y > add semantic role (paragraph) to disclaimer --- tarteaucitron.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index d3c8fe3d..f53eb0a4 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -422,7 +422,7 @@ var tarteaucitron = { if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) { html += '
'; //html += '
'; - html += ' '; + html += ' '; html += ' ' + tarteaucitron.lang.alertBigPrivacy; html += ' '; //html += ' '; @@ -442,7 +442,7 @@ var tarteaucitron = { } else { html += '
'; //html += '
'; - html += ' '; + html += ' '; if (tarteaucitron.parameters.highPrivacy) { html += ' ' + tarteaucitron.lang.alertBigPrivacy; From 4be35a65824f6ae39815fbb7b5c39ab2cb770fee Mon Sep 17 00:00:00 2001 From: Nicolas Zerr Date: Wed, 4 Oct 2023 15:52:56 +0200 Subject: [PATCH 2/3] A11Y > Cookie banner identified as dialog when orientation=middle|popup + focus trap --- tarteaucitron.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index f53eb0a4..6dc2b525 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -308,6 +308,7 @@ var tarteaucitron = { html = '', index, orientation = 'Top', + modalAttrs = '', cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'], i; @@ -419,8 +420,12 @@ var tarteaucitron = { orientation = 'Bottom'; } + if (tarteaucitron.parameters.orientation === 'middle' || tarteaucitron.parameters.orientation === 'popup') { + modalAttrs = ' role="dialog" aria-modal="true" aria-labelledby="tac_title"'; + } + if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) { - html += '
'; + html += '
'; //html += '
'; html += ' '; html += ' ' + tarteaucitron.lang.alertBigPrivacy; @@ -440,7 +445,7 @@ var tarteaucitron = { //html += '
'; html += '
'; } else { - html += '
'; + html += '
'; //html += '
'; html += ' '; @@ -985,6 +990,10 @@ var tarteaucitron = { if (property == "display" && value == "block" && id == "tarteaucitronBack") { document.getElementById(id).style["opacity"] = "0.7"; } + + if (property == "display" && value == "block" && id == "tarteaucitronAlertBig" && (tarteaucitron.parameters.orientation == "middle"|| tarteaucitron.parameters.orientation == "popup")) { + tarteaucitron.userInterface.focusTrap('tarteaucitronAlertBig'); + } } } }, @@ -1258,7 +1267,7 @@ var tarteaucitron = { if (document.getElementsByTagName('body')[0].classList !== undefined) { document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open'); } - tarteaucitron.userInterface.focusTrap(); + tarteaucitron.userInterface.focusTrap('tarteaucitron'); tarteaucitron.userInterface.jsSizing('main'); //ie compatibility @@ -1327,7 +1336,7 @@ var tarteaucitron = { if (typeof(window.dispatchEvent) === 'function') {window.dispatchEvent(tacClosePanelEvent);} }, - "focusTrap": function() { + "focusTrap": function(parentElement) { "use strict"; var focusableEls, @@ -1335,7 +1344,7 @@ var tarteaucitron = { lastFocusableEl, filtered; - focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button'); + focusableEls = document.getElementById(parentElement).querySelectorAll('a[href], button'); filtered = []; // get only visible items @@ -1349,7 +1358,7 @@ var tarteaucitron = { lastFocusableEl = filtered[filtered.length - 1]; //loop focus inside tarteaucitron - document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) { + document.getElementById(parentElement).addEventListener("keydown", function (evt) { if ( evt.key === 'Tab' || evt.keyCode === 9 ) { From 1ff5dad5c7780d41a26125bc1ac85324b63c49df Mon Sep 17 00:00:00 2001 From: Nicolas Zerr Date: Wed, 4 Oct 2023 16:46:17 +0200 Subject: [PATCH 3/3] A11Y > fix focus move on click on Allow in site --- tarteaucitron.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tarteaucitron.js b/tarteaucitron.js index 6dc2b525..d590e902 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -783,6 +783,15 @@ var tarteaucitron = { }); } + // accessibility: on click on "Allow" in the site (not in TAC module), move focus to the loaded service's parent + var allowBtnsInSite = document.querySelectorAll(".tarteaucitronAllow:not(#tarteaucitronRoot .tarteaucitronAllow)"); + for (i = 0; i < allowBtnsInSite.length; i++) { + tarteaucitron.addClickEventToElement(allowBtnsInSite[i], function () { + this.closest('.tac_activate').parentNode.setAttribute("tabindex","-1"); + this.closest('.tac_activate').parentNode.focus(); + }); + } + var allowBtns = document.getElementsByClassName("tarteaucitronAllow"); for (i = 0; i < allowBtns.length; i++) { tarteaucitron.addClickEventToElement(allowBtns[i], function () {