Browse Source

Version 1.4 de tarteaucitron

pull/2/head
Akilia 3 years ago
parent
commit
adb889d05f
  1. 490
      lib/tarteaucitron/tarteaucitron.js
  2. 405
      lib/tarteaucitron/tarteaucitron.services.js
  3. 8
      paquet.xml

490
lib/tarteaucitron/tarteaucitron.js

@ -1,6 +1,5 @@
/*jslint browser: true, evil: true */
// define correct path for files inclusion
var scripts = document.getElementsByTagName('script'),
path = scripts[scripts.length - 1].src.split('?')[0],
tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
@ -18,7 +17,7 @@ var scripts = document.getElementsByTagName('script'),
var tarteaucitron = {
"version": 20181120,
"version": 20200114,
"cdn": cdn,
"user": {},
"lang": {},
@ -43,128 +42,37 @@ var tarteaucitron = {
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);
tarteaucitron.initEvents.loadEvent(false);
}, 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 = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + 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) + '%';
}
}
tarteaucitron.initEvents.scrollEvent();
}, false);
window.addEventListener("keydown", function (evt) {
if (evt.keyCode === 27) {
tarteaucitron.userInterface.closePanel();
}
tarteaucitron.initEvents.keydownEvent(false, evt);
}, false);
window.addEventListener("hashchange", function () {
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
tarteaucitron.userInterface.openPanel();
}
tarteaucitron.initEvents.hashchangeEvent();
}, 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');
}
}
tarteaucitron.initEvents.resizeEvent();
}, false);
} else {
window.attachEvent("onload", function () {
tarteaucitron.load();
tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
elem.attachEvent("onclick", function (event) {
tarteaucitron.userInterface.openPanel();
event.preventDefault();
});
}, true);
tarteaucitron.initEvents.loadEvent(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 = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + 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) + '%';
}
}
tarteaucitron.initEvents.scrollEvent();
});
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();
}
}
}
tarteaucitron.initEvents.keydownEvent(true, evt);
});
window.attachEvent("onhashchange", function () {
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
tarteaucitron.userInterface.openPanel();
}
tarteaucitron.initEvents.hashchangeEvent();
});
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');
}
}
tarteaucitron.initEvents.resizeEvent();
});
}
@ -201,6 +109,89 @@ var tarteaucitron = {
tarteaucitron.events.init();
}
},
"initEvents": {
"loadEvent": function (isOldBrowser) {
tarteaucitron.load();
tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
if (isOldBrowser) {
elem.attachEvent("onclick", function (event) {
tarteaucitron.userInterface.openPanel();
event.preventDefault();
});
} else {
elem.addEventListener("click", function (event) {
tarteaucitron.userInterface.openPanel();
event.preventDefault();
}, false);
}
}, true);
},
"keydownEvent": function (isOldBrowser, evt) {
if (evt.keyCode === 27) {
tarteaucitron.userInterface.closePanel();
}
if (isOldBrowser) {
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();
}
}
}
}
},
"hashchangeEvent": function () {
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
tarteaucitron.userInterface.openPanel();
}
},
"resizeEvent": function () {
var tacElem = document.getElementById('tarteaucitron');
var tacCookieContainer = document.getElementById('tarteaucitronCookiesListContainer');
if (tacElem && tacElem.style.display === 'block') {
tarteaucitron.userInterface.jsSizing('main');
}
if (tacCookieContainer && tacCookieContainer.style.display === 'block') {
tarteaucitron.userInterface.jsSizing('cookie');
}
},
"scrollEvent": function () {
var scrollPos = window.pageYOffset || document.documentElement.scrollTop;
var heightPosition;
var tacPercentage = document.getElementById('tarteaucitronPercentage');
var tacAlertBig = document.getElementById('tarteaucitronAlertBig');
if (tacAlertBig && !tarteaucitron.highPrivacy) {
if (tacAlertBig.style.display === 'block') {
heightPosition = tacAlertBig.offsetHeight + 'px';
if (scrollPos > (screen.height * 2)) {
tarteaucitron.userInterface.respondAll(true);
} else if (scrollPos > (screen.height / 2)) {
document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
}
if (tacPercentage) {
if (tarteaucitron.orientation === 'top') {
tacPercentage.style.top = heightPosition;
} else {
tacPercentage.style.bottom = heightPosition;
}
tacPercentage.style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
}
}
}
},
},
"load": function () {
"use strict";
var cdn = tarteaucitron.cdn,
@ -212,19 +203,31 @@ var tarteaucitron = {
"adblocker": false,
"hashtag": '#tarteaucitron',
"cookieName": 'tarteaucitron',
"highPrivacy": false,
"orientation": "top",
"highPrivacy": true,
"orientation": "middle",
"bodyPosition": "bottom",
"removeCredit": false,
"showAlertSmall": true,
"cookieslist": true,
"handleBrowserDNTRequest": false,
"AcceptAllCta" : false,
"AcceptAllCta" : true,
"moreInfoLink": true,
"privacyUrl": "",
"useExternalCss": false
"useExternalCss": false,
"useExternalJs": false
},
params = tarteaucitron.parameters;
// Don't show the middle bar if we are on the privacy policy page
if (window.location.href == tarteaucitron.parameters.privacyUrl && tarteaucitron.parameters.orientation == "middle") {
tarteaucitron.parameters.orientation = "bottom";
}
// Step -1
if (typeof tarteaucitronCustomPremium !== 'undefined') {
tarteaucitronCustomPremium();
}
// Step 0: get params
if (params !== undefined) {
@ -241,7 +244,6 @@ var tarteaucitron = {
tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
// Step 1: load css
if ( !tarteaucitron.parameters.useExternalCss ) {
linkElement.rel = 'stylesheet';
@ -250,12 +252,27 @@ var tarteaucitron = {
document.getElementsByTagName('head')[0].appendChild(linkElement);
}
// Step 2: load language and services
tarteaucitron.addScript(pathToLang, '', function () {
tarteaucitron.addInternalScript(pathToLang, '', function () {
if(tarteaucitronCustomText !== ''){
tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
}
tarteaucitron.addScript(pathToServices, '', function () {
tarteaucitron.addInternalScript(pathToServices, '', function () {
// css for new middle bar
if (tarteaucitron.orientation === 'middle') {
var customThemeMiddle = document.createElement('style'),
cssRuleMiddle = 'div#tarteaucitronRoot.tarteaucitronBeforeVisible:before {content: \'\';position: fixed;width: 100%;height: 100%;background: white;top: 0;left: 0;z-index: 999;opacity: 0.5;}div#tarteaucitronAlertBig:before {content: \'' + tarteaucitron.lang.middleBarHead + '\';font-size: 50px;}body #tarteaucitronRoot div#tarteaucitronAlertBig {width: 60%;min-width: 285px;height: auto;margin: auto;left: 50%;top: 50%;transform: translate(-50%, -50%);box-shadow: 0 0 9000px #000;border-radius: 20px;padding: 50px 0;}span#tarteaucitronDisclaimerAlert {padding: 0 30px;}#tarteaucitronRoot span#tarteaucitronDisclaimerAlert {margin: 50px 0;display: block;text-align: center;font-size: 21px;}';
customThemeMiddle.type = 'text/css';
if (customThemeMiddle.styleSheet) {
customThemeMiddle.styleSheet.cssText = cssRuleMiddle;
} else {
customThemeMiddle.appendChild(document.createTextNode(cssRuleMiddle));
}
document.getElementsByTagName('head')[0].appendChild(customThemeMiddle);
}
var body = document.body,
div = document.createElement('div'),
@ -281,11 +298,11 @@ var tarteaucitron = {
html += ' <div id="tarteaucitronServices">';
html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
html += ' <span class="tarteaucitronH1" role="heading" aria-level="1" id="dialogTitle">'+ tarteaucitron.lang.title + '</span>';
html += ' <div id="tarteaucitronInfo" class="tarteaucitronInfoBox">';
html += ' <div id="tarteaucitronInfo">';
html += ' ' + tarteaucitron.lang.disclaimer;
if (tarteaucitron.parameters.privacyUrl !== "") {
html += ' <br/><br/>';
html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
html += ' <button type="button" id="tarteaucitronPrivacyUrlDialog" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
html += ' ' + tarteaucitron.lang.privacyUrl;
html += ' </button>';
}
@ -314,10 +331,11 @@ var tarteaucitron = {
html += ' </div>';
html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
}
html += ' <li id="tarteaucitronNoServicesTitle" class="tarteaucitronLine">' + tarteaucitron.lang.noServices + '</li>';
html += ' </ul>';
html += ' <div class="tarteaucitronHidden" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></div>';
if (tarteaucitron.parameters.removeCredit === false) {
html += ' <a class="tarteaucitronSelfLink" href="https://opt-out.ferank.eu/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '">๐Ÿ‹ ' + tarteaucitron.lang.credit + '</a>';
html += ' <a class="tarteaucitronSelfLink" href="https://tarteaucitron.io/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '">๐Ÿ‹ ' + tarteaucitron.lang.credit + '</a>';
}
html += ' </div>';
html += ' </div>';
@ -329,9 +347,11 @@ var tarteaucitron = {
if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
//html += '<div class="tarteaucitronAlertBigWrapper">';
html += ' <span id="tarteaucitronDisclaimerAlert">';
html += ' ' + tarteaucitron.lang.alertBigPrivacy;
html += ' </span>';
//html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
html += ' ' + tarteaucitron.lang.personalize;
html += ' </button>';
@ -342,9 +362,12 @@ var tarteaucitron = {
html += ' </button>';
}
//html += ' </span>';
//html += '</div>';
html += '</div>';
} else {
html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
//html += '<div class="tarteaucitronAlertBigWrapper">';
html += ' <span id="tarteaucitronDisclaimerAlert">';
if (tarteaucitron.parameters.highPrivacy) {
@ -354,9 +377,19 @@ var tarteaucitron = {
}
html += ' </span>';
//html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
html += ' </button>';
if (tarteaucitron.parameters.orientation === 'middle') {
html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
html += ' &#10007; ' + tarteaucitron.lang.denyAll;
html += ' </button>';
html += ' <br/><br/>';
}
html += ' <button type="button" id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
html += ' ' + tarteaucitron.lang.personalize;
html += ' </button>';
@ -367,6 +400,8 @@ var tarteaucitron = {
html += ' </button>';
}
//html += ' </span>';
//html += '</div>';
html += '</div>';
html += '<div id="tarteaucitronPercentage"></div>';
}
@ -398,7 +433,7 @@ var tarteaucitron = {
html += '</div>';
}
tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
tarteaucitron.addInternalScript(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
@ -414,9 +449,29 @@ 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
var tacRootAvailableEvent;
if(typeof(Event) === 'function') {
tacRootAvailableEvent = new Event("tac.root_available");
}else{
tacRootAvailableEvent = document.createEvent('Event');
tacRootAvailableEvent.initEvent("tac.root_available", true, true);
}
//end ie compatibility
window.dispatchEvent(tacRootAvailableEvent);
if (tarteaucitron.job !== undefined) {
tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
for (index = 0; index < tarteaucitron.job.length; index += 1) {
@ -466,26 +521,22 @@ var tarteaucitron = {
html += ' ' + tarteaucitron.lang.adblock + '<br/>';
html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
html += ' </p>';
html += ' <button type="button" id="tarteaucitronPersonalize" onclick="location.reload();">';
html += ' <button type="button" class="tarteaucitronCTAButton" onclick="location.reload();">';
html += ' ' + tarteaucitron.lang.reload;
html += ' </button>';
html += '</div>';
html += '<div id="tarteaucitronPremium"></div>';
// 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);
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);
@ -505,13 +556,13 @@ var tarteaucitron = {
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;
isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
isAutostart = (!service.needConsent),
isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
isDenied = (cookie.indexOf(service.key + '=false') >= 0),
isAllowed = (cookie.indexOf(service.key + '=true') >= 0),
isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1");
if (tarteaucitron.added[service.key] !== true) {
tarteaucitron.added[service.key] = true;
@ -523,7 +574,7 @@ var tarteaucitron = {
if (tarteaucitron.parameters.moreInfoLink == true) {
var link = 'https://opt-out.ferank.eu/service/' + service.key + '/';
var link = 'https://tarteaucitron.io/service/' + service.key + '/';
if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
link = service.readmoreLink;
}
@ -556,6 +607,8 @@ var tarteaucitron = {
document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
}
tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
tarteaucitron.userInterface.order(service.type);
}
@ -574,6 +627,7 @@ var tarteaucitron = {
if (tarteaucitron.launch[service.key] !== true) {
tarteaucitron.launch[service.key] = true;
service.js();
tarteaucitron.sendEvent(service.key + '_loaded');
}
tarteaucitron.state[service.key] = true;
tarteaucitron.userInterface.color(service.key, true);
@ -600,6 +654,22 @@ var tarteaucitron = {
}
tarteaucitron.cookie.checkCount(service.key);
tarteaucitron.sendEvent(service.key + '_added')
},
"sendEvent" : function(event_key) {
if(event_key !== undefined) {
//ie compatibility
var send_event_item;
if(typeof(Event) === 'function') {
send_event_item = new Event(event_key);
}else{
send_event_item = document.createEvent('Event');
send_event_item.initEvent(event_key, true, true);
}
//end ie compatibility
document.dispatchEvent(send_event_item);
}
},
"cleanArray": function cleanArray(arr) {
"use strict";
@ -633,6 +703,18 @@ var tarteaucitron = {
document.getElementById(id).style[property] = value;
}
},
"addClass": function (id, className) {
"use strict";
if (document.getElementById(id) !== null) {
document.getElementById(id).classList.add(className);
}
},
"removeClass": function (id, className) {
"use strict";
if (document.getElementById(id) !== null) {
document.getElementById(id).classList.remove(className);
}
},
"respondAll": function (status) {
"use strict";
var s = tarteaucitron.services,
@ -680,6 +762,7 @@ var tarteaucitron = {
tarteaucitron.pro('!' + key + '=engage');
tarteaucitron.launch[key] = true;
tarteaucitron.sendEvent(key + '_loaded');
tarteaucitron.services[key].js();
}
}
@ -720,14 +803,23 @@ var tarteaucitron = {
tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
if (nbDenied === 0 && nbPending === 0) {
document.getElementById(c + 'AllDenied').classList.remove('tarteaucitronIsSelected');
document.getElementById(c + 'AllAllowed').classList.add('tarteaucitronIsSelected');
tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
} else if (nbAllowed === 0 && nbPending === 0) {
document.getElementById(c + 'AllAllowed').classList.remove('tarteaucitronIsSelected');
document.getElementById(c + 'AllDenied').classList.add('tarteaucitronIsSelected');
tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
} else {
document.getElementById(c + 'AllDenied').classList.remove('tarteaucitronIsSelected');
document.getElementById(c + 'AllAllowed').classList.remove('tarteaucitronIsSelected');
tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
}
// close the alert if all service have been reviewed
@ -758,16 +850,31 @@ var tarteaucitron = {
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');
//ie compatibility
var tacOpenPanelEvent;
if(typeof(Event) === 'function') {
tacOpenPanelEvent = new Event("tac.open_panel");
}else{
tacOpenPanelEvent = document.createEvent('Event');
tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
}
//end ie compatibility
window.dispatchEvent(tacOpenPanelEvent);
},
"closePanel": function () {
"use strict";
if (document.location.hash === tarteaucitron.hashtag) {
document.location.hash = '';
if (window.history) {
window.history.replaceState('', document.title, window.location.pathname + window.location.search);
} else {
document.location.hash = '';
}
}
tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
@ -784,9 +891,19 @@ var tarteaucitron = {
if (document.getElementById('tarteaucitronCloseAlert') !== null) {
document.getElementById('tarteaucitronCloseAlert').focus();
}
//document.getElementById('contentWrapper').setAttribute("aria-hidden", "false");
document.getElementsByTagName('body')[0].classList.remove('modal-open');
//ie compatibility
var tacClosePanelEvent;
if(typeof(Event) === 'function') {
tacClosePanelEvent = new Event("tac.close_panel");
}else{
tacClosePanelEvent = document.createEvent('Event');
tacClosePanelEvent.initEvent("tac.close_panel", true, true);
}
//end ie compatibility
window.dispatchEvent(tacClosePanelEvent);
},
"focusTrap": function() {
"use strict";
@ -834,6 +951,19 @@ var tarteaucitron = {
tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
//ie compatibility
var tacOpenAlertEvent;
if(typeof(Event) === 'function') {
tacOpenAlertEvent = new Event("tac.open_alert");
}else{
tacOpenAlertEvent = document.createEvent('Event');
tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
}
//end ie compatibility
window.dispatchEvent(tacOpenAlertEvent);
},
"closeAlert": function () {
"use strict";
@ -841,7 +971,20 @@ var tarteaucitron = {
tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
tarteaucitron.userInterface.jsSizing('box');
//ie compatibility
var tacCloseAlertEvent;
if(typeof(Event) === 'function') {
tacCloseAlertEvent = new Event("tac.close_alert");
}else{
tacCloseAlertEvent = document.createEvent('Event');
tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
}
//end ie compatibility
window.dispatchEvent(tacCloseAlertEvent);
},
"toggleCookiesList": function () {
"use strict";
@ -996,17 +1139,17 @@ var tarteaucitron = {
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;
}
}
// correct
if (mainTop < 0) {
mainTop = 0;
}
// apply
tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
}
@ -1231,17 +1374,17 @@ var tarteaucitron = {
"getLanguage": function () {
"use strict";
var availableLanguages = 'cs,en,fr,es,it,de,nl,pt,pl,ru,el',
var availableLanguages = 'bg,cn,cs,da,de,el,en,es,fi,fr,hu,it,ja,nl,pl,pt,ro,ru,sk,tr',
defaultLanguage = 'en';
if (tarteaucitronForceLanguage !== '') {
if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
return tarteaucitronForceLanguage;
}
}
if (!navigator) { return 'en'; }
var lang = navigator.language || navigator.browserLanguage ||
navigator.systemLanguage || navigator.userLang || null,
userLanguage = lang ? lang.substr(0, 2) : null;
@ -1279,7 +1422,7 @@ var tarteaucitron = {
return 'en_US';
}
},
"addScript": function (url, id, callback, execute, attrName, attrVal) {
"addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
"use strict";
var script,
done = false;
@ -1300,18 +1443,27 @@ var tarteaucitron = {
}
if (typeof callback === 'function') {
script.onreadystatechange = script.onload = function () {
var state = script.readyState;
if (!done && (!state || /loaded|complete/.test(state))) {
done = true;
callback();
}
};
if ( !tarteaucitron.parameters.useExternalJs ) {
script.onreadystatechange = script.onload = function () {
var state = script.readyState;
if (!done && (!state || /loaded|complete/.test(state))) {
done = true;
callback();
}
};
} else {
callback();
}
}
document.getElementsByTagName('head')[0].appendChild(script);
if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
document.getElementsByTagName('head')[0].appendChild(script);
}
}
},
"addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
},
"makeAsync": {
"antiGhost": 0,
"buffer": '',
@ -1341,7 +1493,7 @@ var tarteaucitron = {
return;
}
tarteaucitron.makeAsync.antiGhost += 1;
tarteaucitron.addScript(url, '', function () {
tarteaucitron.addInternalScript(url, '', function () {
if (document.getElementById(id) !== null) {
document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
tarteaucitron.makeAsync.buffer = '';
@ -1447,16 +1599,16 @@ var tarteaucitron = {
if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
var div = document.getElementById('tarteaucitronPremium'),
timestamp = new Date().getTime(),
url = 'https://opt-out.ferank.eu/premium.php?';
url = 'https://tarteaucitron.io/log/?';
if (div === null) {
return;
}
url += 'account=' + tarteaucitron.uuid + '&';
url += 'domain=' + tarteaucitron.domain + '&';
url += 'uuid=' + tarteaucitron.uuid + '&';
url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
url += '_' + timestamp;
url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
url += '_time=' + timestamp;
div.innerHTML = '<img src="' + url + '" style="display:none" />';

405
lib/tarteaucitron/tarteaucitron.services.js

@ -30,6 +30,92 @@ tarteaucitron.services.iframe = {
}
};
// amplitude
tarteaucitron.services.amplitude = {
"key": "amplitude",
"type": "analytic",
"name": "Amplitude",
"uri": "https://amplitude.com/privacy",
"needConsent": true,
"cookies": [],
"js": function () {
"use strict";
if (tarteaucitron.user.amplitude === undefined) {
return;
}
tarteaucitron.addScript('https://cdn.amplitude.com/libs/amplitude-5.8.0-min.gz.js', '', function() {
window.amplitude = {
_q: [],
_iq: {}
};
function s(e,t){e.prototype[t]=function(){this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
var o=function(){this._q=[];return this};
var a=["add","append","clearAll","prepend","set","setOnce","unset"];
for(var u=0;u<a.length;u++){s(o,a[u])}
amplitude.Identify=o;
var c=function(){this._q=[];return this};
var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"];
for(var p=0;p<l.length;p++){s(c,l[p])}
amplitude.Revenue=c;
var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","enableTracking","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","onInit","logEventWithTimestamp","logEventWithGroups","setSessionId","resetSessionId"];
function v(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}for(var n=0;n<d.length;n++){t(d[n])}}
v(amplitude);
amplitude.getInstance=function(e){e=(!e||e.length===0?"$default_instance":e).toLowerCase();if(!amplitude._iq.hasOwnProperty(e)){amplitude._iq[e]={_q:[]};v(amplitude._iq[e])}return amplitude._iq[e]};
amplitude.getInstance().init(tarteaucitron.user.amplitude);
});
}
};
// abtasty
tarteaucitron.services.abtasty = {
"key": "abtasty",
"type": "api",
"name": "ABTasty",
"uri": "https://www.abtasty.com/terms-of-use/",
"needConsent": true,
"cookies": ['ABTasty', 'ABTastySession'],
"js": function () {
"use strict";
if (tarteaucitron.user.abtastyID === undefined) {
return;
}
tarteaucitron.addScript('//try.abtasty.com/'+tarteaucitron.user.abtastyID+'.js');
}
};
// yandex metrica
tarteaucitron.services.metrica = {
"key": "metrica",
"type": "analytic",
"name": "Yandex Metrica",
"uri": "https://yandex.com/legal/confidential/",
"needConsent": true,
"cookies": ['_ym_metrika_enabled','_ym_isad', '_ym_uid', '_ym_d','yabs-sid','_ym_debug','_ym_mp2_substs','_ym_hostIndex','_ym_mp2_track','yandexuid','usst'],
"js": function () {
"use strict";
if (tarteaucitron.user.yandexmetrica === undefined) {
return;
}
tarteaucitron.addScript('https://mc.yandex.ru/metrika/tag.js', '', function() {
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(tarteaucitron.user.yandexmetrica, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true,
ecommerce:"dataLayer"
});
});
}
};
// addthis
tarteaucitron.services.addthis = {
"key": "addthis",
@ -177,41 +263,41 @@ tarteaucitron.services.aduptech_conversion = {
tarteaucitron.fallback([IDENTIFIER], "");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var element = elements[i];
if (!element.getAttribute("advertiserId") || !element.getAttribute("conversionCode")) {
continue;
}
var url = CONVERSION_PIXEL_BASE_URL +
"/" + encodeURIComponent(element.getAttribute("advertiserId")) +
"?t=" + encodeURIComponent(element.getAttribute("conversionCode"));
var url = CONVERSION_PIXEL_BASE_URL +
"/" + encodeURIComponent(element.getAttribute("advertiserId")) +
"?t=" + encodeURIComponent(element.getAttribute("conversionCode"));
if (element.getAttribute("price")) {
url += "&price=" + encodeURIComponent(element.getAttribute("price"));
}
if (element.getAttribute("quantity")) {
url += "&quantity=" + encodeURIComponent(element.getAttribute("quantity"));
}
if (element.getAttribute("total")) {
url += "&total=" + encodeURIComponent(element.getAttribute("total"));
}
if (element.getAttribute("orderId")) {
url += "&order_id=" + encodeURIComponent(element.getAttribute("orderId"));
}
if (element.getAttribute("itemNumber")) {
url += "&item_number=" + encodeURIComponent(element.getAttribute("itemNumber"));
}
if (element.getAttribute("description")) {
url += "&description=" + encodeURIComponent(element.getAttribute("description"));
}
(new Image()).src = url;
(new Image()).src = url;
}
}
};
@ -437,6 +523,23 @@ tarteaucitron.services.clicmanager = {
}
};
// contentsquare
tarteaucitron.services.contentsquare = {
"key": "contentsquare",
"type": "api",
"name": "ContentSquare",
"uri": "https://docs.contentsquare.com/uxa-en/#collected-data",
"needConsent": true,
"cookies": ['_cs_id', '_cs_s', '_cs_vars', '_cs_ex', '_cs_c', '_cs_optout'],
"js": function () {
"use strict";
if (tarteaucitron.user.contentsquareID === undefined) {
return;
}
tarteaucitron.addScript('//t.contentsquare.net/uxa/'+tarteaucitron.user.contentsquareID+'.js');
}
};
// crazyegg
tarteaucitron.services.crazyegg = {
"key": "crazyegg",
@ -1202,7 +1305,7 @@ tarteaucitron.services.googlemapssearch = {
// url = x.getAttribute("data-url");
query = escape(x.getAttribute("data-search")),
key = x.getAttribute("data-api-key");
// return '<iframe src="' + url + '" width="' + width + '" height="' + height + '" frameborder="0" scrolling="no" allowtransparency allowfullscreen></iframe>';
return '<iframe width="' + width +'" height="' + height + '" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q='+query+'&key='+key+'" allowfullscreen></iframe> '
});
@ -1265,8 +1368,31 @@ tarteaucitron.services.googletagmanager = {
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
tarteaucitron.addScript('//www.googletagmanager.com/gtm.js?id=' + tarteaucitron.user.googletagmanagerId);
tarteaucitron.addScript('https://www.googletagmanager.com/gtm.js?id=' + tarteaucitron.user.googletagmanagerId);
}
};
// google webfonts
tarteaucitron.services.googlefonts = {
"key": "googlefonts",
"type": "api",
"name": "Google Webfonts",
"uri": "https://www.google.com/intl/de/policies/privacy/",
"needConsent": true,
"cookies": [],
"js": function () {
"use strict";
if (tarteaucitron.user.googleFonts === undefined) {
return;
}
tarteaucitron.addScript('//ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js', '', function () {
WebFont.load({
google: {
families: tarteaucitron.user.googleFonts
}
});
});
}
};
// hubspot
@ -1377,9 +1503,10 @@ tarteaucitron.services.mautic = {
return;
}
window['MauticTrackingObject'] = 'mt';
window['mt'] = window['mt'] || function() {
(window['mt'].q = window['mt'].q || []).push(arguments);
window.MauticTrackingObject = 'mt';
window.mt = window.mt || function () {
window.mt.q = window.mt.q || [];
window.mt.q.push(arguments);
};
tarteaucitron.addScript(tarteaucitron.user.mauticurl, '', function() {
@ -1553,6 +1680,41 @@ tarteaucitron.services.purechat = {
}
};
// rumbletalk
tarteaucitron.services.rumbletalk = {
"key": "rumbletalk",
"type": "social",
"name": "RumbleTalk",
"needConsent": true,
"cookies": ['AWSALB'],
"js": function () {
"use strict";
if (tarteaucitron.user.rumbletalkid === undefined) {
return;
}
tarteaucitron.addScript('https://rumbletalk.com/client/?' + tarteaucitron.user.rumbletalkid);
tarteaucitron.fallback(['rumbletalk'], function (x) {
var width = tarteaucitron.getElemWidth(x),
height = tarteaucitron.getElemHeight(x),
id = x.getAttribute("data-id");
return '<div style="height: ' + height + 'px; width: ' + width + 'px;"><div id="' + id + '"></div></div>';
});
},
"fallback": function () {
"use strict";
var id = 'rumbletalk';
tarteaucitron.fallback(['rumbletalk'], function (elem) {
elem.style.width = tarteaucitron.getElemWidth(elem) + 'px';
elem.style.height = tarteaucitron.getElemHeight(elem) + 'px';
return tarteaucitron.engage(id);
});
}
};
// shareaholic
tarteaucitron.services.shareaholic = {
"key": "shareaholic",
@ -1936,19 +2098,30 @@ tarteaucitron.services.vimeo = {
"js": function () {
"use strict";
tarteaucitron.fallback(['vimeo_player'], function (x) {
var video_id = x.getAttribute("videoID"),
video_width = x.getAttribute("width"),
var video_width = x.getAttribute("data-width") || x.getAttribute("width"),
frame_width = 'width=',
video_height = x.getAttribute("height"),
video_height = x.getAttribute("data-height") || x.getAttribute("height"),
frame_height = 'height=',
video_title = x.getAttribute("title") || '',
video_byline = x.getAttribute("byline") || '',
video_portrait = x.getAttribute("portrait") || '',
video_loop = x.getAttribute("loop") || '',
video_autoplay = x.getAttribute("autoplay") || '',
video_id = x.getAttribute("data-videoID") || x.getAttribute("videoID"),
video_autopause = x.getAttribute("data-autopause") || '',
video_autoplay = x.getAttribute("data-autoplay") || x.getAttribute("autoplay") || '',
video_background = x.getAttribute("data-background") || '',
video_byline = x.getAttribute("data-byline") || x.getAttribute("byline") || '',
video_color = x.getAttribute("data-color") || '',
video_controls = x.getAttribute("data-controls") || '',
video_loop = x.getAttribute("data-loop") || x.getAttribute("loop") || '',
video_maxheight = x.getAttribute("data-maxheight") || '',
video_maxwidth = x.getAttribute("data-maxwidth") || '',
video_muted = x.getAttribute("data-muted") || '',
video_playsinline = x.getAttribute("data-playsinline") || '',
video_portrait = x.getAttribute("data-portrait") || x.getAttribute("portrait") || '',
video_speed = x.getAttribute("data-speed") || '',
video_title = x.getAttribute("data-title") || x.getAttribute("title") || '',
video_transparent = x.getAttribute("data-transparent") || '',
video_frame;
var video_qs = '';
if (video_id === undefined) {
return "";
@ -1964,43 +2137,112 @@ tarteaucitron.services.vimeo = {
frame_height += '"" ';
}
if (video_title.length > 0 || video_byline.length > 0 || video_portrait.length > 0) {
var video_qs = "?";
video_qs = "?";
if (video_title.length > 0) {
video_qs += "title=" + video_title;
}
if (video_title.length > 0) {
video_qs += "title=" + video_title;
if (video_byline.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "byline=" + video_byline;
}
if (video_byline.length > 0) {
if (video_qs.length > 1) {
video_qs += "&";
}
video_qs += "byline=" + video_byline;
if (video_portrait.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "portrait=" + video_portrait;
}
if (video_portrait.length > 0) {
if (video_qs.length > 1) {
video_qs += "&";
}
video_qs += "portrait=" + video_portrait;
if (video_loop.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "loop=" + video_loop;
}
if (video_loop.length > 0) {
if (video_qs.length > 1) {
video_qs += "&";
}
video_qs += "loop=" + video_loop;
if (video_autoplay.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "autoplay=" + video_autoplay;
}
if (video_autopause.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "autopause=" + video_autopause;
}
if (video_autoplay.length > 0) {
if (video_qs.length > 1) {
video_qs += "&";
}
video_qs += "autoplay=" + video_autoplay;
if (video_background.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "background=" + video_background;
}
if (video_color.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "color=" + video_color;
}
if (video_controls.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "controls=" + video_controls;
}
if (video_maxheight.length > 0) {
if (video_qs.length > 0) {
video_qs += "&";
}
video_qs += "maxheight=" + video_maxheight;
}
if (video_maxwidth.length > 0) {