38f959890d
create new build tools.
1 line
4.3 KiB
JavaScript
1 line
4.3 KiB
JavaScript
!function(e){"use strict";var t,n,a,s,i,r;e.matchMedia=e.matchMedia||(t=e.document,a=t.documentElement,s=a.firstElementChild||a.firstChild,i=t.createElement("body"),(r=t.createElement("div")).id="mq-test-1",r.style.cssText="position:absolute;top:-100em",i.style.background="none",i.appendChild(r),function(e){return r.innerHTML='­<style media="'+e+'"> #mq-test-1 { width: 42px; }</style>',a.insertBefore(i,s),n=42===r.offsetWidth,a.removeChild(i),{matches:n,media:e}})}(this),function(y){"use strict";var c={};(y.respond=c).update=function(){};function e(e,t){var n=a();n&&(n.open("GET",e,!0),n.onreadystatechange=function(){4!==n.readyState||200!==n.status&&304!==n.status||t(n.responseText)},4!==n.readyState&&n.send(null))}function p(e){return e.replace(c.regex.minmaxwh,"").match(c.regex.other)}var x,v,E,w,S,i,T,r,C,b,$,z,M,R,o,l,t,m=[],a=function(){var t=!1;try{t=new y.XMLHttpRequest}catch(e){t=new y.ActiveXObject("Microsoft.XMLHTTP")}return function(){return t}}();function n(){R(!0)}c.ajax=e,c.queue=m,c.unsupportedmq=p,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=y.matchMedia&&null!==y.matchMedia("only all")&&y.matchMedia("only all").matches,c.mediaQueriesSupported||(x=y.document,v=x.documentElement,E=[],w=[],S=[],i={},T=x.getElementsByTagName("head")[0]||v,r=x.getElementsByTagName("base")[0],C=T.getElementsByTagName("link"),M=function(){var e,t=x.createElement("div"),n=x.body,a=v.style.fontSize,s=n&&n.style.fontSize,i=!1;return t.style.cssText="position:absolute;font-size:1em;width:1em",n||((n=i=x.createElement("body")).style.background="none"),v.style.fontSize="100%",n.style.fontSize="100%",n.appendChild(t),i&&v.insertBefore(n,v.firstChild),e=t.offsetWidth,i?v.removeChild(n):n.removeChild(t),v.style.fontSize=a,s&&(n.style.fontSize=s),e=z=parseFloat(e)},R=function(e){var t,n,a,s,i,r,o,l="clientWidth",m=v[l],d="CSS1Compat"===x.compatMode&&m||x.body[l]||m,h={},u=C[C.length-1],c=(new Date).getTime();if(e&&b&&c-b<30)return y.clearTimeout($),void($=y.setTimeout(R,30));for(var p in b=c,E){E.hasOwnProperty(p)&&(n=null===(s=(t=E[p]).minw),a=null===(i=t.maxw),s=s&&parseFloat(s)*(-1<s.indexOf("em")?z||M():1),i=i&&parseFloat(i)*(-1<i.indexOf("em")?z||M():1),t.hasquery&&(n&&a||!(n||s<=d)||!(a||d<=i))||(h[t.media]||(h[t.media]=[]),h[t.media].push(w[t.rules])))}for(var f in S)S.hasOwnProperty(f)&&S[f]&&S[f].parentNode===T&&T.removeChild(S[f]);for(var g in S.length=0,h){h.hasOwnProperty(g)&&(r=x.createElement("style"),o=h[g].join("\n"),r.type="text/css",r.media=g,T.insertBefore(r,u.nextSibling),r.styleSheet?r.styleSheet.cssText=o:r.appendChild(x.createTextNode(o)),S.push(r))}},o=function(e,t,n){function a(e){return e.replace(c.regex.urls,"$1"+t+"$2$3")}var s=e.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),i=s&&s.length||0,r=!i&&n;(t=t.substring(0,t.lastIndexOf("/"))).length&&(t+="/"),r&&(i=1);for(var o,l,m,d,h=0;h<i;h++){r?(o=n,w.push(a(e))):(o=s[h].match(c.regex.findStyles)&&RegExp.$1,w.push(RegExp.$2&&a(RegExp.$2))),d=(m=o.split(",")).length;for(var u=0;u<d;u++)l=m[u],p(l)||E.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:w.length-1,hasquery:-1<l.indexOf("("),minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}R()},l=function(){var t;m.length&&(t=m.shift(),e(t.href,function(e){o(e,t.href,t.media),i[t.href]=!0,y.setTimeout(function(){l()},0)}))},(t=function(){for(var e=0;e<C.length;e++){var t=C[e],n=t.href,a=t.media,s=t.rel&&"stylesheet"===t.rel.toLowerCase();n&&s&&!i[n]&&(t.styleSheet&&t.styleSheet.rawCssText?(o(t.styleSheet.rawCssText,n,a),i[n]=!0):(/^([a-zA-Z:]*\/\/)/.test(n)||r)&&n.replace(RegExp.$1,"").split("/")[0]!==y.location.host||("//"===n.substring(0,2)&&(n=y.location.protocol+n),m.push({href:n,media:a})))}l()})(),c.update=t,c.getEmValue=M,y.addEventListener?y.addEventListener("resize",n,!1):y.attachEvent&&y.attachEvent("onresize",n))}(this); |