Comparing version 1.4.1 to 1.5.0
@@ -0,1 +1,5 @@ | ||
## 1.5.0 | ||
Support Reddit. | ||
## 1.4.1 | ||
@@ -2,0 +6,0 @@ |
@@ -10,7 +10,11 @@ var jsonp = require('@borodean/jsonp'); | ||
var id = callbacks.length; | ||
var src = base0 + encodeURIComponent(url) + base1 + id; | ||
var id = String(callbacks.length); | ||
jsonp(callbacks, id, src, callback); | ||
jsonp({ | ||
url: base0 + encodeURIComponent(url) + base1 + id, | ||
parameter: false, | ||
object: callbacks, | ||
key: id | ||
}, callback); | ||
}; | ||
}; |
var jsonp = require('@borodean/jsonp'); | ||
module.exports = function (base, parser) { | ||
module.exports = function (base, parser, parameter) { | ||
return function (url, callback) { | ||
@@ -10,3 +10,6 @@ if (arguments.length < 2) { | ||
jsonp(base + '=' + encodeURIComponent(url), function (err, data) { | ||
jsonp({ | ||
url: base + '=' + encodeURIComponent(url), | ||
parameter: parameter | ||
}, function (err, data) { | ||
if (err) { | ||
@@ -13,0 +16,0 @@ return callback(err); |
@@ -13,6 +13,10 @@ /** | ||
var top = Math.max(0, Math.round(((screen.height / 3) - (height / 2)))); | ||
var left = Math.round((screen.width - width) / 2); | ||
if (width) { | ||
var top = Math.max(0, Math.round(((screen.height / 3) - (height / 2)))); | ||
var left = Math.round((screen.width - width) / 2); | ||
window.open(url, null, 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',location,resizable,scrollbars,toolbar=no'); | ||
window.open(url, null, 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',location,resizable,scrollbars,toolbar=no'); | ||
} else { | ||
window.open(url); | ||
} | ||
} | ||
@@ -19,0 +23,0 @@ |
@@ -1,2 +0,2 @@ | ||
var sharon=function(){"use strict";var t=0,n=function(n,e,o,r){function i(){document.head.removeChild(c),delete n[e]}arguments.length<4&&(r=e,e="j"+t++,o=n+(~n.indexOf("?")?"&":"?")+"callback="+e,n=window);var c=document.createElement("script");c.src=o,c.onerror=function(){i(),r(Error())},n[e]=function(t){i(),r(null,t)},document.head.appendChild(c)},e=n,o=function(t,n){return function(o,r){arguments.length<2&&(r=o,o=location),e(t+"="+encodeURIComponent(o),function(t,e){return t?r(t):void r(null,n(e))})}},r=function(t,n){return n&&Object.keys(n).forEach(function(e){t[e]=n[e]}),t},i=r,c=function(t,n){return n=n||{},function(e,o){"string"==typeof e?o=i({url:e},o):(o=i({url:location},e),n.title&&(o.title=o.title||document.title));var r=Object.keys(o).map(function(t){var e=n[t]||t;return Array.isArray(o[t])?e+"="+o[t].map(encodeURIComponent):e+"="+encodeURIComponent(o[t])});return t+(~t.indexOf("?")?"&":"?")+r.join("&")}},u=function(t,n,e){function o(){var o=t.apply(this,arguments),r=Math.max(0,Math.round(screen.height/3-e/2)),i=Math.round((screen.width-n)/2);window.open(o,null,"width="+n+",height="+e+",top="+r+",left="+i+",location,resizable,scrollbars,toolbar=no")}return o.href=t,o},a=o,s=c,l=u,h=s("https://buffer.com/add",{title:"text"}),p=l(h,850,600),d=a("https://api.bufferapp.com/1/links/shares.json?url",function(t){return t.shares});p.count=d;var m=o,f=c,w=u,v=f("https://www.facebook.com/sharer.php",{url:"u"}),b=w(v,670,340),k=m("https://graph.facebook.com/?id",function(t){return t.share?t.share.share_count:0});b.count=k;var g=c,x=u,y=g("https://mail.google.com/mail/?view=cm",{title:"su",url:"body"}),C=x(y,800,632),j=o,U=c,O=u,I=U("https://www.linkedin.com/shareArticle",{title:"title"}),R=O(I,600,400),A=j("https://www.linkedin.com/countserv/count/share?url",function(t){return t.count});R.count=A;var E=n,M=function(t,n,e){return function(o,r){arguments.length<2&&(r=o,o=location);var i=e.length;E(e,i,t+encodeURIComponent(o)+n+i,r)}},K=M,L=c,S=u,_=L("https://connect.ok.ru/dk?st.cmd=WidgetSharePreview",{url:"st.shareUrl"}),z=S(_,580,350),D=[];window.ODKL={updateCount:function(t,n){D[t](+n)}};var N=K("https://connect.ok.ru/dk?st.cmd=extLike&ref=","&uid=",D);z.count=N;var P=o,V=c,W=u,q=V("https://www.pinterest.com/pin/create/button/",{title:"description"}),B=W(q,750,320),F=P("https://api.pinterest.com/v1/urls/count.json?url",function(t){return t.count});B.count=F;var G=o,H=c,J=u,Q=H("https://plus.google.com/share"),T=J(Q,600,600),X=G("https://share.yandex.ru/gpp.xml?url",Number);T.count=X;var Y=o,Z=c,$=u,tt=Z("https://www.tumblr.com/widgets/share/tool",{title:"title",url:"canonicalUrl"}),nt=$(tt,557,600),et=Y("https://api.tumblr.com/v2/share/stats?url",function(t){return t.response.note_count});nt.count=et;var ot=c,rt=u,it=ot("https://twitter.com/intent/tweet",{title:"text"}),ct=rt(it,550,420),ut=M,at=c,st=u,lt=at("https://vk.com/share.php"),ht=st(lt,650,610),pt=[];window.VK={Share:{count:function(t,n){pt[t](n)}}};var dt=ut("https://vk.com/share.php?act=count&url=","&index=",pt);return ht.count=dt,{buffer:p,facebook:b,gmail:C,linkedin:R,ok:z,pinterest:B,plus:T,tumblr:nt,twitter:ct,vk:ht,weibo:u(c("http://service.weibo.com/share/share.php",{title:"title"}),615,505),xing:u(c("https://www.xing.com/spi/shares/new"),570,530)}}(); | ||
var sharon=function(){"use strict";var t=0,e=function(e,n){var r=e.url||e,o=e.object||window,i=e.key||"j"+t++,c=void 0===e.parameter?"callback":e.parameter,u=document.createElement("script");u.src=c?r+(~r.indexOf("?")?"&":"?")+c+"="+i:r,u.onerror=function(){delete o[i],n(Error())},o[i]=function(t){delete o[i],n(null,t)},document.head.removeChild(document.head.appendChild(u))},n=e,r=function(t,e,r){return function(o,i){arguments.length<2&&(i=o,o=location),n({url:t+"="+encodeURIComponent(o),parameter:r},function(t,n){return t?i(t):void i(null,e(n))})}},o=function(t,e){return e&&Object.keys(e).forEach(function(n){t[n]=e[n]}),t},i=o,c=function(t,e){return e=e||{},function(n,r){"string"==typeof n?r=i({url:n},r):(r=i({url:location},n),e.title&&(r.title=r.title||document.title));var o=Object.keys(r).map(function(t){var n=e[t]||t;return Array.isArray(r[t])?n+"="+r[t].map(encodeURIComponent):n+"="+encodeURIComponent(r[t])});return t+(~t.indexOf("?")?"&":"?")+o.join("&")}},u=function(t,e,n){function r(){var r=t.apply(this,arguments);if(e){var o=Math.max(0,Math.round(screen.height/3-n/2)),i=Math.round((screen.width-e)/2);window.open(r,null,"width="+e+",height="+n+",top="+o+",left="+i+",location,resizable,scrollbars,toolbar=no")}else window.open(r)}return r.href=t,r},a=r,s=c,l=u,p=s("https://buffer.com/add",{title:"text"}),h=l(p,850,600),d=a("https://api.bufferapp.com/1/links/shares.json?url",function(t){return t.shares});h.count=d;var m=r,w=c,f=u,v=w("https://www.facebook.com/sharer.php",{url:"u"}),b=f(v,670,340),k=m("https://graph.facebook.com/?id",function(t){return t.share?t.share.share_count:0});b.count=k;var g=c,x=u,j=g("https://mail.google.com/mail/?view=cm",{title:"su",url:"body"}),y=x(j,800,632),C=r,U=c,O=u,I=U("https://www.linkedin.com/shareArticle",{title:"title"}),R=O(I,600,400),A=C("https://www.linkedin.com/countserv/count/share?url",function(t){return t.count});R.count=A;var E=e,M=function(t,e,n){return function(r,o){arguments.length<2&&(o=r,r=location);var i=n.length+"";E({url:t+encodeURIComponent(r)+e+i,parameter:!1,object:n,key:i},o)}},K=M,L=c,S=u,_=L("https://connect.ok.ru/dk?st.cmd=WidgetSharePreview",{url:"st.shareUrl"}),z=S(_,580,350),D=[];window.ODKL={updateCount:function(t,e){D[t](+e)}};var N=K("https://connect.ok.ru/dk?st.cmd=extLike&ref=","&uid=",D);z.count=N;var P=r,V=c,W=u,q=V("https://www.pinterest.com/pin/create/button/",{title:"description"}),B=W(q,750,320),F=P("https://api.pinterest.com/v1/urls/count.json?url",function(t){return t.count});B.count=F;var G=r,H=c,J=u,Q=H("https://plus.google.com/share"),T=J(Q,600,600),X=G("https://share.yandex.ru/gpp.xml?url",Number);T.count=X;var Y=r,Z=c,$=u,tt=Z("https://www.reddit.com/submit",{title:"title"}),et=$(tt),nt=Y("https://www.reddit.com/api/info.json?url",function(t){return t.data.children.reduce(function(t,e){return t+e.data.score},0)},"jsonp");et.count=nt;var rt=r,ot=c,it=u,ct=ot("https://www.tumblr.com/widgets/share/tool",{title:"title",url:"canonicalUrl"}),ut=it(ct,557,600),at=rt("https://api.tumblr.com/v2/share/stats?url",function(t){return t.response.note_count});ut.count=at;var st=c,lt=u,pt=st("https://twitter.com/intent/tweet",{title:"text"}),ht=lt(pt,550,420),dt=M,mt=c,wt=u,ft=mt("https://vk.com/share.php"),vt=wt(ft,650,610),bt=[];window.VK={Share:{count:function(t,e){bt[t](e)}}};var kt=dt("https://vk.com/share.php?act=count&url=","&index=",bt);return vt.count=kt,{buffer:h,facebook:b,gmail:y,linkedin:R,ok:z,pinterest:B,plus:T,reddit:et,tumblr:ut,twitter:ht,vk:vt,weibo:u(c("http://service.weibo.com/share/share.php",{title:"title"}),615,505),xing:u(c("https://www.xing.com/spi/shares/new"),570,530)}}(); | ||
//# sourceMappingURL=sharon.min.js.map |
@@ -9,2 +9,3 @@ module.exports = { | ||
plus: require('./plus'), | ||
reddit: require('./reddit'), | ||
tumblr: require('./tumblr'), | ||
@@ -11,0 +12,0 @@ twitter: require('./twitter'), |
{ | ||
"name": "sharon", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "A lightweight and modular social sharing library", | ||
@@ -15,2 +15,3 @@ "keywords": [ | ||
"pinterest", | ||
"reddit", | ||
"tumblr", | ||
@@ -32,3 +33,3 @@ "twitter", | ||
"dependencies": { | ||
"@borodean/jsonp": "^1.1.0" | ||
"@borodean/jsonp": "^1.2.0" | ||
}, | ||
@@ -35,0 +36,0 @@ "devDependencies": { |
@@ -8,4 +8,4 @@ [![Sauce Test Status][saucelabs-badge]][saucelabs] | ||
- a toolkit to build your own share buttons; | ||
- supports 12 sharing platforms; | ||
- gzipped size is 1.52 KB; | ||
- supports 13 sharing platforms; | ||
- gzipped size is 1.68 KB; | ||
- you can cherry-pick which sharing platforms to use to make it even smaller. | ||
@@ -78,3 +78,3 @@ | ||
- [Production version][download] – 1.52 KB, minified and gzipped | ||
- [Production version][download] – 1.68 KB, minified and gzipped | ||
- [Source map][download-map] | ||
@@ -97,2 +97,3 @@ | ||
| Pinterest | `sharon.pinterest` | Yes | [Reference][params-pinterest] | | ||
| Reddit | `sharon.reddit` | Yes | [Reference][params-reddit] | | ||
| Tumblr | `sharon.tumblr` | Yes | [Reference][params-tumblr] | | ||
@@ -282,7 +283,7 @@ | Twitter | `sharon.twitter` | | [Reference][params-twitter] | | ||
[download]: https://github.com/borodean/sharon/releases/download/1.4.1/sharon-1.4.1.min.js | ||
[download-map]: https://github.com/borodean/sharon/releases/download/1.4.1/sharon-1.4.1.min.js.map | ||
[download]: https://github.com/borodean/sharon/releases/download/1.5.0/sharon-1.5.0.min.js | ||
[download-map]: https://github.com/borodean/sharon/releases/download/1.5.0/sharon-1.5.0.min.js.map | ||
[media-example]: media/example.png | ||
[media-heart]: https://cdn.rawgit.com/borodean/sharon/1.4.1/media/heart.svg | ||
[media-sharon]: https://cdn.rawgit.com/borodean/sharon/1.4.1/media/sharon.svg | ||
[media-heart]: https://cdn.rawgit.com/borodean/sharon/1.5.0/media/heart.svg | ||
[media-sharon]: https://cdn.rawgit.com/borodean/sharon/1.5.0/media/sharon.svg | ||
[params-buffer]: https://buffer.com/extras/button | ||
@@ -292,2 +293,3 @@ [params-linkedin]: https://developer.linkedin.com/docs/share-on-linkedin | ||
[params-plus]: https://developers.google.com/+/web/share/#sharelink-endpoint | ||
[params-reddit]: https://www.reddit.com/dev/api/#POST_api_submit | ||
[params-tumblr]: https://www.tumblr.com/docs/en/share_button | ||
@@ -294,0 +296,0 @@ [params-twitter]: https://dev.twitter.com/web/tweet-button/web-intent |
Sorry, the diff of this file is not supported yet
39394
25
277
296
Updated@borodean/jsonp@^1.2.0