From ee329bed34ee5433b36a0014b4644a89222649b6 Mon Sep 17 00:00:00 2001 From: bchatard Date: Mon, 6 Aug 2018 17:41:32 +0100 Subject: [PATCH 01/17] Enhance Universal Analytics : * add ability to set additional fields on "create" method (https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create) * add ability to set anonymizeIP to true (https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#anonymizeIp) * add ability to set path to "pageview" method (https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#page) --- tarteaucitron.services.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index e85bbb8..7b3be47 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1047,8 +1047,20 @@ tarteaucitron.services.analytics = { }; window.ga.l = new Date(); tarteaucitron.addScript('https://www.google-analytics.com/analytics.js', '', function () { - ga('create', tarteaucitron.user.analyticsUa, {'cookieExpires': 34128000}); - ga('send', 'pageview'); + var uaCreate = {'cookieExpires': 34128000}; + tarteaucitron.extend(uaCreate, tarteaucitron.user.analyticsUaCreate || {}); + ga('create', tarteaucitron.user.analyticsUa, createConfig); + + if (tarteaucitron.user.analyticsAnonymizeIp) { + ga('set', 'anonymizeIp', true); + } + + if (tarteaucitron.user.analyticsPageView) { + ga('send', 'pageview', tarteaucitron.user.analyticsPageView); + } else { + ga('send', 'pageview'); + } + if (typeof tarteaucitron.user.analyticsMore === 'function') { tarteaucitron.user.analyticsMore(); } From f91e157b312a4152c3321a1c0b34b3f4b8036db5 Mon Sep 17 00:00:00 2001 From: bchatard Date: Tue, 7 Aug 2018 17:56:54 +0100 Subject: [PATCH 02/17] Fix issue introduced in #187 --- tarteaucitron.services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 7b3be47..0a189eb 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1049,7 +1049,7 @@ tarteaucitron.services.analytics = { tarteaucitron.addScript('https://www.google-analytics.com/analytics.js', '', function () { var uaCreate = {'cookieExpires': 34128000}; tarteaucitron.extend(uaCreate, tarteaucitron.user.analyticsUaCreate || {}); - ga('create', tarteaucitron.user.analyticsUa, createConfig); + ga('create', tarteaucitron.user.analyticsUa, uaCreate); if (tarteaucitron.user.analyticsAnonymizeIp) { ga('set', 'anonymizeIp', true); From bcc03885e3e47e1e40565264f1b15b1d49c85129 Mon Sep 17 00:00:00 2001 From: Ayoub Degui Date: Tue, 7 Aug 2018 17:34:32 +0100 Subject: [PATCH 03/17] Adding personalisation for gajs script * adding anonymizeIp option * adding configurable _trackPageview --- tarteaucitron.services.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 0a189eb..f6262d2 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1020,7 +1020,16 @@ tarteaucitron.services.gajs = { "use strict"; window._gaq = window._gaq || []; window._gaq.push(['_setAccount', tarteaucitron.user.gajsUa]); - window._gaq.push(['_trackPageview']); + + if (tarteaucitron.user.gajsAnonymizeIp) { + window._gaq.push (['_gat._anonymizeIp']); + } + + if (tarteaucitron.user.gajsPageView) { + window._gaq.push(['_trackPageview, ' + tarteaucitron.user.gajsPageView]); + } else { + window._gaq.push(['_trackPageview']); + } tarteaucitron.addScript('//www.google-analytics.com/ga.js', '', function () { if (typeof tarteaucitron.user.gajsMore === 'function') { From f86f6d0b0fde6bd8f60e25eb84cec9e93588049e Mon Sep 17 00:00:00 2001 From: javiertury Date: Mon, 13 Aug 2018 13:29:50 +0200 Subject: [PATCH 04/17] Allow to force CDN --- tarteaucitron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 86c874f..4346997 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -3,7 +3,7 @@ // define correct path for files inclusion var scripts = document.getElementsByTagName('script'), path = scripts[scripts.length - 1].src.split('?')[0], - cdn = path.split('/').slice(0, -1).join('/') + '/', + cdn = (tarteaucitronForceCDN === undefined) ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN, alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch, tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage, tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire, From f59d0335125ddc3a36891e0d5066567af3803704 Mon Sep 17 00:00:00 2001 From: javiertury Date: Mon, 13 Aug 2018 13:33:52 +0200 Subject: [PATCH 05/17] Add support for Bing Ads Universal Event Tracking --- tarteaucitron.services.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 0a189eb..b385719 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2285,3 +2285,31 @@ tarteaucitron.services.matomo = { tarteaucitron.addScript(tarteaucitron.user.matomoHost + 'piwik.js', '', '', true, 'defer', true); } }; + +// bing ads universal event tracking +tarteaucitron.services.bingads = { + 'key': 'bingads', + 'type': 'ads', + 'name': 'Bing Ads Universal Event Tracking', + 'uri': 'https://advertise.bingads.microsoft.com/en-us/resources/policies/personalized-ads', + 'needConsent': true, + 'cookies': ['_uetmsclkid'], + 'js': function () { + 'use strict'; + var u = tarteaucitron.user.bingadsTag || 'uetq'; + window[u] = window[u] || []; + + tarteaucitron.addScript('https://bat.bing.com/bat.js', '', function () { + var bingadsCreate = {ti: tarteaucitron.user.bingadsID}; + + if ('bingadsStoreCookies' in tarteaucitron.user) { + bingadsCreate['storeConvTrackCookies'] = tarteaucitron.user.bingadsStoreCookies; + } + + bingadsCreate.q = window[u]; + window[u] = new UET(bingadsCreate); + window[u].push('pageload'); + }); + } +}; + From 8a4fc38be7c52fe4d37d574751c88043cd7eca82 Mon Sep 17 00:00:00 2001 From: javiertury Date: Mon, 13 Aug 2018 13:41:56 +0200 Subject: [PATCH 06/17] Improve Spanish translation --- lang/tarteaucitron.es.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lang/tarteaucitron.es.js b/lang/tarteaucitron.es.js index 512d805..b7df69f 100644 --- a/lang/tarteaucitron.es.js +++ b/lang/tarteaucitron.es.js @@ -1,12 +1,12 @@ /*global tarteaucitron */ tarteaucitron.lang = { "adblock": "Hola! Este sitio web es transparente y le da la opción de activar los servicios de terceros.", - "adblock_call": "Por favor deshabilite su AdBlocker para empezar a personalizar los servicios.", + "adblock_call": "Por favor deshabilite su AdBlocker para personalizar los servicios.", "reload": "Actualizar esta página", "alertBigScroll": "Al continuar para desplazarse,", "alertBigClick": "Si continuas navegando por este sitio web,", - "alertBig": "estar permitiendo servicios terceros", + "alertBig": "estas permitiendo servicios de terceros", "alertBigPrivacy": "Este sitio web usa cookies y te permite controlar lo que deseas activar", "alertSmall": "Gestionar servicios", @@ -35,12 +35,12 @@ tarteaucitron.lang = { "details": "Las redes publicitarias pueden generar ingresos mediante la venta de espacios publicitarios en el sitio." }, "analytic": { - "title": "Mediciión de audiencia", + "title": "Medición de audiencia", "details": "Los servicios de medición de audiencia se usan para generar asistencia estadísticas útiles para mejorar el sitio." }, "social": { "title": "Redes sociales", - "details": "Las redes sociales pueden aumentar la usabilidad del sitio web y ayudar a promoverlo a través de la contribución." + "details": "Las redes sociales pueden aumentar la usabilidad del sitio web y ayudar a promoverlo cuando se comparte." }, "video": { "title": "Videos", @@ -56,7 +56,7 @@ tarteaucitron.lang = { }, "api": { "title": "APIs", - "details": "APIs se utilizan para cargar scripts: geolocalización, motor de búsqueda, traducciones, ..." + "details": "Los APIs se utilizan para cargar scripts: geolocalización, motor de búsqueda, traducciones, ..." }, "other": { "title": "Otro", From d8c9031d54072a06d719727c041334d5b0067064 Mon Sep 17 00:00:00 2001 From: javiertury Date: Mon, 13 Aug 2018 21:06:38 +0200 Subject: [PATCH 07/17] Fix #197: tarteaucitronForceCDN always defined Make sure that `tarteaucitronForceCDN` is always defined. If underfined convert to empty string. When defining `cdn`, use default cdn if `tarteaucitronForceCDN` is an empty string. --- tarteaucitron.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 4346997..a971d5d 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -3,7 +3,8 @@ // define correct path for files inclusion var scripts = document.getElementsByTagName('script'), path = scripts[scripts.length - 1].src.split('?')[0], - cdn = (tarteaucitronForceCDN === undefined) ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN, + 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, From b79fbec9f7ef4fe357dabdf7212a77f25c93569a Mon Sep 17 00:00:00 2001 From: Lena Date: Tue, 14 Aug 2018 10:36:33 +0200 Subject: [PATCH 08/17] Accessibility fixes --- css/tarteaucitron.css | 28 ++++++++++- tarteaucitron.js | 108 ++++++++++++++++++++++-------------------- 2 files changed, 83 insertions(+), 53 deletions(-) diff --git a/css/tarteaucitron.css b/css/tarteaucitron.css index 3b0951d..84806e0 100644 --- a/css/tarteaucitron.css +++ b/css/tarteaucitron.css @@ -1,3 +1,13 @@ +.modal-open{ + overflow: hidden; + height: 100%; +} + + +a:focus, button:focus { + outline: 2px solid #cb3333; +} + /*** * Responsive layout for the control panel */ @@ -71,11 +81,14 @@ color: #fff; } -#tarteaucitron b { +#tarteaucitron strong { font-size: 22px; font-weight: 500; } +#tarteaucitron ul { + padding: 0; +} /*** * Root div added just before */ @@ -96,6 +109,18 @@ vertical-align: initial; } +#tarteaucitronRoot h1 { + font-size: 1.5em; + text-align: center; + color: #fff; +} + +#tarteaucitronRoot h2 { + display: inline-block; + margin-left: 5px; + color: #fff; +} + /*** * Control panel */ @@ -289,6 +314,7 @@ text-align: center; text-decoration: none; width: auto; + border: 0; } #tarteaucitron #tarteaucitronServices .tarteaucitronLine .tarteaucitronName .tarteaucitronListCookies { diff --git a/tarteaucitron.js b/tarteaucitron.js index a971d5d..a7b794c 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -55,7 +55,7 @@ var tarteaucitron = { 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; + document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig; } if (tarteaucitron.orientation === 'top') { @@ -110,7 +110,7 @@ var tarteaucitron = { 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; + document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig; } if (tarteaucitron.orientation === 'top') { document.getElementById('tarteaucitronPercentage').style.top = heightPosition; @@ -236,46 +236,45 @@ var tarteaucitron = { // Step 3: prepare the html html += '
'; - html += '
'; - html += '
'; - html += '
'; + html += ''; + html += ''; + html += ' '; html += '
'; - html += '
'; + html += '

'+ tarteaucitron.lang.title + '

'; html += '
'; - html += ' ' + tarteaucitron.lang.all + ''; + html += '

' + tarteaucitron.lang.all + '

'; html += '
'; html += '
'; - html += '
'; - html += ' ✓ ' + tarteaucitron.lang.allow; - html += '
'; - html += '
'; - html += ' ✗ ' + tarteaucitron.lang.deny; - html += '
'; + html += ' '; + html += ' '; html += '
'; html += '
'; html += '
'; html += ' ' + tarteaucitron.lang.disclaimer; if (defaults.removeCredit === false) { html += '

'; - html += ' ' + tarteaucitron.lang.credit + ''; + html += ' ' + tarteaucitron.lang.credit + ''; } html += '
'; html += '
'; - html += '
'; + html += '
    '; for (i = 0; i < cat.length; i += 1) { - html += '
    '; + html += '
  • '; html += '
    '; - html += ' ' + tarteaucitron.lang[cat[i]].title; + html += ' '; html += '
    '; html += '
    '; html += ' ' + tarteaucitron.lang[cat[i]].details; html += '
    '; - html += '
  • '; - html += '
    '; + html += '
      '; } - html += '
      '; + html += '
    '; html += '
    '; html += '
    '; html += '
    '; @@ -289,43 +288,43 @@ var tarteaucitron = { html += ' '; html += ' ' + tarteaucitron.lang.alertBigPrivacy; html += ' '; - html += ' '; + html += ' '; html += '
    '; } else { html += '
    '; html += ' '; html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig; html += ' '; - html += ' '; + html += ' '; + html += ' '; html += '
    '; html += '
    '; } if (defaults.showAlertSmall === true) { html += '
    '; - html += '
    '; + html += '
    0
    '; + html += ' '; html += '
    '; - html += '
    '; + html += '
    '; + html += ' '; html += '
    '; - html += ' 0 cookie'; + html += ' 0 cookie'; html += '
    '; html += '
    '; html += '
    '; @@ -388,11 +387,11 @@ var tarteaucitron = { html = '
    '; html += ' '; html += ' ' + tarteaucitron.lang.adblock + '
    '; - html += ' ' + tarteaucitron.lang.adblock_call + ''; + html += ' ' + tarteaucitron.lang.adblock_call + ''; html += '
    '; - html += ' '; + html += ' '; html += '
    '; html += '
    '; div.id = 'tarteaucitronRoot'; @@ -426,27 +425,27 @@ var tarteaucitron = { if (tarteaucitron.added[service.key] !== true) { tarteaucitron.added[service.key] = true; - html += '
    '; + html += '
  • '; html += '
    '; - html += ' ' + service.name + '
    '; + html += '

    ' + service.name + '


    '; html += '
    '; - html += ' '; + html += ' '; html += ' ' + tarteaucitron.lang.more; html += ' '; html += ' - '; - html += ' '; + html += ' '; html += ' ' + tarteaucitron.lang.source; html += ' '; html += '
    '; html += '
    '; - html += '
    '; + html += '
    '; - html += '
    '; + html += ' '; + html += '
    '; + html += ' '; html += '
    '; - html += '
  • '; + html += ''; tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block'); @@ -653,6 +652,8 @@ var tarteaucitron = { tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block'); tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block'); tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none'); + document.getElementById('tarteaucitronClosePanel').focus(); + document.getElementsByTagName('body')[0].classList.add('modal-open'); tarteaucitron.userInterface.jsSizing('main'); }, "closePanel": function () { @@ -673,6 +674,9 @@ var tarteaucitron = { } else { tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none'); } + document.getElementById('tarteaucitronCloseAlert').focus(); + document.getElementsByTagName('body')[0].classList.remove('modal-open'); + }, "openAlert": function () { "use strict"; @@ -1036,14 +1040,14 @@ var tarteaucitron = { html += '
    '; } html += '
    '; - html += '
    × ' + name + ''; + html += '
    ' + name + ''; html += '
    '; html += '
    ' + cookies[i].split('=').slice(1).join('=') + '
    '; html += '
    '; } } else { html += '
    '; - html += '
    -
    '; + html += '
    -
    '; html += '
    '; html += '
    '; } @@ -1243,10 +1247,10 @@ var tarteaucitron = { html += '
    '; html += '
    '; - html += ' ' + tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback; - html += '
    '; + html += ' ' + tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback; + html += '
    '; + html += ' '; html += '
    '; html += '
    '; From 49c6cc77cd6e6ed3a115287bd51c3e61fb0eebd4 Mon Sep 17 00:00:00 2001 From: Lena Date: Tue, 14 Aug 2018 13:42:49 +0200 Subject: [PATCH 09/17] add a wrapper with aria-hidden when dialog is open + update CSS --- css/tarteaucitron.css | 44 ++++++++++++++++++++++++++-------- tarteaucitron.js | 56 +++++++++++++++++++++++++++++++++---------- 2 files changed, 78 insertions(+), 22 deletions(-) diff --git a/css/tarteaucitron.css b/css/tarteaucitron.css index 84806e0..9ae70c8 100644 --- a/css/tarteaucitron.css +++ b/css/tarteaucitron.css @@ -3,7 +3,6 @@ height: 100%; } - a:focus, button:focus { outline: 2px solid #cb3333; } @@ -47,6 +46,18 @@ a:focus, button:focus { #tarteaucitron #tarteaucitronServices .tarteaucitronTitle { text-align: left !important; } + + .tarteaucitronName h2 { + max-width: 80%; + } + + #tarteaucitron #tarteaucitronServices .tarteaucitronLine .tarteaucitronAsk { + text-align: center !important; + } + + #tarteaucitron #tarteaucitronServices .tarteaucitronLine .tarteaucitronAsk button { + margin-bottom: 5px; + } } @media screen and (min-width:768px) and (max-width:991px) { @@ -77,6 +88,12 @@ a:focus, button:focus { text-decoration: none; } +#tarteaucitronRoot button { + background: transparent; + border: 0; +} + +#tarteaucitronAlertBig strong, #tarteaucitronAlertSmall strong, #tarteaucitronAlertBig a, #tarteaucitronAlertSmall a { color: #fff; } @@ -89,6 +106,12 @@ a:focus, button:focus { #tarteaucitron ul { padding: 0; } + +.cookie-list { + list-style: none; + padding: 0; + margin: 0; +} /*** * Root div added just before */ @@ -188,8 +211,8 @@ a:focus, button:focus { position: relative; } -#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronTitle, -#tarteaucitron #tarteaucitronServices .tarteaucitronTitle, +#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronTitle button, +#tarteaucitron #tarteaucitronServices .tarteaucitronTitle button, #tarteaucitron #tarteaucitronInfo, #tarteaucitron #tarteaucitronServices .tarteaucitronDetails { background: #333; @@ -224,6 +247,7 @@ a:focus, button:focus { #tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronTitle { padding: 5px 10px; + margin: 0; } #tarteaucitron #tarteaucitronInfo, @@ -275,7 +299,7 @@ a:focus, button:focus { margin-top: 2px; } -#tarteaucitron #tarteaucitronServices .tarteaucitronMainLine .tarteaucitronName b { +#tarteaucitron #tarteaucitronServices .tarteaucitronMainLine .tarteaucitronName button { color: #fff; } @@ -348,12 +372,12 @@ a:focus, button:focus { } #tarteaucitronAlertBig #tarteaucitronDisclaimerAlert, -#tarteaucitronAlertBig #tarteaucitronDisclaimerAlert b { +#tarteaucitronAlertBig #tarteaucitronDisclaimerAlert strong { font: 15px verdana; color: #fff; } -#tarteaucitronAlertBig #tarteaucitronDisclaimerAlert b { +#tarteaucitronAlertBig #tarteaucitronDisclaimerAlert strong { font-weight: 700; } @@ -487,7 +511,7 @@ a:focus, button:focus { text-align: left; } -#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList b { +#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList strong { color: #333; } @@ -498,7 +522,7 @@ a:focus, button:focus { text-align: left; } -#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesTitle b { +#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesTitle strong { color: #fff; font-size: 16px; } @@ -523,7 +547,7 @@ a:focus, button:focus { width: 50%; } -#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronCookiesListMain .tarteaucitronCookiesListLeft a b { +#tarteaucitronAlertSmall #tarteaucitronCookiesListContainer #tarteaucitronCookiesList .tarteaucitronCookiesListMain .tarteaucitronCookiesListLeft a strong { color: darkred; } @@ -557,7 +581,7 @@ a:focus, button:focus { vertical-align: middle; } -.tac_activate .tac_float b { +.tac_activate .tac_float strong { color: #fff; } diff --git a/tarteaucitron.js b/tarteaucitron.js index a7b794c..1b6fb6d 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -324,7 +324,7 @@ var tarteaucitron = { html += ' ' + tarteaucitron.lang.close; html += ' '; html += '
    '; - html += ' 0 cookie'; + html += '

    0 cookie

    '; html += '
    '; html += '
    '; html += '
    '; @@ -336,10 +336,27 @@ var tarteaucitron = { tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () { if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) { + + // 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; + + // move el into wrapper + //wrapper.appendChild(el); + if (tarteaucitron.job !== undefined) { tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job); for (index = 0; index < tarteaucitron.job.length; index += 1) { @@ -384,16 +401,28 @@ var tarteaucitron = { if (defaults.adblocker === true) { setTimeout(function () { if (tarteaucitronNoAdBlocker === false) { - html = '
    '; - 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; @@ -653,6 +682,7 @@ var tarteaucitron = { 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.jsSizing('main'); }, @@ -675,6 +705,7 @@ var tarteaucitron = { tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none'); } document.getElementById('tarteaucitronCloseAlert').focus(); + document.getElementById('contentWrapper').setAttribute("aria-hidden", "false"); document.getElementsByTagName('body')[0].classList.remove('modal-open'); }, @@ -1027,24 +1058,25 @@ var tarteaucitron = { if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) { savedname = tarteaucitron.cookie.owner[name].join(' // '); html += '
    '; - html += '
    '; + html += '

    '; html += ' ' + tarteaucitron.cookie.owner[name].join(' // '); - html += '

    '; - html += '
    '; + html += ' '; + html += '
    '; } else { html += '
    '; html += '
    -
    '; From 412206eea53b4e1033755c65ec4e326fd27be023 Mon Sep 17 00:00:00 2001 From: Lena Date: Tue, 14 Aug 2018 15:45:48 +0200 Subject: [PATCH 10/17] add focusTrap method --- tarteaucitron.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tarteaucitron.js b/tarteaucitron.js index 1b6fb6d..d6db161 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -67,6 +67,7 @@ var tarteaucitron = { } } }, false); + window.addEventListener("keydown", function (evt) { if (evt.keyCode === 27) { tarteaucitron.userInterface.closePanel(); @@ -125,6 +126,21 @@ var tarteaucitron = { 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 !== '') { @@ -678,12 +694,15 @@ var tarteaucitron = { }, "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 () { @@ -709,6 +728,46 @@ var tarteaucitron = { 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'; From f64fecd67b2b2b6cb31ef57de0a246b5b86d622f Mon Sep 17 00:00:00 2001 From: Lena Date: Tue, 14 Aug 2018 15:55:49 +0200 Subject: [PATCH 11/17] better comments + add translations --- lang/tarteaucitron.cs.js | 8 ++++++++ lang/tarteaucitron.de.js | 8 ++++++++ lang/tarteaucitron.en.js | 8 ++++++++ lang/tarteaucitron.es.js | 18 +++++++++++++----- lang/tarteaucitron.fr.js | 8 ++++++++ lang/tarteaucitron.it.js | 8 ++++++++ lang/tarteaucitron.nl.js | 8 ++++++++ lang/tarteaucitron.pl.js | 8 ++++++++ lang/tarteaucitron.pt.js | 9 +++++++++ lang/tarteaucitron.ru.js | 8 ++++++++ tarteaucitron.js | 6 +----- 11 files changed, 87 insertions(+), 10 deletions(-) diff --git a/lang/tarteaucitron.cs.js b/lang/tarteaucitron.cs.js index 057d71f..915d950 100644 --- a/lang/tarteaucitron.cs.js +++ b/lang/tarteaucitron.cs.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Dozvědět se více", "source": "Zobrazit oficiální stránku", "credit": "Správce cookies od tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "je vypnutý.", diff --git a/lang/tarteaucitron.de.js b/lang/tarteaucitron.de.js index 23cdc5f..939149d 100644 --- a/lang/tarteaucitron.de.js +++ b/lang/tarteaucitron.de.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Weiter lesen", "source": "Zur offiziellen Webseite", "credit": "Cookies manager von tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "ist deaktiviert.", diff --git a/lang/tarteaucitron.en.js b/lang/tarteaucitron.en.js index 90c8ebb..8441457 100644 --- a/lang/tarteaucitron.en.js +++ b/lang/tarteaucitron.en.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Read more", "source": "View the official website", "credit": "Cookies manager by tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "is disabled.", diff --git a/lang/tarteaucitron.es.js b/lang/tarteaucitron.es.js index b7df69f..986ef67 100644 --- a/lang/tarteaucitron.es.js +++ b/lang/tarteaucitron.es.js @@ -1,12 +1,12 @@ /*global tarteaucitron */ tarteaucitron.lang = { "adblock": "Hola! Este sitio web es transparente y le da la opción de activar los servicios de terceros.", - "adblock_call": "Por favor deshabilite su AdBlocker para personalizar los servicios.", + "adblock_call": "Por favor deshabilite su AdBlocker para empezar a personalizar los servicios.", "reload": "Actualizar esta página", "alertBigScroll": "Al continuar para desplazarse,", "alertBigClick": "Si continuas navegando por este sitio web,", - "alertBig": "estas permitiendo servicios de terceros", + "alertBig": "estar permitiendo servicios terceros", "alertBigPrivacy": "Este sitio web usa cookies y te permite controlar lo que deseas activar", "alertSmall": "Gestionar servicios", @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Leer más", "source": "Ver sitio web oficial", "credit": "Gestor de cookies realizada por tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "está deshabilitado.", @@ -35,12 +43,12 @@ tarteaucitron.lang = { "details": "Las redes publicitarias pueden generar ingresos mediante la venta de espacios publicitarios en el sitio." }, "analytic": { - "title": "Medición de audiencia", + "title": "Mediciión de audiencia", "details": "Los servicios de medición de audiencia se usan para generar asistencia estadísticas útiles para mejorar el sitio." }, "social": { "title": "Redes sociales", - "details": "Las redes sociales pueden aumentar la usabilidad del sitio web y ayudar a promoverlo cuando se comparte." + "details": "Las redes sociales pueden aumentar la usabilidad del sitio web y ayudar a promoverlo a través de la contribución." }, "video": { "title": "Videos", @@ -56,7 +64,7 @@ tarteaucitron.lang = { }, "api": { "title": "APIs", - "details": "Los APIs se utilizan para cargar scripts: geolocalización, motor de búsqueda, traducciones, ..." + "details": "APIs se utilizan para cargar scripts: geolocalización, motor de búsqueda, traducciones, ..." }, "other": { "title": "Otro", diff --git a/lang/tarteaucitron.fr.js b/lang/tarteaucitron.fr.js index 6512403..09fd7e1 100644 --- a/lang/tarteaucitron.fr.js +++ b/lang/tarteaucitron.fr.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "En savoir plus", "source": "Voir le site officiel", "credit": "Gestion des cookies par tarteaucitron.js", + + "toggleInfoBox": "Afficher/masquer les informations sur le stockage des cookies", + "title": "Panneau de gestion des cookies", + "cookieDetail": "Détail des cookies", + "ourSite": "sur notre site", + "newWindow": "(nouvelle fenêtre)", + "allowAll": "Autoriser tous les cookies", + "denyAll": "Interdire tous les cookies", "fallback": "est désactivé.", diff --git a/lang/tarteaucitron.it.js b/lang/tarteaucitron.it.js index 8b2faf1..89f8393 100644 --- a/lang/tarteaucitron.it.js +++ b/lang/tarteaucitron.it.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Saperne di più", "source": "Vai al sito ufficiale", "credit": "Gestione dei cookies da tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "è disattivato", diff --git a/lang/tarteaucitron.nl.js b/lang/tarteaucitron.nl.js index dda9e78..2b7a1a5 100644 --- a/lang/tarteaucitron.nl.js +++ b/lang/tarteaucitron.nl.js @@ -30,6 +30,14 @@ tarteaucitron.lang = { "fallback": "is uitgeschakeld.", + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", + "ads": { "title": "Advertentienetwerk", "details": "Advertentienetwerken kunnen inkomsten genereren door advertentieruimte op de site te verkopen." diff --git a/lang/tarteaucitron.pl.js b/lang/tarteaucitron.pl.js index 6fe5b8e..fdbcc95 100644 --- a/lang/tarteaucitron.pl.js +++ b/lang/tarteaucitron.pl.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Więcej informacji", "source": "Zobacz oficjalną stronę internetowa", "credit": "Cookies menadżer z tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "jest nieaktywna.", diff --git a/lang/tarteaucitron.pt.js b/lang/tarteaucitron.pt.js index 690fd20..303893b 100644 --- a/lang/tarteaucitron.pt.js +++ b/lang/tarteaucitron.pt.js @@ -25,6 +25,15 @@ tarteaucitron.lang = { "more": "Ler mais", "source": "Ver o site oficial", "credit": "Gerenciador de cookies por tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", + "fallback": "está desativado.", "ads": { "title": "Rede de anúncios", diff --git a/lang/tarteaucitron.ru.js b/lang/tarteaucitron.ru.js index d99370c..995c8c8 100644 --- a/lang/tarteaucitron.ru.js +++ b/lang/tarteaucitron.ru.js @@ -27,6 +27,14 @@ tarteaucitron.lang = { "more": "Подробнее", "source": "Посетите официальный сайт", "credit": "Кукис манаджер tarteaucitron.js", + + "toggleInfoBox": "Show/hide informations about cookie storage", + "title": "Cookies management panel", + "cookieDetail": "Cookie detail for", + "ourSite": "on our site", + "newWindow": "(new window)", + "allowAll": "Allow all cookies", + "denyAll": "Deny all cookies", "fallback": "Деактивирован.", diff --git a/tarteaucitron.js b/tarteaucitron.js index d6db161..c6a9a11 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -353,7 +353,7 @@ var tarteaucitron = { tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () { if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) { - // create wrapper container + // 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"; @@ -369,10 +369,6 @@ var tarteaucitron = { body.appendChild(div, body); div.innerHTML = html; - - // move el into wrapper - //wrapper.appendChild(el); - if (tarteaucitron.job !== undefined) { tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job); for (index = 0; index < tarteaucitron.job.length; index += 1) { From 0cac45893b6218f3b9b1e8a5c5aa2be3512ae14e Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Tue, 14 Aug 2018 16:54:27 +0200 Subject: [PATCH 12/17] Add support for analytics pre-pageview userland logic It allows to prepare data sent during pageview, for instance `ec:setAction` for enhanced e-commerce analytics. --- tarteaucitron.services.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index f6262d2..c87cfff 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1064,6 +1064,10 @@ tarteaucitron.services.analytics = { ga('set', 'anonymizeIp', true); } + if (typeof tarteaucitron.user.analyticsPrepare === 'function') { + tarteaucitron.user.analyticsPrepare(); + } + if (tarteaucitron.user.analyticsPageView) { ga('send', 'pageview', tarteaucitron.user.analyticsPageView); } else { From 5b1a1a332bfb19dc69d205297877441717afff55 Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Tue, 28 Aug 2018 10:01:18 +0200 Subject: [PATCH 13/17] Reset and fix style issue --- css/tarteaucitron.css | 69 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/css/tarteaucitron.css b/css/tarteaucitron.css index 9ae70c8..7490f38 100644 --- a/css/tarteaucitron.css +++ b/css/tarteaucitron.css @@ -3,8 +3,41 @@ height: 100%; } -a:focus, button:focus { - outline: 2px solid #cb3333; +/*** +* Reset CSS +*/ +#tarteaucitronRoot div, #tarteaucitronRoot span, #tarteaucitronRoot applet, #tarteaucitronRoot object, #tarteaucitronRoot iframe, #tarteaucitronRoot h1, #tarteaucitronRoot h2, #tarteaucitronRoot h3, #tarteaucitronRoot h4, #tarteaucitronRoot h5, #tarteaucitronRoot h6, #tarteaucitronRoot p, #tarteaucitronRoot blockquote, #tarteaucitronRoot pre, #tarteaucitronRoot a, #tarteaucitronRoot abbr, #tarteaucitronRoot acronym, #tarteaucitronRoot address, #tarteaucitronRoot big, #tarteaucitronRoot cite, #tarteaucitronRoot code, #tarteaucitronRoot del, #tarteaucitronRoot dfn, #tarteaucitronRoot em, #tarteaucitronRoot img, #tarteaucitronRoot ins, #tarteaucitronRoot kbd, #tarteaucitronRoot q, #tarteaucitronRoot s, #tarteaucitronRoot samp, #tarteaucitronRoot small, #tarteaucitronRoot strike, #tarteaucitronRoot strong, #tarteaucitronRoot sub, #tarteaucitronRoot sup, #tarteaucitronRoot tt, #tarteaucitronRoot var, #tarteaucitronRoot b, #tarteaucitronRoot u, #tarteaucitronRoot i, #tarteaucitronRoot center, #tarteaucitronRoot dl, #tarteaucitronRoot dt, #tarteaucitronRoot dd, #tarteaucitronRoot ol, #tarteaucitronRoot ul, #tarteaucitronRoot li, #tarteaucitronRoot fieldset, #tarteaucitronRoot form, #tarteaucitronRoot label, #tarteaucitronRoot legend, #tarteaucitronRoot table, #tarteaucitronRoot caption, #tarteaucitronRoot tbody, #tarteaucitronRoot tfoot, #tarteaucitronRoot thead, #tarteaucitronRoot tr, #tarteaucitronRoot th, #tarteaucitronRoot td,article, #tarteaucitronRoot aside, #tarteaucitronRoot canvas, #tarteaucitronRoot details, #tarteaucitronRoot embed, #tarteaucitronRoot figure, #tarteaucitronRoot figcaption, #tarteaucitronRoot footer, #tarteaucitronRoot header, #tarteaucitronRoot hgroup, #tarteaucitronRoot menu, #tarteaucitronRoot nav, #tarteaucitronRoot output, #tarteaucitronRoot ruby, #tarteaucitronRoot section, #tarteaucitronRoot summary, #tarteaucitronRoot time, #tarteaucitronRoot mark, #tarteaucitronRoot audio, #tarteaucitronRoot video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; + background: initial; + text-align: initial; + text-shadow: initial; +} +/* HTML5 display-role reset for older browsers */ +#tarteaucitronRoot article, #tarteaucitronRoot aside, #tarteaucitronRoot details, #tarteaucitronRoot figcaption, #tarteaucitronRoot figure, #tarteaucitronRoot footer, #tarteaucitronRoot header, #tarteaucitronRoot hgroup, #tarteaucitronRoot menu, #tarteaucitronRoot nav, #tarteaucitronRoot section { + display: block; +} +#tarteaucitronRoot ol, #tarteaucitronRoot ul { + list-style: none; +} +#tarteaucitronRoot blockquote, #tarteaucitronRoot q { + quotes: none; +} +#tarteaucitronRoot blockquote:before, #tarteaucitronRoot blockquote:after, #tarteaucitronRoot q:before, #tarteaucitronRoot q:after { + content: ''; + content: none; +} +#tarteaucitronRoot table { + border-collapse: collapse; + border-spacing: 0; +} + +#tarteaucitronRoot a:focus, #tarteaucitronRoot button:focus { + /*outline: 2px solid #cb3333;*/ } /*** @@ -77,6 +110,16 @@ a:focus, button:focus { zoom: 1; } +#tarteaucitronRoot div#tarteaucitron { + left: 0; + right: 0; + margin: auto; +} + +#tarteaucitronRoot button#tarteaucitronBack { + background: #eee; +} + #tarteaucitron .clear { clear: both; } @@ -136,6 +179,7 @@ a:focus, button:focus { font-size: 1.5em; text-align: center; color: #fff; + margin: 15px 0 28px; } #tarteaucitronRoot h2 { @@ -144,6 +188,10 @@ a:focus, button:focus { color: #fff; } +h2#tarteaucitronCookiesNumberBis { + margin-left: 0; +} + /*** * Control panel */ @@ -346,6 +394,16 @@ a:focus, button:focus { font-size: 12px; } +#tarteaucitron h3 { + font-size: 18px; +} + +#tarteaucitron #tarteaucitronMainLineOffset .tarteaucitronName { + width: auto!important; + margin-left: 0!important; + font-size: 14px; +} + /*** * Big alert */ @@ -357,7 +415,7 @@ a:focus, button:focus { bottom: 0; } -#tarteaucitronAlertBig { +#tarteaucitronRoot #tarteaucitronAlertBig { background: #333; color: #fff; display: none; @@ -366,9 +424,12 @@ a:focus, button:focus { padding: 5px 5%; position: fixed; text-align: center; - width: 90%; box-sizing: content-box; z-index: 2147483645; + text-align: center; + padding: 10px; + margin: auto; + width: 100%; } #tarteaucitronAlertBig #tarteaucitronDisclaimerAlert, From 618eea713f84d0916e934933d4032a12e36274f8 Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Tue, 28 Aug 2018 10:33:19 +0200 Subject: [PATCH 14/17] Fix the default value for the parameters --- tarteaucitron.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index c6a9a11..8c7795c 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -16,7 +16,7 @@ var scripts = document.getElementsByTagName('script'), var tarteaucitron = { - "version": 323, + "version": 20180828, "cdn": cdn, "user": {}, "lang": {}, @@ -213,14 +213,19 @@ var tarteaucitron = { // Step 0: get params if (params !== undefined) { - tarteaucitron.extend(defaults, params); + + for (var k in defaults) { + if(!tarteaucitron.parameters.hasOwnProperty(k)) { + tarteaucitron.parameters[k] = defaults[k]; + } + } } // global - tarteaucitron.orientation = defaults.orientation; - tarteaucitron.hashtag = defaults.hashtag; - tarteaucitron.highPrivacy = defaults.highPrivacy; - tarteaucitron.handleBrowserDNTRequest = defaults.handleBrowserDNTRequest; + tarteaucitron.orientation = tarteaucitron.parameters.orientation; + tarteaucitron.hashtag = tarteaucitron.parameters.hashtag; + tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy; + tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest; // Step 1: load css linkElement.rel = 'stylesheet'; @@ -273,7 +278,7 @@ var tarteaucitron = { html += '
    '; html += '
    '; html += ' ' + tarteaucitron.lang.disclaimer; - if (defaults.removeCredit === false) { + if (tarteaucitron.parameters.removeCredit === false) { html += '

    '; html += ' ' + tarteaucitron.lang.credit + ''; } @@ -295,11 +300,11 @@ var tarteaucitron = { html += '
    '; html += ''; - if (defaults.orientation === 'bottom') { + if (tarteaucitron.parameters.orientation === 'bottom') { orientation = 'Bottom'; } - if (defaults.highPrivacy) { + if (tarteaucitron.parameters.highPrivacy) { html += '
    '; html += ' '; html += ' ' + tarteaucitron.lang.alertBigPrivacy; @@ -323,7 +328,7 @@ var tarteaucitron = { html += '
    '; } - if (defaults.showAlertSmall === true) { + if (tarteaucitron.parameters.showAlertSmall === true) { html += '
    '; html += ' '; html += '
    '; @@ -351,7 +356,7 @@ var tarteaucitron = { } tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () { - if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) { + 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'); @@ -408,9 +413,9 @@ var tarteaucitron = { tarteaucitron.cookie.number(); setInterval(tarteaucitron.cookie.number, 60000); } - }, defaults.adblocker); + }, tarteaucitron.parameters.adblocker); - if (defaults.adblocker === true) { + if (tarteaucitron.parameters.adblocker === true) { setTimeout(function () { if (tarteaucitronNoAdBlocker === false) { html = '