forked from dolox/fallback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fallback.min.js
9 lines (9 loc) · 3.75 KB
/
fallback.min.js
1
2
3
4
5
6
7
8
9
/* fallback.js v1.1.9 | http://fallback.io/ | Salvatore Garbesi <[email protected]> | (c) 2015 Dolox, Inc. */
(function(l,g){var b={g:[],B:{},C:0,head:g.getElementsByTagName("head")[0],a:{},p:0,q:{},f:[],e:{},m:0,d:{},c:{},s:0,u:function(){for(var a in b.k)b.k[a]&&b.A(b.k[a])},k:["Array","Function","Object","String"],A:function(a){b["is_"+a.toLowerCase()]=function(d){return"undefined"!==typeof d&&Object.prototype.toString.call(d)=="[object "+a+"]"}},i:function(a){this.is_function(a)||(a=function(){});return a},n:function(a,d){for(var c in a)if(a[c]===d)return c;return-1},is_defined:function(a){try{if(eval("window."+
a))return!0}catch(d){}return!1},t:function(a,d){this.is_object(d)&&(d.integrity&&a.setAttribute("integrity",d.integrity),d.crossorigin&&a.setAttribute("crossorigin",d.crossorigin))},importer:function(a,d){var c,b,e,h,m,k,g,l={};for(e in a)if(h=a[e])m=this.is_string(h)?[h]:this.is_object(h)?h.urls:h,this.is_array(m)&&(c=[],this.is_array(this.a[e])&&(c=this.a[e]),l[e]=m,this.a[e]=c.concat(m),this.q[e]=h);h={};if(this.is_object(d)&&(this.is_object(d.shim)||(this.is_object(d.deps)?d.shim=d.deps:this.is_object(d.dependencies)&&
(d.shim=d.dependencies)),this.is_object(d.shim)))for(k in m=d.shim,m)if(c=m[k],this.a[k]&&c&&(this.is_string(c)&&(c=[c]),this.is_array(c))){g=[];for(b in c)e=c[b],this.a[e]&&e!==k&&g.push(e);c=[];this.is_array(this.d[k])&&(c=this.d[k]);h[k]=g;this.d[k]=c.concat(g)}return{a:l,d:h}},css:{}};b.css.l=function(a){if(!g.styleSheets)return!1;var d,c,f;for(d in g.styleSheets)if(c=g.styleSheets[d],0!==c)try{if(c.rules&&(f=b.css.r(c.rules,a))||c.cssRules&&(f=b.css.r(c.cssRules,a)))return f}catch(e){}return!1};
b.css.r=function(a,d){var c,b;for(c in a)if(b=a[c],b.selectorText===d)return!0;return!1};b.load=function(a,d,c){var b,e;if(!this.is_object(a))return!1;this.is_function(d)&&(c=d,d={});this.is_object(d)||(d={});a=this.importer(a,d);for(b in a.a)e=a.a[b],this.d[b]||this.b(b,e);this.is_function(d.callback)&&this.ready([],d.callback);this.is_function(c)&&this.ready([],c)};b.ready=function(a,b){var c,f;if(this.is_function(a))b=a,a=[];else{if(!this.is_array(a)||this.is_string(a))a=[a];for(c in a)f=a[c],
this.a[f]&&!this.d[f]&&this.b(f,this.a[f])}this.g.push({i:this.i(b),a:a});return this.j()};b.j=function(){var a,b,c,f,e,h=[],g=[];for(a in this.g)if(e=this.g[a],this.is_object(e)&&this.is_array(e.a)&&this.is_function(e.i)){f=!1;if(0<e.a.length){b=0;for(c in this.c)0<=this.n(e.a,c)&&b++;b===e.a.length&&(f=!0)}else this.p===this.s+this.m&&(f=!0);f?g.push(e.i):h.push(this.g[a])}this.g=h;for(a in g)g[a](this.c,this.e)};b.w=function(){var a,b,c,f;for(c in this.d)if((f=this.d[c])&&!this.c[c]){a=0;for(b in f)this.c[f[b]]&&
a++;a===f.length&&(this.b(c,this.a[c]),delete this.d[c])}};b.b=function(a,b){if(-1!==this.n(this.f,a))return!1;this.p++;this.f.push(a);return this.b.o(a,b)};b.b.o=function(a,d){var c,f="js",e={loaded:!1,h:a,v:b.q[a],f:!0,url:d.shift(),urls:d};if(-1<e.url.indexOf(".css")){f="css";if(b.css.l(a))return e.f=!1,b.b.c(e);c=g.createElement("link");c.crossorigin=!0;c.rel="stylesheet";c.href=e.url}else{if(b.is_defined(a))return e.f=!1,b.b.c(e);c=g.createElement("script");c.src=e.url}b.t(c,e.v);c.onload=function(){return"js"===
f&&!b.is_defined(a)||"js"!==f&&!b.css.l(a)&&Object.hasOwnProperty.call(l,"ActiveXObject")&&!l.ActiveXObject?b.b.e(e):b.b.c(e)};c.onreadystatechange=function(){if(!this.readyState||"loaded"===this.readyState||"complete"===this.readyState)return this.onreadystatechange=null,"js"!==f||b.is_defined(a)?b.b.c(e):b.b.e(e)};c.onerror=function(){return b.b.e(e)};return b.head.appendChild(c)};b.b.e=function(a){a.f=!1;b.e[a.h]||(b.e[a.h]=[]);b.e[a.h].push(a.url);return a.urls.length?b.b.o(a.h,a.urls):(b.m++,
b.j())};b.b.c=function(a){a.loaded||(a.loaded=!0,b.c[a.h]=a.url,b.s++);b.w();return b.j()};b.u();l.fallback=l.fbk=b})(window,document);