diff --git a/README.md b/README.md index 3acc293..6f2acda 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ include `share-buttons.js` in the end of page: ``` -Paste this html on the page: +Paste this HTML on the page: ``` html
@@ -110,4 +110,4 @@ If your using [Font-Awesome](https://github.com/FortAwesome/Font-Awesome): ---- -© 2015 - 2019 Yauheni Pakala +© 2015 - 2020 Yauheni Pakala diff --git a/dist/share-buttons.js b/dist/share-buttons.js index 9df83cc..ec124af 100644 --- a/dist/share-buttons.js +++ b/dist/share-buttons.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).ShareButtons=t()}(this,function(){"use strict";var f=window,m=f.document;var e=new function(){function s(e,n){return e.replace(/\{(\d+)\}/g,function(e,t){return n[t]||e})}function u(e){return e.join(" - ")}function l(e){return encodeURIComponent(e)}this.i=function(){var e,t=m.querySelectorAll(".share-btn");for(e=t.length;e--;)n(t[e])};var n=function(e){var t,n=e.querySelectorAll("a");for(t=n.length;t--;)r(n[t],{id:"",url:i(e),title:c(e),desc:o(e)})},r=function(e,t){t.id=h(e,"data-id"),t.id&&a(e,"click",t)},i=function(e){return h(e,"data-url")||location.href||" "},c=function(e){return h(e,"data-title")||m.title||" "},o=function(e){var t=m.querySelector("meta[name=description]");return h(e,"data-desc")||t&&h(t,"content")||" "},a=function(e,t,n){function r(){d(n.id,n.url,n.title,n.desc)}e.addEventListener?e.addEventListener(t,r):e.attachEvent("on"+t,function(){r.call(e)})},h=function(e,t){return e.getAttribute(t)},d=function(e,t,n,r){var i=l(t),c=l(r),o=l(n),a=o||c||"";switch(e){case"fb":p(s("https://www.facebook.com/sharer/sharer.php?u={0}",[i]),n);break;case"vk":p(s("https://vk.com/share.php?url={0}&title={1}",[i,u([o,c])]),n);break;case"tw":p(s("https://twitter.com/intent/tweet?url={0}&text={1}",[i,u([o,c])]),n);break;case"tg":p(s("https://t.me/share/url?url={0}&text={1}",[i,u([o,c])]),n);break;case"pk":p(s("https://getpocket.com/edit?url={0}&title={1}",[i,u([o,c])]),n);break;case"re":p(s("https://reddit.com/submit/?url={0}",[i]),n);break;case"ev":p(s("https://www.evernote.com/clip.action?url={0}&t={1}",[i,o]),n);break;case"in":p(s("https://www.linkedin.com/shareArticle?mini=true&url={0}&title={1}&summary={2}&source={0}",[i,o,u([o,c])]),n);break;case"pi":p(s("https://pinterest.com/pin/create/button/?url={0}&media={0}&description={1}",[i,u([o,c])]),n);break;case"sk":p(s("https://web.skype.com/share?url={0}&source=button&text={1}",[i,u([o,c])]),n);break;case"wa":p(s("whatsapp://send?text={0}%20{1}",[u([o,c]),i]),n);break;case"ok":p(s("https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&service=odnoklassniki&st.shareUrl={0}",[i]),n);break;case"tu":p(s("https://www.tumblr.com/widgets/share/tool?posttype=link&title={0}&caption={0}&content={1}&canonicalUrl={1}&shareSource=tumblr_share_button",[u([o,c]),i]),n);break;case"hn":p(s("https://news.ycombinator.com/submitlink?t={0}&u={1}",[u([o,c]),i]),n);break;case"xi":p(s("https://www.xing.com/app/user?op=share;url={0};title={1}",[i,u([o,c])]),n);break;case"mail":0 - * @version 1.2 + * @version 1.5 * @license MIT */ function ShareButtons() { @@ -31,7 +31,7 @@ TU_LINK_FORMAT = 'https://www.tumblr.com/widgets/share/tool?posttype=link&title={0}&caption={0}&content={1}&canonicalUrl={1}&shareSource=tumblr_share_button', HN_LINK_FORMAT = 'https://news.ycombinator.com/submitlink?t={0}&u={1}', XI_LINK_FORMAT = 'https://www.xing.com/app/user?op=share;url={0};title={1}', - MAIL_LINK_FORMAT = 'mailto:?Subject={0}{1}&body={2}{3}', + MAIL_LINK_FORMAT = 'mailto:?subject={0}&body={1}', FB_CLASS_NAME = 'fb', VK_CLASS_NAME = 'vk', TW_CLASS_NAME = 'tw', @@ -314,14 +314,11 @@ if (title.length > 0 && desc.length > 0) { text = mergeForTitle([title, desc]); } - if (text.length > 0) { - text = text + ' / '; - } - if (title.length > 0) { - title += ' / '; + if (url.length > 0) { + text = text + ' / ' + url; } - location.href = stringFormat(MAIL_LINK_FORMAT, [title, titleDef, text, url]); + location.href = stringFormat(MAIL_LINK_FORMAT, [title, text]); break; case PRINT_CLASS_NAME: