rsocialize 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c501b6b895d6b9338c6ac517f42f810f04d62f3e
4
- data.tar.gz: a142afe8650054a6d721728593fed6a98711bf31
3
+ metadata.gz: 24b5f4ca6d4c8a220a936de6166c7d55fa099106
4
+ data.tar.gz: 4a4b8389ea3765553d2e66c3bed26b1e72eea109
5
5
  SHA512:
6
- metadata.gz: 05f78152ed2a6e42715a760ab8a94c3178f6197ae792f3ed584501d2f5bb059a98b97f7a833dfd2207bc9783d714edeecf54cdc5123e01e79260ab082c279b9b
7
- data.tar.gz: fde3958e32b71f694f5b0fb3c714956fbec6d30f0d3e129c729816a39aecba225c00221ca4764b35786fe592e9cbf3d42b59b5ef473df43e3d5bb80c339239f0
6
+ metadata.gz: 615e42ef4dbdd40c39ff7a63dfc8707cd28385d0b7e39915355e5b85e7cc8ffbb5dd69605e2ed812afa0c641f6e7d36b59769fc51fd0d30748c415fe22310719
7
+ data.tar.gz: 1078f3ea007b03be958d206908ef98b1dfdb25fb83f0ce1485a96183f395ff8823759b86a9d05e6f45de13dc3226e51eb0e22a8f85c16d857203b848fc62cdf0
data/.gitignore CHANGED
@@ -15,4 +15,7 @@ capybara-*.html
15
15
  **.orig
16
16
  rerun.txt
17
17
  pickle-email-*.html
