forked from pyrsmk/mediatizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmediatizr-0.3.0.Sheethub.min.js
1 lines (1 loc) · 2.58 KB
/
mediatizr-0.3.0.Sheethub.min.js
1
this.Sheethub=function(){var e=document,t="getElementsByTagName",n=e[t]("head")[0],r="removeChild",i="parentNode",s={},o=!1,u=[],a=0,f,l=[],c=e[t]("link"),h=e[t]("style"),p,d,v=function(){if(!--a){o=!0;var e=u.length;while(e)u[--e]()}},m=function(t){var s,o=!1,u=[],a,f="appendChild",l="styleSheet",c,h=function(){n[f](s=e.createElement("style")),s[l]||s[f](e.createTextNode(""))},p=function(){o=!0,c=u.length;while(c)u[--c]()},d={listen:function(e){u.push(e)},ready:function(){return o},set:function(e){s.tagName=="LINK"&&(s[i][r](s),h()),s[l]?s[l].cssText=e:s.firstChild.nodeValue=e,a=e},get:function(){return a},node:function(){return s}},v=function(){n?typeof t=="object"?(s=t,s.tagName=="LINK"?(this.XMLHttpRequest?c=new XMLHttpRequest:c=new ActiveXObject("Microsoft.XMLHTTP"),c.open("GET",s.href,!0),c.onreadystatechange=function(){c.readyState==4&&(a=c.responseText.replace(/\.\.\//g,""),p())},c.send(null)):a=s[l]?s[l].cssText:s.innerHTML):(h(),typeof t=="string"&&d.set(t),p()):setTimeout(v,250)};return v(),d},g={listen:function(e){u.push(e)},ready:function(){return o},list:function(){return s},has:function(e){return s[e]},add:function(e,t){g.has(e)||(s[e]=new m(t))},get:function(e){if(!e)return s;if(g.has(e))return s[e]},remove:function(e){g.has(e)&&(p=s[e].node(),p[i][r](p),delete s[e])}};p=-1;while(d=c[++p])d.rel.toLowerCase()=="stylesheet"&&(l.push(d),++a);p=h.length;while(p)l.push(h[--p]);p=-1;while(f=l[++p])!(d=f.title)&&f.href&&(d="sheet"+Math.round(Math.random()*9e3+1e3)),d&&(g.add(d,f),s[d].ready()?v():s[d].listen(v));return g}();(function(){var e=window,t=document,n=t.documentElement,r=e.Sheethub,i="mediatizr",s="get",o="node",u,a=function(){var e=r[s](),t,n={},u,a,f,l,c,h,p,d="indexOf",v,m=function(){var e,t,i,u,a,f;for(e in n){u=n[e].split("and"),t=-1;while(u[++t])i=u[t].match(/\(\s*(.+?)\s*:\s*(.+?)(px|em)\s*\)/),a=W(i[3]=="em"),f=i[2],r[s](e)[o]().disabled=i[1][d]("min")?a>f:a<f}},g=function(e){var t,n,r=0,i=0;while(t!=-1||n!=-1){t=e[d]("{",r),n=e[d]("}",r),n>t&&t!=-1?(++i,r=t+1):(--i,r=n+1);if(!i)return n}return-1};v=0;for(t in e)if(!t.match("^"+i)){f=e[t][s](),p=0;while((l=f[d]("@media",p))!=-1){c=g(f.substr(l));if(h=f.substr(l+6,c-4).match(/([\S\s]+?)and([\S\s]+?)\{([\S\s]+)/i))r.add(u=i+ ++v+t,h[3]),a=r[s](u)[o](),a.media=h[1],n[u]=(h[2]+"").toLowerCase(),a.disabled=!0;p=l+c}}W(m),m()};(e.supportMediaQueries=function(){return e.matchMedia?!0:(u=t.createElement("p"),u.id=i,u.style.position="absolute",u.style.top="-99em",n.appendChild(u),r.add(i,"#"+i+"{width:9px}"),r[s](i)[o]().media="only all",u.offsetWidth==9&&!r.remove(i)&&!!n.removeChild(u))}())||(r.ready()?a():r.listen(a))})();