Skip to content

Instantly share code, notes, and snippets.

@mapmeld
Created August 12, 2012 06:06
Show Gist options
  • Save mapmeld/3330039 to your computer and use it in GitHub Desktop.
Save mapmeld/3330039 to your computer and use it in GitHub Desktop.
Blockee Share Feature
/*
* Manages Share Button.
*/
var ShareFeature = {
show: function() {
var longUrl = "http://blockee.org" + Backbone.history.fragment;
var url = "http://api.bitly.com/v3/shorten?longUrl=" + encodeURIComponent(longUrl) + "&login=o_cdttlflq9&apiKey=R_54cc6bcddf5bd50607743cc8158d722f";
$.getJSON(url, function(data) {
$(".twitter-share-iframe")[0].src="//platform.twitter.com/widgets/tweet_button.html?count=none&url=" + encodeURIComponent(data.data.url);
// commented out the old Facebook update
//$(".facebook-share-iframe")[0].src="//facebook.com/plugins/like.php?href=" + encodeURIComponent(data.data.url) + "&send=false&layout=standard&width=450&show_faces=false&action=like&colorscheme=light&font&height=35";
$("#long_url").val( data.data.url );
$("#shares").css({ display: "block" });
$("#share-button").css({ display: "none" });
});
},
// added the new Facebook update
FBPublish: function(){
// calling the API ...
var obj = {
method: 'feed',
link: 'http://blockee.org' + Backbone.history.fragment,
picture: 'http://i.imgur.com/BbUJG.png',
name: 'Blockee',
caption: 'Pimp Your Block',
description: 'This is a story.'
};
var callback = function(response){
console.log(response);
};
FB.ui(obj, callback);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment