Merge branch 'master' into display-cta-accept-all-with-highPrivacy

This commit is contained in:
r-baudot 2018-08-06 13:27:24 +02:00 committed by GitHub
commit b43cbce36b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 199 additions and 102 deletions

View File

@ -63,6 +63,7 @@ Bonus:
* Marketing Automation & CRM
* Mautic
* Webmecanik Automation
* Koban
* Social network
* AddThis
@ -117,6 +118,7 @@ In PHP for example, you can bypass all the script by setting this var `tarteauci
<script type="text/javascript">
tarteaucitron.init({
"hashtag": "#tarteaucitron", /* Ouverture automatique du panel avec le hashtag */
"cookieName": "tartaucitron", /* Nom du cookie */
"highPrivacy": false, /* désactiver le consentement implicite (en naviguant) ? */
"AcceptAllCta" : false, /* Afficher le CTA "Tout accepter" si "hightPrivacy : true" */
"orientation": "top", /* le bandeau doit être en haut (top) ou en bas (bottom) ? */

View File

@ -7,10 +7,13 @@ var scripts = document.getElementsByTagName('script'),
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": 323,
"cdn": cdn,
@ -181,6 +184,7 @@ var tarteaucitron = {
defaults = {
"adblocker": false,
"hashtag": '#tarteaucitron',
"cookieName": 'tarteaucitron',
"highPrivacy": false,
"orientation": "top",
"removeCredit": false,
@ -210,6 +214,10 @@ var tarteaucitron = {
// 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,
@ -277,6 +285,7 @@ var tarteaucitron = {
}
if (defaults.highPrivacy && !defaults.AcceptAllCta) {
html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
html += ' <span id="tarteaucitronDisclaimerAlert">';
html += ' ' + tarteaucitron.lang.alertBigPrivacy;
@ -887,7 +896,7 @@ var tarteaucitron = {
expireTime = time + timeExipre, // 365 days
regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
cookie = tarteaucitron.cookie.read().replace(regex, ""),
value = 'tarteaucitron=' + cookie + '!' + key + '=' + status,
value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
@ -899,7 +908,7 @@ var tarteaucitron = {
},
"read": function () {
"use strict";
var nameEQ = "tarteaucitron=",
var nameEQ = tarteaucitron.parameters.cookieName + "=",
ca = document.cookie.split(';'),
i,
c;
@ -1286,5 +1295,18 @@ var tarteaucitron = {
}
tarteaucitron.cookie.number();
},
"AddOrUpdate" : function(source, custom){
/**
Utility function to Add or update the fields of obj1 with the ones in obj2
*/
for(key in custom){
if(custom[key] instanceof Object){
source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
}else{
source[key] = custom[key];
}
}
return source;
}
};

View File

@ -711,7 +711,7 @@ tarteaucitron.services.facebook = {
"cookies": [],
"js": function () {
"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', 'fb-video'], '');
tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk');
if (tarteaucitron.isAjax === true) {
if (typeof FB !== "undefined") {
@ -722,7 +722,7 @@ tarteaucitron.services.facebook = {
"fallback": function () {
"use strict";
var id = 'facebook';
tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like'], tarteaucitron.engage(id));
tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like', 'fb-video'], tarteaucitron.engage(id));
}
};
@ -1073,7 +1073,7 @@ tarteaucitron.services.gtag = {
"use strict";
window.dataLayer = window.dataLayer || [];
tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.gtagUa, '', function () {
function gtag(){dataLayer.push(arguments);}
window.gtag = function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', tarteaucitron.user.gtagUa);
@ -1103,7 +1103,13 @@ tarteaucitron.services.googlemaps = {
tarteaucitron.user.mapscallback = 'tac_googlemaps_callback';
}
tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?v=3.exp&key=' + tarteaucitron.user.googlemapsKey + '&callback='+tarteaucitron.user.mapscallback);
// Add Google Maps libraries if any (https://developers.google.com/maps/documentation/javascript/libraries)
var googleMapsLibraries = '';
if (tarteaucitron.user.googlemapsLibraries) {
googleMapsLibraries = '&libraries=' + tarteaucitron.user.googlemapsLibraries;
}
tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?v=3.exp&key=' + tarteaucitron.user.googlemapsKey + '&callback='+tarteaucitron.user.mapscallback + googleMapsLibraries);
window.tac_googlemaps_callback = function () {
tarteaucitron.fallback(['googlemaps-canvas'], function (x) {
@ -2192,7 +2198,7 @@ tarteaucitron.services.multiplegtag = {
tarteaucitron.user.multiplegtagUa.forEach(function(ua) {
tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () {
function gtag(){dataLayer.push(arguments);}
window.gtag = function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', ua);
});
@ -2200,3 +2206,70 @@ tarteaucitron.services.multiplegtag = {
}
};
// Koban
tarteaucitron.services.koban = {
"key": "koban",
"type": "analytic",
"name": "Koban",
"uri": "https://koban.cloud/tos",
"needConsent": true,
"cookies": ['kbntrk'],
"js": function () {
"use strict";
if (tarteaucitron.user.kobanurl === undefined) {
return;
}
if (tarteaucitron.user.kobanapi === undefined) {
return;
}
window.KobanObject = 'kb';
window.kb = window.kb || function() {
window.kb.q = window.kb.q || [];
window.kb.q.push(arguments);
};
window.kb.l = new Date();
kb('reg', tarteaucitron.user.kobanapi);
tarteaucitron.addScript(tarteaucitron.user.kobanurl, '', function() {
});
}
};
// matomo
/*
1. Set the following variable before the initialization :
tarteaucitron.user.matomoId = YOUR_SITE_ID_FROM_MATOMO;
tarteaucitron.user.matomoHost = "YOUR_MATOMO_URL"; //eg: https://stat.mydomain.com/
2. Push the service :
(tarteaucitron.job = tarteaucitron.job || []).push('matomo');
3. HTML
You don't need to add any html code, if the service is autorized, the javascript is added. otherwise no.
*/
tarteaucitron.services.matomo = {
"key": "matomo",
"type": "analytic",
"name": "Matomo (formerly known as Piwik)",
"uri": "https://matomo.org/faq/general/faq_146/",
"needConsent": true,
"cookies": ['_pk_ref', '_pk_cvar', '_pk_id', '_pk_ses', '_pk_hsr', 'piwik_ignore', '_pk_uid'],
"js": function () {
"use strict";
if (tarteaucitron.user.matomoId === undefined) {
return;
}
window._paq = window._paq || [];
window._paq.push(["setSiteId", tarteaucitron.user.matomoId]);
window._paq.push(["setTrackerUrl", tarteaucitron.user.matomoHost + "piwik.php"]);
window._paq.push(["setDoNotTrack", 1]);
window._paq.push(["trackPageView"]);
window._paq.push(["setIgnoreClasses", ["no-tracking", "colorbox"]]);
window._paq.push(["enableLinkTracking"]);
tarteaucitron.addScript(tarteaucitron.user.matomoHost + 'piwik.js', '', '', true, 'defer', true);
}
};