sharelinks
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "sharelinks", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "Mr Chimp <chimpytk@gmail.com>" |
@@ -83,3 +83,3 @@ (function (root, factory) { | ||
elem = e.currentTarget, | ||
platform = platforms[elem.dataset['platform']] || false; | ||
platform = platforms[elem.dataset.platform] || false; | ||
@@ -104,3 +104,3 @@ if (typeof platform === 'undefined') { | ||
elements.forEach(function (element) { | ||
Array.prototype.forEach.call(elements, function (element) { | ||
var share_url, dest, title, image, | ||
@@ -121,3 +121,3 @@ platform = platforms[element.dataset.platform] || false; | ||
element.setAttribute('href', share_url) | ||
element.setAttribute('href', share_url); | ||
@@ -124,0 +124,0 @@ if (element.addEventListener) { |
@@ -1,1 +0,1 @@ | ||
(function(root,factory){if(typeof define==="function"&&define.amd){define([],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory()}else{root.sharelinks=factory()}})(this,function(){var platforms={facebook:{href:"https://www.facebook.com/sharer/sharer.php?u=%URL%",width:400,height:500},twitter:{href:"https://twitter.com/intent/tweet?status=%TITLE%+-+%URL%",width:540,height:260},tumblr:{href:"http://www.tumblr.com/share/link?url=%URL%",width:500,height:500},google:{href:"https://plus.google.com/share?url=%URL%",width:600,height:600},linkedin:{href:"http://www.linkedin.com/shareArticle?mini=true&url=%URL%&title=%TITLE%",width:520,height:570},pinterest:{href:"http://pinterest.com/pin/create/button/?url=%URL%&description=%TITLE%&media=%IMAGE%",width:520,height:570}};var elements;return function(selector){elements=document.querySelectorAll(selector);function makeLink(platform,url,title,image){return platform.href.replace("%URL%",encodeURIComponent(url).replace(/%20/g,"+")).replace("%TITLE%",encodeURIComponent(title).replace(/%20/g,"+")).replace("%IMAGE%",encodeURIComponent(image).replace(/%20/g,"+"))}function findImage(){var og_image=document.querySelector('meta[property="og:image"]');var image="";if(og_image){image=og_image.getAttribute("content")}else{var images=document.getElementsByTagName("img");if(images.length>0){image=images[0].getAttribute("src")}}return image}function handleClick(e){if(e.which==1){e.preventDefault();var width,height,image,href,platform=platforms[e.target.dataset["platform"]]||false,elem=e.target;if(typeof platform==="undefined"){throw"Sharelinks Error: Invalid data-platform: "+$(this).data("platform")}width=elem.dataset.width||platform.width;height=elem.dataset.height||platform.height;image=elem.dataset.image||findImage();if(elem.dataset.url){href=makeLink(platform,elem.dataset.url,elem.dataset.title,image)}else{href=elem.getAttribute("href")}window.open(href,"","status=yes, width="+width+", height="+height)}}elements.forEach(function(element){var share_url,dest,title,image,platform=platforms[element.dataset.platform]||false;if(!platform){if(typeof console.error==="function"){console.error("Sharelinks Error: Invalid data-platform: "+element.dataset.platform)}}else{dest=element.dataset.url||window.location.href;title=element.dataset.title||document.title;image=element.dataset.image||findImage();share_url=makeLink(platform,dest,title,image);element.setAttribute("href",share_url);if(element.addEventListener){element.addEventListener("click",handleClick,false)}else{element.attachEvent("onclick",handleClick)}}})}}); | ||
(function(root,factory){if(typeof define==="function"&&define.amd){define([],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory()}else{root.sharelinks=factory()}})(this,function(){var platforms={facebook:{href:"https://www.facebook.com/sharer/sharer.php?u=%URL%",width:400,height:500},twitter:{href:"https://twitter.com/intent/tweet?status=%TITLE%+-+%URL%",width:540,height:260},tumblr:{href:"http://www.tumblr.com/share/link?url=%URL%",width:500,height:500},google:{href:"https://plus.google.com/share?url=%URL%",width:600,height:600},linkedin:{href:"http://www.linkedin.com/shareArticle?mini=true&url=%URL%&title=%TITLE%",width:520,height:570},pinterest:{href:"http://pinterest.com/pin/create/button/?url=%URL%&description=%TITLE%&media=%IMAGE%",width:520,height:570}};var elements;return function(selector){elements=document.querySelectorAll(selector);function makeLink(platform,url,title,image){return platform.href.replace("%URL%",encodeURIComponent(url).replace(/%20/g,"+")).replace("%TITLE%",encodeURIComponent(title).replace(/%20/g,"+")).replace("%IMAGE%",encodeURIComponent(image).replace(/%20/g,"+"))}function findImage(){var image="";var og_image=document.querySelector('meta[property="og:image"]');if(og_image){image=og_image.getAttribute("content")}else{var images=document.getElementsByTagName("img");if(images.length>0){image=images[0].getAttribute("src")}}return image}function handleClick(e){if(e.which==1){e.preventDefault();var width,height,image,href,elem=e.currentTarget,platform=platforms[elem.dataset.platform]||false;if(typeof platform==="undefined"){throw"Sharelinks Error: Invalid data-platform: "+$(this).data("platform")}width=elem.dataset.width||platform.width;height=elem.dataset.height||platform.height;image=elem.dataset.image||findImage();if(elem.dataset.url){href=makeLink(platform,elem.dataset.url,elem.dataset.title,image)}else{href=elem.getAttribute("href")}window.open(href,"","status=yes, width="+width+", height="+height)}}Array.prototype.forEach.call(elements,function(element){var share_url,dest,title,image,platform=platforms[element.dataset.platform]||false;if(!platform){if(typeof console.error==="function"){console.error("Sharelinks Error: Invalid data-platform: "+element.dataset.platform)}}else{dest=element.dataset.url||window.location.href;title=element.dataset.title||document.title;image=element.dataset.image||findImage();share_url=makeLink(platform,dest,title,image);element.setAttribute("href",share_url);if(element.addEventListener){element.addEventListener("click",handleClick,false)}else{element.attachEvent("onclick",handleClick)}}})}}); |
{ | ||
"name": "sharelinks", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"repository": "git@github.com/mrchimp/sharelinks", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
13896