diff --git a/README.md b/README.md index e2f37d4..026353d 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Bonus: * Shareaholic * ShareThis * Twitter + * Twitter Cards * Support * UserVoice diff --git a/tarteaucitron.js b/tarteaucitron.js index 098742b..1a39763 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -10,7 +10,7 @@ var scripts = document.getElementsByTagName('script'), tarteaucitronNoAdBlocker = false; var tarteaucitron = { - "version": 204.5, + "version": 204.6, "cdn": cdn, "user": {}, "lang": {}, diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 076e58c..b96a6b0 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1,4 +1,4 @@ -/*global tarteaucitron, ga, Shareaholic, stLight, clicky, top, google, Typekit, FB, ferankReady, IN, stButtons*/ +/*global tarteaucitron, ga, Shareaholic, stLight, clicky, top, google, Typekit, FB, ferankReady, IN, stButtons, twttr*/ /*jslint regexp: true, nomen: true*/ // addthis @@ -905,6 +905,61 @@ tarteaucitron.services.twitter = { } }; +// twitter embed +tarteaucitron.services.twitterembed = { + "key": "twitterembed", + "type": "social", + "name": "Twitter Cards", + "uri": "https://support.twitter.com/articles/20170514", + "needConsent": true, + "cookies": [], + "js": function () { + "use strict"; + var uniqIds = [], + i, + e, + html; + + tarteaucitron.fallback(['twitterembed-canvas'], function (x) { + var uniqId = '_' + Math.random().toString(36).substr(2, 9); + uniqIds.push(uniqId); + html = '
'; + return html; + }); + + tarteaucitron.addScript('//platform.twitter.com/widgets.js', 'twitter-wjs', function () { + for (i = 0; i < uniqIds.length; i += 1) { + e = document.getElementById(uniqIds[i]); + twttr.widgets.createTweet( + e.getAttribute('tweetid'), + e, + { + theme: e.getAttribute('theme'), + cards: e.getAttribute('cards'), + conversation: e.getAttribute('conversation'), + lang: tarteaucitron.getLanguage(), + dnt: true, + width: e.getAttribute('data-width'), + align: e.getAttribute('data-align') + } + ); + } + }); + }, + "fallback": function () { + "use strict"; + var id = 'twitterembed'; + tarteaucitron.fallback(['twitterembed-canvas'], tarteaucitron.engage(id)); + } +}; + // user voice tarteaucitron.services.uservoice = { "key": "uservoice",