Skip to content

Instantly share code, notes, and snippets.

@bladeofsteel
Created November 25, 2012 17:55
Show Gist options
  • Save bladeofsteel/4144560 to your computer and use it in GitHub Desktop.
Save bladeofsteel/4144560 to your computer and use it in GitHub Desktop.
Элементарные социальные share-кнопки. see http://habrahabr.ru/post/156185/ & http://jsfiddle.net/rrZBR/1/
<a href="http://vk.com/share.php?url=URL&title=TITLE&description=DESC&image=IMG_PATH&noparse=true" target="_blank" onclick="return Share.me(this);"> {шарь меня правильно}</a>
<a href="http://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=TITLE&p%5Bsummary%5D=DESC&p%5Burl%5D=URL&p%5Bimages%5D%5B0%5D=IMG_PATH" target="_blank" onclick="return Share.me(this);">{шарь меня правильно}</a>
<a href="http://connect.mail.ru/share?url=URL&title=TITLE&description=DESC&imageurl=IMG_PATH" target="_blank" onclick="return Share.me(this);">{шарь меня правильно}</a>
<a href="http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st.comments=DESC&st._surl=URL" target="_blank" onclick="return Share.me(this);">{шарь меня правильно}</a>
<a href="https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Ffiddle.jshell.net%2F_display%2F&text=TITLE&url=URL" target="_blank" onclick="return Share.me(this)">{шарь меня правильно}</a>​
Share = {
vkontakte: function(purl, ptitle, pimg, text) {
url = 'http://vkontakte.ru/share.php?';
url += 'url=' + encodeURIComponent(purl);
url += '&title=' + encodeURIComponent(ptitle);
url += '&description=' + encodeURIComponent(text);
url += '&image=' + encodeURIComponent(pimg);
url += '&noparse=true';
Share.popup(url);
},
odnoklassniki: function(purl, text) {
url = 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
url += '&st.comments=' + encodeURIComponent(text);
url += '&st._surl=' + encodeURIComponent(purl);
Share.popup(url);
},
facebook: function(purl, ptitle, pimg, text) {
url = 'http://www.facebook.com/sharer.php?s=100';
url += '&p[title]=' + encodeURIComponent(ptitle);
url += '&p[summary]=' + encodeURIComponent(text);
url += '&p[url]=' + encodeURIComponent(purl);
url += '&p[images][0]=' + encodeURIComponent(pimg);
Share.popup(url);
},
twitter: function(purl, ptitle) {
url = 'http://twitter.com/share?';
url += 'text=' + encodeURIComponent(ptitle);
url += '&url=' + encodeURIComponent(purl);
url += '&counturl=' + encodeURIComponent(purl);
Share.popup(url);
},
mailru: function(purl, ptitle, pimg, text) {
url = 'http://connect.mail.ru/share?';
url += 'url=' + encodeURIComponent(purl);
url += '&title=' + encodeURIComponent(ptitle);
url += '&description=' + encodeURIComponent(text);
url += '&imageurl=' + encodeURIComponent(pimg);
Share.popup(url)
},
me : function(el){
console.log(el.href);
Share.popup(el.href);
return false;
},
popup: function(url) {
window.open(url,'','toolbar=0,status=0,width=626,height=436');
}
};​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment