Advertisement
VladimirsBudkins

Social share

Mar 11th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Share = {
  2.         vkontakte: function (purl, ptitle, pimg, text) {
  3.             url = 'http://vkontakte.ru/share.php?';
  4.             url += 'url=' + encodeURIComponent(purl);
  5.             url += '&title=' + encodeURIComponent(ptitle);
  6.             url += '&description=' + encodeURIComponent(text);
  7.             url += '&image=' + encodeURIComponent(pimg);
  8.             url += '&noparse=true';
  9.             Share.popup(url);
  10.         },
  11.         facebook: function (purl, ptitle, pimg, text) {
  12.             url = 'http://www.facebook.com/sharer/sharer.php?s=100';
  13.             url += '&p[title]=' + encodeURIComponent(ptitle);
  14.             url += '&p[summary]=' + encodeURIComponent(text);
  15.             url += '&p[url]=' + encodeURIComponent(purl);
  16.             url += '&p[images][0]=' + encodeURIComponent(pimg);
  17.             Share.popup(url);
  18.         },
  19.         twitter: function (purl, ptitle) {
  20.             url = 'http://twitter.com/share?';
  21.             url += 'text=' + encodeURIComponent(ptitle);
  22.             url += '&url=' + encodeURIComponent(purl);
  23.             url += '&counturl=' + encodeURIComponent(purl);
  24.             Share.popup(url);
  25.         },
  26.         gplus: function (purl, ptitle) {
  27.             url = 'http://plus.google.com/share?';
  28.             url += 'text=' + encodeURIComponent(ptitle);
  29.             url += '&url=' + encodeURIComponent(purl);
  30.             url += '&counturl=' + encodeURIComponent(purl);
  31.             Share.popup(url);
  32.         },
  33.         popup: function (url) {
  34.             var leftvar = (screen.width - 800) / 2;
  35.             var topvar = (screen.height - 600) / 2;
  36.             window.open(url, '', 'toolbar=0,status=0,width=626,height=436,left=' + leftvar + ',top=' + topvar + '');
  37.         }
  38.     };
  39.     //example
  40.     var img = document.getElementsByTagName("img")[0];
  41.     Share.vkontakte(document.location.href, document.title, img.src, document.description);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement