Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Created January 15, 2013 21:23
Show Gist options
  • Save Sigmus/4542209 to your computer and use it in GitHub Desktop.
Save Sigmus/4542209 to your computer and use it in GitHub Desktop.
define(function(){
return function(params){
return {
init: function() {
var that = this;
$('a.share').on('click', function(e){
e.preventDefault();
that[ $(this).data('rede') ]();
});
},
facebook: function (){
url = "http://www.facebook.com/sharer.php";
centerW = window.screenX + (window.innerWidth - 626) / 2;
centerH = window.screenY + (window.innerHeight - 436) / 2;
return window.open(url + "?u=" + params.shareURL + "&t=" + params.shareTitle, "_blank", "width=626, height=436, toolbar=0, status=0 top="
+ centerH + ", left=" + centerW + ", screenX=" + centerW + ", screenY=" + centerH);
},
twitter: function (){
url = "http://twitter.com/share";
centerW = window.screenX + (window.innerWidth - 540) / 2;
centerH = window.screenY + (window.innerHeight - 380) / 2;
return window.open(url + "?url=" + params.shareURL + "&text=" + params.ShareDescription, "_blank", "width=540, height=380, toolbar=0, status=0 top="
+ centerH + ", left=" + centerW + ", screenX=" + centerW + ", screenY=" + centerH);
},
pinterest: function (){
url = "http://pinterest.com/pin/create/button/";
centerW = window.screenX + (window.innerWidth - 540) / 2;
centerH = window.screenY + (window.innerHeight - 380) / 2;
return window.open(url + "?url=" + params.shareURL + "&media= " + params.ShareMedia + "&description=" + params.ShareDescription, "_blank", "width=540, height=380, toolbar=0, status=0 top="
+ centerH + ", left=" + centerW + ", screenX=" + centerW + ", screenY=" + centerH);
},
orkut: function (){
url = "http://promote.orkut.com/preview?";
params = "";
centerW = window.screenX + (window.innerWidth - 540) / 2;
centerH = window.screenY + (window.innerHeight - 380) / 2;
qs = {
src: 'bkmrklt',
v: 1,
nt: "orkut.com",
du: escape(params.shareURL),
tt: escape(params.shareTitle),
rdrinl: 1
};
for (p in qs) {
params += p + "=" + qs[p] + "&";
}
return window.open(url + "?" + params, "_blank", "width=640, height=510, toolbar=0, status=0 top="
+ centerH + ", left=" + centerW + ", screenX=" + centerW + ", screenY=" + centerH);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment