socialite_js-source 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +32 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.bufferapp.js +42 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.extension-template.js +72 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.facebook.js +65 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.github.js +57 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.googleplus.js +67 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.hackernews.js +30 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.linkedin.js +32 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.pinterest.js +47 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.spotify.js +34 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.twitter.js +89 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.vkontakte.js +81 -0
- data/lib/socialite_js/assets/javascript/extensions/socialite.weibo.js +66 -0
- data/lib/socialite_js/assets/javascript/socialite.js +708 -0
- data/lib/socialite_js/assets/javascript/socialite.min.js +49 -0
- data/lib/socialite_js/source/version.rb +5 -0
- data/lib/socialite_js/source.rb +44 -0
- data/socialite_js-source.gemspec +22 -0
- data/test/socialite_js/source_test.rb +38 -0
- data/test/test_helper.rb +3 -0
- metadata +88 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Socialite v2.0 - Vkontakte extension
|
|
3
|
+
* http://socialitejs.com
|
|
4
|
+
* Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
|
|
5
|
+
*/
|
|
6
|
+
(function(window, document, Socialite, undefined)
|
|
7
|
+
{
|
|
8
|
+
// http://vk.com/developers.php?oid=-1&p=Share
|
|
9
|
+
// http://vk.com/developers.php?oid=-1&p=Like
|
|
10
|
+
// http://vk.com/developers.php?oid=-1&p=Groups
|
|
11
|
+
|
|
12
|
+
var VKCallbacks = [];
|
|
13
|
+
|
|
14
|
+
Socialite.setup({
|
|
15
|
+
vkontakte: {
|
|
16
|
+
apiId: null,
|
|
17
|
+
group: {
|
|
18
|
+
id: 0,
|
|
19
|
+
mode: 0,
|
|
20
|
+
width: 300,
|
|
21
|
+
height: 290
|
|
22
|
+
},
|
|
23
|
+
like: {
|
|
24
|
+
type: 'mini'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
Socialite.network('vkontakte', {
|
|
30
|
+
script: {
|
|
31
|
+
src : '//userapi.com/js/api/openapi.js?49',
|
|
32
|
+
id : 'vk-jsapi'
|
|
33
|
+
},
|
|
34
|
+
onload: function(network) {
|
|
35
|
+
var settings = Socialite.settings.vkontakte;
|
|
36
|
+
VK.init({apiId: settings.apiId, onlyWidgets: true});
|
|
37
|
+
for (var i = 0, i$l = VKCallbacks.length; i < i$l; VKCallbacks[i].call(this), i++);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var extendConfWithAttributes = function(el, attributes, original) {
|
|
42
|
+
var result = {}, key;
|
|
43
|
+
for (var k = 0, k$l = attributes.length; k < k$l; key = attributes[k], result[key] = el.getAttribute('data-' + key) || original[key], k++);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Socialite.widget('vkontakte', 'group', {
|
|
48
|
+
init: function(instance)
|
|
49
|
+
{
|
|
50
|
+
if (typeof window.VK !== 'object') VKCallbacks.push(function(){
|
|
51
|
+
var el = document.createElement('div'),
|
|
52
|
+
settings = Socialite.settings.vkontakte;
|
|
53
|
+
el.className = 'vk-group';
|
|
54
|
+
// Vkontakte needs explicit element id
|
|
55
|
+
el.id = 'vkontakte-group-' + (new Date()).getTime();
|
|
56
|
+
Socialite.copyDataAttributes(instance.el, el);
|
|
57
|
+
group = extendConfWithAttributes(instance.el, ['id', 'mode', 'width', 'height'], settings.group);
|
|
58
|
+
instance.el.appendChild(el);
|
|
59
|
+
VK.Widgets.Group(el.id, group, group['id']);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
Socialite.widget('vkontakte', 'like', {
|
|
65
|
+
init: function(instance)
|
|
66
|
+
{
|
|
67
|
+
if (typeof window.VK !== 'object') VKCallbacks.push(function(){
|
|
68
|
+
var el = document.createElement('div'),
|
|
69
|
+
settings = Socialite.settings.vkontakte;
|
|
70
|
+
el.className = 'vk-like';
|
|
71
|
+
// Vkontakte needs explicit element id
|
|
72
|
+
el.id = 'vkontakte-like-' + (new Date()).getTime() + Math.random().toString().replace('.', '-');
|
|
73
|
+
Socialite.copyDataAttributes(instance.el, el);
|
|
74
|
+
like = extendConfWithAttributes(instance.el, ['type'], settings.like);
|
|
75
|
+
instance.el.appendChild(el);
|
|
76
|
+
VK.Widgets.Like(el.id, like);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
})(window, window.document, window.Socialite);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Socialite v2.0 - Weibo extension
|
|
3
|
+
* http://socialitejs.com
|
|
4
|
+
* Copyright (c) 2011 David Bushell
|
|
5
|
+
* Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
|
|
6
|
+
*/
|
|
7
|
+
(function(window, document, Socialite, undefined)
|
|
8
|
+
{
|
|
9
|
+
// External documentation URLs
|
|
10
|
+
// http://open.weibo.com/sharebutton
|
|
11
|
+
|
|
12
|
+
Socialite.setup({
|
|
13
|
+
weibo: {
|
|
14
|
+
language : 'zh_cn',
|
|
15
|
+
appkey : ''
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
Socialite.network('weibo');
|
|
20
|
+
|
|
21
|
+
Socialite.widget('weibo', 'share', {
|
|
22
|
+
process: null,
|
|
23
|
+
init: function(instance)
|
|
24
|
+
{
|
|
25
|
+
Socialite.processInstance(instance);
|
|
26
|
+
var src = 'http://hits.sinajs.cn/A1/weiboshare.html?',
|
|
27
|
+
data = {
|
|
28
|
+
url : instance.el.getAttribute('data-url') || location.href,
|
|
29
|
+
title : instance.el.getAttribute('data-title') || document.title,
|
|
30
|
+
type : instance.el.getAttribute('data-type') || '6',
|
|
31
|
+
ralateUid : instance.el.getAttribute('data-ralateuid') || '',
|
|
32
|
+
language : Socialite.settings.weibo.language,
|
|
33
|
+
appkey : Socialite.settings.weibo.appkey,
|
|
34
|
+
rnd : new Date().valueOf()
|
|
35
|
+
},
|
|
36
|
+
width = parseInt(instance.el.getAttribute('data-width'), 10),
|
|
37
|
+
height = parseInt(instance.el.getAttribute('data-height'), 10),
|
|
38
|
+
params = [];
|
|
39
|
+
|
|
40
|
+
for (var a in data) {
|
|
41
|
+
params.push(a + '=' + encodeURIComponent(data[a] || ''));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
src += params.join('&') + '&';
|
|
45
|
+
|
|
46
|
+
instance.el.setAttribute('data-url', '');
|
|
47
|
+
instance.el.setAttribute('data-title', '');
|
|
48
|
+
instance.el.setAttribute('data-type', '');
|
|
49
|
+
instance.el.setAttribute('data-ralateuid', '');
|
|
50
|
+
instance.el.setAttribute('data-width', '');
|
|
51
|
+
instance.el.setAttribute('data-height', '');
|
|
52
|
+
instance.el.setAttribute('data-default-href', '');
|
|
53
|
+
instance.el.setAttribute('data-socialite', '');
|
|
54
|
+
|
|
55
|
+
src += Socialite.getDataAttributes(instance.el, true);
|
|
56
|
+
|
|
57
|
+
var iframe = Socialite.createIframe(src, instance);
|
|
58
|
+
iframe.style.width = (isNaN(width) ? 86 : width) + 'px';
|
|
59
|
+
iframe.style.height = (isNaN(height) ? 16 : height) + 'px';
|
|
60
|
+
instance.el.appendChild(iframe);
|
|
61
|
+
|
|
62
|
+
Socialite.activateInstance(instance);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
})(window, window.document, window.Socialite);
|