open-consul/website/build/javascripts/respond.min-88c91176.js

2 lines
3.7 KiB
JavaScript
Raw Normal View History

2014-02-08 00:41:03 +00:00
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
window.matchMedia=window.matchMedia||function(t){"use strict";var e,n=t.documentElement,r=n.firstElementChild||n.firstChild,i=t.createElement("body"),o=t.createElement("div");return o.id="mq-test-1",o.style.cssText="position:absolute;top:-100em",i.style.background="none",i.appendChild(o),function(t){return o.innerHTML='&shy;<style media="'+t+'"> #mq-test-1 { width: 42px; }</style>',n.insertBefore(i,r),e=42===o.offsetWidth,n.removeChild(i),{matches:e,media:t}}}(document),function(t){"use strict";function e(){w(!0)}var n={};t.respond=n,n.update=function(){},n.mediaQueriesSupported=t.matchMedia&&t.matchMedia("only all").matches,n.mediaQueriesSupported;var r,i,o,s=t.document,a=s.documentElement,l=[],u=[],c=[],h={},f=30,p=s.getElementsByTagName("head")[0]||a,d=s.getElementsByTagName("base")[0],g=p.getElementsByTagName("link"),m=[],v=function(){for(var e=0;g.length>e;e++){var n=g[e],r=n.href,i=n.media,o=n.rel&&"stylesheet"===n.rel.toLowerCase();r&&o&&!h[r]&&(n.styleSheet&&n.styleSheet.rawCssText?(x(n.styleSheet.rawCssText,r,i),h[r]=!0):(!/^([a-zA-Z:]*\/\/)/.test(r)&&!d||r.replace(RegExp.$1,"").split("/")[0]===t.location.host)&&m.push({href:r,media:i}))}y()},y=function(){if(m.length){var t=m.shift();k(t.href,function(e){x(e,t.href,t.media),h[t.href]=!0,setTimeout(function(){y()},0)})}},x=function(t,e,n){var r=t.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi),i=r&&r.length||0;e=e.substring(0,e.lastIndexOf("/"));var o=function(t){return t.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+e+"$2$3")},s=!i&&n;e.length&&(e+="/"),s&&(i=1);for(var a=0;i>a;a++){var c,h,f,p;s?(c=n,u.push(o(t))):(c=r[a].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1,u.push(RegExp.$2&&o(RegExp.$2))),f=c.split(","),p=f.length;for(var d=0;p>d;d++)h=f[d],l.push({media:h.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/)&&RegExp.$2||"all",rules:u.length-1,hasquery:h.indexOf("(")>-1,minw:h.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:h.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}w()},b=function(){var t,e=s.createElement("div"),n=s.body,r=!1;return e.style.cssText="position:absolute;font-size:1em;width:1em",n||(n=r=s.createElement("body"),n.style.background="none"),n.appendChild(e),a.insertBefore(n,a.firstChild),t=e.offsetWidth,r?a.removeChild(n):n.removeChild(e),t=o=parseFloat(t)},w=function(t){var e="clientWidth",n=a[e],h="CSS1Compat"===s.compatMode&&n||s.body[e]||n,d={},m=g[g.length-1],v=(new Date).getTime();if(t&&r&&f>v-r)return clearTimeout(i),i=setTimeout(w,f),void 0;r=v;for(var y in l)if(l.hasOwnProperty(y)){var x=l[y],k=x.minw,S=x.maxw,M=null===k,C=null===S,T="em";k&&(k=parseFloat(k)*(k.indexOf(T)>-1?o||b():1)),S&&(S=parseFloat(S)*(S.indexOf(T)>-1?o||b():1)),x.hasquery&&(M&&C||!(M||h>=k)||!(C||S>=h))||(d[x.media]||(d[x.media]=[]),d[x.media].push(u[x.rules]))}for(var A in c)c.hasOwnProperty(A)&&c[A]&&c[A].parentNode===p&&p.removeChild(c[A]);for(var _ in d)if(d.hasOwnProperty(_)){var E=s.createElement("style"),L=d[_].join("\n");E.type="text/css",E.media=_,p.insertBefore(E,m.nextSibling),E.styleSheet?E.styleSheet.cssText=L:E.appendChild(s.createTextNode(L)),c.push(E)}},k=function(t,e){var n=S();n&&(n.open("GET",t,!0),n.onreadystatechange=function(){4!==n.readyState||200!==n.status&&304!==n.status||e(n.responseText)},4!==n.readyState&&n.send(null))},S=function(){var e=!1;try{e=new t.XMLHttpRequest}catch(n){e=new t.ActiveXObject("Microsoft.XMLHTTP")}return function(){return e}}();v(),n.update=v,t.addEventListener?t.addEventListener("resize",e,!1):t.attachEvent&&t.attachEvent("onresize",e)}(this);