Add a bodyPosition param

For blind people, the cookie banner must appear first in the source code. For this reason a bodyPosition parameter with the default value "top" is specified to  manage #tarteaucitronRoot
This commit is contained in:
Carsten Meyer 2020-01-08 15:35:54 +01:00 committed by GitHub
parent 72e7a77a37
commit f2eb28fa0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -214,6 +214,7 @@ var tarteaucitron = {
"cookieName": 'tarteaucitron',
"highPrivacy": true,
"orientation": "middle",
"bodyPosition": "top",
"removeCredit": false,
"showAlertSmall": true,
"cookieslist": true,
@ -443,7 +444,15 @@ var tarteaucitron = {
document.body.appendChild(wrapper);*/
div.id = 'tarteaucitronRoot';
body.appendChild(div, body);
if (tarteaucitron.parameters.bodyPosition === 'top') {
// Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
var bodyFirstChild = body.firstChild;
body.insertBefore(div, bodyFirstChild);
}
else {
// Append tarteaucitron: #tarteaucitronRoot last-child of the body
body.appendChild(div, body);
}
div.innerHTML = html;
//ie compatibility
@ -514,7 +523,15 @@ var tarteaucitron = {
html += '<div id="tarteaucitronPremium"></div>';
div.id = 'tarteaucitronRoot';
body.appendChild(div, body);
if (tarteaucitron.parameters.bodyPosition === 'top') {
// Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
var bodyFirstChild = body.firstChild;
body.insertBefore(div, bodyFirstChild);
}
else {
// Append tarteaucitron: #tarteaucitronRoot last-child of the body
body.appendChild(div, body);
}
div.innerHTML = html;
}
}, 1500);