18
- .project
18
+ .project
19
+ .ruby-version
20
+ .ruby-gemset
21
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+
2
+
3
+ #0.0.5 - 9/1/2015 Tuesday
4
+
5
+ ##Changed
6
+
7
+ * Added a changelog (CHANGELOG.md)
8
+
9
+ ##Fixed
10
+
11
+ * Don't allow the uninstall to delete assets/images directory
12
+
13
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- [![Code Climate](https://codeclimate.com/github/treble37/rsocialize.png)](https://codeclimate.com/github/treble37/rsocialize) [![Code Climate](https://codeclimate.com/github/treble37/coverage.png)](https://codeclimate.com/github/treble37/rsocialize)
1
+ [![Code Climate](https://codeclimate.com/github/treble37/rsocialize/badges/gpa.svg)](https://codeclimate.com/github/treble37/rsocialize)
2
2
 
3
3
  ##Help contribute to the development & maintenance of this gem via GitTip:
4
- [![Fund me on Gittip](https://www.gittip.com/assets/7.0.8/logo.png)](https://www.gittip.com/treble37/)
4
+
5
+ [![Gratipay](https://img.shields.io/gratipay/treble37.svg)](https://gratipay.com/treble37/)
5
6
 
6
7
  Hey Internet, I make most of my money during the day by working just like everyone else, so seeing a donation really helps motivate me to keep improving this gem. Even if you don't donate, please feel free to leave me feedback / feature requests / issues via the Github issues.
7
8
 
@@ -0,0 +1,63 @@
1
+ class DivTemplate
2
+ attr_accessor :options
3
+
4
+ def initialize(opts={})
5
+ @options = {}
6
+ @options.merge!(opts)
7
+ end
8
+
9
+ end
10
+
11
+ class Example1 < DivTemplate
12
+ def div_str
13
+ %Q{
14
+ <div id="example1">
15
+ <div id="twitter" data-url="#{options[:twitter][:url]}" data-text="#{options[:twitter][:text]}" data-title="#{options[:twitter][:title]}"></div>
16
+ <div id="facebook" data-url="#{options[:facebook][:url]}" data-text="#{options[:facebook][:text]}" data-title="#{options[:facebook][:title]}"></div>
17
+ <div id="googleplus" data-url="#{options[:googleplus][:url]}" data-text="#{options[:googleplus][:text]}" data-title="#{options[:googleplus][:title]}"></div>
18
+ </div>
19
+ }.html_safe
20
+ end
21
+ end
22
+
23
+ class Example2 < DivTemplate
24
+ def div_str
25
+ %Q{
26
+ <div id="#{options[:div_template]}">
27
+ <div id="shareme" data-url="#{options[:url]}" data-text="#{options[:text]}"></div>
28
+ </div>
29
+ }.html_safe
30
+ end
31
+ end
32
+
33
+ class Example5 < DivTemplate
34
+ def div_str
35
+ %Q{
36
+ <div id="#{options[:div_template]}">
37
+ <div id="shareme" data-url="#{options[:url]}" data-text="#{options[:text]}"></div>
38
+ </div>
39
+ }.html_safe
40
+ end
41
+ end
42
+
43
+ class Example3 < DivTemplate
44
+ def div_str
45
+ %Q{
46
+ <div id="example3">
47
+ <div id="shareme" data-url="#{options[:url]}" data-text="#{options[:text]}" data-title="#{options[:title]}"></div>
48
+ </div>
49
+ }.html_safe
50
+ end
51
+ end
52
+
53
+ class Example6 < DivTemplate
54
+ def div_str
55
+ %Q{
56
+ <div id="example6">
57
+ <div id="twitter" data-url="#{options[:twitter][:url]}" data-text="#{options[:twitter][:text]}"></div>
58
+ <div id="facebook" data-url="#{options[:facebook][:url]}" data-text="#{options[:facebook][:text]}"></div>
59
+ <div id="googleplus" data-url="#{options[:googleplus][:url]}" data-text="#{options[:googleplus][:text]}"></div>
60
+ </div>
61
+ }.html_safe
62
+ end
63
+ end
@@ -0,0 +1,110 @@
1
+ JQUERY_SHARRRE_FILE = "jquery.sharrre-1.3.5.min.js"
2
+
3
+ EXAMPLE1_JS_OPTIONS = {
4
+ :twitter=>{:share=>{:twitter=>true},:enableHover=>false, :enableTracking=>true, :buttons=>{:twitter=>{:via=>'_JulienH'}},:click=>%Q[function(api, options){
5
+ api.simulateClick();
6
+ api.openPopup('twitter');} ]
7
+ },
8
+ :facebook=>{:share=>{:facebook=>true}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
9
+ api.simulateClick();
10
+ api.openPopup('facebook');}
11
+ ]
12
+ },
13
+ :googlePlus=>{:share=>{:googlePlus=>true},:enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
14
+ api.simulateClick();
15
+ api.openPopup('googlePlus');} ]
16
+ }
17
+ }
18
+ EXAMPLE2_JS_OPTIONS = {
19
+ shareme: {
20
+ share: {
21
+ twitter: true,
22
+ facebook: true,
23
+ googlePlus: true
24
+ },
25
+ template: %Q{<div class="box"><div class="left">Share</div><div class="middle"><a href="#" class="facebook">f</a><a href="#" class="twitter">t</a><a href="#" class="googleplus">+1</a></div><div class="right">{total}</div></div>},
26
+ enableHover: false,
27
+ enableTracking: true,
28
+ render: %Q[function(api, options){
29
+ $(api.element).on('click', '.twitter', function() {
30
+ api.openPopup('twitter');
31
+ });
32
+ $(api.element).on('click', '.facebook', function() {
33
+ api.openPopup('facebook');
34
+ });
35
+ $(api.element).on('click', '.googleplus', function() {
36
+ api.openPopup('googlePlus');
37
+ });
38
+ }]
39
+ }
40
+ }
41
+ EXAMPLE3_JS_OPTIONS = {
42
+ shareme: {
43
+ share: {
44
+ googlePlus: true,
45
+ facebook: true,
46
+ twitter: true,
47
+ digg: true,
48
+ delicious: true
49
+ },
50
+ enableTracking: true,
51
+ buttons: {
52
+ googlePlus: {size: 'tall'},
53
+ facebook: {layout: 'box_count'},
54
+ twitter: {count: 'vertical'},
55
+ digg: {type: 'DiggMedium'},
56
+ delicious: {size: 'tall'}
57
+ },
58
+ hover: %Q[function(api, options){
59
+ $(api.element).find('.buttons').show();
60
+ }],
61
+ hide: %Q[function(api, options){
62
+ $(api.element).find('.buttons').hide();
63
+ }]
64
+ }
65
+ }
66
+ EXAMPLE5_JS_OPTIONS = {
67
+ shareme: {
68
+ share: {
69
+ googlePlus: true,
70
+ facebook: true,
71
+ twitter: true,
72
+ digg: true,
73
+ delicious: true,
74
+ stumbleupon: true,
75
+ linkedin: true,
76
+ pinterest: true
77
+ },
78
+ buttons: {
79
+ googlePlus: {size: 'tall'},
80
+ facebook: {layout: 'box_count'},
81
+ twitter: {count: 'vertical'},
82
+ digg: {type: 'DiggMedium'},
83
+ delicious: {size: 'tall'},
84
+ stumbleupon: {layout: '5'},
85
+ linkedin: {counter: 'top'},
86
+ pinterest: {media: 'http://sharrre.com/img/example1.png', description: %Q{$('#shareme').data('text'), layout: 'vertical'}}
87
+ },
88
+ enableHover: false,
89
+ enableCounter: false,
90
+ enableTracking: true
91
+ }
92
+ }
93
+
94
+ EXAMPLE6_JS_OPTIONS ={
95
+ :twitter=>{:share=>{:twitter=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>}, :enableHover=>false, :enableTracking=>true, :buttons =>{ twitter: {via: '_JulienH'}}, :click=>%Q[function(api, options){
96
+ api.simulateClick();
97
+ api.openPopup('twitter');}
98
+ ]
99
+ },
100
+ :facebook=> {:share=>{:facebook=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Like</div></a>}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
101
+ api.simulateClick();
102
+ api.openPopup('facebook');}
103
+ ]
104
+ },
105
+ :googlePlus=>{:share=>{:googlePlus=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>+1</div></a>}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
106
+ api.simulateClick();
107
+ api.openPopup('googlePlus');}
108
+ ]
109
+ }
110
+ }
@@ -16,6 +16,7 @@ module Rsocialize
16
16
  copy_file %Q{#{Rsocialize::JQUERY_SHARRRE_FILE}}, %Q{app/assets/javascripts/#{Rsocialize::JQUERY_SHARRRE_FILE}}
17
17
  copy_file 'rsocialize_controller.rb', 'app/lib/rsocialize_controller.rb'
18
18
  directory 'images', 'app/assets/images'
19
+ copy_file 'images/example6.png'
19
20
  end
20
21
  def modify_css
21
22
  css_path = "app/assets/stylesheets/"+"#{css_layout_name}css.txt"
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Sharrre.com - Make your sharing widget!
3
+ * Version: beta 1.3.5
4
+ * Author: Julien Hany
5
+ * License: MIT http://en.wikipedia.org/wiki/MIT_License or GPLv2 http://en.wikipedia.org/wiki/GNU_General_Public_License
6
+ */
7
+ ;(function(g,i,j,b){var h="sharrre",f={className:"sharrre",share:{googlePlus:false,facebook:false,twitter:false,digg:false,delicious:false,stumbleupon:false,linkedin:false,pinterest:false},shareTotal:0,template:"",title:"",url:j.location.href,text:j.title,urlCurl:"sharrre.php",count:{},total:0,shorterTotal:true,enableHover:true,enableCounter:true,enableTracking:false,hover:function(){},hide:function(){},click:function(){},render:function(){},buttons:{googlePlus:{url:"",urlCount:false,size:"medium",lang:"en-US",annotation:""},facebook:{url:"",urlCount:false,action:"like",layout:"button_count",width:"",send:"false",faces:"false",colorscheme:"",font:"",lang:"en_US"},twitter:{url:"",urlCount:false,count:"horizontal",hashtags:"",via:"",related:"",lang:"en"},digg:{url:"",urlCount:false,type:"DiggCompact"},delicious:{url:"",urlCount:false,size:"medium"},stumbleupon:{url:"",urlCount:false,layout:"1"},linkedin:{url:"",urlCount:false,counter:""},pinterest:{url:"",media:"",description:"",layout:"horizontal"}}},c={googlePlus:"",facebook:"https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27{url}%27&callback=?",twitter:"http://cdn.api.twitter.com/1/urls/count.json?url={url}&callback=?",digg:"http://services.digg.com/2.0/story.getInfo?links={url}&type=javascript&callback=?",delicious:"http://feeds.delicious.com/v2/json/urlinfo/data?url={url}&callback=?",stumbleupon:"",linkedin:"http://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?",pinterest:"http://api.pinterest.com/v1/urls/count.json?url={url}&callback=?"},l={googlePlus:function(m){var n=m.options.buttons.googlePlus;g(m.element).find(".buttons").append('<div class="button googleplus"><div class="g-plusone" data-size="'+n.size+'" data-href="'+(n.url!==""?n.url:m.options.url)+'" data-annotation="'+n.annotation+'"></div></div>');i.___gcfg={lang:m.options.buttons.googlePlus.lang};var o=0;if(typeof gapi==="undefined"&&o==0){o=1;(function(){var p=j.createElement("script");p.type="text/javascript";p.async=true;p.src="//apis.google.com/js/plusone.js";var q=j.getElementsByTagName("script")[0];q.parentNode.insertBefore(p,q)})()}else{gapi.plusone.go()}},facebook:function(m){var n=m.options.buttons.facebook;g(m.element).find(".buttons").append('<div class="button facebook"><div id="fb-root"></div><div class="fb-like" data-href="'+(n.url!==""?n.url:m.options.url)+'" data-send="'+n.send+'" data-layout="'+n.layout+'" data-width="'+n.width+'" data-show-faces="'+n.faces+'" data-action="'+n.action+'" data-colorscheme="'+n.colorscheme+'" data-font="'+n.font+'" data-via="'+n.via+'"></div></div>');var o=0;if(typeof FB==="undefined"&&o==0){o=1;(function(t,p,u){var r,q=t.getElementsByTagName(p)[0];if(t.getElementById(u)){return}r=t.createElement(p);r.id=u;r.src="//connect.facebook.net/"+n.lang+"/all.js#xfbml=1";q.parentNode.insertBefore(r,q)}(j,"script","facebook-jssdk"))}else{FB.XFBML.parse()}},twitter:function(m){var n=m.options.buttons.twitter;g(m.element).find(".buttons").append('<div class="button twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-url="'+(n.url!==""?n.url:m.options.url)+'" data-count="'+n.count+'" data-text="'+m.options.text+'" data-via="'+n.via+'" data-hashtags="'+n.hashtags+'" data-related="'+n.related+'" data-lang="'+n.lang+'">Tweet</a></div>');var o=0;if(typeof twttr==="undefined"&&o==0){o=1;(function(){var q=j.createElement("script");q.type="text/javascript";q.async=true;q.src="//platform.twitter.com/widgets.js";var p=j.getElementsByTagName("script")[0];p.parentNode.insertBefore(q,p)})()}else{g.ajax({url:"//platform.twitter.com/widgets.js",dataType:"script",cache:true})}},digg:function(m){var n=m.options.buttons.digg;g(m.element).find(".buttons").append('<div class="button digg"><a class="DiggThisButton '+n.type+'" rel="nofollow external" href="http://digg.com/submit?url='+encodeURIComponent((n.url!==""?n.url:m.options.url))+'"></a></div>');var o=0;if(typeof __DBW==="undefined"&&o==0){o=1;(function(){var q=j.createElement("SCRIPT"),p=j.getElementsByTagName("SCRIPT")[0];q.type="text/javascript";q.async=true;q.src="//widgets.digg.com/buttons.js";p.parentNode.insertBefore(q,p)})()}},delicious:function(o){if(o.options.buttons.delicious.size=="tall"){var p="width:50px;",n="height:35px;width:50px;font-size:15px;line-height:35px;",m="height:18px;line-height:18px;margin-top:3px;"}else{var p="width:93px;",n="float:right;padding:0 3px;height:20px;width:26px;line-height:20px;",m="float:left;height:20px;line-height:20px;"}var q=o.shorterTotal(o.options.count.delicious);if(typeof q==="undefined"){q=0}g(o.element).find(".buttons").append('<div class="button delicious"><div style="'+p+'font:12px Arial,Helvetica,sans-serif;cursor:pointer;color:#666666;display:inline-block;float:none;height:20px;line-height:normal;margin:0;padding:0;text-indent:0;vertical-align:baseline;"><div style="'+n+'background-color:#fff;margin-bottom:5px;overflow:hidden;text-align:center;border:1px solid #ccc;border-radius:3px;">'+q+'</div><div style="'+m+'display:block;padding:0;text-align:center;text-decoration:none;width:50px;background-color:#7EACEE;border:1px solid #40679C;border-radius:3px;color:#fff;"><img src="http://www.delicious.com/static/img/delicious.small.gif" height="10" width="10" alt="Delicious" /> Add</div></div></div>');g(o.element).find(".delicious").on("click",function(){o.openPopup("delicious")})},stumbleupon:function(m){var n=m.options.buttons.stumbleupon;g(m.element).find(".buttons").append('<div class="button stumbleupon"><su:badge layout="'+n.layout+'" location="'+(n.url!==""?n.url:m.options.url)+'"></su:badge></div>');var o=0;if(typeof STMBLPN==="undefined"&&o==0){o=1;(function(){var p=j.createElement("script");p.type="text/javascript";p.async=true;p.src="//platform.stumbleupon.com/1/widgets.js";var q=j.getElementsByTagName("script")[0];q.parentNode.insertBefore(p,q)})();s=i.setTimeout(function(){if(typeof STMBLPN!=="undefined"){STMBLPN.processWidgets();clearInterval(s)}},500)}else{STMBLPN.processWidgets()}},linkedin:function(m){var n=m.options.buttons.linkedin;g(m.element).find(".buttons").append('<div class="button linkedin"><script type="in/share" data-url="'+(n.url!==""?n.url:m.options.url)+'" data-counter="'+n.counter+'"><\/script></div>');var o=0;if(typeof i.IN==="undefined"&&o==0){o=1;(function(){var p=j.createElement("script");p.type="text/javascript";p.async=true;p.src="//platform.linkedin.com/in.js";var q=j.getElementsByTagName("script")[0];q.parentNode.insertBefore(p,q)})()}else{i.IN.init()}},pinterest:function(m){var n=m.options.buttons.pinterest;g(m.element).find(".buttons").append('<div class="button pinterest"><a href="http://pinterest.com/pin/create/button/?url='+(n.url!==""?n.url:m.options.url)+"&media="+n.media+"&description="+n.description+'" class="pin-it-button" count-layout="'+n.layout+'">Pin It</a></div>');(function(){var o=j.createElement("script");o.type="text/javascript";o.async=true;o.src="//assets.pinterest.com/js/pinit.js";var p=j.getElementsByTagName("script")[0];p.parentNode.insertBefore(o,p)})()}},d={googlePlus:function(){},facebook:function(){fb=i.setInterval(function(){if(typeof FB!=="undefined"){FB.Event.subscribe("edge.create",function(m){_gaq.push(["_trackSocial","facebook","like",m])});FB.Event.subscribe("edge.remove",function(m){_gaq.push(["_trackSocial","facebook","unlike",m])});FB.Event.subscribe("message.send",function(m){_gaq.push(["_trackSocial","facebook","send",m])});clearInterval(fb)}},1000)},twitter:function(){tw=i.setInterval(function(){if(typeof twttr!=="undefined"){twttr.events.bind("tweet",function(m){if(m){_gaq.push(["_trackSocial","twitter","tweet"])}});clearInterval(tw)}},1000)},digg:function(){},delicious:function(){},stumbleupon:function(){},linkedin:function(){function m(){_gaq.push(["_trackSocial","linkedin","share"])}},pinterest:function(){}},a={googlePlus:function(m){i.open("https://plus.google.com/share?hl="+m.buttons.googlePlus.lang+"&url="+encodeURIComponent((m.buttons.googlePlus.url!==""?m.buttons.googlePlus.url:m.url)),"","toolbar=0, status=0, width=900, height=500")},facebook:function(m){i.open("http://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent((m.buttons.facebook.url!==""?m.buttons.facebook.url:m.url))+"&t="+m.text+"","","toolbar=0, status=0, width=900, height=500")},twitter:function(m){i.open("https://twitter.com/intent/tweet?text="+encodeURIComponent(m.text)+"&url="+encodeURIComponent((m.buttons.twitter.url!==""?m.buttons.twitter.url:m.url))+(m.buttons.twitter.via!==""?"&via="+m.buttons.twitter.via:""),"","toolbar=0, status=0, width=650, height=360")},digg:function(m){i.open("http://digg.com/tools/diggthis/submit?url="+encodeURIComponent((m.buttons.digg.url!==""?m.buttons.digg.url:m.url))+"&title="+m.text+"&related=true&style=true","","toolbar=0, status=0, width=650, height=360")},delicious:function(m){i.open("http://www.delicious.com/save?v=5&noui&jump=close&url="+encodeURIComponent((m.buttons.delicious.url!==""?m.buttons.delicious.url:m.url))+"&title="+m.text,"delicious","toolbar=no,width=550,height=550")},stumbleupon:function(m){i.open("http://www.stumbleupon.com/badge/?url="+encodeURIComponent((m.buttons.delicious.url!==""?m.buttons.delicious.url:m.url)),"stumbleupon","toolbar=no,width=550,height=550")},linkedin:function(m){i.open("https://www.linkedin.com/cws/share?url="+encodeURIComponent((m.buttons.delicious.url!==""?m.buttons.delicious.url:m.url))+"&token=&isFramed=true","linkedin","toolbar=no,width=550,height=550")},pinterest:function(m){i.open("http://pinterest.com/pin/create/button/?url="+encodeURIComponent((m.buttons.pinterest.url!==""?m.buttons.pinterest.url:m.url))+"&media="+encodeURIComponent(m.buttons.pinterest.media)+"&description="+m.buttons.pinterest.description,"pinterest","toolbar=no,width=700,height=300")}};function k(n,m){this.element=n;this.options=g.extend(true,{},f,m);this.options.share=m.share;this._defaults=f;this._name=h;this.init()}k.prototype.init=function(){var m=this;if(this.options.urlCurl!==""){c.googlePlus=this.options.urlCurl+"?url={url}&type=googlePlus";c.stumbleupon=this.options.urlCurl+"?url={url}&type=stumbleupon"}g(this.element).addClass(this.options.className);if(typeof g(this.element).data("title")!=="undefined"){this.options.title=g(this.element).attr("data-title")}if(typeof g(this.element).data("url")!=="undefined"){this.options.url=g(this.element).data("url")}if(typeof g(this.element).data("text")!=="undefined"){this.options.text=g(this.element).data("text")}g.each(this.options.share,function(n,o){if(o===true){m.options.shareTotal++}});if(m.options.enableCounter===true){g.each(this.options.share,function(n,p){if(p===true){try{m.getSocialJson(n)}catch(o){}}})}else{if(m.options.template!==""){this.options.render(this,this.options)}else{this.loadButtons()}}g(this.element).hover(function(){if(g(this).find(".buttons").length===0&&m.options.enableHover===true){m.loadButtons()}m.options.hover(m,m.options)},function(){m.options.hide(m,m.options)});g(this.element).click(function(){m.options.click(m,m.options);return false})};k.prototype.loadButtons=function(){var m=this;g(this.element).append('<div class="buttons"></div>');g.each(m.options.share,function(n,o){if(o==true){l[n](m);if(m.options.enableTracking===true){d[n]()}}})};k.prototype.getSocialJson=function(o){var m=this,p=0,n=c[o].replace("{url}",encodeURIComponent(this.options.url));if(this.options.buttons[o].urlCount===true&&this.options.buttons[o].url!==""){n=c[o].replace("{url}",this.options.buttons[o].url)}if(n!=""&&m.options.urlCurl!==""){g.getJSON(n,function(r){if(typeof r.count!=="undefined"){var q=r.count+"";q=q.replace("\u00c2\u00a0","");p+=parseInt(q,10)}else{if(r.data&&r.data.length>0&&typeof r.data[0].total_count!=="undefined"){p+=parseInt(r.data[0].total_count,10)}else{if(typeof r[0]!=="undefined"){p+=parseInt(r[0].total_posts,10)}else{if(typeof r[0]!=="undefined"){}}}}m.options.count[o]=p;m.options.total+=p;m.renderer();m.rendererPerso()}).error(function(){m.options.count[o]=0;m.rendererPerso()})}else{m.renderer();m.options.count[o]=0;m.rendererPerso()}};k.prototype.rendererPerso=function(){var m=0;for(e in this.options.count){m++}if(m===this.options.shareTotal){this.options.render(this,this.options)}};k.prototype.renderer=function(){var n=this.options.total,m=this.options.template;if(this.options.shorterTotal===true){n=this.shorterTotal(n)}if(m!==""){m=m.replace("{total}",n);g(this.element).html(m)}else{g(this.element).html('<div class="box"><a class="count" href="#">'+n+"</a>"+(this.options.title!==""?'<a class="share" href="#">'+this.options.title+"</a>":"")+"</div>")}};k.prototype.shorterTotal=function(m){if(m>=1000000){m=(m/1000000).toFixed(2)+"M"}else{if(m>=1000){m=(m/1000).toFixed(1)+"k"}}return m};k.prototype.openPopup=function(m){a[m](this.options);if(this.options.enableTracking===true){var n={googlePlus:{site:"Google",action:"+1"},facebook:{site:"facebook",action:"like"},twitter:{site:"twitter",action:"tweet"},digg:{site:"digg",action:"add"},delicious:{site:"delicious",action:"add"},stumbleupon:{site:"stumbleupon",action:"add"},linkedin:{site:"linkedin",action:"share"},pinterest:{site:"pinterest",action:"pin"}};_gaq.push(["_trackSocial",n[m].site,n[m].action])}};k.prototype.simulateClick=function(){var m=g(this.element).html();g(this.element).html(m.replace(this.options.total,this.options.total+1))};k.prototype.update=function(m,n){if(m!==""){this.options.url=m}if(n!==""){this.options.text=n}};g.fn[h]=function(n){var m=arguments;if(n===b||typeof n==="object"){return this.each(function(){if(!g.data(this,"plugin_"+h)){g.data(this,"plugin_"+h,new k(this,n))}})}else{if(typeof n==="string"&&n[0]!=="_"&&n!=="init"){return this.each(function(){var o=g.data(this,"plugin_"+h);if(o instanceof k&&typeof o[n]==="function"){o[n].apply(o,Array.prototype.slice.call(m,1))}})}}}})(jQuery,window,document);
@@ -14,11 +14,11 @@ module Rsocialize
14
14
  remove_file 'app/assets/stylesheets/rsocialize.css'
15
15
  remove_file %Q{app/assets/javascripts/#{Rsocialize::JQUERY_SHARRRE_FILE}}
16
16
  remove_file 'app/lib/rsocialize_controller.rb'
17
- remove_file 'app/assets/images'
17
+ remove_file 'app/assets/images/example6.png'
18
18
  end
19
19
  def unmodify_routes
20
20
  line = %Q{match '/sharrre' => 'rsocialize#sharrre', via: :get}
21
21
  gsub_file 'config/routes.rb', /(#{Regexp.escape(line)})/mi,''
22
22
  end
23
23
  end #class UninstallGenerator
24
- end
24
+ end
data/lib/rsocialize.rb CHANGED
@@ -1,116 +1,10 @@
1
1
  require "rsocialize/version"
2
2
  require "action_view"
3
+ require 'div_template'
4
+ require 'example_options'
5
+
3
6
  module Rsocialize
4
7
  require 'rsocialize/engine' if defined?(Rails)
5
- JQUERY_SHARRRE_FILE = "jquery.sharrre-1.3.4.min.js"
6
- EXAMPLE1_JS_OPTIONS = {
7
- :twitter=>{:share=>{:twitter=>true},:enableHover=>false, :enableTracking=>true, :buttons=>{:twitter=>{:via=>'_JulienH'}},:click=>%Q[function(api, options){
8
- api.simulateClick();
9
- api.openPopup('twitter');} ]
10
- },
11
- :facebook=>{:share=>{:facebook=>true}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
12
- api.simulateClick();
13
- api.openPopup('facebook');}
14
- ]
15
- },
16
- :googlePlus=>{:share=>{:googlePlus=>true},:enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
17
- api.simulateClick();
18
- api.openPopup('googlePlus');} ]
19
- }
20
- }
21
- EXAMPLE2_JS_OPTIONS = {
22
- shareme: {
23
- share: {
24
- twitter: true,
25
- facebook: true,
26
- googlePlus: true
27
- },
28
- template: %Q{<div class="box"><div class="left">Share</div><div class="middle"><a href="#" class="facebook">f</a><a href="#" class="twitter">t</a><a href="#" class="googleplus">+1</a></div><div class="right">{total}</div></div>},
29
- enableHover: false,
30
- enableTracking: true,
31
- render: %Q[function(api, options){
32
- $(api.element).on('click', '.twitter', function() {
33
- api.openPopup('twitter');
34
- });
35
- $(api.element).on('click', '.facebook', function() {
36
- api.openPopup('facebook');
37
- });
38
- $(api.element).on('click', '.googleplus', function() {
39
- api.openPopup('googlePlus');
40
- });
41
- }]
42
- }
43
- }
44
- EXAMPLE3_JS_OPTIONS = {
45
- shareme: {
46
- share: {
47
- googlePlus: true,
48
- facebook: true,
49
- twitter: true,
50
- digg: true,
51
- delicious: true
52
- },
53
- enableTracking: true,
54
- buttons: {
55
- googlePlus: {size: 'tall'},
56
- facebook: {layout: 'box_count'},
57
- twitter: {count: 'vertical'},
58
- digg: {type: 'DiggMedium'},
59
- delicious: {size: 'tall'}
60
- },
61
- hover: %Q[function(api, options){
62
- $(api.element).find('.buttons').show();
63
- }],
64
- hide: %Q[function(api, options){
65
- $(api.element).find('.buttons').hide();
66
- }]
67
- }
68
- }
69
- EXAMPLE5_JS_OPTIONS = {
70
- shareme: {
71
- share: {
72
- googlePlus: true,
73
- facebook: true,
74
- twitter: true,
75
- digg: true,
76
- delicious: true,
77
- stumbleupon: true,
78
- linkedin: true,
79
- pinterest: true
80
- },
81
- buttons: {
82
- googlePlus: {size: 'tall'},
83
- facebook: {layout: 'box_count'},
84
- twitter: {count: 'vertical'},
85
- digg: {type: 'DiggMedium'},
86
- delicious: {size: 'tall'},
87
- stumbleupon: {layout: '5'},
88
- linkedin: {counter: 'top'},
89
- pinterest: {media: 'http://sharrre.com/img/example1.png', description: %Q{$('#shareme').data('text'), layout: 'vertical'}}
90
- },
91
- enableHover: false,
92
- enableCounter: false,
93
- enableTracking: true
94
- }
95
- }
96
-
97
- EXAMPLE6_JS_OPTIONS ={
98
- :twitter=>{:share=>{:twitter=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>}, :enableHover=>false, :enableTracking=>true, :buttons =>{ twitter: {via: '_JulienH'}}, :click=>%Q[function(api, options){
99
- api.simulateClick();
100
- api.openPopup('twitter');}
101
- ]
102
- },
103
- :facebook=> {:share=>{:facebook=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Like</div></a>}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
104
- api.simulateClick();
105
- api.openPopup('facebook');}
106
- ]
107
- },
108
- :googlePlus=>{:share=>{:googlePlus=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>+1</div></a>}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
109
- api.simulateClick();
110
- api.openPopup('googlePlus');}
111
- ]
112
- }
113
- }
114
8
  def rsocialize_div_tag(div_tag_str="", options={})
