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.
@@ -0,0 +1,49 @@
1
+ /*!
2
+ * Socialite v2.0
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
+ window.Socialite=function(e,t,n){"use strict"
8
+ var a=0,i=[],o={},r={},l=/^($|loaded|complete)/,s=e.encodeURIComponent,c={settings:{},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},hasClass:function(e,t){return-1!==(" "+e.className+" ").indexOf(" "+t+" ")},addClass:function(e,t){c.hasClass(e,t)||(e.className=""===e.className?t:e.className+" "+t)},removeClass:function(e,t){e.className=c.trim(" "+e.className+" ".replace(" "+t+" "," "))},extendObject:function(e,t,a){for(var i in t){var o=e[i]!==n
9
+ o&&"object"==typeof t[i]?c.extendObject(e[i],t[i],a):(a||!o)&&(e[i]=t[i])}},getElements:function(e,t){for(var n=0,a=[],i=!!e.getElementsByClassName,o=i?e.getElementsByClassName(t):e.getElementsByTagName("*");o.length>n;n++)(i||c.hasClass(o[n],t))&&a.push(o[n])
10
+ return a},getDataAttributes:function(e,t,n){for(var a=0,i="",o={},r=e.attributes;r.length>a;a++){var l=r[a].name,c=r[a].value
11
+ c.length&&0===l.indexOf("data-")&&(t&&(l=l.substring(5)),n?o[l]=c:i+=s(l)+"="+s(c)+"&")}return n?o:i},copyDataAttributes:function(e,t,n,a){var i=c.getDataAttributes(e,n,!0)
12
+ for(var o in i)t.setAttribute(a?o.replace(/-/g,"_"):o,i[o])},createIframe:function(e,n){var a=t.createElement("iframe")
13
+ return a.style.cssText="overflow: hidden; border: none;",c.extendObject(a,{src:e,allowtransparency:"true",frameborder:"0",scrolling:"no"},!0),n&&(a.onload=a.onreadystatechange=function(){l.test(a.readyState||"")&&(a.onload=a.onreadystatechange=null,c.activateInstance(n))}),a},networkReady:function(e){return o[e]?o[e].loaded:n},appendNetwork:function(e){if(e&&!e.appended){if("function"==typeof e.append&&e.append(e)===!1)return e.appended=e.loaded=!0,c.activateAll(e),n
14
+ e.script&&(e.el=t.createElement("script"),c.extendObject(e.el,e.script,!0),e.el.async=!0,e.el.onload=e.el.onreadystatechange=function(){if(l.test(e.el.readyState||"")){if(e.el.onload=e.el.onreadystatechange=null,e.loaded=!0,"function"==typeof e.onload&&e.onload(e)===!1)return
15
+ c.activateAll(e)}},t.body.appendChild(e.el)),e.appended=!0}},removeNetwork:function(e){return c.networkReady(e.name)?(e.el.parentNode&&e.el.parentNode.removeChild(e.el),!(e.appended=e.loaded=!1)):!1},reloadNetwork:function(e){var t=o[e]
16
+ t&&c.removeNetwork(t)&&c.appendNetwork(t)},createInstance:function(e,t){var o=!0,r={el:e,uid:a++,widget:t}
17
+ return i.push(r),t.process!==n&&(o="function"==typeof t.process?t.process(r):!1),o&&c.processInstance(r),r.el.setAttribute("data-socialite",r.uid),r.el.className="socialite "+t.name+" socialite-instance",r},processInstance:function(e){var n=e.el
18
+ e.el=t.createElement("div"),e.el.className=n.className,c.copyDataAttributes(n,e.el),"a"!==n.nodeName.toLowerCase()||n.getAttribute("data-default-href")||e.el.setAttribute("data-default-href",n.getAttribute("href"))
19
+ var a=n.parentNode
20
+ a.insertBefore(e.el,n),a.removeChild(n)},activateInstance:function(e){return e&&!e.loaded?(e.loaded=!0,"function"==typeof e.widget.activate&&e.widget.activate(e),c.addClass(e.el,"socialite-loaded"),e.onload?e.onload(e.el):null):n},activateAll:function(e){"string"==typeof e&&(e=o[e])
21
+ for(var t=0;i.length>t;t++){var n=i[t]
22
+ n.init&&n.widget.network===e&&c.activateInstance(n)}},load:function(e,a,o,l,s){if(e=e&&"object"==typeof e&&1===e.nodeType?e:t,!a||"object"!=typeof a)return c.load(e,c.getElements(e,"socialite"),o,l,s),n
23
+ var d
24
+ if(/Array/.test(Object.prototype.toString.call(a)))for(d=0;a.length>d;d++)c.load(e,a[d],o,l,s)
25
+ else if(1===a.nodeType){if(!o||!r[o]){o=null
26
+ var p=a.className.split(" ")
27
+ for(d=0;p.length>d;d++)if(r[p[d]]){o=p[d]
28
+ break}if(!o)return}var u,f=r[o],g=parseInt(a.getAttribute("data-socialite"),10)
29
+ if(isNaN(g))u=c.createInstance(a,f)
30
+ else for(d=0;i.length>d;d++)if(i[d].uid===g){u=i[d]
31
+ break}!s&&u&&(u.init||(u.init=!0,u.onload="function"==typeof l?l:null,f.init(u)),f.network.appended?c.networkReady(f.network.name)&&c.activateInstance(u):c.appendNetwork(f.network))}},activate:function(t,n,a){e.Socialite.load(null,t,n,a)},process:function(t,n,a){e.Socialite.load(t,n,a,null,!0)},network:function(e,t){o[e]={name:e,el:null,appended:!1,loaded:!1,widgets:{}},t&&c.extendObject(o[e],t)},widget:function(e,t,n){n.name=e+"-"+t,o[e]&&!r[n.name]&&(n.network=o[e],o[e].widgets[t]=r[n.name]=n)},setup:function(e){c.extendObject(c.settings,e,!0)}}
32
+ return c}(window,window.document),function(e,n,a){a.setup({facebook:{lang:"en_GB",appId:null},twitter:{lang:"en"},googleplus:{lang:"en-GB"}}),a.network("facebook",{script:{src:"//connect.facebook.net/{{language}}/all.js",id:"facebook-jssdk"},append:function(t){var i=n.createElement("div"),o=a.settings.facebook,r={onlike:"edge.create",onunlike:"edge.remove",onsend:"message.send"}
33
+ i.id="fb-root",n.body.appendChild(i),t.script.src=t.script.src.replace("{{language}}",o.lang),e.fbAsyncInit=function(){e.FB.init({appId:o.appId,xfbml:!0})
34
+ for(var t in r)"function"==typeof o[t]&&e.FB.Event.subscribe(r[t],o[t])}}}),a.widget("facebook","like",{init:function(t){var i=n.createElement("div")
35
+ i.className="fb-like",a.copyDataAttributes(t.el,i),t.el.appendChild(i),e.FB&&e.FB.XFBML&&e.FB.XFBML.parse(t.el)}}),a.network("twitter",{script:{src:"//platform.twitter.com/widgets.js",id:"twitter-wjs",charset:"utf-8"},append:function(){var n="object"!=typeof e.twttr,i=a.settings.twitter,o=["click","tweet","retweet","favorite","follow"]
36
+ return n&&(e.twttr=t={_e:[],ready:function(e){t._e.push(e)}}),e.twttr.ready(function(e){for(var t=0;o.length>t;t++){var n=o[t]
37
+ "function"==typeof i["on"+n]&&e.events.bind(n,i["on"+n])}a.activateAll("twitter")}),n}})
38
+ var i=function(e){var t=n.createElement("a")
39
+ t.className=e.widget.name+"-button",a.copyDataAttributes(e.el,t),t.setAttribute("href",e.el.getAttribute("data-default-href")),t.setAttribute("data-lang",e.el.getAttribute("data-lang")||a.settings.twitter.lang),e.el.appendChild(t)},o=function(){e.twttr&&"object"==typeof e.twttr.widgets&&"function"==typeof e.twttr.widgets.load&&e.twttr.widgets.load()}
40
+ a.widget("twitter","share",{init:i,activate:o}),a.widget("twitter","follow",{init:i,activate:o}),a.widget("twitter","hashtag",{init:i,activate:o}),a.widget("twitter","mention",{init:i,activate:o}),a.widget("twitter","embed",{process:function(e){e.innerEl=e.el,e.innerEl.getAttribute("data-lang")||e.innerEl.setAttribute("data-lang",a.settings.twitter.lang),e.el=n.createElement("div"),e.el.className=e.innerEl.className,e.innerEl.className="",e.innerEl.parentNode.insertBefore(e.el,e.innerEl),e.el.appendChild(e.innerEl)},init:function(e){e.innerEl.className="twitter-tweet"},activate:o}),a.network("googleplus",{script:{src:"//apis.google.com/js/plusone.js"},append:function(){return e.gapi?!1:(e.___gcfg={lang:a.settings.googleplus.lang,parsetags:"explicit"},undefined)}})
41
+ var r=function(e){var t=n.createElement("div")
42
+ t.className="g-"+e.widget.gtype,a.copyDataAttributes(e.el,t),e.el.appendChild(t),e.gplusEl=t},l=function(e,t){return"function"!=typeof t?null:function(n){t(e.el,n)}},s=function(t){var n=t.widget.gtype
43
+ if(e.gapi&&e.gapi[n]){for(var i=a.settings.googleplus,o=a.getDataAttributes(t.el,!0,!0),r=["onstartinteraction","onendinteraction","callback"],s=0;r.length>s;s++)o[r[s]]=l(t,i[r[s]])
44
+ e.gapi[n].render(t.gplusEl,o)}}
45
+ a.widget("googleplus","one",{init:r,activate:s,gtype:"plusone"}),a.widget("googleplus","share",{init:r,activate:s,gtype:"plus"}),a.widget("googleplus","badge",{init:r,activate:s,gtype:"plus"}),a.network("linkedin",{script:{src:"//platform.linkedin.com/in.js"}})
46
+ var c=function(t){var i=n.createElement("script")
47
+ i.type="IN/"+t.widget.intype,a.copyDataAttributes(t.el,i),t.el.appendChild(i),"object"==typeof e.IN&&"function"==typeof e.IN.parse&&(e.IN.parse(t.el),a.activateInstance(t))}
48
+ a.widget("linkedin","share",{init:c,intype:"Share"}),a.widget("linkedin","recommend",{init:c,intype:"RecommendProduct"})}(window,window.document,window.Socialite),function(){var e=window._socialite
49
+ if(/Array/.test(Object.prototype.toString.call(e)))for(var t=0,n=e.length;n>t;t++)"function"==typeof e[t]&&e[t]()}();
@@ -0,0 +1,5 @@
1
+ module SocialiteJs
2
+ module Source
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,44 @@
1
+ require "socialite_js/source/version"
2
+
3
+ module SocialiteJs
4
+ module Source
5
+ def self.vendor_path
6
+ File.expand_path("../vendor/assets/javascript", __FILE__)
7
+ end
8
+
9
+ def self.bundled_path
10
+ "#{vendor_path}/socialite.js"
11
+ end
12
+
13
+ def self.bundled_minimized_path
14
+ "#{vendor_path}/socialite.min.js"
15
+ end
16
+
17
+ def self.supported_extensions
18
+ %w[bufferapp
19
+ extension-template
20
+ facebook
21
+ github
22
+ googleplus
23
+ hackernews
24
+ linkedin
25
+ pinterest
26
+ spotify
27
+ twitter
28
+ vkontakte
29
+ weibo
30
+ icefy]
31
+ end
32
+
33
+ def self.method_missing(meth, *args, &block)
34
+ if (match = meth.to_s.match(/\A(?<extension_name>(.)+)_extension_path\z/)) &&
35
+ supported_extensions.include?(match['extension_name'])
36
+ # NOTE: not checking if the file actually exists. but checking
37
+ # from a master list of supported extensions
38
+ "#{vendor_path}/extensions/socialite.#{match['extension_name']}.js"
39
+ else
40
+ super
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'socialite_js/source/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "socialite_js-source"
8
+ gem.version = SocialiteJs::Source::VERSION
9
+ gem.authors = ["Deepak Kannan"]
10
+ gem.email = ["kannan.deepak@gmail.com"]
11
+
12
+ gem.summary = %q{rubygems shell over socialite.js}
13
+ gem.description = %q{JavaScript source code for socialite.js wrapped in a rubygems shell. socialite.js is a library to display social sharing buttons. check http://socialitejs.com/}
14
+ gem.homepage = "https://github.com/deepak/socialite_js-source"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency "debugger", "~> 1.5.0"
22
+ end
@@ -0,0 +1,38 @@
1
+ require_relative '../test_helper'
2
+ require 'socialite_js/source'
3
+
4
+ module SocialiteJs
5
+ describe Source do
6
+ before do
7
+ @subject = SocialiteJs::Source
8
+ @vendor_path = File.expand_path("../../../lib/socialite_js/vendor/assets/javascript", __FILE__)
9
+ end
10
+
11
+ it "has vendor path" do
12
+ @subject.vendor_path.must_equal @vendor_path
13
+ end
14
+
15
+ it "has bundled_path" do
16
+ @subject.bundled_path.must_equal "#{@vendor_path}/socialite.js"
17
+ end
18
+
19
+ it "has bundled_minimized_path" do
20
+ @subject.bundled_minimized_path.must_equal "#{@vendor_path}/socialite.min.js"
21
+ end
22
+
23
+ it "has an non-empty array of supported_extensions" do
24
+ @subject.supported_extensions.must_be_instance_of Array
25
+ @subject.supported_extensions.wont_be_empty
26
+ end
27
+
28
+ describe "extension_path" do
29
+ it "has an attribute for a supported extension type" do
30
+ @subject.github_extension_path.must_equal "#{@vendor_path}/extensions/socialite.github.js"
31
+ end
32
+
33
+ it "does not have an attribute for a unsupported extension type" do
34
+ lambda { @subject.foobar_extension_path }.must_raise(NoMethodError)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/pride'
3
+ require 'minitest/autorun'
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: socialite_js-source
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Deepak Kannan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: debugger
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.5.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.0
30
+ description: JavaScript source code for socialite.js wrapped in a rubygems shell.
31
+ socialite.js is a library to display social sharing buttons. check http://socialitejs.com/
32
+ email:
33
+ - kannan.deepak@gmail.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - lib/socialite_js/assets/javascript/extensions/socialite.bufferapp.js
44
+ - lib/socialite_js/assets/javascript/extensions/socialite.extension-template.js
45
+ - lib/socialite_js/assets/javascript/extensions/socialite.facebook.js
46
+ - lib/socialite_js/assets/javascript/extensions/socialite.github.js
47
+ - lib/socialite_js/assets/javascript/extensions/socialite.googleplus.js
48
+ - lib/socialite_js/assets/javascript/extensions/socialite.hackernews.js
49
+ - lib/socialite_js/assets/javascript/extensions/socialite.linkedin.js
50
+ - lib/socialite_js/assets/javascript/extensions/socialite.pinterest.js
51
+ - lib/socialite_js/assets/javascript/extensions/socialite.spotify.js
52
+ - lib/socialite_js/assets/javascript/extensions/socialite.twitter.js
53
+ - lib/socialite_js/assets/javascript/extensions/socialite.vkontakte.js
54
+ - lib/socialite_js/assets/javascript/extensions/socialite.weibo.js
55
+ - lib/socialite_js/assets/javascript/socialite.js
56
+ - lib/socialite_js/assets/javascript/socialite.min.js
57
+ - lib/socialite_js/source.rb
58
+ - lib/socialite_js/source/version.rb
59
+ - socialite_js-source.gemspec
60
+ - test/socialite_js/source_test.rb
61
+ - test/test_helper.rb
62
+ homepage: https://github.com/deepak/socialite_js-source
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.24
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: rubygems shell over socialite.js
86
+ test_files:
87
+ - test/socialite_js/source_test.rb
88
+ - test/test_helper.rb