-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzload.min.js
7 lines (7 loc) · 3.45 KB
/
zload.min.js
1
2
3
4
5
6
7
/**
* $zload - version 3.3 - Copyright (c) 2012-2017 Infotoo International Limited - http://www.infotoo.com (MIT license)
*
* Required LazyLoad 2.0.3 - Copyright (c) 2011 Ryan Grove <[email protected]> - https://github.com/rgrove/lazyload/ (MIT license)
* Last updated: 2017-05-04
*/
(function(u){var n=function(){j(arguments)};n.map={};n.version="3.3";var h={},p,c,d=u.styleSheets,g={},k=0,b={css:[],js:[]};var o=function(x,w){if(!n.map[x]){n.map[x]=w}else{for(var y in w){n.map[x][y]=w[y]}}};var f=function(x){if(!n.map[x]){return}if(n.map[x].isReady){e(x);return}if(n.map[x].isLoad){return}if(n.map[x].load&&typeof(n.map[x].load)=="function"){n.map[x].load()}else{n.map[x].isLoad=1;var z=((n.map[x].js)?n.map[x].js.length:0)+((n.map[x].css)?n.map[x].css.length:0)+((n.map[x].uses)?n.map[x].uses.length:0);var A=(n.map[x].fn)?n.map[x].fn.length:0;var v=0;var w=function(){z-=1;if(z<=0){if(v<A){v+=1;(function(B){if(typeof(B)=="function"){setTimeout(function(){B(w)},1)}else{w()}})(n.map[x].fn[v-1])}else{n.map[x].isReady=1;e(x)}}};if(n.map[x].uses){for(var y=0;y<n.map[x].uses.length;y++){$zload(n.map[x].uses[y],w)}}if(n.map[x].css){for(var y=0;y<n.map[x].css.length;y++){t("css",n.map[x].css[y],w)}}if(n.map[x].js){for(var y=0;y<n.map[x].js.length;y++){t("js",n.map[x].js[y],w)}}}};var j=function(w){if(typeof(w[0])=="string"){var y=w[0];if(w.length>1){for(var z=1;z<w.length;z++){var x=w[z];if(typeof(x)=="object"){o(y,x)}else{if(typeof(x)=="function"){i(y,x)}else{if(typeof(x)=="number"){setTimeout(function(){f(y)},x)}}}}}f(y)}};var i=function(v,w){if(!h[v]){h[v]=[]}h[v].push(w)};var e=function(v){if(h[v]&&h[v].length>0){var w=h[v].shift();setTimeout(function(){e(v)},1);w()}};var r=function(x,w){var y=u.createElement(x),v;for(v in w){if(w.hasOwnProperty(v)){y.setAttribute(v,w[v])}}return y};var s=function(v){var x=g[v],y,w;if(x){y=x.callback;w=x.urls;w.shift();k=0;if(!w.length){y&&y.call();g[v]=null;b[v].length&&t(v)}}};var l=function(){var v=navigator.userAgent;p={async:u.createElement("script").async===true};(p.webkit=/AppleWebKit\//.test(v))||(p.ie=/MSIE/.test(v))||(p.opera=/Opera/.test(v))||(p.gecko=/Gecko\//.test(v))||(p.unknown=true)};var a={Version:function(){var v=999;if(navigator.appVersion.indexOf("MSIE")!=-1){v=parseFloat(navigator.appVersion.split("MSIE")[1])}return v}};var t=function(E,D,F){var z=function(){s(E)},G=E==="css",w=[],A,B,y,x,C,v;p||l();if(D){D=typeof D==="string"?[D]:D.concat();if(G||p.async||p.gecko||p.opera){b[E].push({urls:D,callback:F})}else{for(A=0,B=D.length;A<B;++A){b[E].push({urls:[D[A]],callback:A===B-1?F:null})}}}if(g[E]||!(x=g[E]=b[E].shift())){return}c||(c=u.head||u.getElementsByTagName("head")[0]);C=x.urls;for(A=0,B=C.length;A<B;++A){v=C[A];if(G){y=p.gecko?r("style"):r("link",{href:v,rel:"stylesheet"})}else{y=r("script",{src:v});y.async=false}y.className="lazyload";y.setAttribute("charset","utf-8");if(p.ie&&!G&&a.Version()<10){y.onreadystatechange=function(){if(/loaded|complete/.test(y.readyState)){y.onreadystatechange=null;z()}}}else{if(G&&(p.gecko||p.webkit)){if(p.webkit){x.urls[A]=y.href;q()}else{y.innerHTML='@import "'+v+'";';m(y)}}else{y.onload=y.onerror=z}}w.push(y)}for(A=0,B=w.length;A<B;++A){c.appendChild(w[A])}};var m=function(x){var w;try{w=!!x.sheet.cssRules}catch(v){k+=1;if(k<200){setTimeout(function(){m(x)},50)}else{w&&s("css")}return}s("css")};var q=function(){var w=g.css,v;if(w){v=d.length;while(--v>=0){if(d[v].href===w.urls[0]){s("css");break}}k+=1;if(w){if(k<200){setTimeout(q,50)}else{s("css")}}}};window.$zload=n})(this.document);