115
9
  #options{} :=
116
10
  # url: http://www.example.com/
@@ -120,75 +14,35 @@ module Rsocialize
120
14
  :twitter=>{:url=>"http://sharrre.com/", :text=>"Make your sharing widget with Sharrre (jQuery Plugin)", :title=>"Tweet"},
121
15
  :div_template=>"example1", :url=>"http://sharrre.com/", :text=>"Make your sharing widget with Sharrre (jQuery Plugin)", :title=>"share this page"}.merge(options)
122
16
 
123
- data_url = options[:url]
124
- data_text = options[:text]
125
- data_title = options[:title]
126
- div_str = "".html_safe
127
- case options[:div_template]
128
- when "example1"
129
- div_str = %Q{
130
- <div id="example1">
131
- <div id="twitter" data-url="#{options[:twitter][:url]}" data-text="#{options[:twitter][:text]}" data-title="#{options[:twitter][:title]}"></div>
132
- <div id="facebook" data-url="#{options[:facebook][:url]}" data-text="#{options[:facebook][:text]}" data-title="#{options[:facebook][:title]}"></div>
133
- <div id="googleplus" data-url="#{options[:googleplus][:url]}" data-text="#{options[:googleplus][:text]}" data-title="#{options[:googleplus][:title]}"></div>
134
- </div>
135
- }.html_safe
136
- when "example2", "example5"
137
- div_str = %Q{
138
- <div id="#{options[:div_template]}">
139
- <div id="shareme" data-url="#{data_url}" data-text="#{data_text}"></div>
140
- </div>
141
- }.html_safe
142
- when "example3"
143
- div_str = %Q{
144
- <div id="example3">
145
- <div id="shareme" data-url="#{data_url}" data-text="#{data_text}" data-title="#{data_title}"></div>
146
- </div>
147
- }.html_safe
148
- when "example6"
149
- div_str = %Q{
150
- <div id="example6">
151
- <div id="twitter" data-url="#{options[:twitter][:url]}" data-text="#{options[:twitter][:text]}"></div>
152
- <div id="facebook" data-url="#{options[:facebook][:url]}" data-text="#{options[:facebook][:text]}"></div>
153
- <div id="googleplus" data-url="#{options[:googleplus][:url]}" data-text="#{options[:googleplus][:text]}"></div>
154
- </div>
155
- }.html_safe
156
- else #assume empty or custom
157
- if (div_tag_str.empty?) #use template <div>
158
- div_str = %Q{
17
+ div_str = if !(options[:div_template]=~/example[12356]/).nil?
18
+ klass = options[:div_template].slice(0,1).capitalize + options[:div_template].slice(1..-1)
19
+ klass.constantize.new(options).div_str
20
+ elsif div_tag_str.empty? #assume empty or custom
21
+ #use template <div>
22
+ %Q{
159
23
  <div id="#{options[:div_template]}">
160
- <div id="twitter" data-url="#{data_url}" data-text="#{data_text}" data-title="Tweet"></div>
161
- <div id="facebook" data-url="#{data_url}" data-text="#{data_text}" data-title="Like"></div>
162
- <div id="googleplus" data-url="#{data_url}" data-text="#{data_text}" data-title="+1"></div>
24
+ <div id="twitter" data-url="#{options[:url]}" data-text="#{options[:text]}" data-title="Tweet"></div>
25
+ <div id="facebook" data-url="#{options[:url]}" data-text="#{options[:text]}" data-title="Like"></div>
26
+ <div id="googleplus" data-url="#{options[:url]}" data-text="#{options[:text]}" data-title="+1"></div>
163
27
  </div>
164
28
  }.html_safe
165
- else #use your own <div> classes
166
- div_str = div_tag_str.html_safe
167
- end
29
+ else #use your own <div> classes
30
+ div_tag_str.html_safe
168
31
  end
169
32
 
170
33
  return div_str
171
34
  end
35
+
172
36
  def rsocialize_js_tag(options={})
173
- case options[:js_template]
174
- when "example1"
175
- options = EXAMPLE1_JS_OPTIONS
176
- when "example2"
177
- options = EXAMPLE2_JS_OPTIONS
178
- when "example3"
179
- options = EXAMPLE3_JS_OPTIONS
180
- when "example5"
181
- options = EXAMPLE5_JS_OPTIONS
182
- when "example6"
183
- options = EXAMPLE6_JS_OPTIONS
184
- end
37
+ options = Object.const_get(options[:js_template].upcase + "_JS_OPTIONS") if options[:js_template]=~/example\d{1}/
185
38
  options=options.merge(options)
186
39
 
187
40
  js_str = "<script>\n".html_safe
188
- js_str = js_str+rsocialize_build_js(options).html_safe
41
+ js_str = js_str + rsocialize_build_js(options).html_safe
189
42
  js_str += "</script>".html_safe
190
43
  return js_str
191
44
  end
45
+
192
46
  def rsocialize_build_js(options={})
193
47
  @debug_str = ""
194
48
  @js_str = "$(document).ready(function() { "
@@ -204,6 +58,7 @@ module Rsocialize
204
58
  @js_str = @js_str + "});"
205
59
  return @js_str
206
60
  end
61
+
207
62
  def recursive_js_build(options, key, button_val)
208
63
  @retval=%Q{#{key.to_s}: }
209
64
  @retval = @retval+"{" if hash_depth(options[key])>0
@@ -229,6 +84,7 @@ module Rsocialize
229
84
  end
230
85
  return @retval
231
86
  end
87
+
232
88
  def hash_depth(bhash)
233
89
  #return depth of hash as an integer
234
90
  return 0 if !bhash.is_a?(Hash) #no hash = 0
@@ -1,3 +1,3 @@
1
1
  module Rsocialize
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/rsocialize.gemspec CHANGED
@@ -19,8 +19,9 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
  gem.version = Rsocialize::VERSION
21
21
 
22
- gem.add_development_dependency "rspec",">=2.11.0"
22
+ gem.add_development_dependency "rspec",">=3.3.0"
23
23
  gem.add_development_dependency "rake",">=0.9.2.2"
24
+ gem.add_development_dependency "pry", ">=0.10.1"
24
25
  gem.add_runtime_dependency "curb", "~>0.8.2"
25
26
  gem.add_runtime_dependency "activesupport", ">= 3.2.8"
26
27
  gem.add_runtime_dependency "nokogiri", ">= 1.5.5"
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
+ require 'pry'
3
4
  require 'rsocialize'
4
5
 
5
6
  RSpec.configure do |config|
6
- config.color_enabled = true
7
+ config.color = true
7
8
  config.formatter = 'documentation'
8
- end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsocialize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruce Park
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.11.0
19
+ version: 3.3.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.11.0
26
+ version: 3.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.9.2.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: curb
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -102,10 +116,13 @@ extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
118
  - ".gitignore"
119
+ - CHANGELOG.md
120
+ - Gemfile
105
121
  - LICENSE
106
122
  - README.md
107
123
  - Rakefile
108
- - lib/.rvmrc
124
+ - lib/div_template.rb
125
+ - lib/example_options.rb
109
126
  - lib/generators/USAGE
110
127
  - lib/generators/rsocialize/install_generator.rb
111
128
  - lib/generators/rsocialize/switch_css_generator.rb
@@ -115,7 +132,7 @@ files:
115
132
  - lib/generators/rsocialize/templates/example5.css
116
133
  - lib/generators/rsocialize/templates/example6.css
117
134
  - lib/generators/rsocialize/templates/images/example6.png
118
- - lib/generators/rsocialize/templates/jquery.sharrre-1.3.4.min.js
135
+ - lib/generators/rsocialize/templates/jquery.sharrre-1.3.5.min.js
119
136
  - lib/generators/rsocialize/templates/rsocialize.css
120
137
  - lib/generators/rsocialize/templates/rsocialize_controller.rb
121
138
  - lib/generators/rsocialize/uninstall_generator.rb
@@ -144,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
161
  version: '0'
145
162
  requirements: []
146
163
  rubyforge_project:
147
- rubygems_version: 2.2.2
164
+ rubygems_version: 2.4.8
148
165
  signing_key:
149
166
  specification_version: 4
150
167
  summary: Provides a simple way to add social media buttons to your rails application. It's
@@ -1 +0,0 @@
1
- (function(t,n,r,i){function h(e,n){this.element=e;this.options=t.extend(true,{},u,n);this.options.share=n.share;this._defaults=u;this._name=o;this.init()}var o="sharrre",u={className:"sharrre",share:{googlePlus:false,facebook:false,twitter:false,digg:false,delicious:false,stumbleupon:false,linkedin:false,pinterest:false},shareTotal:0,template:"",title:"",url:r.location.href,text:r.title,urlCurl:"sharrre",count:{},total:0,shorterTotal:true,enableHover:true,enableCounter:true,enableTracking:false,hover:function(){},hide:function(){},click:function(){},render:function(){},buttons:{googlePlus:{url:"",urlCount:false,size:"medium",lang:"en-US",annotation:""},facebook:{url:"",urlCount:false,action:"like",layout:"button_count",width:"",send:"false",faces:"false",colorscheme:"",font:"",lang:"en_US"},twitter:{url:"",urlCount:false,count:"horizontal",hashtags:"",via:"",related:"",lang:"en"},digg:{url:"",urlCount:false,type:"DiggCompact"},delicious:{url:"",urlCount:false,size:"medium"},stumbleupon:{url:"",urlCount:false,layout:"1"},linkedin:{url:"",urlCount:false,counter:""},pinterest:{url:"",media:"",description:"",layout:"horizontal"}}},a={googlePlus:"",facebook:"https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27{url}%27&callback=?",twitter:"http://cdn.api.twitter.com/1/urls/count.json?url={url}&callback=?",digg:"http://services.digg.com/2.0/story.getInfo?links={url}&type=javascript&callback=?",delicious:"http://feeds.delicious.com/v2/json/urlinfo/data?url={url}&callback=?",stumbleupon:"",linkedin:"http://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?",pinterest:""},f={googlePlus:function(e){var i=e.options.buttons.googlePlus;t(e.element).find(".buttons").append('<div class="button googleplus"><div class="g-plusone" data-size="'+i.size+'" data-href="'+(i.url!==""?i.url:e.options.url)+'" data-annotation="'+i.annotation+'"></div></div>');n.___gcfg={lang:e.options.buttons.googlePlus.lang};var s=0;if(typeof gapi==="undefined"&&s==0){s=1;(function(){var e=r.createElement("script");e.type="text/javascript";e.async=true;e.src="//apis.google.com/js/plusone.js";var t=r.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()}else{gapi.plusone.go()}},facebook:function(e){var n=e.options.buttons.facebook;t(e.element).find(".buttons").append('<div class="button facebook"><div id="fb-root"></div><div class="fb-like" data-href="'+(n.url!==""?n.url:e.options.url)+'" data-send="'+n.send+'" data-layout="'+n.layout+'" data-width="'+n.width+'" data-show-faces="'+n.faces+'" data-action="'+n.action+'" data-colorscheme="'+n.colorscheme+'" data-font="'+n.font+'" data-via="'+n.via+'"></div></div>');var i=0;if(typeof FB==="undefined"&&i==0){i=1;(function(e,t,r){var i,s=e.getElementsByTagName(t)[0];if(e.getElementById(r)){return}i=e.createElement(t);i.id=r;i.src="//connect.facebook.net/"+n.lang+"/all.js#xfbml=1";s.parentNode.insertBefore(i,s)})(r,"script","facebook-jssdk")}else{FB.XFBML.parse()}},twitter:function(e){var n=e.options.buttons.twitter;t(e.element).find(".buttons").append('<div class="button twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-url="'+(n.url!==""?n.url:e.options.url)+'" data-count="'+n.count+'" data-text="'+e.options.text+'" data-via="'+n.via+'" data-hashtags="'+n.hashtags+'" data-related="'+n.related+'" data-lang="'+n.lang+'">Tweet</a></div>');var i=0;if(typeof twttr==="undefined"&&i==0){i=1;(function(){var e=r.createElement("script");e.type="text/javascript";e.async=true;e.src="//platform.twitter.com/widgets.js";var t=r.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()}else{t.ajax({url:"//platform.twitter.com/widgets.js",dataType:"script",cache:true})}},digg:function(e){var n=e.options.buttons.digg;t(e.element).find(".buttons").append('<div class="button digg"><a class="DiggThisButton '+n.type+'" rel="nofollow external" href="http://digg.com/submit?url='+encodeURIComponent(n.url!==""?n.url:e.options.url)+'"></a></div>');var i=0;if(typeof __DBW==="undefined"&&i==0){i=1;(function(){var e=r.createElement("SCRIPT"),t=r.getElementsByTagName("SCRIPT")[0];e.type="text/javascript";e.async=true;e.src="//widgets.digg.com/buttons.js";t.parentNode.insertBefore(e,t)})()}},delicious:function(e){if(e.options.buttons.delicious.size=="tall"){var n="width:50px;",r="height:35px;width:50px;font-size:15px;line-height:35px;",i="height:18px;line-height:18px;margin-top:3px;"}else{var n="width:93px;",r="float:right;padding:0 3px;height:20px;width:26px;line-height:20px;",i="float:left;height:20px;line-height:20px;"}var s=e.shorterTotal(e.options.count.delicious);if(typeof s==="undefined"){s=0}t(e.element).find(".buttons").append('<div class="button delicious"><div style="'+n+'font:12px Arial,Helvetica,sans-serif;cursor:pointer;color:#666666;display:inline-block;float:none;height:20px;line-height:normal;margin:0;padding:0;text-indent:0;vertical-align:baseline;">'+'<div style="'+r+'background-color:#fff;margin-bottom:5px;overflow:hidden;text-align:center;border:1px solid #ccc;border-radius:3px;">'+s+"</div>"+'<div style="'+i+'display:block;padding:0;text-align:center;text-decoration:none;width:50px;background-color:#7EACEE;border:1px solid #40679C;border-radius:3px;color:#fff;">'+'<img src="http://www.delicious.com/static/img/delicious.small.gif" height="10" width="10" alt="Delicious" /> Add</div></div></div>');t(e.element).find(".delicious").on("click",function(){e.openPopup("delicious")})},stumbleupon:function(e){var i=e.options.buttons.stumbleupon;t(e.element).find(".buttons").append('<div class="button stumbleupon"><su:badge layout="'+i.layout+'" location="'+(i.url!==""?i.url:e.options.url)+'"></su:badge></div>');var o=0;if(typeof STMBLPN==="undefined"&&o==0){o=1;(function(){var e=r.createElement("script");e.type="text/javascript";e.async=true;e.src="//platform.stumbleupon.com/1/widgets.js";var t=r.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();s=n.setTimeout(function(){if(typeof STMBLPN!=="undefined"){STMBLPN.processWidgets();clearInterval(s)}},500)}else{STMBLPN.processWidgets()}},linkedin:function(e){var i=e.options.buttons.linkedin;t(e.element).find(".buttons").append('<div class="button linkedin"><script type="in/share" data-url="'+(i.url!==""?i.url:e.options.url)+'" data-counter="'+i.counter+'"></script></div>');var s=0;if(typeof n.IN==="undefined"&&s==0){s=1;(function(){var e=r.createElement("script");e.type="text/javascript";e.async=true;e.src="//platform.linkedin.com/in.js";var t=r.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()}else{n.IN.init()}},pinterest:function(e){var n=e.options.buttons.pinterest;t(e.element).find(".buttons").append('<div class="button pinterest"><a href="http://pinterest.com/pin/create/button/?url='+(n.url!==""?n.url:e.options.url)+"&media="+n.media+"&description="+n.description+'" class="pin-it-button" count-layout="'+n.layout+'">Pin It</a></div>');(function(){var e=r.createElement("script");e.type="text/javascript";e.async=true;e.src="//assets.pinterest.com/js/pinit.js";var t=r.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})()}},l={googlePlus:function(){},facebook:function(){fb=n.setInterval(function(){if(typeof FB!=="undefined"){FB.Event.subscribe("edge.create",function(e){_gaq.push(["_trackSocial","facebook","like",e])});FB.Event.subscribe("edge.remove",function(e){_gaq.push(["_trackSocial","facebook","unlike",e])});FB.Event.subscribe("message.send",function(e){_gaq.push(["_trackSocial","facebook","send",e])});clearInterval(fb)}},1e3)},twitter:function(){tw=n.setInterval(function(){if(typeof twttr!=="undefined"){twttr.events.bind("tweet",function(e){if(e){_gaq.push(["_trackSocial","twitter","tweet"])}});clearInterval(tw)}},1e3)},digg:function(){},delicious:function(){},stumbleupon:function(){},linkedin:function(){function e(){_gaq.push(["_trackSocial","linkedin","share"])}},pinterest:function(){}},c={googlePlus:function(e){n.open("https://plus.google.com/share?hl="+e.buttons.googlePlus.lang+"&url="+encodeURIComponent(e.buttons.googlePlus.url!==""?e.buttons.googlePlus.url:e.url),"","toolbar=0, status=0, width=900, height=500")},facebook:function(e){n.open("http://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(e.buttons.facebook.url!==""?e.buttons.facebook.url:e.url)+"&t="+e.text+"","","toolbar=0, status=0, width=900, height=500")},twitter:function(e){n.open("https://twitter.com/intent/tweet?text="+encodeURIComponent(e.text)+"&url="+encodeURIComponent(e.buttons.twitter.url!==""?e.buttons.twitter.url:e.url)+(e.buttons.twitter.via!==""?"&via="+e.buttons.twitter.via:""),"","toolbar=0, status=0, width=650, height=360")},digg:function(e){n.open("http://digg.com/tools/diggthis/submit?url="+encodeURIComponent(e.buttons.digg.url!==""?e.buttons.digg.url:e.url)+"&title="+e.text+"&related=true&style=true","","toolbar=0, status=0, width=650, height=360")},delicious:function(e){n.open("http://www.delicious.com/save?v=5&noui&jump=close&url="+encodeURIComponent(e.buttons.delicious.url!==""?e.buttons.delicious.url:e.url)+"&title="+e.text,"delicious","toolbar=no,width=550,height=550")},stumbleupon:function(e){n.open("http://www.stumbleupon.com/badge/?url="+encodeURIComponent(e.buttons.delicious.url!==""?e.buttons.delicious.url:e.url),"stumbleupon","toolbar=no,width=550,height=550")},linkedin:function(e){n.open("https://www.linkedin.com/cws/share?url="+encodeURIComponent(e.buttons.delicious.url!==""?e.buttons.delicious.url:e.url)+"&token=&isFramed=true","linkedin","toolbar=no,width=550,height=550")},pinterest:function(e){n.open("http://pinterest.com/pin/create/button/?url="+encodeURIComponent(e.buttons.pinterest.url!==""?e.buttons.pinterest.url:e.url)+"&media="+encodeURIComponent(e.buttons.pinterest.media)+"&description="+e.buttons.pinterest.description,"pinterest","toolbar=no,width=700,height=300")}};h.prototype.init=function(){var e=this;if(this.options.urlCurl!==""){a.googlePlus=this.options.urlCurl+"?url={url}&type=googlePlus";a.stumbleupon=this.options.urlCurl+"?url={url}&type=stumbleupon";a.pinterest=this.options.urlCurl+"?url={url}&type=pinterest"}t(this.element).addClass(this.options.className);if(typeof t(this.element).data("title")!=="undefined"){this.options.title=t(this.element).attr("data-title")}if(typeof t(this.element).data("url")!=="undefined"){this.options.url=t(this.element).data("url")}if(typeof t(this.element).data("text")!=="undefined"){this.options.text=t(this.element).data("text")}t.each(this.options.share,function(t,n){if(n===true){e.options.shareTotal++}});if(e.options.enableCounter===true){t.each(this.options.share,function(t,n){if(n===true){try{e.getSocialJson(t)}catch(r){}}})}else if(e.options.template!==""){this.options.render(this,this.options)}else{this.loadButtons()}t(this.element).hover(function(){if(t(this).find(".buttons").length===0&&e.options.enableHover===true){e.loadButtons()}e.options.hover(e,e.options)},function(){e.options.hide(e,e.options)});t(this.element).click(function(){e.options.click(e,e.options);return false})};h.prototype.loadButtons=function(){var e=this;t(this.element).append('<div class="buttons"></div>');t.each(e.options.share,function(t,n){if(n==true){f[t](e);if(e.options.enableTracking===true){l[t]()}}})};h.prototype.getSocialJson=function(e){var n=this,r=0,i=a[e].replace("{url}",encodeURIComponent(this.options.url));if(this.options.buttons[e].urlCount===true&&this.options.buttons[e].url!==""){i=a[e].replace("{url}",this.options.buttons[e].url)}if(i!=""&&n.options.urlCurl!==""){t.getJSON(i,function(t){if(typeof t.count!=="undefined"){var i=t.count+"";i=i.replace("Â ","");r+=parseInt(i,10)}else if(t.data&&t.data.length>0&&typeof t.data[0].total_count!=="undefined"){r+=parseInt(t.data[0].total_count,10)}else if(typeof t.shares!=="undefined"){r+=parseInt(t.shares,10)}else if(typeof t[0]!=="undefined"){r+=parseInt(t[0].total_posts,10)}else if(typeof t[0]!=="undefined"){}n.options.count[e]=r;n.options.total+=r;n.renderer();n.rendererPerso()}).error(function(){n.options.count[e]=0;n.rendererPerso()})}else{n.renderer();n.options.count[e]=0;n.rendererPerso()}};h.prototype.rendererPerso=function(){var t=0;for(e in this.options.count){t++}if(t===this.options.shareTotal){this.options.render(this,this.options)}};h.prototype.renderer=function(){var e=this.options.total,n=this.options.template;if(this.options.shorterTotal===true){e=this.shorterTotal(e)}if(n!==""){n=n.replace("{total}",e);t(this.element).html(n)}else{t(this.element).html('<div class="box"><a class="count" href="#">'+e+"</a>"+(this.options.title!==""?'<a class="share" href="#">'+this.options.title+"</a>":"")+"</div>")}};h.prototype.shorterTotal=function(e){if(e>=1e6){e=(e/1e6).toFixed(2)+"M"}else if(e>=1e3){e=(e/1e3).toFixed(1)+"k"}return e};h.prototype.openPopup=function(e){c[e](this.options);if(this.options.enableTracking===true){var t={googlePlus:{site:"Google",action:"+1"},facebook:{site:"facebook",action:"like"},twitter:{site:"twitter",action:"tweet"},digg:{site:"digg",action:"add"},delicious:{site:"delicious",action:"add"},stumbleupon:{site:"stumbleupon",action:"add"},linkedin:{site:"linkedin",action:"share"},pinterest:{site:"pinterest",action:"pin"}};_gaq.push(["_trackSocial",t[e].site,t[e].action])}};h.prototype.simulateClick=function(){var e=t(this.element).html();t(this.element).html(e.replace(this.options.total,this.options.total+1))};h.prototype.update=function(e,t){if(e!==""){this.options.url=e}if(t!==""){this.options.text=t}};t.fn[o]=function(e){var n=arguments;if(e===i||typeof e==="object"){return this.each(function(){if(!t.data(this,"plugin_"+o)){t.data(this,"plugin_"+o,new h(this,e))}})}else if(typeof e==="string"&&e[0]!=="_"&&e!=="init"){return this.each(function(){var r=t.data(this,"plugin_"+o);if(r instanceof h&&typeof r[e]==="function"){r[e].apply(r,Array.prototype.slice.call(n,1))}})}}})(jQuery,window,document)