Repository navigation
Expand file tree
/
Copy pathoj.GoogleButton.js
More file actions
90 lines (74 loc) · 2.1 KB
/
Copy pathoj.GoogleButton.js
File metadata and controls
90 lines (74 loc) · 2.1 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// oj.GoogleButton
module.exports = function(oj,settings){
if (typeof settings !== 'object')
settings = {}
var GoogleButton = oj.createType('GoogleButton', {
base: oj.View,
constructor: function(){
var this_ = this;
var union = oj.argumentsUnion(arguments);
var options = union.options;
var args = union.args;
// First argument is username
if(args.length > 0)
this.username = args[0];
// Shift properties
var props = [
'label',
'large',
'showCount',
'showUsername',
'username'
];
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (options[prop] != null)
this[prop] = oj.argumentShift(options, prop);
}
// Create el
this.el = oj(function(){
var size = null, tailor = null;
if (this_.large)
size = {'data-size':'large'};
if (!this_.showTailoring)
tailor = {'data-dnt':false};
oj.a("Follow @" + this_.username, {
href: 'https://twitter.com/' + this_.username,
c:'twitter-follow-button',
'data-show-count':this_.showCount,
'data-show-screen-name':this_.showUsername,
style:{display:'none'}
},
tailor,
size
);
});
GoogleButton.base.constructor.apply(this, [options]);
this.loadTwitterAPI();
},
properties: {
username: 'evanmoran',
showUsername: true,
showCount: false,
showTailoring: true,
large: false
},
methods: {
loadTwitterAPI:function(){
var this_ = this;
if (oj.isClient && !_loaded) {
var p=/^http:/.test(document.location)?'http':'https';
$.ajax({
url: p + '://platform.twitter.com/widgets.js',
dataType: "script",
cached: true,
// Show button once api has been called (avoids flickering)
complete: function(){this_.$el.show()}
});
}
_loaded = 1;
}
}
});
return {GoogleButton:GoogleButton};
};