-
Notifications
You must be signed in to change notification settings - Fork 67
/
02-facebook.js
53 lines (51 loc) · 1.39 KB
/
02-facebook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
app.directive('ngSocialFacebook', ['$parse', function ($parse) {
'use strict';
var options = {
counter: {
url: '//graph.facebook.com/fql?q=SELECT+total_count+FROM+link_stat+WHERE+url%3D%22{url}%22' +
'&callback=JSON_CALLBACK',
getNumber: function (data) {
if (0 === data.data.length) {
return 0;
}
return data.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: true,
replace: true,
transclude: true,
template: '<li>' +
'<a ng-href="{{ctrl.link(options)}}" target="_blank" ng-click="ctrl.clickShare($event, options)"' +
' class="ng-social-button">' +
'<span class="ng-social-icon"></span>' +
'<span class="ng-social-text" ng-transclude></span>' +
'</a>' +
'<span ng-show="count" class="ng-social-counter">{{ count }}</span>' +
'</li>',
link: function (scope, element, attrs, ctrl) {
element.addClass('ng-social-facebook');
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
};
}]);