forked from djds4rce/angular-socialshare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-socialshare.min.js
1 lines (1 loc) · 5.53 KB
/
angular-socialshare.min.js
1
"use strict";angular.module("djds4rce.angular-socialshare",[]).factory("$FB",["$window",function(t){return{init:function(e){if(!e)throw"FB App Id Cannot be blank";this.fbId=e,t.fbAsyncInit=function(){FB.init({appId:e,channelUrl:"app/channel.html",status:!0,xfbml:!0})},function(t){var e,n="facebook-jssdk",i=t.getElementsByTagName("script")[0];t.getElementById(n)||(e=t.createElement("script"),e.id=n,e.async=!0,e.src="//connect.facebook.net/en_US/all.js",i.parentNode.insertBefore(e,i))}(document)}}}]).directive("facebook",["$timeout","$http",function(t,e){return{scope:{shares:"="},transclude:!0,template:'<div class="facebookButton"><div class="pluginButton"><div class="pluginButtonContainer"><div class="pluginButtonImage"><button type="button"><i class="pluginButtonIcon img sp_plugin-button-2x sx_plugin-button-2x_favblue"></i></button></div><span class="pluginButtonLabel">Share</span></div></div></div><div class="facebookCount"><div class="pluginCountButton pluginCountNum"><span ng-transclude></span></div><div class="pluginCountButtonNub"><s></s><i></i></div></div>',link:function(n,i,o){o.shares&&e.get("https://api.facebook.com/method/links.getStats?urls="+o.url+"&format=json").success(function(t){var e=t[0]?t[0].share_count.toString():0,i="";e.length>6?("0"!=e.slice(-6,-5)&&(i="."+e.slice(-6,-5)),e=e.slice(0,-6),e=e+i+"M"):e.length>3&&("0"!=e.slice(-3,-2)&&(i="."+e.slice(-3,-2)),e=e.slice(0,-3),e=e+i+"k"),n.shares=e}).error(function(){n.shares=0}),t(function(){i.bind("click",function(t){FB.ui({method:"share",href:o.url}),t.preventDefault()})})}}}]).directive("twitter",["$timeout","$window",function(t,e){return{link:function(n,i,o){t(function(){twttr.widgets.createShareButton(o.url||e.location.href,i[0],function(){},{count:o.count,text:o.text,via:o.via,size:o.size})})}}}]).directive("linkedin",["$timeout","$http","$window",function(t,e,n){return{scope:{shares:"="},transclude:!0,template:'<div class="linkedinButton"><div class="pluginButton"><div class="pluginButtonContainer"><div class="pluginButtonImage">in</div><span class="pluginButtonLabel"><span>Share</span></span></div></div></div><div class="linkedinCount"><div class="pluginCountButton"><div class="pluginCountButtonRight"><div class="pluginCountButtonLeft"><span ng-transclude></span></div></div></div></div>',link:function(i,o,r){r.shares&&e.jsonp("http://www.linkedin.com/countserv/count/share?url="+r.link+"&callback=JSON_CALLBACK&format=jsonp").success(function(t){i.shares=t.count.toLocaleString()}).error(function(){i.shares=0}),t(function(){o.bind("click",function(){var t=encodeURIComponent(r.url).replace(/'/g,"%27").replace(/"/g,"%22");n.open("//www.linkedin.com/shareArticle?mini=true&url="+t+"&title="+r.title+"&summary="+r.summary)})})}}}]).directive("gplus",[function(){return{link:function(){"undefined"==typeof gapi&&!function(){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://apis.google.com/js/plusone.js";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}()}}}]).directive("tumblrText",[function(){return{link:function(t,e,n){var i=document.createElement("a");i.setAttribute("href","http://www.tumblr.com/share/link?url="+encodeURIComponent(n.url)+"&name="+encodeURIComponent(n.name)+"&description="+encodeURIComponent(n.description)),i.setAttribute("title",n.title||"Share on Tumblr"),i.setAttribute("style",n.styling||"display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;"),e.append(i)}}}]).directive("tumblrQoute",[function(){return{link:function(t,e,n){var i=document.createElement("a");i.setAttribute("href","http://www.tumblr.com/share/quote?quote="+encodeURIComponent(n.qoute)+"&source="+encodeURIComponent(n.source)),i.setAttribute("title",n.title||"Share on Tumblr"),i.setAttribute("style",n.styling||"display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;"),e.append(i)}}}]).directive("tumblrImage",[function(){return{link:function(t,e,n){var i=document.createElement("a");i.setAttribute("href","http://www.tumblr.com/share/photo?source="+encodeURIComponent(n.source)+"&caption="+encodeURIComponent(n.caption)+"&clickthru="+encodeURIComponent(n.clickthru)),i.setAttribute("title",n.title||"Share on Tumblr"),i.setAttribute("style",n.styling||"display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;"),e.append(i)}}}]).directive("tumblrVideo",[function(){return{link:function(t,e,n){var i=document.createElement("a");i.setAttribute("href","http://www.tumblr.com/share/video?embed="+encodeURIComponent(n.embedcode)+"&caption="+encodeURIComponent(n.caption)),i.setAttribute("title",n.title||"Share on Tumblr"),i.setAttribute("style",n.styling||"display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;"),e.append(i)}}}]).directive("pintrest",[function(){return{template:'<a href="{{href}}" data-pin-do="{{pinDo}}" data-pin-config="{{pinConfig}}"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a>',link:function(t,e,n){t.href="//www.pinterest.com/pin/create/button/?url="+encodeURIComponent(n.href)+"&media="+encodeURIComponent(n.img)+"&description="+encodeURIComponent(n.description),t.pinDo=n.pinDo||"buttonPin",t.pinConfig=n.pinConfig||"beside"}}}]);