jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/sharing/social-share-kit-1.0.4/dist/js/social-share-kit.min.js
2016-04-28 23:10:48 -04:00

8 lines
5.3 KiB
JavaScript

/*!
* Social Share Kit v1.0.3 (http://socialsharekit.com)
* Copyright 2015 Social Share Kit / Kaspars Sprogis.
* Licensed under Creative Commons Attribution-NonCommercial 3.0 license:
* https://github.com/darklow/social-share-kit/blob/master/LICENSE
* ---
*/
;var SocialShareKit=(function(){var f,d,v,t={},q="*|*";function x(A){d=A||{};v=/(twitter|facebook|google-plus|pinterest|tumblr|vk|linkedin|email)/;n(function(){f=g(d.selector||".ssk");if(!f.length){return}e(f,function(C){var D=s(C),B;if(!D){return}r(C,"click",h);p(C,"click",h);if(C.parentNode.className.indexOf("ssk-count")!==-1){D=D[0];B=D+q+z(D,C);if(!(B in t)){t[B]=[]}t[B].push(C)}});j()})}function n(A){if(document.readyState!="loading"){A()}else{if(document.addEventListener){document.addEventListener("DOMContentLoaded",A)}else{document.attachEvent("onreadystatechange",function(){if(document.readyState!="loading"){A()}})}}}function g(A){return document.querySelectorAll(A)}function e(C,B){for(var A=0;A<C.length;A++){B(C[A],A)}}function p(C,A,B){if(C.addEventListener){C.addEventListener(A,B)}else{C.attachEvent("on"+A,function(){B.call(C)})}}function r(C,A,B){if(C.removeEventListener){C.removeEventListener(A,B)}else{C.detachEvent("on"+A,B)}}function s(A){return A.className.match(v)}function h(D){var C=l(D),B=s(C),A;if(!B){return}A=u(B[0],C);if(!A){return}if(B[0]!="email"){k(A)}else{document.location=A}}function l(B){var A=B||window.event;if(A.preventDefault){A.preventDefault()}else{A.returnValue=false;A.cancelBubble=true}return A.target||A.srcElement}function k(B){var C=575,A=400,F=(document.documentElement.clientWidth/2-C/2),E=(document.documentElement.clientHeight-A)/2,D="status=1,resizable=yes,width="+C+",height="+A+",top="+E+",left="+F;win=window.open(B,"",D);win.focus();return win}function u(D,C){var A,B=a(D,C),F=z(D,C,B),G=encodeURIComponent(F),H=typeof B.title!=="undefined"?B.title:m(D),J=typeof B.text!=="undefined"?B.text:c(D),E=B.image,I=B.via;switch(D){case"facebook":A="https://www.facebook.com/share.php?u="+G;break;case"twitter":A="https://twitter.com/share?url="+G+"&text="+encodeURIComponent(H+(J&&H?" - ":"")+J);I=I||y("twitter:site");if(I){A+="&via="+I.replace("@","")}break;case"google-plus":A="https://plus.google.com/share?url="+G;break;case"pinterest":A="http://pinterest.com/pin/create/button/?url="+G+"&description="+encodeURIComponent(J);E=E||y("og:image");if(E){A+="&media="+encodeURIComponent(E)}break;case"tumblr":A="http://www.tumblr.com/share/link?url="+G+"&name="+encodeURIComponent(H)+"&description="+encodeURIComponent(J);break;case"linkedin":A="http://www.linkedin.com/shareArticle?mini=true&url="+G+"&title="+encodeURIComponent(H)+"&summary="+encodeURIComponent(J);break;case"vk":A="http://vkontakte.ru/share.php?url="+G;break;case"email":A="mailto:?subject="+encodeURIComponent(H)+"&body="+encodeURIComponent(H+"\n"+F+"\n\n"+J+"\n");break}return A}function z(C,B,A){A=A||a(C,B);return A.url||window.location.href}function m(A){var B;if(A=="twitter"){B=y("twitter:title")}return B||document.title}function c(A){var B;if(A=="twitter"){B=y("twitter:description")}return B||y("description")}function y(C,B){var D,A=g("meta["+(B?B:C.indexOf("og:")===0?"property":"name")+'="'+C+'"]');if(A.length){D=A[0].getAttribute("content")||""}return D||""}function a(D,C){var B=["url","title","text","image"],A={},H,I,E,F,G=C.parentNode;D=="twitter"&&B.push("via");for(F in B){I=B[F];E="data-"+I;H=C.getAttribute(E)||G.getAttribute(E)||(d[D]&&typeof d[D][I]!="undefined"?d[D][I]:d[I]);if(typeof H!="undefined"){A[I]=H}}return A}function j(){var A,B;for(A in t){B=A.split(q);(function(C){w(B[0],B[1],function(D){for(var E in C){i(C[E],D)}})})(t[A])}}function i(B,A){var C=document.createElement("div");C.innerHTML=A;C.className="ssk-num";B.appendChild(C)}function w(E,F,G){var C,B,A,D=encodeURIComponent(F);switch(E){case"facebook":C="http://graph.facebook.com/?id="+D;B=function(H){return G(H.shares?H.shares:0)};break;case"twitter":C="http://cdn.api.twitter.com/1/urls/count.json?url="+D;B=function(H){return G(H.count)};break;case"google-plus":C="https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ";A='[{"method":"pos.plusones.get","id":"p","params":{"id":"'+F+'","userId":"@viewer","groupId":"@self","nolog":true},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]';B=function(H){H=JSON.parse(H);if(H.length){return G(H[0].result.metadata.globalCounts.count)}};o(C,B,A);return;case"linkedin":C="http://www.linkedin.com/countserv/count/share?url="+D;B=function(H){return G(H.count)};break;case"pinterest":C="http://api.pinterest.com/v1/urls/count.json?url="+D;B=function(H){return G(H.count)};break;case"vk":C="http://vk.com/share.php?act=count&url="+D;B=function(H){return G(H)};break}C&&B&&b(E,C,B,A)}function o(B,D,A){var C=new XMLHttpRequest();C.onreadystatechange=function(){if(this.readyState===4){if(this.status>=200&&this.status<400){D(this.responseText)}}};C.open("POST",B,true);C.setRequestHeader("Content-Type","application/json");C.send(A)}function b(C,B,E){var D="cb_"+C+"_"+Math.round(100000*Math.random()),A=document.createElement("script");window[D]=function(F){try{delete window[D]}catch(G){}document.body.removeChild(A);E(F)};if(C=="vk"){window.VK={Share:{count:function(G,F){window[D](F)}}}}else{if(C=="google-plus"){window.services={gplus:{cb:window[D]}}}}A.src=B+(B.indexOf("?")>=0?"&":"?")+"callback="+D;document.body.appendChild(A);return true}return{init:x}})();window.SocialShareKit=SocialShareKit;