Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "prefetch", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Customizable interaction-based link prefetching.", | ||
@@ -5,0 +5,0 @@ "main": "prefetch.js", |
@@ -0,1 +1,6 @@ | ||
/** | ||
* Copyright (c) 2015 Joe Podwys | ||
* Copyright (c) 2014-2015 Alexandre Dieulot (For segments taken from InstantClick.js) | ||
*/ | ||
(function (root, factory) { | ||
@@ -18,2 +23,3 @@ if (typeof exports === 'object') module.exports = factory(); | ||
self.addContainers(config.containers); | ||
return self; | ||
} | ||
@@ -87,7 +93,5 @@ | ||
function isExcluded(a){ | ||
if(self.$exclusions.length){ | ||
for(var i = 0; i < self.$exclusions.length; ++i){ | ||
if(a.href.indexOf(self.$exclusions[i]) > -1){ | ||
return true; | ||
} | ||
for(var i = 0; i < self.$exclusions.length; ++i){ | ||
if(a.href.indexOf(self.$exclusions[i]) > -1){ | ||
return true; | ||
} | ||
@@ -109,13 +113,19 @@ } | ||
function createLinkTag(url){ | ||
var link = document.createElement('link'); | ||
link.setAttribute('rel', 'prefetch'); | ||
link.setAttribute('href', url); | ||
return link; | ||
} | ||
function injectPrefetchLink(a){ | ||
if(a && isPrefetchable(a)){ | ||
var url = (typeof a === 'object') ? a.href : a; | ||
var link = document.createElement('link'); | ||
link.setAttribute('rel', 'prefetch'); | ||
link.setAttribute('href', url); | ||
if(!a) return; | ||
var url = (typeof a === 'object') ? a.href : a; | ||
var link = (url) ? createLinkTag(url) : null; | ||
if(link){ | ||
document.getElementsByTagName('head')[0].appendChild(link); | ||
if(typeof a === 'object'){ | ||
a.setAttribute('data-no-prefetch', ''); | ||
} | ||
} | ||
if(typeof a === 'object'){ | ||
a.setAttribute('data-no-prefetch', ''); | ||
} | ||
} | ||
@@ -130,5 +140,3 @@ | ||
function mousedown(e){ | ||
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)){ | ||
return; | ||
} | ||
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)) return; | ||
var a = getLinkTarget(e.target); | ||
@@ -139,5 +147,3 @@ injectPrefetchLink(a); | ||
function mouseover(e){ | ||
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)){ | ||
return; | ||
} | ||
if(self.$lastTouchTimestamp > (new Date().getTime() - 500)) return; | ||
var a = getLinkTarget(e.target); | ||
@@ -176,3 +182,3 @@ if(a && isPrefetchable(a)){ | ||
return new Prefetch(); | ||
return new Prefetch().init(); | ||
}); |
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
9521
158