-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy path04-google-plus.js
63 lines (60 loc) · 1.67 KB
/
04-google-plus.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
54
55
56
57
58
59
60
61
62
63
app.directive('ngSocialGooglePlus', ['$parse', function ($parse) {
'use strict';
var options = {
counter: {
url: '//share.yandex.ru/gpp.xml?url={url}',
getNumber: function (data) {
return data.count;
},
get: function (jsonUrl, deferred, $http) {
if (options._) {
deferred.reject();
return;
}
if (!window.services) window.services = {};
window.services.gplus = {
cb: function (number) {
options._.resolve(number);
}
};
options._ = deferred;
$http.jsonp(jsonUrl);
}
},
popup: {
url: 'https://plus.google.com/share?url={url}',
width: 700,
height: 500
},
track: {
'name': 'Google+',
'action': 'share'
}
};
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-google-plus');
if (!ctrl) {
return;
}
options.urlOptions = {
url: $parse(attrs.url)(scope)
};
scope.options = options;
scope.ctrl = ctrl;
ctrl.init(scope, element, options);
}
};
}]);