Skip to content

Instantly share code, notes, and snippets.

@fcingolani
Created October 12, 2012 03:32
Show Gist options
  • Save fcingolani/3877139 to your computer and use it in GitHub Desktop.
Save fcingolani/3877139 to your computer and use it in GitHub Desktop.
Socialite.js - Facebook Like Box and Twitter Embedded Timeline extension
(function() {
Socialite.widget('facebook', 'likebox', {
init: function(instance) {
var el;
el = document.createElement('div');
el.className = 'fb-like-box';
Socialite.copyDataAttributes(instance.el, el);
instance.el.appendChild(el);
if (window.FB && window.FB.XFBML) {
return window.FB.XFBML.parse(instance.el);
}
}
});
Socialite.widget('twitter', 'timeline', {
init: function(instance) {
var el;
el = document.createElement('a');
el.className = 'twitter-timeline';
Socialite.copyDataAttributes(instance.el, el);
return instance.el.appendChild(el);
},
activate: function(instance) {
if (window.twttr && typeof window.twttr.widgets === 'object' && typeof window.twttr.widgets.load === 'function') {
return window.twttr.widgets.load();
}
}
});
}).call(this);
Socialite.widget 'facebook', 'likebox',
init: (instance) ->
el = document.createElement 'div'
el.className = 'fb-like-box'
Socialite.copyDataAttributes instance.el, el
instance.el.appendChild el
if window.FB && window.FB.XFBML
window.FB.XFBML.parse instance.el
Socialite.widget 'twitter', 'timeline',
init: (instance) ->
el = document.createElement 'a'
el.className = 'twitter-timeline'
Socialite.copyDataAttributes instance.el, el
instance.el.appendChild el
activate: (instance) ->
if (window.twttr && typeof window.twttr.widgets is 'object' && typeof window.twttr.widgets.load is 'function')
window.twttr.widgets.load()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment