|
angular.module('ngSocialMedia',[]) |
|
.directive('fbShare',function($window){ |
|
|
|
var fbShare = function(url, winWidth, winHeight) { |
|
|
|
url = url || $window.location.href; |
|
|
|
|
|
winWidth = winWidth || 520; |
|
winHeight = winHeight || 350; |
|
|
|
var winTop = (screen.height / 2) - (winHeight / 2); |
|
var winLeft = (screen.width / 2) - (winWidth / 2); |
|
window.open('https://www.facebook.com/sharer.php?s=100&p[url]=' + url , 'fbSharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight); |
|
|
|
} |
|
return { |
|
link:function(scope,elem,attrs){ |
|
elem.click(function(){ |
|
fbShare(attrs.fbShare); |
|
}); |
|
} |
|
} |
|
|
|
}) |
|
|
|
.directive('twShare',function($window){ |
|
|
|
var twShare = function(content, winWidth, winHeight) { |
|
|
|
|
|
var url = $window.location.href; |
|
|
|
content = content || 'Join Gourmet Society to get at least 20% discount at all of our partner restaurants, plus other exclusive treats. '+url; |
|
|
|
winWidth = winWidth || 520; |
|
winHeight = winHeight || 350; |
|
|
|
var winTop = (screen.height / 2) - (winHeight / 2); |
|
var winLeft = (screen.width / 2) - (winWidth / 2); |
|
window.open('https://twitter.com/home?status=' + encodeURIComponent(content) , 'twShare', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight); |
|
} |
|
return { |
|
link:function(scope,elem,attrs){ |
|
elem.click(function(){ |
|
twShare(attrs.twShare); |
|
}); |
|
} |
|
} |
|
|
|
}) |
|
|
|
|
|
.directive('gplusShare',function($window){ |
|
|
|
var gplusShare = function(url, winWidth, winHeight) { |
|
|
|
|
|
url = url || $window.location.href; |
|
|
|
|
|
winWidth = winWidth || 520; |
|
winHeight = winHeight || 350; |
|
|
|
var winTop = (screen.height / 2) - (winHeight / 2); |
|
var winLeft = (screen.width / 2) - (winWidth / 2); |
|
window.open('https://plus.google.com/share?url=' + url , 'gplusShare', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight); |
|
} |
|
return { |
|
link:function(scope,elem,attrs){ |
|
elem.click(function(){ |
|
gplusShare(attrs.gplusShare); |
|
}); |
|
} |
|
} |
|
|
|
}) |
|
|
|
; |