/*jslint browser: true, evil: true */
function onScroll(scrollPos) {
var heightPosition;
if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
if (scrollPos > (screen.height * 2)) {
tarteaucitron.userInterface.respondAll(true);
} else if (scrollPos > (screen.height / 2)) {
document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig;
}
if (tarteaucitron.orientation === 'top') {
document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
} else {
document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
}
document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
}
}
}
// define correct path for files inclusion
var scripts = document.getElementsByTagName('script'),
path = scripts[scripts.length - 1].src.split('?')[0],
tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
timeExipre = 31536000000,
tarteaucitronProLoadServices,
tarteaucitronNoAdBlocker = false;
var tarteaucitron = {
"version": 20181023,
"cdn": cdn,
"user": {},
"lang": {},
"services": {},
"added": [],
"idprocessed": [],
"state": [],
"launch": [],
"parameters": {},
"isAjax": false,
"reloadThePage": false,
"events": {
"init": function () {},
"load": function () {},
},
"init": function (params) {
"use strict";
var origOpen;
tarteaucitron.parameters = params;
if (alreadyLaunch === 0) {
alreadyLaunch = 1;
if (window.addEventListener) {
window.addEventListener("load", function () {
tarteaucitron.load();
tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
elem.addEventListener("click", function (event) {
tarteaucitron.userInterface.openPanel();
event.preventDefault();
}, false);
}, true);
}, false);
window.addEventListener("scroll", function () {
var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
heightPosition;
if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
if (scrollPos > (screen.height * 2)) {
tarteaucitron.userInterface.respondAll(true);
} else if (scrollPos > (screen.height / 2)) {
document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig;
}
if (tarteaucitron.orientation === 'top') {
document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
} else {
document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
}
document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
}
}
}, false);
window.addEventListener("keydown", function (evt) {
if (evt.keyCode === 27) {
tarteaucitron.userInterface.closePanel();
}
}, false);
window.addEventListener("hashchange", function () {
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
tarteaucitron.userInterface.openPanel();
}
}, false);
window.addEventListener("resize", function () {
if (document.getElementById('tarteaucitron') !== null) {
if (document.getElementById('tarteaucitron').style.display === 'block') {
tarteaucitron.userInterface.jsSizing('main');
}
}
if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
tarteaucitron.userInterface.jsSizing('cookie');
}
}
}, false);
} else {
window.attachEvent("onload", function () {
tarteaucitron.load();
tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
elem.attachEvent("onclick", function (event) {
tarteaucitron.userInterface.openPanel();
event.preventDefault();
});
}, true);
});
window.attachEvent("onscroll", function () {
var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
heightPosition;
if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
if (scrollPos > (screen.height * 2)) {
tarteaucitron.userInterface.respondAll(true);
} else if (scrollPos > (screen.height / 2)) {
document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig;
}
if (tarteaucitron.orientation === 'top') {
document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
} else {
document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
}
document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
}
}
});
window.attachEvent("onkeydown", function (evt) {
if (evt.keyCode === 27) {
tarteaucitron.userInterface.closePanel();
}
if ( evt.keyCode === 9 && focusableEls.indexOf(evt.target) >= 0) {
if ( evt.shiftKey ) /* shift + tab */ {
if (document.activeElement === firstFocusableEl) {
lastFocusableEl.focus();
evt.preventDefault();
}
} else /* tab */ {
if (document.activeElement === lastFocusableEl) {
firstFocusableEl.focus();
evt.preventDefault();
}
}
}
});
window.attachEvent("onhashchange", function () {
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
tarteaucitron.userInterface.openPanel();
}
});
window.attachEvent("onresize", function () {
if (document.getElementById('tarteaucitron') !== null) {
if (document.getElementById('tarteaucitron').style.display === 'block') {
tarteaucitron.userInterface.jsSizing('main');
}
}
if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
tarteaucitron.userInterface.jsSizing('cookie');
}
}
});
}
if (typeof XMLHttpRequest !== 'undefined') {
origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
if (window.addEventListener) {
this.addEventListener("load", function () {
if (typeof tarteaucitronProLoadServices === 'function') {
tarteaucitronProLoadServices();
}
}, false);
} else if (typeof this.attachEvent !== 'undefined') {
this.attachEvent("onload", function () {
if (typeof tarteaucitronProLoadServices === 'function') {
tarteaucitronProLoadServices();
}
});
} else {
if (typeof tarteaucitronProLoadServices === 'function') {
setTimeout(tarteaucitronProLoadServices, 1000);
}
}
try {
origOpen.apply(this, arguments);
} catch (err) {}
};
}
}
if(tarteaucitron.events.init) {
tarteaucitron.events.init();
}
},
"load": function () {
"use strict";
var cdn = tarteaucitron.cdn,
language = tarteaucitron.getLanguage(),
pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js?v=' + tarteaucitron.version,
pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
linkElement = document.createElement('link'),
defaults = {
"adblocker": false,
"hashtag": '#tarteaucitron',
"cookieName": 'tarteaucitron',
"highPrivacy": false,
"orientation": "top",
"removeCredit": false,
"showAlertSmall": true,
"cookieslist": true,
"handleBrowserDNTRequest": false,
"AcceptAllCta" : false,
"moreInfoLink": true,
"privacyUrl": "",
"useExternalCss": false
},
params = tarteaucitron.parameters;
// Step 0: get params
if (params !== undefined) {
for (var k in defaults) {
if(!tarteaucitron.parameters.hasOwnProperty(k)) {
tarteaucitron.parameters[k] = defaults[k];
}
}
}
// global
tarteaucitron.orientation = tarteaucitron.parameters.orientation;
tarteaucitron.hashtag = tarteaucitron.parameters.hashtag;
tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
// Step 1: load css
if ( !tarteaucitron.parameters.useExternalCss ) {
linkElement.rel = 'stylesheet';
linkElement.type = 'text/css';
linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
document.getElementsByTagName('head')[0].appendChild(linkElement);
}
// Step 2: load language and services
tarteaucitron.addScript(pathToLang, '', function () {
if(tarteaucitronCustomText !== ''){
tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
}
tarteaucitron.addScript(pathToServices, '', function () {
var body = document.body,
div = document.createElement('div'),
html = '',
index,
orientation = 'Top',
cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
i;
cat = cat.sort(function (a, b) {
if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
return 0;
});
// Step 3: prepare the html
html += '
';
html += ' ';
html += '';
html += '
';
html += ' '
html += ' '
html += ' ' + tarteaucitron.lang.close;
html += ' ';
html += '
';
html += '
';
html += '
'+ tarteaucitron.lang.title + ' ';
html += '
';
html += ' ' + tarteaucitron.lang.disclaimer;
if (tarteaucitron.parameters.privacyUrl !== "") {
html += ' ';
html += ' ';
html += ' ' + tarteaucitron.lang.privacyUrl;
html += ' ';
}
html += '
';
html += '
';
html += ' ' + tarteaucitron.lang.all + ' ';
html += '
';
html += '
';
html += '
';
html += '
';
html += '
';
html += '
';
if (tarteaucitron.parameters.orientation === 'bottom') {
orientation = 'Bottom';
}
if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
html += '';
html += ' ';
html += ' ' + tarteaucitron.lang.alertBigPrivacy;
html += ' ';
html += ' ';
html += ' ' + tarteaucitron.lang.personalize;
html += ' ';
if (tarteaucitron.parameters.privacyUrl !== "") {
html += ' ';
html += ' ' + tarteaucitron.lang.privacyUrl;
html += ' ';
}
html += '
';
} else {
html += '';
html += '
';
if (tarteaucitron.parameters.highPrivacy) {
html += ' ' + tarteaucitron.lang.alertBigPrivacy;
} else {
html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
}
html += ' ';
html += '
';
html += ' '
html += ' '
html += ' ' + tarteaucitron.lang.acceptAll;
html += ' ';
html += '
';
html += ' ' + tarteaucitron.lang.personalize;
html += ' ';
if (tarteaucitron.parameters.privacyUrl !== "") {
html += '
';
html += ' ' + tarteaucitron.lang.privacyUrl;
html += ' ';
}
html += '
';
html += '
';
}
if (tarteaucitron.parameters.showAlertSmall === true) {
html += '';
html += '
';
html += ' ' + tarteaucitron.lang.alertSmall;
html += ' ';
html += ' ';
html += ' ';
html += ' ';
html += ' ';
if (tarteaucitron.parameters.cookieslist === true) {
html += ' 0 ';
html += '
';
html += '
';
html += ' ' + tarteaucitron.lang.close;
html += ' ';
html += '
';
html += ' 0 cookie ';
html += '
';
html += '
';
html += '
';
} else {
html += '
';
}
html += '';
}
tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) {
// create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
/*var wrapper = document.createElement('div');
wrapper.id = "contentWrapper";
while (document.body.firstChild)
{
wrapper.appendChild(document.body.firstChild);
}
// Append the wrapper to the body
document.body.appendChild(wrapper);*/
div.id = 'tarteaucitronRoot';
body.appendChild(div, body);
div.innerHTML = html;
if (tarteaucitron.job !== undefined) {
tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
for (index = 0; index < tarteaucitron.job.length; index += 1) {
tarteaucitron.addService(tarteaucitron.job[index]);
}
} else {
tarteaucitron.job = []
}
tarteaucitron.isAjax = true;
tarteaucitron.job.push = function (id) {
// ie <9 hack
if (typeof tarteaucitron.job.indexOf === 'undefined') {
tarteaucitron.job.indexOf = function (obj, start) {
var i,
j = this.length;
for (i = (start || 0); i < j; i += 1) {
if (this[i] === obj) { return i; }
}
return -1;
};
}
if (tarteaucitron.job.indexOf(id) === -1) {
Array.prototype.push.call(this, id);
}
tarteaucitron.launch[id] = false;
tarteaucitron.addService(id);
};
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
tarteaucitron.userInterface.openPanel();
}
tarteaucitron.cookie.number();
setInterval(tarteaucitron.cookie.number, 60000);
}
}, tarteaucitron.parameters.adblocker);
if (tarteaucitron.parameters.adblocker === true) {
setTimeout(function () {
if (tarteaucitronNoAdBlocker === false) {
html = '';
html += '
';
html += ' ' + tarteaucitron.lang.adblock + ' ';
html += ' ' + tarteaucitron.lang.adblock_call + ' ';
html += '
';
html += '
';
html += ' ' + tarteaucitron.lang.reload;
html += ' ';
html += '
';
html += '
';
// create wrapper container
/*var wrapper = document.createElement('div');
wrapper.id = "contentWrapper";
while (document.body.firstChild)
{
wrapper.appendChild(document.body.firstChild);
}
// Append the wrapper to the body
document.body.appendChild(wrapper);*/
div.id = 'tarteaucitronRoot';
body.appendChild(div, body);
div.innerHTML = html;
}
}, 1500);
}
});
});
if(tarteaucitron.events.load) {
tarteaucitron.events.load();
}
},
"addService": function (serviceId) {
"use strict";
var html = '',
s = tarteaucitron.services,
service = s[serviceId],
cookie = tarteaucitron.cookie.read(),
hostname = document.location.hostname,
hostRef = document.referrer.split('/')[2],
isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl) ? true : false,
isAutostart = (!service.needConsent) ? true : false,
isWaiting = (cookie.indexOf(service.key + '=wait') >= 0) ? true : false,
isDenied = (cookie.indexOf(service.key + '=false') >= 0) ? true : false,
isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false,
isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0) ? true : false,
isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1") ? true : false;
if (tarteaucitron.added[service.key] !== true) {
tarteaucitron.added[service.key] = true;
html += '';
html += ' ';
html += '
' + service.name + ' ';
html += '
';
if (tarteaucitron.parameters.moreInfoLink == true) {
var link = 'https://opt-out.ferank.eu/service/' + service.key + '/';
if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
link = service.readmoreLink;
}
if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
link = tarteaucitron.parameters.readmoreLink;
}
html += '
';
html += ' ' + tarteaucitron.lang.source;
html += ' ';
}
html += '
';
html += ' ';
html += '
';
html += ' '
html += ' '
html += ' ' + tarteaucitron.lang.allow + '';
html += ' ';
html += '
';
html += ' '
html += ' '
html += ' ' + tarteaucitron.lang.deny;
html += ' ';
html += '
';
html += ' ';
tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
}
tarteaucitron.userInterface.order(service.type);
}
tarteaucitron.pro('!' + service.key + '=' + isAllowed);
// allow by default for non EU
if (isResponded === false && tarteaucitron.user.bypass === true) {
isAllowed = true;
tarteaucitron.cookie.create(service.key, true);
}
if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
if (!isAllowed) {
tarteaucitron.cookie.create(service.key, true);
}
if (tarteaucitron.launch[service.key] !== true) {
tarteaucitron.launch[service.key] = true;
service.js();
}
tarteaucitron.state[service.key] = true;
tarteaucitron.userInterface.color(service.key, true);
} else if (isDenied) {
if (typeof service.fallback === 'function') {
service.fallback();
}
tarteaucitron.state[service.key] = false;
tarteaucitron.userInterface.color(service.key, false);
} else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
tarteaucitron.cookie.create(service.key, 'false');
if (typeof service.fallback === 'function') {
service.fallback();
}
tarteaucitron.state[service.key] = false;
tarteaucitron.userInterface.color(service.key, false);
} else if (!isResponded) {
tarteaucitron.cookie.create(service.key, 'wait');
if (typeof service.fallback === 'function') {
service.fallback();
}
tarteaucitron.userInterface.color(service.key, 'wait');
tarteaucitron.userInterface.openAlert();
}
tarteaucitron.cookie.checkCount(service.key);
},
"cleanArray": function cleanArray(arr) {
"use strict";
var i,
len = arr.length,
out = [],
obj = {},
s = tarteaucitron.services;
for (i = 0; i < len; i += 1) {
if (!obj[arr[i]]) {
obj[arr[i]] = {};
if (tarteaucitron.services[arr[i]] !== undefined) {
out.push(arr[i]);
}
}
}
out = out.sort(function (a, b) {
if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
return 0;
});
return out;
},
"userInterface": {
"css": function (id, property, value) {
"use strict";
if (document.getElementById(id) !== null) {
document.getElementById(id).style[property] = value;
}
},
"respondAll": function (status) {
"use strict";
var s = tarteaucitron.services,
service,
key,
index = 0;
for (index = 0; index < tarteaucitron.job.length; index += 1) {
service = s[tarteaucitron.job[index]];
key = service.key;
if (tarteaucitron.state[key] !== status) {
if (status === false && tarteaucitron.launch[key] === true) {
tarteaucitron.reloadThePage = true;
}
if (tarteaucitron.launch[key] !== true && status === true) {
tarteaucitron.pro('!' + key + '=engage');
tarteaucitron.launch[key] = true;
tarteaucitron.services[key].js();
}
tarteaucitron.state[key] = status;
tarteaucitron.cookie.create(key, status);
tarteaucitron.userInterface.color(key, status);
}
}
},
"respond": function (el, status) {
"use strict";
var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
// return if same state
if (tarteaucitron.state[key] === status) {
return;
}
if (status === false && tarteaucitron.launch[key] === true) {
tarteaucitron.reloadThePage = true;
}
// if not already launched... launch the service
if (status === true) {
if (tarteaucitron.launch[key] !== true) {
tarteaucitron.pro('!' + key + '=engage');
tarteaucitron.launch[key] = true;
tarteaucitron.services[key].js();
}
}
tarteaucitron.state[key] = status;
tarteaucitron.cookie.create(key, status);
tarteaucitron.userInterface.color(key, status);
},
"color": function (key, status) {
"use strict";
var gray = '#808080',
greenDark = '#32B35E',
greenLight = '#E6FFE2',
redDark = '#FF5652',
redLight = '#FFE2E2',
yellowDark = '#FBDA26',
c = 'tarteaucitron',
nbDenied = 0,
nbPending = 0,
nbAllowed = 0,
sum = tarteaucitron.job.length,
index;
if (status === true) {
tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '1px solid ' + greenDark);
tarteaucitron.userInterface.css(key + 'Allowed', 'borderColor', greenDark);
tarteaucitron.userInterface.css(key + 'Allowed', 'color', greenDark);
tarteaucitron.userInterface.css(key + 'Allowed', 'fill', greenDark);
tarteaucitron.userInterface.css(key + 'Denied', 'borderColor', gray);
tarteaucitron.userInterface.css(key + 'Denied', 'color', gray);
tarteaucitron.userInterface.css(key + 'Denied', 'fill', gray);
document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
} else if (status === false) {
tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '1px solid ' + redDark);
tarteaucitron.userInterface.css(key + 'Allowed', 'color', gray);
tarteaucitron.userInterface.css(key + 'Allowed', 'fill', gray);
tarteaucitron.userInterface.css(key + 'Allowed', 'borderColor', gray);
tarteaucitron.userInterface.css(key + 'Denied', 'color', redDark);
tarteaucitron.userInterface.css(key + 'Denied', 'fill', redDark);
tarteaucitron.userInterface.css(key + 'Denied', 'borderColor', redDark);
document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
}
// check if all services are allowed
for (index = 0; index < sum; index += 1) {
if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
nbDenied += 1;
} else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
nbPending += 1;
} else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
nbAllowed += 1;
}
}
tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
if (nbDenied === 0 && nbPending === 0) {
tarteaucitron.userInterface.css(c + 'AllAllowed', 'borderColor', greenDark);
tarteaucitron.userInterface.css(c + 'AllAllowed', 'color', greenDark);
tarteaucitron.userInterface.css(c + 'AllAllowed', 'fill', greenDark);
tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '0.4');
tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '1');
} else if (nbAllowed === 0 && nbPending === 0) {
tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '0.4');
tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '1');
tarteaucitron.userInterface.css(c + 'AllDenied', 'borderColor', redDark);
tarteaucitron.userInterface.css(c + 'AllDenied', 'color', redDark);
tarteaucitron.userInterface.css(c + 'AllDenied', 'fill', redDark);
} else {
tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '1');
tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '1');
}
// close the alert if all service have been reviewed
if (nbPending === 0) {
tarteaucitron.userInterface.closeAlert();
}
if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
}
if (status === true) {
if (document.getElementById('tacCL' + key) !== null) {
document.getElementById('tacCL' + key).innerHTML = '...';
}
setTimeout(function () {
tarteaucitron.cookie.checkCount(key);
}, 2500);
} else {
tarteaucitron.cookie.checkCount(key);
}
},
"openPanel": function () {
"use strict";
tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
document.getElementById('tarteaucitronClosePanel').focus();
//document.getElementById('contentWrapper').setAttribute("aria-hidden", "true");
document.getElementsByTagName('body')[0].classList.add('modal-open');
tarteaucitron.userInterface.focusTrap();
tarteaucitron.userInterface.jsSizing('main');
},
"closePanel": function () {
"use strict";
if (document.location.hash === tarteaucitron.hashtag) {
document.location.hash = '';
}
tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
elem.style.display = 'none';
}, true);
if (tarteaucitron.reloadThePage === true) {
window.location.reload();
} else {
tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
}
if (document.getElementById('tarteaucitronCloseAlert') !== null) {
document.getElementById('tarteaucitronCloseAlert').focus();
}
//document.getElementById('contentWrapper').setAttribute("aria-hidden", "false");
document.getElementsByTagName('body')[0].classList.remove('modal-open');
},
"focusTrap": function() {
"use strict";
var focusableEls,
firstFocusableEl,
lastFocusableEl,
filtered;
focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
filtered = [];
// get only visible items
for (var i = 0, max = focusableEls.length; i < max; i++) {
if (focusableEls[i].offsetHeight > 0) {
filtered.push(focusableEls[i]);
}
}
firstFocusableEl = filtered[0];
lastFocusableEl = filtered[filtered.length - 1];
//loop focus inside tarteaucitron
document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
if ( evt.shiftKey ) /* shift + tab */ {
if (document.activeElement === firstFocusableEl) {
lastFocusableEl.focus();
evt.preventDefault();
}
} else /* tab */ {
if (document.activeElement === lastFocusableEl) {
firstFocusableEl.focus();
evt.preventDefault();
}
}
}
})
},
"openAlert": function () {
"use strict";
var c = 'tarteaucitron';
tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
},
"closeAlert": function () {
"use strict";
var c = 'tarteaucitron';
tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
tarteaucitron.userInterface.jsSizing('box');
},
"toggleCookiesList": function () {
"use strict";
var div = document.getElementById('tarteaucitronCookiesListContainer');
if (div === null) {
return;
}
if (div.style.display !== 'block') {
tarteaucitron.cookie.number();
div.style.display = 'block';
tarteaucitron.userInterface.jsSizing('cookie');
tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
elem.style.display = 'none';
}, true);
} else {
div.style.display = 'none';
tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
}
},
"toggle": function (id, closeClass) {
"use strict";
var div = document.getElementById(id);
if (div === null) {
return;
}
if (closeClass !== undefined) {
tarteaucitron.fallback([closeClass], function (elem) {
if (elem.id !== id) {
elem.style.display = 'none';
}
}, true);
}
if (div.style.display !== 'block') {
div.style.display = 'block';
} else {
div.style.display = 'none';
}
},
"order": function (id) {
"use strict";
var main = document.getElementById('tarteaucitronServices_' + id),
allDivs,
store = [],
i;
if (main === null) {
return;
}
allDivs = main.childNodes;
if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
Array.prototype.map.call(main.children, Object).sort(function (a, b) {
//var mainChildren = Array.from(main.children);
//mainChildren.sort(function (a, b) {
if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
return 0;
}).forEach(function (element) {
main.appendChild(element);
});
}
},
"jsSizing": function (type) {
"use strict";
var scrollbarMarginRight = 10,
scrollbarWidthParent,
scrollbarWidthChild,
servicesHeight,
e = window,
a = 'inner',
windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
mainTop,
mainHeight,
closeButtonHeight,
headerHeight,
cookiesListHeight,
cookiesCloseHeight,
cookiesTitleHeight,
paddingBox,
alertSmallHeight,
cookiesNumberHeight;
if (type === 'box') {
if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
// reset
tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
// calculate
alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
// apply
tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
}
} else if (type === 'main') {
// get the real window width for media query
if (window.innerWidth === undefined) {
a = 'client';
e = document.documentElement || document.body;
}
// height of the services list container
if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
// reset
tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
// calculate
mainHeight = document.getElementById('tarteaucitron').offsetHeight;
closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
// apply
servicesHeight = (mainHeight - closeButtonHeight + 2);
tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
}
// align the main allow/deny button depending on scrollbar width
if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
// media query
if (e[a + 'Width'] <= 479) {
tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
} else if (e[a + 'Width'] <= 767) {
scrollbarMarginRight = 12;
}
scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
}
// center the main panel
if (document.getElementById('tarteaucitron') !== null) {
// media query
if (e[a + 'Width'] <= 767) {
mainTop = 0;
} else {
mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
}
// correct
if (mainTop < 0) {
mainTop = 0;
}
if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
}
}
// apply
tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
}
} else if (type === 'cookie') {
// put cookies list at bottom
if (document.getElementById('tarteaucitronAlertSmall') !== null) {
tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
}
// height of cookies list
if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
// reset
tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
// calculate
cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
// apply
tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
}
}
}
},
"cookie": {
"owner": {},
"create": function (key, status) {
"use strict";
if (tarteaucitronForceExpire !== '') {
// The number of day cann't be higher than 1 year
timeExipre = (tarteaucitronForceExpire > 365) ? 31536000000 : tarteaucitronForceExpire * 86400000; // Multiplication to tranform the number of days to milliseconds
}
var d = new Date(),
time = d.getTime(),
expireTime = time + timeExipre, // 365 days
regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
cookie = tarteaucitron.cookie.read().replace(regex, ""),
value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
d.setTime(expireTime);
document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
},
"read": function () {
"use strict";
var nameEQ = tarteaucitron.parameters.cookieName + "=",
ca = document.cookie.split(';'),
i,
c;
for (i = 0; i < ca.length; i += 1) {
c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) === 0) {
return c.substring(nameEQ.length, c.length);
}
}
return '';
},
"purge": function (arr) {
"use strict";
var i;
for (i = 0; i < arr.length; i += 1) {
document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
}
},
"checkCount": function (key) {
"use strict";
var arr = tarteaucitron.services[key].cookies,
nb = arr.length,
nbCurrent = 0,
html = '',
i,
status = document.cookie.indexOf(key + '=true');
if (status >= 0 && nb === 0) {
html += tarteaucitron.lang.useNoCookie;
} else if (status >= 0) {
for (i = 0; i < nb; i += 1) {
if (document.cookie.indexOf(arr[i] + '=') !== -1) {
nbCurrent += 1;
if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
tarteaucitron.cookie.owner[arr[i]] = [];
}
if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
}
}
}
if (nbCurrent > 0) {
html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
if (nbCurrent > 1) {
html += 's';
}
html += '.';
} else {
html += tarteaucitron.lang.useNoCookie;
}
} else if (nb === 0) {
html = tarteaucitron.lang.noCookie;
} else {
html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
if (nb > 1) {
html += 's';
}
html += '.';
}
if (document.getElementById('tacCL' + key) !== null) {
document.getElementById('tacCL' + key).innerHTML = html;
}
},
"crossIndexOf": function (arr, match) {
"use strict";
var i;
for (i = 0; i < arr.length; i += 1) {
if (arr[i] === match) {
return true;
}
}
return false;
},
"number": function () {
"use strict";
var cookies = document.cookie.split(';'),
nb = (document.cookie !== '') ? cookies.length : 0,
html = '',
i,
name,
namea,
nameb,
c,
d,
s = (nb > 1) ? 's' : '',
savedname,
regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
cookies = cookies.sort(function (a, b) {
namea = a.split('=', 1).toString().replace(/ /g, '');
nameb = b.split('=', 1).toString().replace(/ /g, '');
c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
if (c + a > d + b) { return 1; }
if (c + a < d + b) { return -1; }
return 0;
});
if (document.cookie !== '') {
for (i = 0; i < nb; i += 1) {
name = cookies[i].split('=', 1).toString().replace(/ /g, '');
if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
savedname = tarteaucitron.cookie.owner[name].join(' // ');
html += '';
html += ' ';
html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
html += ' ';
html += '