4
4
var FB_LINK = 'https://www.facebook.com/sharer/sharer.php?u=' ;
5
5
var VK_LINK = 'https://vk.com/share.php?url={0}&description={1}. {2}' ;
6
6
var TW_LINK = 'https://twitter.com/intent/tweet?url=' ;
7
- var GP_LINK = 'https://plus.google.com/share?url=' ;
8
- var IN_LINK = 'https://www.linkedin.com/shareArticle?mini=true&url=' ;
7
+ // var GP_LINK = 'https://plus.google.com/share?url=';
8
+ // var IN_LINK = 'https://www.linkedin.com/shareArticle?mini=true&url=';
9
9
10
10
// from http://evgeniy.pakalo.name/post/49
11
11
var _F = function ( str , args ) {
21
21
this . init = function ( ) {
22
22
var _this = this ,
23
23
share = document . querySelectorAll ( '.share-btn' ) ;
24
+
24
25
for ( var i = 0 , l = share . length ; i < l ; i ++ ) {
25
- var url = share [ i ] . getAttribute ( 'data-url' ) || location . href ,
26
- title = share [ i ] . getAttribute ( 'data-title' ) || document . title ,
27
- desc = share [ i ] . getAttribute ( 'data-desc' ) || ' ' ,
26
+ var url = this . getUrl ( share [ i ] ) ,
27
+ title = this . getTitle ( share [ i ] ) ,
28
+ desc = this . getDesc ( share [ i ] ) ,
28
29
el = share [ i ] . querySelectorAll ( 'a' ) ;
29
30
30
31
for ( var a = 0 , al = el . length ; a < al ; a ++ ) {
41
42
}
42
43
} ;
43
44
45
+ this . getUrl = function ( share ) {
46
+ return share . getAttribute ( 'data-url' ) || location . href || ' ' ;
47
+ } ;
48
+
49
+ this . getTitle = function ( share ) {
50
+ return share . getAttribute ( 'data-title' ) || document . title || ' ' ;
51
+ } ;
52
+
53
+ this . getDesc = function ( share ) {
54
+ var metaDesc = document . querySelector ( 'meta[name=description]' ) ;
55
+ return share . getAttribute ( 'data-desc' ) || ( metaDesc && metaDesc . getAttribute ( 'content' ) ) || ' ' ;
56
+ } ;
57
+
44
58
this . addEventListener = function ( el , eventName , opt ) {
45
59
var _this = this ,
46
60
handler = function ( ) {
84
98
this . popupCenter ( TW_LINK + url + text , this . title , this . width , this . height ) ;
85
99
break ;
86
100
87
- case 'gp' :
88
- this . popupCenter ( GP_LINK + url , this . title , this . width , this . height ) ;
89
- break ;
101
+ // case 'gp':
102
+ // this.popupCenter(GP_LINK + url, this.title, this.width, this.height);
103
+ // break;
90
104
91
- case 'in' :
92
- this . popupCenter ( IN_LINK + url , this . title , this . width , this . height ) ;
93
- break ;
105
+ // case 'in':
106
+ // this.popupCenter(IN_LINK + url, this.title, this.width, this.height);
107
+ // break;
94
108
95
109
case 'mail' :
96
110
var text = title || desc || '' ;
149
163
} ;
150
164
151
165
152
-
153
- // start
154
- var sb = new ShareButtons ( ) ;
155
- sb . init ( ) ;
156
-
166
+ // start
167
+ new ShareButtons ( ) . init ( ) ;
157
168
} ( ) ) ;
158
169
159
170
0 commit comments