-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathformfactor-min.js
1 lines (1 loc) · 3.29 KB
/
formfactor-min.js
1
(function(){window.matchMedia||(window.matchMedia=function(a,b){var c,d=a.documentElement,e=a.createElement("body"),f=a.createElement("div");f.setAttribute("id","ejs-qtest"),e.appendChild(f);return function(b){var g=a.createElement("style"),h="@media "+b+" { #ejs-qtest { position: absolute; } }";g.type="text/css",g.styleSheet?g.styleSheet.cssText=h:g.appendChild(a.createTextNode(h)),d.insertBefore(e,d.firstChild),d.insertBefore(g,d.firstChild),c=(window.getComputedStyle?window.getComputedStyle(f,null):f.currentStyle).position=="absolute",d.removeChild(e),d.removeChild(g);return{matches:c,media:b}}}(document));var a="__formfactorJSOverride=",b={excss:{tag:"link",rel:"stylesheet",urlKind:"href",type:"text/excss"},less:{tag:"link",rel:"stylesheet/less",urlKind:"href",type:"text/css"},css:{tag:"link",rel:"stylesheet",urlKind:"href",type:"text/css"},js:{tag:"script",urlKind:"src",type:"text/javascript"},coffee:{tag:"script",urlKind:"src",type:"text/coffescript"}},c=function(a){var b=matchMedia(a);return b.matches},d=function(a){return typeof a=="function"&&a()||typeof a=="boolean"&&a||typeof a=="string"&&c(a)},e=document.head||document.getElementsByTagName("head")[0],f={},g=function(a){var b=f[a],c;for(var e=0;c=b[e];e++)if(d(c))return!0;return!1},h=function(a,c,d,e,f){var g=a.substring(a.lastIndexOf(".")+1),h=b[g]||{type:f,rel:d,urlKind:e},i=document.createElement(h.tag||c);h.rel&&(i.rel=h.rel),h.type&&(i.type=h.type),i[h.urlKind]=a;return i},i=function(){var a=[],b;this.enqueue=function(c){a.push(c),!!b==!1&&(b=a.shift(),this.download())};var c=this.download=function(){b.onload=b.onreadystatechange=d,e.appendChild(b)},d=function(d){if(d.type=="load"||b.readyState=="complete"||b.readyState=="loaded")b=a.shift(),b&&c()}},j=function(a){a.callbacks=a.callbacks||function(){},a.resources=a.resources||[];var b=new i;if(typeof a.resources=="string")e.appendChild(h(a.resources));else if(a.resources instanceof Array){var c;for(var d=0;c=a.resources[d];d++){var f;typeof c=="string"?f=h(c):f=h(c.href,c.tag,c.rel,c.urlKind,c.type),f.localName=="script"?b.enqueue(f):e.appendChild(f)}}if(typeof a.callbacks=="function")a.callbacks(a.formfactor);else if(a.callbacks instanceof Array){var g;for(var j=0;g=a.callbacks;j++)g(a.formfactor)}if(document.querySelector){var k=document.querySelector("html");k.classList&&k.classList.add(a.formfactor)}},k=function(a){var b={};b[a]={};return o(b)==a},l=function(a){return!k(a)},m=function(){var b=document.cookie.split(";");for(var c=0;c<b.length;c++){var d=b[c];while(d.charAt(0)==" ")d=d.substring(1,d.length);if(d.indexOf(a)==0)return d.substring(a.length,d.length)}return null},n=function(b,c){var d=a+b;c.domain&&(d+="; Domain="+c.domain),c.path&&(d+="; Path="+c.path),document.cookie=d},o=function(a,b,c){b=b||{resources:[],callbacks:function(){}},c=c||function(){};var d,e=m();if(!!e==!1){for(var f=0;d=a[f];f++)if(g(d.formfactor)){j(d),c(d.formfactor);return d.formfactor}}else if(e!="default")for(var f=0;d=a[f];f++)if(d.formfactor==e){j(d),c(d.formfactor);return d.formfactor}j(b),c();return},p=function(a){for(var b in a)f[b]=a[b]},q=function(){var a=[];for(var b=0;formfactorAction=formfactorActions[b];b++)a.pushr(formfactorAction.formfactor);return a},r=function(a,b){if(!!f[a]==!1)throw"Unknown Formfactor";n(a,b)};window.formfactor={register:p,detect:o,factors:q,override:r,is:k,isnt:l}})()