Browse Source

Add Allow button directly in the service container

Amauri CHAMPEAUX 10 years ago
parent
commit
22d3005fbd
5 changed files with 108 additions and 5 deletions
  1. 42 2
      css/tarteaucitron.css
  2. 2 0
      lang/tarteaucitron.en.js
  3. 2 0
      lang/tarteaucitron.fr.js
  4. 15 0
      tarteaucitron.js
  5. 47 3
      tarteaucitron.services.js

+ 42 - 2
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
  */

+ 2 - 0
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",

+ 2 - 0
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",

+ 15 - 0
tarteaucitron.js

@@ -381,5 +381,20 @@ var tarteaucitron = {
                 }
             }
         }
+    },
+    "engage": function (id) {
+        "use strict";
+        var html = '';
+        
+        html += '<div class="tac_activate">';
+        html += '   <div class="tac_float">';
+        html += '      <b>' + id + '</b> ' + tarteaucitron.lang.fallback + '<br/>';
+        html += '      <div class="tarteaucitronAllow" id="tacEngage' + id + '">';
+        html += '          ' + tarteaucitron.lang.allow;
+        html += '       </div>';
+        html += '   </div>';
+        html += '</div>';
+        
+        return html;
     }
 };

+ 47 - 3
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);
+        };
     }
 };