/*! * jQuery Floating Social Share Plugin v1.0.1 * http://www.burakozdemir.co.uk * * Copyright 2015 Burak Ă–zdemir - * Released under the MIT license */ !function(t,e,n){function s(e,n){this.element=e,this.settings=t.extend({},c,n),this._defaults=c,this._name=o,this.init()}function i(t,s,i,a){var r=e.innerWidth?e.innerWidth:n.documentElement.clientWidth?n.documentElement.clientWidth:screen.width,l=e.innerHeight?e.innerHeight:n.documentElement.clientHeight?n.documentElement.clientHeight:screen.height,o=r/2-i/2+10,c=l/2-a/2+50,p=e.open(t,s,"scrollbars=yes, width="+i+", height="+a+", top="+c+", left="+o);p.focus()}function a(t){return t>=1e9?(t/1e9).toFixed(1).replace(/\.0$/,"")+"G":t>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+"M":t>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+"K":t}function r(s){var i=e.innerWidth?e.innerWidth:n.documentElement.clientWidth?n.documentElement.clientWidth:screen.width;961>i?t.each(s,function(){t(this).css("width",100/s.length+"%")}):t.each(s,function(){t(this).removeAttr("style")})}function l(n,s,i){switch(s=encodeURI(s),n){case"facebook":t.get("https://graph.facebook.com/"+s,function(e){if(e.shares&&e.shares>0){var n=t("",{"class":"shareCount"});n.append(a(e.shares)),i.append(n),i.find("i").removeClass("m-top5")}},"jsonp");break;case"twitter":t.get("https://urls.api.twitter.com/1/urls/count.json?url="+s+"&callback=?",function(e){if(e.count&&e.count>0){var n=t("",{"class":"shareCount"});n.append(a(e.count)),i.append(n),i.find("i").removeClass("m-top5")}},"jsonp");break;case"linkedin":t.get("https://www.linkedin.com/countserv/count/share?url="+s+"&callback=?",function(e){if(e.count&&e.count>0){var n=t("",{"class":"shareCount"});n.append(a(e.count)),i.append(n),i.find("i").removeClass("m-top5")}},"jsonp");break;case"pinterest":t.get("https://api.pinterest.com/v1/urls/count.json?url="+s+"&callback=?",function(e){if(e.count&&e.count>0){var n=t("",{"class":"shareCount"});n.append(a(e.count)),i.append(n),i.find("i").removeClass("m-top5")}},"jsonp");break;case"google-plus":e.services||(e.services={},e.services.gplus={}),e.services.gplus.cb=function(t){e.gplusShares=t},t.getScript("http://share.yandex.ru/gpp.xml?url="+s+"&callback=?",function(){if(e.gplusShares>0){var n=t("",{"class":"shareCount"});n.append(a(e.gplusShares)),i.append(n),i.find("i").removeClass("m-top5")}});break;default:return-1}}var o="floatingSocialShare",c={place:"top-left",counter:!0,buttons:["facebook","twitter","google-plus","linkedin"],title:n.title,url:e.location.href,text:"share with ",description:t("meta[name='description']").attr("content"),popup_width:400,popup_height:300};t.extend(s.prototype,{init:function(){var n=this;-1==t.inArray(this.settings.place,u)&&(this.settings.place=this._defaults.place);var s=t("
",{id:"floatingSocialShare"}),a=t("
",{"class":this.settings.place});a.appendTo(s),t.each(this.settings.buttons,function(e,s){t.each(p,function(e,i){if(s==e){var r=t("",{title:n.settings.title,"class":""+i.className+" pop-upper"}),o=t("",{"class":"m-top5 fa fa-"+s}),c=i.url;return c=c.replace("{url}",n.settings.url).replace("{title}",n.settings.title).replace("{description}",n.settings.description),r.attr("href",c).attr("title",n.settings.text+s).append(o),n.settings.counter===!0&&l(s,n.settings.url,r),a.append(r),!1}})}),s.appendTo(this.element);var o=t(this.element).find(".pop-upper");o.on("click",function(e){e.preventDefault(),i(t(this).attr("href"),t(this).attr("title"),n.settings.popup_width,n.settings.popup_height)}),r(o),t(e).resize(function(){r(o)})}});var p={facebook:{className:"facebook",url:"https://www.facebook.com/sharer/sharer.php?u={url}&t={title}"},twitter:{className:"twitter",url:"https://twitter.com/home?status={url}"},"google-plus":{className:"google-plus",url:"https://plus.google.com/share?url={url}"},linkedin:{className:"linkedin",url:"https://www.linkedin.com/shareArticle?mini=true&url={url}&title={title}&summary={description}&source="},envelope:{className:"envelope",url:"mailto:asd@asd.com?subject={url}"},pinterest:{className:"pinterest",url:"https://pinterest.com/pin/create%2Fbutton/?url={url}"},stumbleupon:{className:"stumbleupon",url:"https://www.stumbleupon.com/submit?url={url}&title={title}"}},u=["top-left","top-right"];t.fn[o]=function(e){return this.each(function(){t.data(this,"plugin_"+o)||t.data(this,"plugin_"+o,new s(this,e))}),this}}(jQuery,window,document);