-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy path09-github-forks.js
40 lines (39 loc) · 1.23 KB
/
09-github-forks.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
'use strict';
angular.module("ngSocial").directive('ngSocialGithubForks', function () {
var options = {
counter: {
url: '//api.github.com/repos/{user}/{repository}?callback=JSON_CALLBACK',
getNumber: function (data) {
return data.data.forks_count;
}
},
clickUrl: 'https://github.com/{user}/{repository}/'
};
return {
restrict: 'C',
require: '^?ngSocialButtons',
scope: true,
replace: true,
transclude: true,
template: '<li> \
<a ng-href="{{ctrl.link(options)}}" target="_blank" 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-github ng-social-github-forks');
if (!ctrl) {
return;
}
options.urlOptions = {
'user': attrs.user,
'repository': attrs.repository
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
}
});