socialite_js-source 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
*.gem
|
2
|
+
!vendor/cache/*
|
3
|
+
|
4
|
+
*.rbc
|
5
|
+
.bundle
|
6
|
+
.config
|
7
|
+
Gemfile.lock
|
8
|
+
coverage
|
9
|
+
InstalledFiles
|
10
|
+
lib/bundler/man
|
11
|
+
pkg
|
12
|
+
spec/reports
|
13
|
+
test/tmp
|
14
|
+
test/version_tmp
|
15
|
+
tmp
|
16
|
+
|
17
|
+
# YARD artifacts
|
18
|
+
.yardoc
|
19
|
+
_yardoc
|
20
|
+
doc/
|
21
|
+
rdoc
|
22
|
+
|
23
|
+
# temporary emacs files
|
24
|
+
\#*
|
25
|
+
\.\#*
|
26
|
+
|
27
|
+
.rvmrc
|
28
|
+
.ruby-version
|
29
|
+
.ruby-gemset
|
30
|
+
|
31
|
+
NOTES
|
32
|
+
.rspec
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Deepak Kannan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# SocialiteJs::Source
|
2
|
+
|
3
|
+
JavaScript source code for socialite.js wrapped in a rubygems shell.
|
4
|
+
socialite.js is a library to display social sharing buttons.
|
5
|
+
|
6
|
+
check http://socialitejs.com/ and https://github.com/dbushell/Socialite
|
7
|
+
|
8
|
+
This rubygem is a shell over the socialite.js
|
9
|
+
Its version will be the same as socialite.js and was created to:
|
10
|
+
1. make it easier to bundle socialite.js in Rails apps
|
11
|
+
2. release management. version and specify a specific version of socialite.js in your Rails apps
|
12
|
+
|
13
|
+
#### Why does the gem name have dashes ?
|
14
|
+
|
15
|
+
The name of the gem is socialite_js-source. It contains a dashes because it sits under the namespace of socialite_js
|
16
|
+
so you will be requiring 'socialite_js/source' not 'socialite-source' in your ruby code
|
17
|
+
|
18
|
+
see http://guides.rubygems.org/patterns/#consistent-naming under the "Use dashes for extensions" section
|
19
|
+
|
20
|
+
## TODO
|
21
|
+
Seems like the socialite.js library does not follow any specific versioning
|
22
|
+
|
23
|
+
And btw hate the name of the gem.
|
24
|
+
@gnufied said it best on the #ruby-lang irc channel
|
25
|
+
the name `socialite_js-source` is `ugg`
|
26
|
+
|
27
|
+
> dkannan: me too but the name socialite is taken
|
28
|
+
> dkannan: how about socialite_js-source
|
29
|
+
> gnufied: ugg
|
30
|
+
|
31
|
+
Any other suggestions :-)
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
Add this line to your application's Gemfile:
|
36
|
+
|
37
|
+
gem 'socialite_js-source'
|
38
|
+
|
39
|
+
And then execute:
|
40
|
+
|
41
|
+
$ bundle
|
42
|
+
|
43
|
+
Or install it yourself as:
|
44
|
+
|
45
|
+
$ gem install socialite_js-source
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - Bufferapp 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
|
+
// http://bufferapp.com/extras/button
|
10
|
+
|
11
|
+
Socialite.network('bufferapp', {
|
12
|
+
script: {
|
13
|
+
src: '//static.bufferapp.com/js/button.js'
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
Socialite.widget('bufferapp', 'button', {
|
18
|
+
reappend: null,
|
19
|
+
init: function(instance)
|
20
|
+
{
|
21
|
+
var el = document.createElement('a');
|
22
|
+
el.className = 'buffer-add-button';
|
23
|
+
Socialite.copyDataAttributes(instance.el, el);
|
24
|
+
el.setAttribute('href', instance.el.getAttribute('data-default-href'));
|
25
|
+
instance.el.appendChild(el);
|
26
|
+
},
|
27
|
+
activate: function(instance)
|
28
|
+
{
|
29
|
+
var w = instance.widget,
|
30
|
+
n = w.network.name;
|
31
|
+
if (Socialite.networkReady(n)) {
|
32
|
+
if (w.reappend) {
|
33
|
+
clearTimeout(w.reappend);
|
34
|
+
}
|
35
|
+
w.reappend = setTimeout(function() {
|
36
|
+
Socialite.reloadNetwork(n);
|
37
|
+
}, 50);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - Extension template
|
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
|
+
|
11
|
+
// add required default settings
|
12
|
+
Socialite.setup({
|
13
|
+
'network_name': {
|
14
|
+
lang: 'en'
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
/**
|
19
|
+
* One network can cater for multiple widgets
|
20
|
+
* Check the extensions repository to make sure it doesn't already exist
|
21
|
+
* The script object is optional for extentions that require simple images or iframes
|
22
|
+
*/
|
23
|
+
Socialite.network('network_name', {
|
24
|
+
script: {
|
25
|
+
src : '//network_name.js',
|
26
|
+
charset : 'utf-8'
|
27
|
+
},
|
28
|
+
/**
|
29
|
+
* (optional) Called before `Socialite.load()` appends the network script via `Socialite.appendNetwork()`
|
30
|
+
*/
|
31
|
+
append: function(network)
|
32
|
+
{
|
33
|
+
// return false to cancel the append and activate all instances immedicately
|
34
|
+
},
|
35
|
+
/**
|
36
|
+
* (optional) called after an appended network script has loaded
|
37
|
+
*/
|
38
|
+
onload: function(network)
|
39
|
+
{
|
40
|
+
// return false to cancel automatically activation of all instances
|
41
|
+
}
|
42
|
+
});
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Add a unique widget to the network
|
46
|
+
* Socialite will activate elements with a class name of `network_name-widget_name`, e.g. `twitter-share`
|
47
|
+
*/
|
48
|
+
Socialite.widget('network_name', 'widget_name', {
|
49
|
+
/**
|
50
|
+
* (optional) Called after a new instance has been created but before it is initialised
|
51
|
+
*/
|
52
|
+
process: function(instance)
|
53
|
+
{
|
54
|
+
// return false or replace function with `null` to cancel the default processing of `Socialite.processInstance()`
|
55
|
+
},
|
56
|
+
/**
|
57
|
+
* Called when an instance is loaded
|
58
|
+
*/
|
59
|
+
init: function(instance)
|
60
|
+
{
|
61
|
+
// After this function that instance should resemble the suggested implementation by the social network
|
62
|
+
},
|
63
|
+
/**
|
64
|
+
* (optional) Called by `Socialite.activateInstance()` when the network has loaded and the final widget is ready to display
|
65
|
+
*/
|
66
|
+
activate: function(instance)
|
67
|
+
{
|
68
|
+
//
|
69
|
+
}
|
70
|
+
});
|
71
|
+
|
72
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - Facebook 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
|
+
// http://developers.facebook.com/docs/reference/plugins/like/
|
10
|
+
// http://developers.facebook.com/docs/reference/javascript/FB.init/
|
11
|
+
|
12
|
+
Socialite.setup({
|
13
|
+
facebook: {
|
14
|
+
lang: 'en_GB',
|
15
|
+
appId: null
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
Socialite.network('facebook', {
|
20
|
+
script: {
|
21
|
+
src : '//connect.facebook.net/{{language}}/all.js',
|
22
|
+
id : 'facebook-jssdk'
|
23
|
+
},
|
24
|
+
append: function(network)
|
25
|
+
{
|
26
|
+
var fb = document.createElement('div'),
|
27
|
+
settings = Socialite.settings.facebook,
|
28
|
+
events = {
|
29
|
+
onlike: 'edge.create',
|
30
|
+
onunlike: 'edge.remove',
|
31
|
+
onsend: 'message.send' ,
|
32
|
+
oncomment: 'comment.create',
|
33
|
+
onuncomment: 'comment.remove'
|
34
|
+
};
|
35
|
+
fb.id = 'fb-root';
|
36
|
+
document.body.appendChild(fb);
|
37
|
+
network.script.src = network.script.src.replace('{{language}}', settings.lang);
|
38
|
+
window.fbAsyncInit = function() {
|
39
|
+
window.FB.init({
|
40
|
+
appId: settings.appId,
|
41
|
+
xfbml: true
|
42
|
+
});
|
43
|
+
for (var e in events) {
|
44
|
+
if (typeof settings[e] === 'function') {
|
45
|
+
window.FB.Event.subscribe(events[e], settings[e]);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
};
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
Socialite.widget('facebook', 'like', {
|
53
|
+
init: function(instance)
|
54
|
+
{
|
55
|
+
var el = document.createElement('div');
|
56
|
+
el.className = 'fb-like';
|
57
|
+
Socialite.copyDataAttributes(instance.el, el);
|
58
|
+
instance.el.appendChild(el);
|
59
|
+
if (window.FB && window.FB.XFBML) {
|
60
|
+
window.FB.XFBML.parse(instance.el);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,57 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - GitHub 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
|
+
// http://markdotto.github.com/github-buttons/
|
10
|
+
// https://github.com/markdotto/github-buttons/
|
11
|
+
|
12
|
+
Socialite.network('github');
|
13
|
+
|
14
|
+
// github.size[size][type][has_count][dimension]
|
15
|
+
Socialite.setup({
|
16
|
+
github: {
|
17
|
+
size: [
|
18
|
+
{
|
19
|
+
watch : [ [ 62,20], [110,20] ],
|
20
|
+
fork : [ [ 53,20], [ 95,20] ],
|
21
|
+
follow : [ [150,20], [200,20] ]
|
22
|
+
},
|
23
|
+
{
|
24
|
+
watch : [ [100,30], [170,30] ],
|
25
|
+
fork : [ [80, 30], [155,30] ],
|
26
|
+
follow : [ [200,30], [300,30] ]
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
});
|
31
|
+
|
32
|
+
var initGitHub = function(instance)
|
33
|
+
{
|
34
|
+
var type = instance.el.getAttribute('data-type'),
|
35
|
+
size = instance.el.getAttribute('data-size') === 'large' ? 1 : 0,
|
36
|
+
count = instance.el.getAttribute('data-count') === 'true' ? 1 : 0,
|
37
|
+
data = Socialite.settings.github.size;
|
38
|
+
|
39
|
+
type = (type && data[size].hasOwnProperty(type)) ? type : 'watch';
|
40
|
+
|
41
|
+
instance.el.setAttribute('data-type', type);
|
42
|
+
instance.el.setAttribute('data-count', !!count);
|
43
|
+
|
44
|
+
Socialite.processInstance(instance);
|
45
|
+
var src = 'http://ghbtns.com/github-btn.html?' + Socialite.getDataAttributes(instance.el, true);
|
46
|
+
var iframe = Socialite.createIframe(src, instance);
|
47
|
+
iframe.style.width = data[size][type][count][0] + 'px';
|
48
|
+
iframe.style.height = data[size][type][count][1] + 'px';
|
49
|
+
instance.el.appendChild(iframe);
|
50
|
+
Socialite.activateInstance(instance);
|
51
|
+
};
|
52
|
+
|
53
|
+
Socialite.widget('github', 'watch', { process: null, init: initGitHub });
|
54
|
+
Socialite.widget('github', 'fork', { process: null, init: initGitHub });
|
55
|
+
Socialite.widget('github', 'follow', { process: null, init: initGitHub });
|
56
|
+
|
57
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - GooglePlus 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
|
+
// https://developers.google.com/+/plugins/+1button/
|
10
|
+
// Google does not support IE7
|
11
|
+
|
12
|
+
Socialite.setup({
|
13
|
+
googleplus: {
|
14
|
+
lang: 'en-GB'
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
Socialite.network('googleplus', {
|
19
|
+
script: {
|
20
|
+
src: '//apis.google.com/js/plusone.js'
|
21
|
+
},
|
22
|
+
append: function(network)
|
23
|
+
{
|
24
|
+
if (window.gapi) {
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
window.___gcfg = {
|
28
|
+
lang: Socialite.settings.googleplus.lang,
|
29
|
+
parsetags: 'explicit'
|
30
|
+
};
|
31
|
+
}
|
32
|
+
});
|
33
|
+
|
34
|
+
var googleplusInit = function(instance)
|
35
|
+
{
|
36
|
+
var el = document.createElement('div');
|
37
|
+
el.className = 'g-' + instance.widget.gtype;
|
38
|
+
Socialite.copyDataAttributes(instance.el, el);
|
39
|
+
instance.el.appendChild(el);
|
40
|
+
instance.gplusEl = el;
|
41
|
+
};
|
42
|
+
|
43
|
+
var googleplusEvent = function(instance, callback) {
|
44
|
+
return (typeof callback !== 'function') ? null : function(data) {
|
45
|
+
callback(instance.el, data);
|
46
|
+
};
|
47
|
+
};
|
48
|
+
|
49
|
+
var googleplusActivate = function(instance)
|
50
|
+
{
|
51
|
+
var type = instance.widget.gtype;
|
52
|
+
if (window.gapi && window.gapi[type]) {
|
53
|
+
var settings = Socialite.settings.googleplus,
|
54
|
+
params = Socialite.getDataAttributes(instance.el, true, true),
|
55
|
+
events = ['onstartinteraction', 'onendinteraction', 'callback'];
|
56
|
+
for (var i = 0; i < events.length; i++) {
|
57
|
+
params[events[i]] = googleplusEvent(instance, settings[events[i]]);
|
58
|
+
}
|
59
|
+
window.gapi[type].render(instance.gplusEl, params);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
Socialite.widget('googleplus', 'one', { init: googleplusInit, activate: googleplusActivate, gtype: 'plusone' });
|
64
|
+
Socialite.widget('googleplus', 'share', { init: googleplusInit, activate: googleplusActivate, gtype: 'plus' });
|
65
|
+
Socialite.widget('googleplus', 'badge', { init: googleplusInit, activate: googleplusActivate, gtype: 'plus' });
|
66
|
+
|
67
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,30 @@
|
|
1
|
+
//
|
2
|
+
// Hacker News
|
3
|
+
// https://github.com/igrigorik/hackernews-button
|
4
|
+
//
|
5
|
+
(function(window, document, Socialite, undefined)
|
6
|
+
{
|
7
|
+
|
8
|
+
Socialite.network('hackernews', {
|
9
|
+
script: {
|
10
|
+
src: '//hnbutton.appspot.com/static/hn.js'
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
var hackernewsInit = function(instance) {
|
15
|
+
var el = document.createElement('a');
|
16
|
+
el.className = 'hn-share-button';
|
17
|
+
Socialite.copyDataAttributes(instance.el, el);
|
18
|
+
instance.el.appendChild(el);
|
19
|
+
};
|
20
|
+
|
21
|
+
Socialite.widget('hackernews', 'share', {
|
22
|
+
init: hackernewsInit,
|
23
|
+
activate: function(instance) {
|
24
|
+
if (window.HN) {
|
25
|
+
window.HN.render(instance.el);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - LinkedIn 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
|
+
// http://developer.linkedin.com/plugins/share-button/
|
10
|
+
|
11
|
+
Socialite.network('linkedin', {
|
12
|
+
script: {
|
13
|
+
src: '//platform.linkedin.com/in.js'
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
var linkedinInit = function(instance)
|
18
|
+
{
|
19
|
+
var el = document.createElement('script');
|
20
|
+
el.type = 'IN/' + instance.widget.intype;
|
21
|
+
Socialite.copyDataAttributes(instance.el, el);
|
22
|
+
instance.el.appendChild(el);
|
23
|
+
if (typeof window.IN === 'object' && typeof window.IN.parse === 'function') {
|
24
|
+
window.IN.parse(instance.el);
|
25
|
+
Socialite.activateInstance(instance);
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
Socialite.widget('linkedin', 'share', { init: linkedinInit, intype: 'Share' });
|
30
|
+
Socialite.widget('linkedin', 'recommend', { init: linkedinInit, intype: 'RecommendProduct' });
|
31
|
+
|
32
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - Pinterest 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
|
+
// http://pinterest.com/about/goodies/
|
10
|
+
|
11
|
+
Socialite.network('pinterest', {
|
12
|
+
script: {
|
13
|
+
src: '//assets.pinterest.com/js/pinit.js'
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
Socialite.widget('pinterest', 'pinit', {
|
18
|
+
process: function(instance)
|
19
|
+
{
|
20
|
+
// Pinterest activates all <a> elements with a href containing share URL
|
21
|
+
// so we have to jump through hoops to protect each instance
|
22
|
+
if (instance.el.nodeName.toLowerCase() !== 'a') {
|
23
|
+
return true;
|
24
|
+
}
|
25
|
+
var id = 'socialite-instance-' + instance.uid,
|
26
|
+
href = instance.el.getAttribute('href');
|
27
|
+
instance.el.id = id;
|
28
|
+
instance.el.href = '#' + id;
|
29
|
+
instance.el.setAttribute('data-default-href', href);
|
30
|
+
instance.el.setAttribute('onclick', '(function(){window.open("' + href + '")})();');
|
31
|
+
},
|
32
|
+
init: function(instance)
|
33
|
+
{
|
34
|
+
Socialite.processInstance(instance);
|
35
|
+
var el = document.createElement('a');
|
36
|
+
el.className = 'pin-it-button';
|
37
|
+
Socialite.copyDataAttributes(instance.el, el);
|
38
|
+
el.setAttribute('href', instance.el.getAttribute('data-default-href'));
|
39
|
+
el.setAttribute('count-layout', instance.el.getAttribute('data-count-layout') || 'horizontal');
|
40
|
+
instance.el.appendChild(el);
|
41
|
+
if (Socialite.networkReady('pinterest')) {
|
42
|
+
Socialite.reloadNetwork('pinterest');
|
43
|
+
}
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - Spotify 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
|
+
// https://developer.spotify.com/technologies/spotify-play-button/
|
10
|
+
|
11
|
+
Socialite.network('spotify');
|
12
|
+
|
13
|
+
Socialite.widget('spotify', 'play', {
|
14
|
+
process: null,
|
15
|
+
init: function(instance)
|
16
|
+
{
|
17
|
+
Socialite.processInstance(instance);
|
18
|
+
var src = 'https://embed.spotify.com/?',
|
19
|
+
width = parseInt(instance.el.getAttribute('data-width'), 10),
|
20
|
+
height = parseInt(instance.el.getAttribute('data-height'), 10);
|
21
|
+
src += 'uri=' + (instance.el.getAttribute('data-default-href') || instance.el.getAttribute('data-href')) + '&';
|
22
|
+
instance.el.setAttribute('data-href', '');
|
23
|
+
instance.el.setAttribute('data-default-href', '');
|
24
|
+
instance.el.setAttribute('data-socialite', '');
|
25
|
+
src += Socialite.getDataAttributes(instance.el, true);
|
26
|
+
var iframe = Socialite.createIframe(src, instance);
|
27
|
+
iframe.style.width = (isNaN(width) ? 300 : width) + 'px';
|
28
|
+
iframe.style.height = (isNaN(height) ? 380 : height) + 'px';
|
29
|
+
instance.el.appendChild(iframe);
|
30
|
+
Socialite.activateInstance(instance);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
|
34
|
+
})(window, window.document, window.Socialite);
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*!
|
2
|
+
* Socialite v2.0 - Twitter 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
|
+
// https://dev.twitter.com/docs/tweet-button/
|
10
|
+
// https://dev.twitter.com/docs/intents/events/
|
11
|
+
// https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial#twitter
|
12
|
+
|
13
|
+
Socialite.setup({
|
14
|
+
twitter: {
|
15
|
+
lang: 'en'
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
Socialite.network('twitter', {
|
20
|
+
script: {
|
21
|
+
src : '//platform.twitter.com/widgets.js',
|
22
|
+
id : 'twitter-wjs',
|
23
|
+
charset : 'utf-8'
|
24
|
+
},
|
25
|
+
append: function()
|
26
|
+
{
|
27
|
+
var notwttr = (typeof window.twttr !== 'object'),
|
28
|
+
settings = Socialite.settings.twitter,
|
29
|
+
events = ['click', 'tweet', 'retweet', 'favorite', 'follow'];
|
30
|
+
if (notwttr) {
|
31
|
+
window.twttr = (t = { _e: [], ready: function(f) { t._e.push(f); } });
|
32
|
+
}
|
33
|
+
window.twttr.ready(function(twttr)
|
34
|
+
{
|
35
|
+
for (var i = 0; i < events.length; i++) {
|
36
|
+
var e = events[i];
|
37
|
+
if (typeof settings['on' + e] === 'function') {
|
38
|
+
twttr.events.bind(e, settings['on' + e]);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
Socialite.activateAll('twitter');
|
42
|
+
});
|
43
|
+
return notwttr;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
var twitterInit = function(instance)
|
48
|
+
{
|
49
|
+
var el = document.createElement('a');
|
50
|
+
el.className = instance.widget.name + '-button';
|
51
|
+
Socialite.copyDataAttributes(instance.el, el);
|
52
|
+
el.setAttribute('href', instance.el.getAttribute('data-default-href'));
|
53
|
+
el.setAttribute('data-lang', instance.el.getAttribute('data-lang') || Socialite.settings.twitter.lang);
|
54
|
+
instance.el.appendChild(el);
|
55
|
+
};
|
56
|
+
|
57
|
+
var twitterActivate = function(instance)
|
58
|
+
{
|
59
|
+
if (window.twttr && typeof window.twttr.widgets === 'object' && typeof window.twttr.widgets.load === 'function') {
|
60
|
+
window.twttr.widgets.load();
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
Socialite.widget('twitter', 'share', { init: twitterInit, activate: twitterActivate });
|
65
|
+
Socialite.widget('twitter', 'follow', { init: twitterInit, activate: twitterActivate });
|
66
|
+
Socialite.widget('twitter', 'hashtag', { init: twitterInit, activate: twitterActivate });
|
67
|
+
Socialite.widget('twitter', 'mention', { init: twitterInit, activate: twitterActivate });
|
68
|
+
|
69
|
+
Socialite.widget('twitter', 'embed', {
|
70
|
+
process: function(instance)
|
71
|
+
{
|
72
|
+
instance.innerEl = instance.el;
|
73
|
+
if (!instance.innerEl.getAttribute('data-lang')) {
|
74
|
+
instance.innerEl.setAttribute('data-lang', Socialite.settings.twitter.lang);
|
75
|
+
}
|
76
|
+
instance.el = document.createElement('div');
|
77
|
+
instance.el.className = instance.innerEl.className;
|
78
|
+
instance.innerEl.className = '';
|
79
|
+
instance.innerEl.parentNode.insertBefore(instance.el, instance.innerEl);
|
80
|
+
instance.el.appendChild(instance.innerEl);
|
81
|
+
},
|
82
|
+
init: function(instance)
|
83
|
+
{
|
84
|
+
instance.innerEl.className = 'twitter-tweet';
|
85
|
+
},
|
86
|
+
activate: twitterActivate
|
87
|
+
});
|
88
|
+
|
89
|
+
})(window, window.document, window.Socialite);
|