diff --git a/angular-social.js b/angular-social.js index 6011097..148126c 100644 --- a/angular-social.js +++ b/angular-social.js @@ -1,2 +1,2 @@ -function template(a,b,c){"use strict";return a.replace(/\{([^\}]+)\}/g,function(a,d){return d in b?c?c(b[d]):b[d]:a})}var app=angular.module("ngSocial",[]);app.directive("ngSocialButtons",["$compile","$q","$parse","$http","$location",function(a,b,c,d,e){"use strict";return{restrict:"A",scope:{url:"=",title:"=",description:"=",image:"=",showcounts:"="},replace:!0,transclude:!0,template:'
',controller:["$scope","$q","$http",function(a,b,c){var d=function(){return a.url||e.absUrl()},f=this;return this.init=function(a,b,c){c.counter&&f.getCount(a.options).then(function(b){a.count=b})},this.link=function(b){b=b||{};var c=b.urlOptions||{};return c.url=d(),c.title||(c.title=a.title),c.image||(c.image=a.image),c.description||(c.description=a.description||""),f.makeUrl(b.clickUrl||b.popup.url,c)},this.clickShare=function(b,c){if(!b.shiftKey&&!b.ctrlKey){b.preventDefault(),c.track&&"undefined"!=typeof _gaq&&angular.isArray(_gaq)&&_gaq.push(["_trackSocial",c.track.name,c.track.action,a.url]);var d=!0;if(angular.isFunction(c.click)&&(d=c.click.call(this,c)),d){var e=f.link(c);f.openPopup(e,c.popup)}}},this.openPopup=function(a,b){var c=Math.round(screen.width/2-b.width/2),d=0;screen.height>b.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");e?e.focus():location.href=a},this.getCount=function(e){var g=b.defer(),h=e.urlOptions||{};h.url=d(),h.title||(h.title=a.title);var i=f.makeUrl(e.counter.url,h),j=angular.isUndefined(a.showcounts)?!0:a.showcounts;return j&&(e.counter.get?e.counter.get(i,g,c):c.jsonp(i).success(function(a){g.resolve(e.counter.getNumber?e.counter.getNumber(a):a)})),g.promise},this.makeUrl=function(a,b){return template(a,b,encodeURIComponent)},this}]}}]),app.directive("ngSocialFacebook",["$parse",function(a){"use strict";var b={counter:{url:"//graph.facebook.com/fql?q=SELECT+total_count+FROM+link_stat+WHERE+url%3D%22{url}%22&callback=JSON_CALLBACK",getNumber:function(a){return 0===a.data.length?0:a.data[0].total_count}},popup:{url:"http://www.facebook.com/sharer/sharer.php?u={url}",width:600,height:500},track:{name:"facebook",action:"send"}};return{restrict:"C",require:"^?ngSocialButtons",scope:!0,replace:!0,transclude:!0,template:'