Skip to content

Instantly share code, notes, and snippets.

@jeffdrumgod
Last active August 29, 2015 14:00
Show Gist options
  • Save jeffdrumgod/11414145 to your computer and use it in GitHub Desktop.
Save jeffdrumgod/11414145 to your computer and use it in GitHub Desktop.
Base de funções para share icons
// https://gist.github.com/jeffdrumgod/11414145
var Shares_custom = new function() {
this.updateUrl = function(url){
if(url){
share_url = url;
}else{
share_url = location.href;
}
return encodeURIComponent(this.share_url);
}
this.fb = function() {
var sharer = "https://www.facebook.com/sharer/sharer.php?u=" + this.share_url;
window.open(sharer, 'sharer', 'width='+this.window_width+',height='+this.window_height);
}
this.twitter = function() {
var sharer = "http://twitter.com/share?text="+this.text+"&url="+this.share_url;
window.open(sharer, 'sharer', 'width='+this.window_width+',height='+this.window_height);
}
this.plus = function() {
var sharer = "https://plus.google.com/share?url=" + this.share_url;
window.open(sharer, 'sharer', 'width='+this.window_width+',height='+this.window_height);
}
this.youtube = function(){
var sharer = "http://www.youtube.com/"+this.youtube_name;
window.open(sharer, 'sharer', 'width='+this.window_width+',height='+this.window_height);
}
this.mail = function(){
var sharer = 'mailto:?subject=Olá, quero recomendar este produto para você&body=Creio que você tenha interesse neste produto,' +
'veja mais detalhes sobre \"'+this.text+'\" aqui: ' + window.location;
window.location=sharer;
}
this.pinterest = function(image, description) {
(function(d){
var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
p.type = 'text/javascript';
p.async = true;
p.src = '//assets.pinterest.com/js/pinit.js';
f.parentNode.insertBefore(p, f);
}(document));
var sharer = "http://pinterest.com/pin/create/button/?url=" + this.share_url + "&media" + encodeURIComponent(image) + "&description=" + encodeURIComponent(description);
window.open(sharer, 'sharer', 'width='+this.window_width+',height='+this.window_height);
}
this.window_width = 626;
this.window_height = 436;
this.youtube_name = 'USER_NAME';
this.text = encodeURIComponent(this.text);
this.share_url = this.updateUrl();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment