Add Twitter Cards
This commit is contained in:
parent
67f9155099
commit
b375eebd75
|
|
@ -63,6 +63,7 @@ Bonus:
|
|||
* Shareaholic
|
||||
* ShareThis
|
||||
* Twitter
|
||||
* Twitter Cards
|
||||
|
||||
* Support
|
||||
* UserVoice
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ var scripts = document.getElementsByTagName('script'),
|
|||
tarteaucitronNoAdBlocker = false;
|
||||
|
||||
var tarteaucitron = {
|
||||
"version": 204.5,
|
||||
"version": 204.6,
|
||||
"cdn": cdn,
|
||||
"user": {},
|
||||
"lang": {},
|
||||
|
|
|
|||
|
|
@ -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 = '<div id="' + uniqId + '" ';
|
||||
html += 'tweetid="' + x.getAttribute('tweetid') + '" ';
|
||||
html += 'theme="' + x.getAttribute('theme') + '" ';
|
||||
html += 'cards="' + x.getAttribute('cards') + '" ';
|
||||
html += 'conversation="' + x.getAttribute('conversation') + '" ';
|
||||
html += 'data-width="' + x.getAttribute('data-width') + '" ';
|
||||
html += 'data-align="' + x.getAttribute('data-align') + '" ';
|
||||
html += '></div>';
|
||||
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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue