From 22d3005fbd0c49f332032bf21983cc6f2777e8b2 Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Thu, 25 Sep 2014 19:50:38 +0200 Subject: [PATCH] Add Allow button directly in the service container --- css/tarteaucitron.css | 44 ++++++++++++++++++++++++++++++++-- lang/tarteaucitron.en.js | 2 ++ lang/tarteaucitron.fr.js | 2 ++ tarteaucitron.js | 15 ++++++++++++ tarteaucitron.services.js | 50 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 108 insertions(+), 5 deletions(-) diff --git a/css/tarteaucitron.css b/css/tarteaucitron.css index 3bad697..ad5a109 100644 --- a/css/tarteaucitron.css +++ b/css/tarteaucitron.css @@ -156,7 +156,8 @@ } #tarteaucitron .tarteaucitronLine .tarteaucitronAsk .tarteaucitronAllow, -#tarteaucitron .tarteaucitronLine .tarteaucitronAsk .tarteaucitronDeny { +#tarteaucitron .tarteaucitronLine .tarteaucitronAsk .tarteaucitronDeny, +.tac_activate .tarteaucitronAllow { background: gray; color: #fff; cursor: pointer; @@ -167,7 +168,6 @@ width: auto; } - /*** * Big alert */ @@ -236,6 +236,46 @@ width: 10px; } +/*** + * Fallback activate link + */ + +.tac_activate { + background: #333; + display: block; + height: 100%; + min-height: 100px; + position: relative; + width: 100%; +} + +.tac_activate .tac_float { + background: #333; + bottom: 0; + box-sizing: border-box; + color: #fff; + font-family: verdana; + font-size: 14px; + height: 80px; + left: 0; + line-height: initial; + margin: auto; + padding: 10px 0; + position: absolute; + right: 0; + text-align: center; + top: 0; +} + +.tac_activate .tac_float b { + color: #fff !important; +} + +.tac_activate .tac_float .tarteaucitronAllow { + background-color: #1B870B; + margin-top: 10px; +} + /*** * Fallback links for social networks */ diff --git a/lang/tarteaucitron.en.js b/lang/tarteaucitron.en.js index 70e22b8..b880219 100644 --- a/lang/tarteaucitron.en.js +++ b/lang/tarteaucitron.en.js @@ -10,6 +10,8 @@ tarteaucitron.lang = { "deny": "Deny", "more": "Read more", "source": "View the official website", + + "fallback": "is disabled.", "ads": { "title": "Advertising network", diff --git a/lang/tarteaucitron.fr.js b/lang/tarteaucitron.fr.js index fb8e631..a9c1045 100644 --- a/lang/tarteaucitron.fr.js +++ b/lang/tarteaucitron.fr.js @@ -10,6 +10,8 @@ tarteaucitron.lang = { "deny": "Interdire", "more": "En savoir plus", "source": "Voir le site officiel", + + "fallback": "est désactivé.", "ads": { "title": "Régies publicitaires", diff --git a/tarteaucitron.js b/tarteaucitron.js index f4319fe..a5cbc84 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -381,5 +381,20 @@ var tarteaucitron = { } } } + }, + "engage": function (id) { + "use strict"; + var html = ''; + + html += '
'; + html += '
'; + html += ' ' + id + ' ' + tarteaucitron.lang.fallback + '
'; + html += '
'; + html += ' ' + tarteaucitron.lang.allow; + html += '
'; + html += '
'; + html += '
'; + + return html; } }; \ No newline at end of file diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index b6e5d50..5a8fb6c 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -14,6 +14,15 @@ tarteaucitron.services.disqus = { } tarteaucitron.addScript('//' + tarteaucitron.user.disqusShortname + '.disqus.com/embed.js'); tarteaucitron.addScript('//' + tarteaucitron.user.disqusShortname + '.disqus.com/count.js'); + }, + "fallback": function () { + "use strict"; + var id = 'disqus'; + + document.getElementById('disqus_thread').innerHTML = tarteaucitron.engage(id); + document.getElementById('tacEngage' + id).onclick = function () { + tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true); + }; } }; @@ -31,14 +40,23 @@ tarteaucitron.services.sharethis = { } var switchTo5x = true, uri = ('https:' === document.location.protocol ? 'https://ws' : 'http://w') + '.sharethis.com/button/buttons.js'; + + tarteaucitron.fallback(['tacSharethis'], ''); tarteaucitron.addScript(uri, '', function () { stLight.options({publisher: tarteaucitron.user.sharethisPublisher, doNotHash: false, doNotCopy: false, hashAddressBar: false}); }); }, "fallback": function () { "use strict"; - var cookies = ['__unam']; + var cookies = ['__unam'], + id = 'sharethis'; + tarteaucitron.cookie.purge(cookies); + + tarteaucitron.fallback(['tacSharethis'], tarteaucitron.engage(id)); + document.getElementById('tacEngage' + id).onclick = function () { + tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true); + }; } }; @@ -54,6 +72,8 @@ tarteaucitron.services.shareaholic = { if (tarteaucitron.user.shareaholicSiteId === undefined) { return; } + + tarteaucitron.fallback(['shareaholic-canvas'], ''); tarteaucitron.addScript('//dsms0mj1bbhn4.cloudfront.net/assets/pub/shareaholic.js', '', function () { try { Shareaholic.init(tarteaucitron.user.shareaholicSiteId); @@ -62,8 +82,15 @@ tarteaucitron.services.shareaholic = { }, "fallback": function () { "use strict"; - var cookies = ['__utma', '__utmb', '__utmc', '__utmz']; + var cookies = ['__utma', '__utmb', '__utmc', '__utmz'], + id = 'shareaholic'; + tarteaucitron.cookie.purge(cookies); + + tarteaucitron.fallback(['shareaholic-canvas'], tarteaucitron.engage(id)); + document.getElementById('tacEngage' + id).onclick = function () { + tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true); + }; } }; @@ -79,12 +106,20 @@ tarteaucitron.services.addthis = { if (tarteaucitron.user.addthisPubId === undefined) { return; } + tarteaucitron.fallback(['addthis_sharing_toolbox'], ''); tarteaucitron.addScript('//s7.addthis.com/js/300/addthis_widget.js#pubid=' + tarteaucitron.user.addthisPubId); }, "fallback": function () { "use strict"; - var cookies = ['__atuvc']; + var cookies = ['__atuvc'], + id = 'addthis'; + tarteaucitron.cookie.purge(cookies); + + tarteaucitron.fallback(['addthis_sharing_toolbox'], tarteaucitron.engage(id)); + document.getElementById('tacEngage' + id).onclick = function () { + tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true); + }; } }; @@ -133,6 +168,15 @@ tarteaucitron.services.adsense = { "js": function () { "use strict"; tarteaucitron.addScript('//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'); + }, + "fallback": function () { + "use strict"; + var id = 'adsense'; + + tarteaucitron.fallback(['adsbygoogle'], tarteaucitron.engage(id)); + document.getElementById('tacEngage' + id).onclick = function () { + tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true); + }; } };