-
Notifications
You must be signed in to change notification settings - Fork 0
/
easySocial.min.js
7 lines (7 loc) · 2.51 KB
/
easySocial.min.js
1
2
3
4
5
6
7
/*!
* easySocial v1.0
* http://do-know.com
* Copyright (c) 2016 Alexander Yezhov
* Licensed under the MIT license
*/
function easySocial(o){var b2={"facebook":{name:'Facebook',link:'https://www.facebook.com/sharer/sharer.php?',params:{u:'url',t:'title'}},"twitter":{name:'Twitter',link:'https://twitter.com/intent/tweet?',params:{url:'url',text:'description'}},"linkedin":{name:'LinkedIn',link:'http://www.linkedin.com/shareArticle?mini=true&',params:{url:'url',title:'title',summary:'description'}},"reddit":{name:'Reddit',link:'http://www.reddit.com/submit?',params:{url:'url',title:'title',text:'description'}},"hackernews":{name:'HackerNews',icon:'hacker-news',link:'https://news.ycombinator.com/submitlink?',params:{u:'url',text:'title'}},"googleplus":{name:'Google+',icon:'google-plus',link:'https://plus.google.com/share?',params:{url:'url',title:'title'}},"vk":{name:'VK',link:'http://vk.com/share.php?',params:{url:'url',title:'title',description:'description'}},"digg":{name:'Digg',link:'http://www.digg.com/submit?',params:{url:'url'}},"stumbleupon":{name:'Stumbleupon',link:'http://www.stumbleupon.com/submit?',params:{url:'url',title:'title'}},"email":{name:'Email',icon:'envelope',link:'mailto:?',params:{subject:'title',body:['description','url']}},"whatsapp":{name:'WhatsApp',link:'whatsapp://send?',params:{text:['title','url','description']}},"telegram":{name:'Telegram',icon:'paper-plane',link:'tg://msg?',params:{text:['title','url','description']}},};var b3=' <a href="%url%" title="%caption%" target="_blank">%social-name%</a> ';var i={url:true,title:true,description:true};var b0=[];var a='';var j;var k;var n;var b4;var l;var m;var b1;var h;var b;if(!o||!(o.buttons&&o.buttons.constructor===Array&&o.buttons.length))return null;o.icons=o.icons||{};for(l in o){if(o.hasOwnProperty(l)&&i[l]&&o[l]!==undefined){o[l]=encodeURIComponent(o[l])}};for(j=0;j<o.buttons.length;j++){b1=o.buttons[j];if(b2[b1]){p=b2[b1].params;n=o.tpl||b3;b4=[];for(l in p){if(p.hasOwnProperty(l)){h=p[l].constructor===Array?p[l]:[p[l]];b=[];for(k=0;k<h.length;k++){if(o[h[k]])b.push(o[h[k]])}if(b.length){b4.push(l+'='+b.join('%20'))}}}if(b4.length){m=b2[b1].name||b1;n=n.replace(/%url%/g,b2[b1].link+b4.join('&')).replace(/%social%/g,b1).replace(/%social-name%/g,m).replace(/%icon%/g,o.icons[b1]||b2[b1].icon||b1).replace(/%caption%/g,o.caption?(o.caption+' '+m):m);b0.push(n)}}}if(b0.length){if(o.wrap&&o.after){while(b0.length){a+=o.wrap.replace('%content%',b0.splice(0,o.after).join(''))}}else{a=b0.join('');if(o.wrap){a=o.wrap.replace('%content%',a)}}}return a}