Ajax compatible (!)
This commit is contained in:
parent
e5727618a9
commit
42d55abf8a
|
|
@ -29,9 +29,9 @@
|
||||||
top: 0 !important;
|
top: 0 !important;
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tarteaucitron #tarteaucitronClosePanel {
|
#tarteaucitron #tarteaucitronServices .tarteaucitronTitle {
|
||||||
display: block !important;
|
text-align: left !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,17 +121,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#tarteaucitron #tarteaucitronClosePanel {
|
#tarteaucitron #tarteaucitronClosePanel {
|
||||||
background: #6f6f6f;
|
background: #333333;
|
||||||
border: 4px solid #fff;
|
|
||||||
border-right: 0;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: none;
|
|
||||||
float: right;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 70px;
|
width: 70px;
|
||||||
}
|
}
|
||||||
|
|
@ -159,6 +157,10 @@
|
||||||
min-height: 250px;
|
min-height: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#tarteaucitron #tarteaucitronServices .tarteaucitronHidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#tarteaucitron #tarteaucitronServices .tarteaucitronTitle {
|
#tarteaucitron #tarteaucitronServices .tarteaucitronTitle {
|
||||||
background: rgba(51, 51, 51, 0.2);
|
background: rgba(51, 51, 51, 0.2);
|
||||||
color: #333;
|
color: #333;
|
||||||
|
|
@ -179,9 +181,7 @@
|
||||||
#tarteaucitron #tarteaucitronServices .tarteaucitronLine {
|
#tarteaucitron #tarteaucitronServices .tarteaucitronLine {
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
border-left: 5px solid #f5f5f5;
|
border-left: 5px solid #f5f5f5;
|
||||||
height: auto;
|
|
||||||
margin: 1px 0;
|
margin: 1px 0;
|
||||||
min-height: 100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 15px 5px;
|
padding: 15px 5px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
414
tarteaucitron.js
414
tarteaucitron.js
|
|
@ -5,24 +5,59 @@ var scripts = document.getElementsByTagName('script'),
|
||||||
path = scripts[scripts.length - 1].src.split('?')[0],
|
path = scripts[scripts.length - 1].src.split('?')[0],
|
||||||
cdn = path.split('/').slice(0, -1).join('/') + '/',
|
cdn = path.split('/').slice(0, -1).join('/') + '/',
|
||||||
alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
|
alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
|
||||||
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage;
|
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
|
||||||
|
tarteaucitronProLoadServices;
|
||||||
|
|
||||||
var tarteaucitron = {
|
var tarteaucitron = {
|
||||||
"cdn": cdn,
|
"cdn": cdn,
|
||||||
"user": {},
|
"user": {},
|
||||||
"lang": {},
|
"lang": {},
|
||||||
"services": {},
|
"services": {},
|
||||||
|
"added": [],
|
||||||
|
"idprocessed": [],
|
||||||
"state": [],
|
"state": [],
|
||||||
"launch": [],
|
"launch": [],
|
||||||
|
"isAjax": false,
|
||||||
"init": function (params) {
|
"init": function (params) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var origOpen = XMLHttpRequest.prototype.open;
|
||||||
|
|
||||||
if (alreadyLaunch === 0) {
|
if (alreadyLaunch === 0) {
|
||||||
alreadyLaunch = 1;
|
alreadyLaunch = 1;
|
||||||
if (window.addEventListener) {
|
if (window.addEventListener) {
|
||||||
window.addEventListener("load", tarteaucitron.load(params), false);
|
window.addEventListener("load", tarteaucitron.load(params), 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);
|
||||||
} else {
|
} else {
|
||||||
window.attachEvent('onload', tarteaucitron.load(params));
|
window.attachEvent("onload", tarteaucitron.load(params));
|
||||||
|
window.attachEvent("onkeydown", function (evt) {
|
||||||
|
if (evt.keyCode === 27) {
|
||||||
|
tarteaucitron.userInterface.closePanel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.attachEvent("onhashchange", function () {
|
||||||
|
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
|
||||||
|
tarteaucitron.userInterface.openPanel();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLHttpRequest.prototype.open = function () {
|
||||||
|
this.addEventListener('load', function () {
|
||||||
|
if (typeof tarteaucitronProLoadServices === 'function') {
|
||||||
|
tarteaucitronProLoadServices();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
origOpen.apply(this, arguments);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"load": function (params) {
|
"load": function (params) {
|
||||||
|
|
@ -45,8 +80,9 @@ var tarteaucitron = {
|
||||||
tarteaucitron.extend(defaults, params);
|
tarteaucitron.extend(defaults, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the hashtag need to be global
|
// global
|
||||||
tarteaucitron.hashtag = defaults.hashtag;
|
tarteaucitron.hashtag = defaults.hashtag;
|
||||||
|
tarteaucitron.highPrivacy = defaults.highPrivacy;
|
||||||
|
|
||||||
// Step 1: load css
|
// Step 1: load css
|
||||||
linkElement.rel = 'stylesheet';
|
linkElement.rel = 'stylesheet';
|
||||||
|
|
@ -60,52 +96,12 @@ var tarteaucitron = {
|
||||||
|
|
||||||
var body = document.body,
|
var body = document.body,
|
||||||
div = document.createElement('div'),
|
div = document.createElement('div'),
|
||||||
hostname = document.location.hostname,
|
|
||||||
hostRef = document.referrer.split('/')[2],
|
|
||||||
isNavigating = (hostRef === hostname) ? true : false,
|
|
||||||
isAutostart,
|
|
||||||
isWaiting,
|
|
||||||
isDenied,
|
|
||||||
isAllowed,
|
|
||||||
isResponded,
|
|
||||||
cookie = tarteaucitron.cookie.read(),
|
|
||||||
s = tarteaucitron.services,
|
s = tarteaucitron.services,
|
||||||
service,
|
|
||||||
html = '',
|
html = '',
|
||||||
lastTitle,
|
|
||||||
alert = false,
|
alert = false,
|
||||||
index,
|
index,
|
||||||
orientation = 'Top';
|
orientation = 'Top';
|
||||||
|
|
||||||
// dedup, clean and sort job[]
|
|
||||||
function cleanArray(arr) {
|
|
||||||
var i,
|
|
||||||
len = arr.length,
|
|
||||||
out = [],
|
|
||||||
obj = {};
|
|
||||||
|
|
||||||
for (i = 0; i < len; i += 1) {
|
|
||||||
if (!obj[arr[i]]) {
|
|
||||||
obj[arr[i]] = {};
|
|
||||||
if (tarteaucitron.services[arr[i]] !== undefined) {
|
|
||||||
out.push(arr[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tarteaucitron.job === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tarteaucitron.job = cleanArray(tarteaucitron.job);
|
|
||||||
tarteaucitron.job = tarteaucitron.job.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;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Step 3: prepare the html
|
// Step 3: prepare the html
|
||||||
html += '<div id="tarteaucitronPremium"></div>';
|
html += '<div id="tarteaucitronPremium"></div>';
|
||||||
html += '<div id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();"></div>';
|
html += '<div id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();"></div>';
|
||||||
|
|
@ -120,71 +116,91 @@ var tarteaucitron = {
|
||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
html += ' <div id="tarteaucitronServices">';
|
html += ' <div id="tarteaucitronServices">';
|
||||||
|
html += ' <div class="tarteaucitronLine tarteaucitronMainLine">';
|
||||||
html += '<div class="tarteaucitronLine tarteaucitronMainLine">';
|
html += ' <div class="tarteaucitronName">';
|
||||||
html += ' <div class="tarteaucitronName">';
|
html += ' <b>' + tarteaucitron.lang.all + '</b>';
|
||||||
html += ' <b>' + tarteaucitron.lang.all + '</b>';
|
html += ' </div>';
|
||||||
|
html += ' <div class="tarteaucitronAsk">';
|
||||||
|
html += ' <div id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
|
||||||
|
html += ' ' + tarteaucitron.lang.allow;
|
||||||
|
html += ' </div> ';
|
||||||
|
html += ' <div id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
|
||||||
|
html += ' ' + tarteaucitron.lang.deny;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div class="clear"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_ads" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.ads.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.ads.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_ads"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_analytic" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.analytic.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.analytic.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_analytic"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_api" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.api.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.api.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_api"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_comment" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.comment.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.comment.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_comment"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_social" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.social.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.social.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_social"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_support" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.support.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.support.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_support"></div>';
|
||||||
|
html += ' <div id="tarteaucitronServicesTitle_video" class="tarteaucitronHidden">';
|
||||||
|
html += ' <div class="tarteaucitronTitle">';
|
||||||
|
html += ' ' + tarteaucitron.lang.video.title;
|
||||||
|
html += ' <div class="tarteaucitronDetails">';
|
||||||
|
html += ' ' + tarteaucitron.lang.video.details;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div id="tarteaucitronServices_video"></div>';
|
||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
html += ' <div class="tarteaucitronAsk">';
|
|
||||||
html += ' <div id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
|
|
||||||
html += ' ' + tarteaucitron.lang.allow;
|
|
||||||
html += ' </div> ';
|
|
||||||
html += ' <div id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
|
|
||||||
html += ' ' + tarteaucitron.lang.deny;
|
|
||||||
html += ' </div>';
|
|
||||||
html += ' </div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div class="clear"></div>';
|
|
||||||
|
|
||||||
for (index = 0; index < tarteaucitron.job.length; index += 1) {
|
|
||||||
service = s[tarteaucitron.job[index]];
|
|
||||||
|
|
||||||
if (lastTitle !== service.type) {
|
|
||||||
html += '<div class="tarteaucitronTitle">';
|
|
||||||
html += ' ' + tarteaucitron.lang[service.type].title;
|
|
||||||
html += ' <div class="tarteaucitronDetails">';
|
|
||||||
html += ' ' + tarteaucitron.lang[service.type].details;
|
|
||||||
html += ' </div>';
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
lastTitle = service.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '<div id="' + service.key + 'Line" class="tarteaucitronLine">';
|
|
||||||
html += ' <div class="tarteaucitronName">';
|
|
||||||
html += ' <b>' + service.name + '</b><br/>';
|
|
||||||
html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
|
|
||||||
html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank">';
|
|
||||||
html += ' ' + tarteaucitron.lang.more;
|
|
||||||
html += ' </a>';
|
|
||||||
html += ' - ';
|
|
||||||
html += ' <a href="' + service.uri + '" target="_blank">';
|
|
||||||
html += ' ' + tarteaucitron.lang.source;
|
|
||||||
html += ' </a>';
|
|
||||||
html += ' </div>';
|
|
||||||
html += ' <div class="tarteaucitronAsk">';
|
|
||||||
html += ' <div id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
|
|
||||||
html += ' ' + tarteaucitron.lang.allow;
|
|
||||||
html += ' </div> ';
|
|
||||||
html += ' <div id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
|
|
||||||
html += ' ' + tarteaucitron.lang.deny;
|
|
||||||
html += ' </div>';
|
|
||||||
html += ' </div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div class="clear"></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
html += ' </div>';
|
|
||||||
|
|
||||||
if (defaults.removeCredit === false) {
|
if (defaults.removeCredit === false) {
|
||||||
html += ' <div id="tarteaucitronFooter">';
|
html += ' <div id="tarteaucitronFooter">';
|
||||||
html += ' <a href="https://opt-out.ferank.eu/" rel="nofollow" target="_blank">' + tarteaucitron.lang.credit + '</a>';
|
html += ' <a href="https://opt-out.ferank.eu/" rel="nofollow" target="_blank">' + tarteaucitron.lang.credit + '</a>';
|
||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|
||||||
// get the banner orientation
|
|
||||||
if (defaults.orientation === 'bottom') {
|
if (defaults.orientation === 'bottom') {
|
||||||
orientation = 'Bottom';
|
orientation = 'Bottom';
|
||||||
}
|
}
|
||||||
|
|
@ -226,64 +242,133 @@ var tarteaucitron = {
|
||||||
div.id = 'tarteaucitronRoot';
|
div.id = 'tarteaucitronRoot';
|
||||||
body.appendChild(div, body);
|
body.appendChild(div, body);
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
|
|
||||||
// Step 4: load services
|
if (tarteaucitron.job !== undefined) {
|
||||||
for (index = 0; index < tarteaucitron.job.length; index += 1) {
|
tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
|
||||||
service = s[tarteaucitron.job[index]];
|
for (index = 0; index < tarteaucitron.job.length; index += 1) {
|
||||||
isAutostart = (!service.needConsent) ? true : false;
|
tarteaucitron.addService(tarteaucitron.job[index]);
|
||||||
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;
|
|
||||||
|
|
||||||
// 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)) && !defaults.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) {
|
|
||||||
tarteaucitron.cookie.create(service.key, 'wait');
|
|
||||||
if (typeof service.fallback === 'function') {
|
|
||||||
service.fallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tarteaucitron.state[service.key] === undefined && !alert) {
|
|
||||||
alert = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
tarteaucitron.cookie.checkCount(service.key);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 5: display the alert
|
|
||||||
if (alert) {
|
|
||||||
tarteaucitron.userInterface.openAlert();
|
|
||||||
} else {
|
|
||||||
tarteaucitron.userInterface.closeAlert();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tarteaucitron.isAjax = true;
|
||||||
|
tarteaucitron.job.push = function (id) {
|
||||||
|
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 !== '') {
|
if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
|
||||||
tarteaucitron.userInterface.openPanel();
|
tarteaucitron.userInterface.openPanel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
"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) ? 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;
|
||||||
|
|
||||||
|
if (tarteaucitron.added[service.key] !== true) {
|
||||||
|
tarteaucitron.added[service.key] = true;
|
||||||
|
|
||||||
|
html += '<div id="' + service.key + 'Line" class="tarteaucitronLine">';
|
||||||
|
html += ' <div class="tarteaucitronName">';
|
||||||
|
html += ' <b>' + service.name + '</b><br/>';
|
||||||
|
html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
|
||||||
|
html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank">';
|
||||||
|
html += ' ' + tarteaucitron.lang.more;
|
||||||
|
html += ' </a>';
|
||||||
|
html += ' - ';
|
||||||
|
html += ' <a href="' + service.uri + '" target="_blank">';
|
||||||
|
html += ' ' + tarteaucitron.lang.source;
|
||||||
|
html += ' </a>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' <div class="tarteaucitronAsk">';
|
||||||
|
html += ' <div id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
|
||||||
|
html += ' ' + tarteaucitron.lang.allow;
|
||||||
|
html += ' </div> ';
|
||||||
|
html += ' <div id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
|
||||||
|
html += ' ' + tarteaucitron.lang.deny;
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
document.getElementById('tarteaucitronServicesTitle_' + service.type).style.display = 'block';
|
||||||
|
document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
|
||||||
|
|
||||||
|
tarteaucitron.userInterface.order(service.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
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": {
|
"userInterface": {
|
||||||
"css": function (id, property, value) {
|
"css": function (id, property, value) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -301,13 +386,15 @@ var tarteaucitron = {
|
||||||
for (index = 0; index < tarteaucitron.job.length; index += 1) {
|
for (index = 0; index < tarteaucitron.job.length; index += 1) {
|
||||||
service = s[tarteaucitron.job[index]];
|
service = s[tarteaucitron.job[index]];
|
||||||
key = service.key;
|
key = service.key;
|
||||||
if (tarteaucitron.launch[key] !== true && status === true) {
|
if (tarteaucitron.state[key] !== status) {
|
||||||
tarteaucitron.launch[key] = true;
|
if (tarteaucitron.launch[key] !== true && status === true) {
|
||||||
tarteaucitron.services[key].js();
|
tarteaucitron.launch[key] = true;
|
||||||
|
tarteaucitron.services[key].js();
|
||||||
|
}
|
||||||
|
tarteaucitron.state[key] = status;
|
||||||
|
tarteaucitron.cookie.create(key, status);
|
||||||
|
tarteaucitron.userInterface.color(key, status);
|
||||||
}
|
}
|
||||||
tarteaucitron.state[key] = status;
|
|
||||||
tarteaucitron.cookie.create(key, status);
|
|
||||||
tarteaucitron.userInterface.color(key, status);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"respond": function (el, status) {
|
"respond": function (el, status) {
|
||||||
|
|
@ -428,6 +515,21 @@ var tarteaucitron = {
|
||||||
var c = 'tarteaucitron';
|
var c = 'tarteaucitron';
|
||||||
tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
|
tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
|
||||||
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
|
tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
|
||||||
|
},
|
||||||
|
"order": function (id) {
|
||||||
|
"use strict";
|
||||||
|
var main = document.getElementById('tarteaucitronServices_' + id),
|
||||||
|
allDivs = main.childNodes,
|
||||||
|
store = [],
|
||||||
|
i;
|
||||||
|
|
||||||
|
Array.prototype.map.call(main.children, Object).sort(function (a, b) {
|
||||||
|
if (a.id > b.id) { return 1; }
|
||||||
|
if (a.id < b.id) { return -1; }
|
||||||
|
return 0;
|
||||||
|
}).forEach(function (element) {
|
||||||
|
main.appendChild(element);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cookie": {
|
"cookie": {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/*global tarteaucitron, ga, Shareaholic, stLight, clicky, top, google, Typekit*/
|
/*global tarteaucitron, ga, Shareaholic, stLight, clicky, top, google, Typekit, FB, ferankReady, IN, stButtons*/
|
||||||
/*jslint regexp: true, nomen: true*/
|
/*jslint regexp: true, nomen: true*/
|
||||||
|
|
||||||
// addthis
|
// addthis
|
||||||
|
|
@ -14,6 +14,15 @@ tarteaucitron.services.addthis = {
|
||||||
if (tarteaucitron.user.addthisPubId === undefined) {
|
if (tarteaucitron.user.addthisPubId === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
window.addthis = null;
|
||||||
|
window._adr = null;
|
||||||
|
window._atc = null;
|
||||||
|
window._atd = null;
|
||||||
|
window._ate = null;
|
||||||
|
window._atr = null;
|
||||||
|
window._atw = null;
|
||||||
|
}
|
||||||
tarteaucitron.fallback(['addthis_sharing_toolbox'], '');
|
tarteaucitron.fallback(['addthis_sharing_toolbox'], '');
|
||||||
tarteaucitron.addScript('//s7.addthis.com/js/300/addthis_widget.js#pubid=' + tarteaucitron.user.addthisPubId);
|
tarteaucitron.addScript('//s7.addthis.com/js/300/addthis_widget.js#pubid=' + tarteaucitron.user.addthisPubId);
|
||||||
},
|
},
|
||||||
|
|
@ -300,6 +309,11 @@ tarteaucitron.services.facebook = {
|
||||||
"use strict";
|
"use strict";
|
||||||
tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like'], '');
|
tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like'], '');
|
||||||
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
|
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
if (typeof FB !== "undefined") {
|
||||||
|
FB.XFBML.parse();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"fallback": function () {
|
"fallback": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -320,6 +334,11 @@ tarteaucitron.services.facebooklikebox = {
|
||||||
"use strict";
|
"use strict";
|
||||||
tarteaucitron.fallback(['fb-like-box'], '');
|
tarteaucitron.fallback(['fb-like-box'], '');
|
||||||
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
|
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
if (typeof FB !== "undefined") {
|
||||||
|
FB.XFBML.parse();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"fallback": function () {
|
"fallback": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -340,6 +359,11 @@ tarteaucitron.services.facebookcomment = {
|
||||||
"use strict";
|
"use strict";
|
||||||
tarteaucitron.fallback(['fb-comments'], '');
|
tarteaucitron.fallback(['fb-comments'], '');
|
||||||
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
|
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
if (typeof FB !== "undefined") {
|
||||||
|
FB.XFBML.parse();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"fallback": function () {
|
"fallback": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -377,6 +401,11 @@ tarteaucitron.services.ferankpub = {
|
||||||
"js": function () {
|
"js": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
tarteaucitron.addScript('//static.ferank.fr/publicite.async.js');
|
tarteaucitron.addScript('//static.ferank.fr/publicite.async.js');
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
if (typeof ferankReady === 'function') {
|
||||||
|
ferankReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"fallback": function () {
|
"fallback": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -653,6 +682,11 @@ tarteaucitron.services.linkedin = {
|
||||||
"use strict";
|
"use strict";
|
||||||
tarteaucitron.fallback(['tacLinkedin'], '');
|
tarteaucitron.fallback(['tacLinkedin'], '');
|
||||||
tarteaucitron.addScript('//platform.linkedin.com/in.js');
|
tarteaucitron.addScript('//platform.linkedin.com/in.js');
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
if (typeof IN !== "undefined") {
|
||||||
|
IN.parse();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"fallback": function () {
|
"fallback": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -756,6 +790,12 @@ tarteaucitron.services.sharethis = {
|
||||||
tarteaucitron.addScript(uri, '', function () {
|
tarteaucitron.addScript(uri, '', function () {
|
||||||
stLight.options({publisher: tarteaucitron.user.sharethisPublisher, doNotHash: false, doNotCopy: false, hashAddressBar: false});
|
stLight.options({publisher: tarteaucitron.user.sharethisPublisher, doNotHash: false, doNotCopy: false, hashAddressBar: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (tarteaucitron.isAjax === true) {
|
||||||
|
if (typeof stButtons !== "undefined") {
|
||||||
|
stButtons.locateElements();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"fallback": function () {
|
"fallback": function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue