Stackedit/public/res/extensions/twitter.js

37 lines
862 B
JavaScript
Raw Normal View History

2014-02-02 21:00:05 +00:00
define([
"jquery",
"underscore",
"constants",
"utils",
"classes/Extension",
2014-02-02 22:00:28 +00:00
], function($, _, constants, utils, Extension) {
2014-02-02 21:00:05 +00:00
var twitter = new Extension("twitter", "Twitter", false, true);
var isLoaded = false;
var isOffline = false;
var init = function() {
if(isLoaded === false && isOffline === false) {
$.ajax({
url: 'http://platform.twitter.com/widgets.js',
dataType: "script"
}).done(function() {
isLoaded = true;
});
}
};
twitter.onReady = function() {
init();
};
twitter.onOfflineChanged = function(isOfflineParam) {
isOffline = isOfflineParam;
init();
};
twitter.onTweet = function() {
isLoaded && window.twttr.widgets.load();
};
return twitter;
});