sharelinks
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Sharelinks=e():t.Sharelinks=e()}(this,(function(){return function(){"use strict";var t={};function e(t,e,i){return void 0===e.dataset[t]?i:e.dataset[t]}function i(t){return encodeURIComponent(t).replaceAll(/%20/g,"+")}let n=[{name:"whatsapp",href:"whatsapp://send?text=%URL%",width:null,height:null,sameWindow:!0},{name:"facebook",href:"https://www.facebook.com/sharer/sharer.php?u=%URL%",width:400,height:500},{name:"twitter",href:"https://twitter.com/intent/tweet?text=%TITLE%+-+%URL%",width:540,height:260},{name:"pinterest",href:"http://pinterest.com/pin/create/button/?url=%URL%&description=%TITLE%&media=%IMAGE%",width:520,height:570},{name:"tumblr",href:"http://www.tumblr.com/share/link?url=%URL%",width:500,height:500},{name:"linkedin",href:"https://www.linkedin.com/sharing/share-offsite/?url=%URL%",width:520,height:570}];return t.default=class{constructor(t,e={}){n.push(...e.platforms??[]),this.options=e,document.querySelectorAll(t).forEach((t=>{t.addEventListener("click",this.onClick.bind(this))}))}makeLink(t,e,n,r){return t.href.replaceAll("%URL%",i(e)).replaceAll("%TITLE%",i(n)).replaceAll("%IMAGE%",i(r))}findImage(t){if(e("image",t))return e("image",t);const i=document.querySelector('meta[property="og:image"]');return i?i.getAttribute("content"):void 0}onClick(t){if(1!==t.which)return;t.preventDefault();const i=t.target,r=n.find((t=>t.name===e("platform",i)));if(void 0===r)throw"Sharelinks Error: Invalid data-platform: "+e("platform",i);const o=e("url",i,window.location.href),a=e("width",i,r.width),h=e("height",i,r.height),l=this.makeLink(r,o,e("title",i,document.title),this.findImage(i));"function"==typeof this.options.callback&&this.options.callback({platform:i.dataset.platform,url:o}),r.sameWindow?window.location.href=l:window.open(l,"","status=yes, width="+a+", height="+h).opener=null}},t.default}()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Sharelinks=e():t.Sharelinks=e()}(this,(function(){return function(){"use strict";var t={};function e(t,e,i){return void 0===e.dataset[t]?i:e.dataset[t]}function i(t){return encodeURIComponent(t).replaceAll(/%20/g,"+")}let n=[{name:"whatsapp",href:"whatsapp://send?text=%URL%",width:null,height:null,sameWindow:!0},{name:"facebook",href:"https://www.facebook.com/sharer/sharer.php?u=%URL%",width:400,height:500},{name:"twitter",href:"https://twitter.com/intent/tweet?text=%TITLE%+-+%URL%",width:540,height:260},{name:"pinterest",href:"http://pinterest.com/pin/create/button/?url=%URL%&description=%TITLE%&media=%IMAGE%",width:520,height:570},{name:"tumblr",href:"http://www.tumblr.com/share/link?url=%URL%",width:500,height:500},{name:"linkedin",href:"https://www.linkedin.com/sharing/share-offsite/?url=%URL%",width:520,height:570}];return t.default=class{constructor(t,e={}){n.push(...e.platforms??[]),this.options=e,document.querySelectorAll(t).forEach((t=>{t.addEventListener("click",this.onClick.bind(this))}))}makeLink(t,e,n,r){return t.href.replaceAll("%URL%",i(e)).replaceAll("%TITLE%",i(n)).replaceAll("%IMAGE%",i(r))}findImage(t){if(e("image",t))return e("image",t);const i=document.querySelector('meta[property="og:image"]');return i?i.getAttribute("content"):void 0}onClick(t){if(1!==t.which)return;t.preventDefault();const i=t.currentTarget,r=n.find((t=>t.name===e("platform",i)));if(void 0===r)throw"Sharelinks Error: Invalid data-platform: "+e("platform",i);const o=e("url",i,window.location.href),a=e("width",i,r.width),h=e("height",i,r.height),l=this.makeLink(r,o,e("title",i,document.title),this.findImage(i));"function"==typeof this.options.callback&&this.options.callback({platform:i.dataset.platform,url:o}),r.sameWindow?window.location.href=l:window.open(l,"","status=yes, width="+a+", height="+h).opener=null}},t.default}()})); |
{ | ||
"name": "sharelinks", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"repository": "git@github.com/mrchimp/sharelinks", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -99,3 +99,3 @@ /** | ||
const elem = e.target; | ||
const elem = e.currentTarget; | ||
const platform = platforms.find((platform) => { | ||
@@ -102,0 +102,0 @@ return platform.name === dataAttr('platform', elem); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12385