Permalink
Browse files

extensions

  • Loading branch information...
1 parent d08c590 commit 1cd11392e663fec43eba1226cf657389f215e949 @dbushell dbushell committed Jun 9, 2012
View
12 README.md
@@ -12,7 +12,7 @@ Copyright © 2012
### Changes from Version 1
-Please be aware that class names used by Socialite have changed since <a href="https://github.com/dbushell/Socialite/tags/">version 1</a>. All instances start with the class `socialite`, they gain the class `socialite-instance` once processed, and finally `socialite-loaded` once activated.
+Please be aware that class names used by Socialite have changed since <a href="https://github.com/dbushell/Socialite/tags/">version 1</a>. All instances start with the class `socialite`, they gain the class `socialite-instance` once processed, and finally `socialite-loaded` once activated. **Pinterest** and **Spotify** extensions are no longer in the default build of `socialite.js`. See end of this README for full change log.
## Using Socialite
@@ -30,6 +30,9 @@ Supported widgets are currently:
* Twitter: `twitter-share`, `twitter-follow`, `twitter-mention`, `twitter-hashtag` and `twitter-embed` (for individual tweets)
* Google+: `googleplus-one`, `googleplus-share`
* LinkedIn: `linkedin-share`, `linkedin-recommend`
+
+Also available as extensions:
+
* Pinterest: `pinterest-pinit`
* Spotify: `spotify-play`
@@ -129,3 +132,10 @@ With these two functions you can add extended support. See the source code for e
Thanks,
[@dbushell](http://twitter.com/dbushell/)
+
+## Change Log
+
+### 2.0.1 - 9th June 2012
+
+* created an `extensions` folder in the repository
+* **Pinterest** and **Spotify** removed from the default `socialite.js` and `socialite.min.js` builds.
View
72 extensions/socialite.extension-template.js
@@ -0,0 +1,72 @@
+/*!
+ * Socialite v2.0 - Extension template
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // External documentation URLs
+
+ // add required default settings
+ Socialite.setup({
+ 'network_name': {
+ lang: 'en'
+ }
+ });
+
+ /**
+ * One network can cater for multiple widgets
+ * Check the extensions repository to make sure it doesn't already exist
+ * The script object is optional for extentions that require simple images or iframes
+ */
+ Socialite.network('network_name', {
+ script: {
+ src : '//network_name.js',
+ charset : 'utf-8'
+ },
+ /**
+ * (optional) Called before `Socialite.load()` appends the network script via `Socialite.appendNetwork()`
+ */
+ append: function(network)
+ {
+ // return false to cancel the append and activate all instances immedicately
+ },
+ /**
+ * (optional) called after an appended network script has loaded
+ */
+ onload: function(network)
+ {
+ // return false to cancel automatically activation of all instances
+ }
+ });
+
+ /**
+ * Add a unique widget to the network
+ * Socialite will activate elements with a class name of `network_name-widget_name`, e.g. `twitter-share`
+ */
+ Socialite.widget('network_name', 'widget_name', {
+ /**
+ * (optional) Called after a new instance has been created but before it is initialised
+ */
+ process: function(instance)
+ {
+ // return false or replace function with `null` to cancel the default processing of `Socialite.processInstance()`
+ },
+ /**
+ * Called when an instance is loaded
+ */
+ init: function(instance)
+ {
+ // After this function that instance should resemble the suggested implementation by the social network
+ },
+ /**
+ * (optional) Called by `Socialite.activateInstance()` when the network has loaded and the final widget is ready to display
+ */
+ activate: function(instance)
+ {
+ //
+ }
+ });
+
+})(window, window.document, window.Socialite);
View
59 extensions/socialite.facebook.js
@@ -0,0 +1,59 @@
+/*!
+ * Socialite v2.0 - Facebook extension
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // http://developers.facebook.com/docs/reference/plugins/like/
+ // http://developers.facebook.com/docs/reference/javascript/FB.init/
+
+ Socialite.setup({
+ facebook: {
+ lang: 'en_GB',
+ appId: null
+ }
+ });
+
+ Socialite.network('facebook', {
+ script: {
+ src : '//connect.facebook.net/{{language}}/all.js',
+ id : 'facebook-jssdk'
+ },
+ append: function(network)
+ {
+ var fb = document.createElement('div'),
+ settings = Socialite.settings.facebook,
+ events = { onlike: 'edge.create', onunlike: 'edge.remove', onsend: 'message.send' };
+ fb.id = 'fb-root';
+ document.body.appendChild(fb);
+ network.script.src = network.script.src.replace('{{language}}', settings.lang);
+ window.fbAsyncInit = function() {
+ window.FB.init({
+ appId: settings.appId,
+ xfbml: true
+ });
+ for (var e in events) {
+ if (typeof settings[e] === 'function') {
+ window.FB.Event.subscribe(events[e], settings[e]);
+ }
+ }
+ };
+ }
+ });
+
+ Socialite.widget('facebook', 'like', {
+ init: function(instance)
+ {
+ var el = document.createElement('div');
+ el.className = 'fb-like';
+ Socialite.copyDataAttributes(instance.el, el);
+ instance.el.appendChild(el);
+ if (window.FB && window.FB.XFBML) {
+ window.FB.XFBML.parse(instance.el);
+ }
+ }
+ });
+
+})(window, window.document, window.Socialite);
View
65 extensions/socialite.googleplus.js
@@ -0,0 +1,65 @@
+/*!
+ * Socialite v2.0 - GooglePlus extension
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // https://developers.google.com/+/plugins/+1button/
+ // Google does not support IE7
+
+ Socialite.setup({
+ googleplus: {
+ lang: 'en-GB'
+ }
+ });
+
+ Socialite.network('googleplus', {
+ script: {
+ src: '//apis.google.com/js/plusone.js'
+ },
+ append: function(network)
+ {
+ if (window.gapi) {
+ return false;
+ }
+ window.___gcfg = {
+ lang: Socialite.settings.googleplus.lang,
+ parsetags: 'explicit'
+ };
+ }
+ });
+
+ var googleplusInit = function(instance)
+ {
+ var el = document.createElement('div');
+ el.className = 'g-' + instance.widget.gtype;
+ Socialite.copyDataAttributes(instance.el, el);
+ instance.el.appendChild(el);
+ };
+
+ var googleplusEvent = function(instance, callback) {
+ return (typeof callback !== 'function') ? null : function(data) {
+ callback(instance.el, data);
+ };
+ };
+
+ var googleplusActivate = function(instance)
+ {
+ var type = instance.widget.gtype;
+ if (window.gapi && window.gapi[type]) {
+ var settings = Socialite.settings.googleplus,
+ params = Socialite.getDataAttributes(instance.el, true, true),
+ events = ['onstartinteraction', 'onendinteraction', 'callback'];
+ for (var i = 0; i < events.length; i++) {
+ params[events[i]] = googleplusEvent(instance, settings[events[i]]);
+ }
+ window.gapi[type].render(instance.el, params);
+ }
+ };
+
+ Socialite.widget('googleplus', 'one', { init: googleplusInit, activate: googleplusActivate, gtype: 'plusone' });
+ Socialite.widget('googleplus', 'share', { init: googleplusInit, activate: googleplusActivate, gtype: 'plus' });
+
+})(window, window.document, window.Socialite);
View
32 extensions/socialite.linkedin.js
@@ -0,0 +1,32 @@
+/*!
+ * Socialite v2.0 - LinkedIn extension
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // http://developer.linkedin.com/plugins/share-button/
+
+ Socialite.network('linkedin', {
+ script: {
+ src: '//platform.linkedin.com/in.js'
+ }
+ });
+
+ var linkedinInit = function(instance)
+ {
+ var el = document.createElement('script');
+ el.type = 'IN/' + instance.widget.intype;
+ Socialite.copyDataAttributes(instance.el, el);
+ instance.el.appendChild(el);
+ if (typeof window.IN === 'object' && typeof window.IN.parse === 'function') {
+ window.IN.parse(instance.el);
+ Socialite.activateInstance(instance);
+ }
+ };
+
+ Socialite.widget('linkedin', 'share', { init: linkedinInit, intype: 'Share' });
+ Socialite.widget('linkedin', 'recommend', { init: linkedinInit, intype: 'RecommendProduct' });
+
+})(window, window.document, window.Socialite);
View
47 extensions/socialite.pinterest.js
@@ -0,0 +1,47 @@
+/*!
+ * Socialite v2.0 - Pinterest extension
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // http://pinterest.com/about/goodies/
+
+ Socialite.network('pinterest', {
+ script: {
+ src: '//assets.pinterest.com/js/pinit.js'
+ }
+ });
+
+ Socialite.widget('pinterest', 'pinit', {
+ process: function(instance)
+ {
+ // Pinterest activates all <a> elements with a href containing share URL
+ // so we have to jump through hoops to protect each instance
+ if (instance.el.nodeName.toLowerCase() !== 'a') {
+ return true;
+ }
+ var id = 'socialite-instance-' + instance.uid,
+ href = instance.el.getAttribute('href');
+ instance.el.id = id;
+ instance.el.href = '#' + id;
+ instance.el.setAttribute('data-default-href', href);
+ instance.el.setAttribute('onclick', '(function(){window.open("' + href + '")})();');
+ },
+ init: function(instance)
+ {
+ Socialite.processInstance(instance);
+ var el = document.createElement('a');
+ el.className = 'pin-it-button';
+ Socialite.copyDataAttributes(instance.el, el);
+ el.setAttribute('href', instance.el.getAttribute('data-default-href'));
+ el.setAttribute('count-layout', instance.el.getAttribute('data-count-layout') || 'horizontal');
+ instance.el.appendChild(el);
+ if (Socialite.networkReady('pinterest')) {
+ Socialite.reloadNetwork('pinterest');
+ }
+ }
+ });
+
+})(window, window.document, window.Socialite);
View
34 extensions/socialite.spotify.js
@@ -0,0 +1,34 @@
+/*!
+ * Socialite v2.0 - Spotify extension
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // https://developer.spotify.com/technologies/spotify-play-button/
+
+ Socialite.network('spotify');
+
+ Socialite.widget('spotify', 'play', {
+ process: null,
+ init: function(instance)
+ {
+ Socialite.processInstance(instance);
+ var src = 'https://embed.spotify.com/?',
+ width = parseInt(instance.el.getAttribute('data-width'), 10),
+ height = parseInt(instance.el.getAttribute('data-height'), 10);
+ src += 'uri=' + (instance.el.getAttribute('data-default-href') || instance.el.getAttribute('data-href')) + '&';
+ instance.el.setAttribute('data-href', '');
+ instance.el.setAttribute('data-default-href', '');
+ instance.el.setAttribute('data-socialite', '');
+ src += Socialite.getDataAttributes(instance.el, true);
+ var iframe = Socialite.createIframe(src, instance);
+ iframe.style.width = (isNaN(width) ? 300 : width) + 'px';
+ iframe.style.height = (isNaN(height) ? 380 : height) + 'px';
+ instance.el.appendChild(iframe);
+ Socialite.activateInstance(instance);
+ }
+ });
+
+})(window, window.document, window.Socialite);
View
89 extensions/socialite.twitter.js
@@ -0,0 +1,89 @@
+/*!
+ * Socialite v2.0 - Twitter extension
+ * http://socialitejs.com
+ * Copyright (c) 2011 David Bushell
+ * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
+ */
+(function(window, document, Socialite, undefined)
+{
+ // https://dev.twitter.com/docs/tweet-button/
+ // https://dev.twitter.com/docs/intents/events/
+ // https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial#twitter
+
+ Socialite.setup({
+ twitter: {
+ lang: 'en'
+ }
+ });
+
+ Socialite.network('twitter', {
+ script: {
+ src : '//platform.twitter.com/widgets.js',
+ id : 'twitter-wjs',
+ charset : 'utf-8'
+ },
+ append: function()
+ {
+ var notwttr = (typeof window.twttr !== 'object'),
+ settings = Socialite.settings.twitter,
+ events = ['click', 'tweet', 'retweet', 'favorite', 'follow'];
+ if (notwttr) {
+ window.twttr = (t = { _e: [], ready: function(f) { t._e.push(f); } });
+ }
+ window.twttr.ready(function(twttr)
+ {
+ for (var i = 0; i < events.length; i++) {
+ var e = events[i];
+ if (typeof settings['on' + e] === 'function') {
+ twttr.events.bind(e, settings['on' + e]);
+ }
+ }
+ Socialite.activateAll('twitter');
+ });
+ return notwttr;
+ }
+ });
+
+ var twitterInit = function(instance)
+ {
+ var el = document.createElement('a');
+ el.className = instance.widget.name + '-button';
+ Socialite.copyDataAttributes(instance.el, el);
+ el.setAttribute('href', instance.el.getAttribute('data-default-href'));
+ el.setAttribute('data-lang', instance.el.getAttribute('data-lang') || Socialite.settings.twitter.lang);
+ instance.el.appendChild(el);
+ };
+
+ var twitterActivate = function(instance)
+ {
+ if (window.twttr && typeof window.twttr.widgets === 'object' && typeof window.twttr.widgets.load === 'function') {
+ window.twttr.widgets.load();
+ }
+ };
+
+ Socialite.widget('twitter', 'share', { init: twitterInit, activate: twitterActivate });
+ Socialite.widget('twitter', 'follow', { init: twitterInit, activate: twitterActivate });
+ Socialite.widget('twitter', 'hashtag', { init: twitterInit, activate: twitterActivate });
+ Socialite.widget('twitter', 'mention', { init: twitterInit, activate: twitterActivate });
+
+ Socialite.widget('twitter', 'embed', {
+ process: function(instance)
+ {
+ instance.innerEl = instance.el;
+ if (!instance.innerEl.getAttribute('data-lang')) {
+ instance.innerEl.setAttribute('data-lang', Socialite.settings.twitter.lang);
+ }
+ instance.el = document.createElement('div');
+ instance.el.className = instance.innerEl.className;
+ instance.innerEl.className = '';
+ instance.innerEl.parentNode.insertBefore(instance.el, instance.innerEl);
+ instance.el.appendChild(instance.innerEl);
+ },
+ init: function(instance)
+ {
+ instance.innerEl.className = 'twitter-tweet';
+ },
+ activate: twitterActivate
+ });
+
+})(window, window.document, window.Socialite);
View
67 socialite.js
@@ -683,73 +683,6 @@ window.Socialite = (function(window, document, undefined)
Socialite.widget('linkedin', 'recommend', { init: linkedinInit, intype: 'RecommendProduct' });
- // Pinterest "pin It" Button
- // http://pinterest.com/about/goodies/
-
- Socialite.network('pinterest', {
- script: {
- src: '//assets.pinterest.com/js/pinit.js'
- }
- });
-
- Socialite.widget('pinterest', 'pinit', {
- process: function(instance)
- {
- // Pinterest activates all <a> elements with a href containing share URL
- // so we have to jump through hoops to protect each instance
- if (instance.el.nodeName.toLowerCase() !== 'a') {
- return true;
- }
- var id = 'socialite-instance-' + instance.uid,
- href = instance.el.getAttribute('href');
- instance.el.id = id;
- instance.el.href = '#' + id;
- instance.el.setAttribute('data-default-href', href);
- instance.el.setAttribute('onclick', '(function(){window.open("' + href + '")})();');
- },
- init: function(instance)
- {
- Socialite.processInstance(instance);
- var el = document.createElement('a');
- el.className = 'pin-it-button';
- Socialite.copyDataAttributes(instance.el, el);
- el.setAttribute('href', instance.el.getAttribute('data-default-href'));
- el.setAttribute('count-layout', instance.el.getAttribute('data-count-layout') || 'horizontal');
- instance.el.appendChild(el);
- if (Socialite.networkReady('pinterest')) {
- Socialite.reloadNetwork('pinterest');
- }
- }
- });
-
-
- // Spotify Play Button
- // https://developer.spotify.com/technologies/spotify-play-button/
-
- Socialite.network('spotify');
-
- Socialite.widget('spotify', 'play', {
- process: null,
- init: function(instance)
- {
- Socialite.processInstance(instance);
- var src = 'https://embed.spotify.com/?',
- width = parseInt(instance.el.getAttribute('data-width'), 10),
- height = parseInt(instance.el.getAttribute('data-height'), 10);
- src += 'uri=' + (instance.el.getAttribute('data-default-href') || instance.el.getAttribute('data-href')) + '&';
- instance.el.setAttribute('data-href', '');
- instance.el.setAttribute('data-default-href', '');
- instance.el.setAttribute('data-socialite', '');
- src += Socialite.getDataAttributes(instance.el, true);
- var iframe = Socialite.createIframe(src, instance);
- iframe.style.width = (isNaN(width) ? 300 : width) + 'px';
- iframe.style.height = (isNaN(height) ? 380 : height) + 'px';
- instance.el.appendChild(iframe);
- Socialite.activateInstance(instance);
- }
- });
-
-
})(window, window.document, window.Socialite);
/**
View
2 socialite.min.js
@@ -4,4 +4,4 @@
* Copyright (c) 2011 David Bushell
* Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
*/
-window.Socialite=function(a,b,c){"use strict";var d=0,e=[],f={},g={},h=/^($|loaded|complete)/,i=a.encodeURIComponent,j={settings:{},hasClass:function(a,b){return(" "+a.className+" ").indexOf(" "+b+" ")!==-1},addClass:function(a,b){j.hasClass(a,b)||(a.className=a.className===""?b:a.className+" "+b)},removeClass:function(a,b){a.className=(" "+a.className+" ").replace(" "+b+" ","")},extendObject:function(a,b,d){for(var e in b){var f=a[e]!==c;if(f&&typeof b[e]=="object")j.extendObject(a[e],b[e],d);else if(d||!f)a[e]=b[e]}},getElements:function(a,b){var c=0,d=[],e=!!a.getElementsByClassName,f=e?a.getElementsByClassName(b):a.getElementsByTagName("*");for(;c<f.length;c++)(e||j.hasClass(f[c],b))&&d.push(f[c]);return d},getDataAttributes:function(a,b,c){var d=0,e="",f={},g=a.attributes;for(;d<g.length;d++){var h=g[d].name,j=g[d].value;j.length&&h.indexOf("data-")===0&&(b&&(h=h.substring(5)),c?f[h]=j:e+=i(h)+"="+i(j)+"&")}return c?f:e},copyDataAttributes:function(a,b,c,d){var e=j.getDataAttributes(a,c,!0);for(var f in e)b.setAttribute(d?f.replace(/-/g,"_"):f,e[f])},createIframe:function(a,c){var d=b.createElement("iframe");return d.style.cssText="overflow: hidden; border: none;",j.extendObject(d,{src:a,allowtransparency:"true",frameborder:"0",scrolling:"no"},!0),c&&(d.onload=d.onreadystatechange=function(){h.test(d.readyState||"")&&(d.onload=d.onreadystatechange=null,j.activateInstance(c))}),d},networkReady:function(a){return f[a]?f[a].loaded:c},appendNetwork:function(a){if(!a||a.appended)return;if(typeof a.append=="function"&&a.append(a)===!1){a.appended=a.loaded=!0,j.activateAll(a);return}a.script&&(a.el=b.createElement("script"),j.extendObject(a.el,a.script,!0),a.el.async=!0,a.el.onload=a.el.onreadystatechange=function(){if(h.test(a.el.readyState||"")){a.el.onload=a.el.onreadystatechange=null,a.loaded=!0;if(typeof a.onload=="function"&&a.onload(a)===!1)return;j.activateAll(a)}},b.body.appendChild(a.el)),a.appended=!0},removeNetwork:function(a){return j.networkReady(a.name)?(a.el.parentNode.removeChild(a.el),!(a.appended=a.loaded=!1)):!1},reloadNetwork:function(a){var b=f[a];b&&j.removeNetwork(b)&&j.appendNetwork(b)},createInstance:function(a,b){var f=!0,g={el:a,uid:d++,widget:b};return e.push(g),b.process!==c&&(f=typeof b.process=="function"?b.process(g):!1),f&&j.processInstance(g),g.el.setAttribute("data-socialite",g.uid),g.el.className="socialite "+b.name+" socialite-instance",g},processInstance:function(a){var c=a.el;a.el=b.createElement("div"),a.el.className=c.className,j.copyDataAttributes(c,a.el),c.nodeName.toLowerCase()==="a"&&!c.getAttribute("data-default-href")&&a.el.setAttribute("data-default-href",c.getAttribute("href"));var d=c.parentNode;d.insertBefore(a.el,c),d.removeChild(c)},activateInstance:function(a){if(a&&!a.loaded)return a.loaded=!0,typeof a.widget.activate=="function"&&a.widget.activate(a),j.addClass(a.el,"socialite-loaded"),a.onload?a.onload(a.el):null},activateAll:function(a){typeof a=="string"&&(a=f[a]);for(var b=0;b<e.length;b++){var c=e[b];c.init&&c.widget.network===a&&j.activateInstance(c)}},load:function(a,c,d,f,h){a=a&&typeof a=="object"&&a.nodeType===1?a:b;if(!c||typeof c!="object"){j.load(a,j.getElements(a,"socialite"),d,f,h);return}var i;if(/Array/.test(Object.prototype.toString.call(c))){for(i=0;i<c.length;i++)j.load(a,c[i],d,f,h);return}if(c.nodeType!==1)return;if(!d||!g[d]){d=null;var k=c.className.split(" ");for(i=0;i<k.length;i++)if(g[k[i]]){d=k[i];break}if(!d)return}var l,m=g[d],n=parseInt(c.getAttribute("data-socialite"),10);if(!isNaN(n)){for(i=0;i<e.length;i++)if(e[i].uid===n){l=e[i];break}}else l=j.createInstance(c,m);if(h||!l)return;l.init||(l.init=!0,l.onload=typeof f=="function"?f:null,m.init(l,j)),m.network.appended?j.networkReady(m.network.name)&&j.activateInstance(l):j.appendNetwork(m.network)},activate:function(b,c,d){a.Socialite.load(null,b,c,d)},process:function(b,c,d){a.Socialite.load(b,c,d,null,!0)},network:function(a,b){f[a]={name:a,el:null,appended:!1,loaded:!1,widgets:{}},b&&j.extendObject(f[a],b)},widget:function(a,b,c){c.name=a+"-"+b;if(!f[a]||g[c.name])return;c.network=f[a],f[a].widgets[b]=g[c.name]=c},setup:function(a){j.extendObject(j.settings,a,!0)}};return j}(window,window.document),function(a,b,c,d){c.setup({facebook:{lang:"en_GB",appId:null},twitter:{lang:"en"},googleplus:{lang:"en-GB"}}),c.network("facebook",{script:{src:"//connect.facebook.net/{{language}}/all.js",id:"facebook-jssdk"},append:function(d){var e=b.createElement("div"),f=c.settings.facebook,g={onlike:"edge.create",onunlike:"edge.remove",onsend:"message.send"};e.id="fb-root",b.body.appendChild(e),d.script.src=d.script.src.replace("{{language}}",f.lang),a.fbAsyncInit=function(){a.FB.init({appId:f.appId,xfbml:!0});for(var b in g)typeof f[b]=="function"&&a.FB.Event.subscribe(g[b],f[b])}}}),c.widget("facebook","like",{init:function(d){var e=b.createElement("div");e.className="fb-like",c.copyDataAttributes(d.el,e),d.el.appendChild(e),a.FB&&a.FB.XFBML&&a.FB.XFBML.parse(d.el)}}),c.network("twitter",{script:{src:"//platform.twitter.com/widgets.js",id:"twitter-wjs",charset:"utf-8"},append:function(){var b=typeof a.twttr!="object",d=c.settings.twitter,e=["click","tweet","retweet","favorite","follow"];return b&&(a.twttr=t={_e:[],ready:function(a){t._e.push(a)}}),a.twttr.ready(function(a){for(var b=0;b<e.length;b++){var f=e[b];typeof d["on"+f]=="function"&&a.events.bind(f,d["on"+f])}c.activateAll("twitter")}),b}});var e=function(a){var d=b.createElement("a");d.className=a.widget.name+"-button",c.copyDataAttributes(a.el,d),d.setAttribute("href",a.el.getAttribute("data-default-href")),d.setAttribute("data-lang",a.el.getAttribute("data-lang")||c.settings.twitter.lang),a.el.appendChild(d)},f=function(b){a.twttr&&typeof a.twttr.widgets=="object"&&typeof a.twttr.widgets.load=="function"&&a.twttr.widgets.load()};c.widget("twitter","share",{init:e,activate:f}),c.widget("twitter","follow",{init:e,activate:f}),c.widget("twitter","hashtag",{init:e,activate:f}),c.widget("twitter","mention",{init:e,activate:f}),c.widget("twitter","embed",{process:function(a){a.innerEl=a.el,a.innerEl.getAttribute("data-lang")||a.innerEl.setAttribute("data-lang",c.settings.twitter.lang),a.el=b.createElement("div"),a.el.className=a.innerEl.className,a.innerEl.className="",a.innerEl.parentNode.insertBefore(a.el,a.innerEl),a.el.appendChild(a.innerEl)},init:function(a){a.innerEl.className="twitter-tweet"},activate:f}),c.network("googleplus",{script:{src:"//apis.google.com/js/plusone.js"},append:function(b){if(a.gapi)return!1;a.___gcfg={lang:c.settings.googleplus.lang,parsetags:"explicit"}}});var g=function(a){var d=b.createElement("div");d.className="g-"+a.widget.gtype,c.copyDataAttributes(a.el,d),a.el.appendChild(d)},h=function(a,b){return typeof b!="function"?null:function(c){b(a.el,c)}},i=function(b){var d=b.widget.gtype;if(a.gapi&&a.gapi[d]){var e=c.settings.googleplus,f=c.getDataAttributes(b.el,!0,!0),g=["onstartinteraction","onendinteraction","callback"];for(var i=0;i<g.length;i++)f[g[i]]=h(b,e[g[i]]);a.gapi[d].render(b.el,f)}};c.widget("googleplus","one",{init:g,activate:i,gtype:"plusone"}),c.widget("googleplus","share",{init:g,activate:i,gtype:"plus"}),c.network("linkedin",{script:{src:"//platform.linkedin.com/in.js"}});var j=function(d){var e=b.createElement("script");e.type="IN/"+d.widget.intype,c.copyDataAttributes(d.el,e),d.el.appendChild(e),typeof a.IN=="object"&&typeof a.IN.parse=="function"&&(a.IN.parse(d.el),c.activateInstance(d))};c.widget("linkedin","share",{init:j,intype:"Share"}),c.widget("linkedin","recommend",{init:j,intype:"RecommendProduct"}),c.network("pinterest",{script:{src:"//assets.pinterest.com/js/pinit.js"}}),c.widget("pinterest","pinit",{process:function(a){if(a.el.nodeName.toLowerCase()!=="a")return!0;var b="socialite-instance-"+a.uid,c=a.el.getAttribute("href");a.el.id=b,a.el.href="#"+b,a.el.setAttribute("data-default-href",c),a.el.setAttribute("onclick",'(function(){window.open("'+c+'")})();')},init:function(a){c.processInstance(a);var d=b.createElement("a");d.className="pin-it-button",c.copyDataAttributes(a.el,d),d.setAttribute("href",a.el.getAttribute("data-default-href")),d.setAttribute("count-layout",a.el.getAttribute("data-count-layout")||"horizontal"),a.el.appendChild(d),c.networkReady("pinterest")&&c.reloadNetwork("pinterest")}}),c.network("spotify"),c.widget("spotify","play",{process:null,init:function(a){c.processInstance(a);var b="https://embed.spotify.com/?",d=parseInt(a.el.getAttribute("data-width"),10),e=parseInt(a.el.getAttribute("data-height"),10);b+="uri="+(a.el.getAttribute("data-default-href")||a.el.getAttribute("data-href"))+"&",a.el.setAttribute("data-href",""),a.el.setAttribute("data-default-href",""),a.el.setAttribute("data-socialite",""),b+=c.getDataAttributes(a.el,!0);var f=c.createIframe(b,a);f.style.width=(isNaN(d)?300:d)+"px",f.style.height=(isNaN(e)?380:e)+"px",a.el.appendChild(f),c.activateInstance(a)}})}(window,window.document,window.Socialite),function(){var a=window._socialite;if(/Array/.test(Object.prototype.toString.call(a)))for(var b=0,c=a.length;b<c;b++)typeof a[b]=="function"&&a[b]()}();
+window.Socialite=function(a,b,c){"use strict";var d=0,e=[],f={},g={},h=/^($|loaded|complete)/,i=a.encodeURIComponent,j={settings:{},hasClass:function(a,b){return(" "+a.className+" ").indexOf(" "+b+" ")!==-1},addClass:function(a,b){j.hasClass(a,b)||(a.className=a.className===""?b:a.className+" "+b)},removeClass:function(a,b){a.className=(" "+a.className+" ").replace(" "+b+" ","")},extendObject:function(a,b,d){for(var e in b){var f=a[e]!==c;if(f&&typeof b[e]=="object")j.extendObject(a[e],b[e],d);else if(d||!f)a[e]=b[e]}},getElements:function(a,b){var c=0,d=[],e=!!a.getElementsByClassName,f=e?a.getElementsByClassName(b):a.getElementsByTagName("*");for(;c<f.length;c++)(e||j.hasClass(f[c],b))&&d.push(f[c]);return d},getDataAttributes:function(a,b,c){var d=0,e="",f={},g=a.attributes;for(;d<g.length;d++){var h=g[d].name,j=g[d].value;j.length&&h.indexOf("data-")===0&&(b&&(h=h.substring(5)),c?f[h]=j:e+=i(h)+"="+i(j)+"&")}return c?f:e},copyDataAttributes:function(a,b,c,d){var e=j.getDataAttributes(a,c,!0);for(var f in e)b.setAttribute(d?f.replace(/-/g,"_"):f,e[f])},createIframe:function(a,c){var d=b.createElement("iframe");return d.style.cssText="overflow: hidden; border: none;",j.extendObject(d,{src:a,allowtransparency:"true",frameborder:"0",scrolling:"no"},!0),c&&(d.onload=d.onreadystatechange=function(){h.test(d.readyState||"")&&(d.onload=d.onreadystatechange=null,j.activateInstance(c))}),d},networkReady:function(a){return f[a]?f[a].loaded:c},appendNetwork:function(a){if(!a||a.appended)return;if(typeof a.append=="function"&&a.append(a)===!1){a.appended=a.loaded=!0,j.activateAll(a);return}a.script&&(a.el=b.createElement("script"),j.extendObject(a.el,a.script,!0),a.el.async=!0,a.el.onload=a.el.onreadystatechange=function(){if(h.test(a.el.readyState||"")){a.el.onload=a.el.onreadystatechange=null,a.loaded=!0;if(typeof a.onload=="function"&&a.onload(a)===!1)return;j.activateAll(a)}},b.body.appendChild(a.el)),a.appended=!0},removeNetwork:function(a){return j.networkReady(a.name)?(a.el.parentNode.removeChild(a.el),!(a.appended=a.loaded=!1)):!1},reloadNetwork:function(a){var b=f[a];b&&j.removeNetwork(b)&&j.appendNetwork(b)},createInstance:function(a,b){var f=!0,g={el:a,uid:d++,widget:b};return e.push(g),b.process!==c&&(f=typeof b.process=="function"?b.process(g):!1),f&&j.processInstance(g),g.el.setAttribute("data-socialite",g.uid),g.el.className="socialite "+b.name+" socialite-instance",g},processInstance:function(a){var c=a.el;a.el=b.createElement("div"),a.el.className=c.className,j.copyDataAttributes(c,a.el),c.nodeName.toLowerCase()==="a"&&!c.getAttribute("data-default-href")&&a.el.setAttribute("data-default-href",c.getAttribute("href"));var d=c.parentNode;d.insertBefore(a.el,c),d.removeChild(c)},activateInstance:function(a){if(a&&!a.loaded)return a.loaded=!0,typeof a.widget.activate=="function"&&a.widget.activate(a),j.addClass(a.el,"socialite-loaded"),a.onload?a.onload(a.el):null},activateAll:function(a){typeof a=="string"&&(a=f[a]);for(var b=0;b<e.length;b++){var c=e[b];c.init&&c.widget.network===a&&j.activateInstance(c)}},load:function(a,c,d,f,h){a=a&&typeof a=="object"&&a.nodeType===1?a:b;if(!c||typeof c!="object"){j.load(a,j.getElements(a,"socialite"),d,f,h);return}var i;if(/Array/.test(Object.prototype.toString.call(c))){for(i=0;i<c.length;i++)j.load(a,c[i],d,f,h);return}if(c.nodeType!==1)return;if(!d||!g[d]){d=null;var k=c.className.split(" ");for(i=0;i<k.length;i++)if(g[k[i]]){d=k[i];break}if(!d)return}var l,m=g[d],n=parseInt(c.getAttribute("data-socialite"),10);if(!isNaN(n)){for(i=0;i<e.length;i++)if(e[i].uid===n){l=e[i];break}}else l=j.createInstance(c,m);if(h||!l)return;l.init||(l.init=!0,l.onload=typeof f=="function"?f:null,m.init(l)),m.network.appended?j.networkReady(m.network.name)&&j.activateInstance(l):j.appendNetwork(m.network)},activate:function(b,c,d){a.Socialite.load(null,b,c,d)},process:function(b,c,d){a.Socialite.load(b,c,d,null,!0)},network:function(a,b){f[a]={name:a,el:null,appended:!1,loaded:!1,widgets:{}},b&&j.extendObject(f[a],b)},widget:function(a,b,c){c.name=a+"-"+b;if(!f[a]||g[c.name])return;c.network=f[a],f[a].widgets[b]=g[c.name]=c},setup:function(a){j.extendObject(j.settings,a,!0)}};return j}(window,window.document),function(a,b,c,d){c.setup({facebook:{lang:"en_GB",appId:null},twitter:{lang:"en"},googleplus:{lang:"en-GB"}}),c.network("facebook",{script:{src:"//connect.facebook.net/{{language}}/all.js",id:"facebook-jssdk"},append:function(d){var e=b.createElement("div"),f=c.settings.facebook,g={onlike:"edge.create",onunlike:"edge.remove",onsend:"message.send"};e.id="fb-root",b.body.appendChild(e),d.script.src=d.script.src.replace("{{language}}",f.lang),a.fbAsyncInit=function(){a.FB.init({appId:f.appId,xfbml:!0});for(var b in g)typeof f[b]=="function"&&a.FB.Event.subscribe(g[b],f[b])}}}),c.widget("facebook","like",{init:function(d){var e=b.createElement("div");e.className="fb-like",c.copyDataAttributes(d.el,e),d.el.appendChild(e),a.FB&&a.FB.XFBML&&a.FB.XFBML.parse(d.el)}}),c.network("twitter",{script:{src:"//platform.twitter.com/widgets.js",id:"twitter-wjs",charset:"utf-8"},append:function(){var b=typeof a.twttr!="object",d=c.settings.twitter,e=["click","tweet","retweet","favorite","follow"];return b&&(a.twttr=t={_e:[],ready:function(a){t._e.push(a)}}),a.twttr.ready(function(a){for(var b=0;b<e.length;b++){var f=e[b];typeof d["on"+f]=="function"&&a.events.bind(f,d["on"+f])}c.activateAll("twitter")}),b}});var e=function(a){var d=b.createElement("a");d.className=a.widget.name+"-button",c.copyDataAttributes(a.el,d),d.setAttribute("href",a.el.getAttribute("data-default-href")),d.setAttribute("data-lang",a.el.getAttribute("data-lang")||c.settings.twitter.lang),a.el.appendChild(d)},f=function(b){a.twttr&&typeof a.twttr.widgets=="object"&&typeof a.twttr.widgets.load=="function"&&a.twttr.widgets.load()};c.widget("twitter","share",{init:e,activate:f}),c.widget("twitter","follow",{init:e,activate:f}),c.widget("twitter","hashtag",{init:e,activate:f}),c.widget("twitter","mention",{init:e,activate:f}),c.widget("twitter","embed",{process:function(a){a.innerEl=a.el,a.innerEl.getAttribute("data-lang")||a.innerEl.setAttribute("data-lang",c.settings.twitter.lang),a.el=b.createElement("div"),a.el.className=a.innerEl.className,a.innerEl.className="",a.innerEl.parentNode.insertBefore(a.el,a.innerEl),a.el.appendChild(a.innerEl)},init:function(a){a.innerEl.className="twitter-tweet"},activate:f}),c.network("googleplus",{script:{src:"//apis.google.com/js/plusone.js"},append:function(b){if(a.gapi)return!1;a.___gcfg={lang:c.settings.googleplus.lang,parsetags:"explicit"}}});var g=function(a){var d=b.createElement("div");d.className="g-"+a.widget.gtype,c.copyDataAttributes(a.el,d),a.el.appendChild(d)},h=function(a,b){return typeof b!="function"?null:function(c){b(a.el,c)}},i=function(b){var d=b.widget.gtype;if(a.gapi&&a.gapi[d]){var e=c.settings.googleplus,f=c.getDataAttributes(b.el,!0,!0),g=["onstartinteraction","onendinteraction","callback"];for(var i=0;i<g.length;i++)f[g[i]]=h(b,e[g[i]]);a.gapi[d].render(b.el,f)}};c.widget("googleplus","one",{init:g,activate:i,gtype:"plusone"}),c.widget("googleplus","share",{init:g,activate:i,gtype:"plus"}),c.network("linkedin",{script:{src:"//platform.linkedin.com/in.js"}});var j=function(d){var e=b.createElement("script");e.type="IN/"+d.widget.intype,c.copyDataAttributes(d.el,e),d.el.appendChild(e),typeof a.IN=="object"&&typeof a.IN.parse=="function"&&(a.IN.parse(d.el),c.activateInstance(d))};c.widget("linkedin","share",{init:j,intype:"Share"}),c.widget("linkedin","recommend",{init:j,intype:"RecommendProduct"})}(window,window.document,window.Socialite),function(){var a=window._socialite;if(/Array/.test(Object.prototype.toString.call(a)))for(var b=0,c=a.length;b<c;b++)typeof a[b]=="function"&&a[b]()}();

0 comments on commit 1cd1139

Please sign in to comment.