/** * Social Likes * http://sapegin.github.com/social-likes * * Sharing buttons for Russian and worldwide social networks. * jQuery removed, only requires simple utilities: GET, onDomReady, http_build_query, addListener, removeListener * * @author Artem Sapegin, Vitaliy Filippov * @copyright 2014 Artem Sapegin (sapegin.me), 2016 Vitaliy Filippov * @license MIT */ /*jshint -W030 */ /* 2014 Artem Sapegin (sapegin.me), 2016 Vitaliy Filippov @license MIT */ document.addEventListener("DOMContentLoaded",function(){setTimeout(function(){(function(){function k(a,b,c){for(var d=-1,e=!1;-1!=(d=a.className.indexOf(b,d+1));)d&&!/\s/.exec(a.className.charAt(d-1))||d!=a.className.length-b.length&&!/\s/.exec(a.className.charAt(d+b.length))||(e=!0,c&&(a.className=a.className.substr(0,d-1)+a.className.substr(d+b.length)));return e}function q(a,b,c){var d=document.createElement("script");d.type="text/javascript";d.src=a;d.onreadystatechange=function(){"complete"== d.readyState?b&&b():"loaded"==d.readyState&&(d.children,"loading"==d.readyState&&c&&c());d.parentNode&&d.parentNode.removeChild(d);d=null};d.onload=function(){b&&b();d.parentNode&&d.parentNode.removeChild(d);d=null};d.onerror=function(){c&&c();d.parentNode&&d.parentNode.removeChild(d);d=null};(document.head||document.getElementsByTagName("head")[0]).appendChild(d)}function t(a,b){this.container=a;this.options=b;this.init()}function u(a,b){this.widget=a;this.options={};for(var c in b)this.options[c]= b[c];this.detectService();this.service&&this.init()}function v(a,b){function c(a,b){return b.toUpper()}for(var d={},e=0;ed.left?a.stype.left=10-d.left+b+"px":d.right>window.innerWidth-10&&(a.style.left=window.innerWidth-d.right-10+b+"px");10>d.top?a.style.top=10-d.top+c+"px":d.bottom>window.innerHeight-10&&(a.style.top=window.innerHeight-d.bottom-10+c+"px")}a.className+=" mbr-social-likes_opened"}var h="https:"===location.protocol?"https:":"http:",l={facebook:{counterUrl:"https://graph.facebook.com/fql?q=SELECT+total_count+FROM+link_stat+WHERE+url%3D%22{url}%22&callback=?",convertNumber:function(a){return a.data[0].total_count}, popupUrl:"https://www.facebook.com/sharer/sharer.php?u={url}",popupWidth:600,popupHeight:359},twitter:{popupUrl:"https://twitter.com/intent/tweet?url={url}&text={title}",popupWidth:600,popupHeight:250,click:function(){/[\.\?:\-\u2013\u2014]\s*$/.test(this.options.title)||(this.options.title+=":");return!0}},mailru:{counterUrl:h+"//connect.mail.ru/share_count?url_list={url}&callback=1&func=?",convertNumber:function(a){for(var b in a)if(a.hasOwnProperty(b))return a[b].shares},popupUrl:"https://connect.mail.ru/share?share_url={url}&title={title}&image_url={image}", popupWidth:492,popupHeight:500},vkontakte:{counterUrl:"https://vk.com/share.php?act=count&url={url}&index={index}",counter:function(a,b){var c=l.vkontakte;c._||(c._=[],window.VK||(window.VK={}),window.VK.Share={count:function(a,b){c._[a].resolve(b)}});var d=c._.length;c._.push(b);q(m(a,{index:d}),null,function(){b.reject()})},popupUrl:"https://vk.com/share.php?url={url}&title={title}&image={image}",popupWidth:655,popupHeight:450},odnoklassniki:{counterUrl:h+"//connect.ok.ru/dk?st.cmd=extLike&ref={url}&uid={index}", counter:function(a,b){var c=l.odnoklassniki;c._||(c._=[],window.ODKL||(window.ODKL={}),window.ODKL.updateCount=function(a,b){a&&c._[a].resolve(b)});var d=c._.length;c._.push(b);q(m(a,{index:d}),null,function(){b.reject()})},popupUrl:"https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&service=odnoklassniki&st.shareUrl={url}",popupWidth:580,popupHeight:336},plusone:{counterUrl:h+"//share.yandex.ru/gpp.xml?url={url}&callback=?",convertNumber:function(a){return parseInt(a.replace(/\D/g,""),10)},popupUrl:"https://plus.google.com/share?url={url}", popupWidth:500,popupHeight:550},pinterest:{counterUrl:h+"//api.pinterest.com/v1/urls/count.json?url={url}&callback=?",convertNumber:function(a){return a.count},popupUrl:"https://pinterest.com/pin/create/button/?url={url}&description={title}",popupWidth:740,popupHeight:550}},p={promises:{},fetch:function(a,b,c){p.promises[a]||(p.promises[a]={});var d=p.promises[a];if(c.forceUpdate||!d[b]){var e={},f;for(f in l[a])e[f]=l[a][f];for(f in c)e[f]=c[f];var g={resolve:function(a){},reject:function(){}};if((a= e.counterUrl&&m(e.counterUrl,{url:b}))&&"function"==typeof e.counter)e.counter(a,g);else if(e.counterUrl){var h=function(a){try{"function"==typeof e.convertNumber&&(a=e.convertNumber(a)),g.resolve(a)}catch(b){g.reject()}};if(0'+this.options.singleTitle+"";b.appendChild(d);addListener(d,"click",function(){k(d,"mbr-social-likes__widget_active",!0)?k(a,"mbr-social-likes_opened",!0):(d.className+=" mbr-social-likes__widget_active",a.style.left=(d.offsetWidth-a.offsetWidth)/2+"px",a.style.top=-a.offsetHeight+"px",y(a),x(a,function(){k(d,"mbr-social-likes__widget_active", !0)}));return!1});this.widget=d}},update:function(a){if(a.forceUpdate||a.url!==this.options.url){this.number=0;this.countersLeft=this.buttons.length;if(this.widget){var b=this.widget.querySelector(".mbr-social-likes__counter");b&&b.parentNode.removeChild(b)}for(var c in a)this.options[c]=a[c];for(b=0;bb.height&&(d=Math.round(screen.height/3-b.height/2));var e=window.open(a,"sl_"+this.service,"left="+c+",top="+d+",width="+b.width+",height="+b.height+",personalbar=0,toolbar=0,scrollbars=1,resizable=1");if(e){e.focus();(c=this.widget["on_popup_opened.mbr-social-likes"])&&c([this.service,e]);var f=this,g=setInterval(function(){if(e.closed){clearInterval(g);var a=f.widget["on_popup_closed.mbr-social-likes"];a&&a(f.service)}},this.options.popupCheckInterval)}else location.href= a}};for(var h=document.querySelectorAll(".mbr-social-likes"),r=0;r