You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

7 lines
4.9 KiB

/* Respond.js v1.4.2: min/max-width media query polyfill
* Copyright 2013 Scott Jehl
* Licensed under MIT
* http://j.mp/respondjs */
/* matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
/* NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
(function(a){a.matchMedia=a.matchMedia||function(f,g){var d,b=f.documentElement,c=b.firstElementChild||b.firstChild,e=f.createElement("body"),h=f.createElement("div");h.id="mq-test-1";h.style.cssText="position:absolute;top:-100em";e.style.background="none";e.appendChild(h);return function(i){h.innerHTML='&shy;<style media="'+i+'"> #mq-test-1 { width: 42px; }</style>';b.insertBefore(e,c);d=h.offsetWidth===42;b.removeChild(e);return{matches:d,media:i}}}(a.document)})(this);(function(k){var u={};k.respond=u;u.update=function(){};var c=[],d=function(){var w=false;try{w=new k.XMLHttpRequest()}catch(A){w=new k.ActiveXObject("Microsoft.XMLHTTP")}return function(){return w}}(),n=function(w,B){var A=d();if(!A){return}A.open("GET",w,true);A.onreadystatechange=function(){if(A.readyState!==4||A.status!==200&&A.status!==304){return}B(A.responseText)};if(A.readyState===4){return}A.send(null)},r=function(w){return w.replace(u.regex.minmaxwh,"").match(u.regex.other)};u.ajax=n;u.queue=c;u.unsupportedmq=r;u.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};u.mediaQueriesSupported=k.matchMedia&&k.matchMedia("only all")!==null&&k.matchMedia("only all").matches;if(u.mediaQueriesSupported){return}var z=k.document,t=z.documentElement,h=[],j=[],q=[],o={},g=30,e=z.getElementsByTagName("head")[0]||t,f=z.getElementsByTagName("base")[0],b=e.getElementsByTagName("link"),l,s,p,y=function(){var B,E=z.createElement("div"),w=z.body,D=t.style.fontSize,C=w&&w.style.fontSize,A=false;E.style.cssText="position:absolute;font-size:1em;width:1em";if(!w){w=A=z.createElement("body");w.style.background="none"}t.style.fontSize="100%";w.style.fontSize="100%";w.appendChild(E);if(A){t.insertBefore(w,t.firstChild)}B=E.offsetWidth;if(A){t.removeChild(w)}else{w.removeChild(E)}t.style.fontSize=D;if(C){w.style.fontSize=C}B=p=parseFloat(B);return B},i=function(L){var Q="clientWidth",C=t[Q],A=z.compatMode==="CSS1Compat"&&C||z.body[Q]||C,O={},P=b[b.length-1],B=new Date().getTime();if(L&&l&&B-l<g){k.clearTimeout(s);s=k.setTimeout(i,g);return}else{l=B}for(var J in h){if(h.hasOwnProperty(J)){var M=h[J],F=M.minw,I=M.maxw,K=F===null,N=I===null,w="em";if(!!F){F=parseFloat(F)*(F.indexOf(w)>-1?p||y():1)}if(!!I){I=parseFloat(I)*(I.indexOf(w)>-1?p||y():1)}if(!M.hasquery||(!K||!N)&&(K||A>=F)&&(N||A<=I)){if(!O[M.media]){O[M.media]=[]}O[M.media].push(j[M.rules])}}}for(var H in q){if(q.hasOwnProperty(H)){if(q[H]&&q[H].parentNode===e){e.removeChild(q[H])}}}q.length=0;for(var G in O){if(O.hasOwnProperty(G)){var E=z.createElement("style"),D=O[G].join("\n");E.type="text/css";E.media=G;e.insertBefore(E,P.nextSibling);if(E.styleSheet){E.styleSheet.cssText=D}else{E.appendChild(z.createTextNode(D))}q.push(E)}}},m=function(K,w,B){var I=K.replace(u.regex.comments,"").replace(u.regex.keyframes,"").match(u.regex.media),L=I&&I.length||0;w=w.substring(0,w.lastIndexOf("/"));var A=function(M){return M.replace(u.regex.urls,"$1"+w+"$2$3")},C=!L&&B;if(w.length){w+="/"}if(C){L=1}for(var F=0;F<L;F++){var G,H,D,J;if(C){G=B;j.push(A(K))}else{G=I[F].match(u.regex.findStyles)&&RegExp.$1;j.push(RegExp.$2&&A(RegExp.$2))}D=G.split(",");J=D.length;for(var E=0;E<J;E++){H=D[E];if(r(H)){continue}h.push({media:H.split("(")[0].match(u.regex.only)&&RegExp.$2||"all",rules:j.length-1,hasquery:H.indexOf("(")>-1,minw:H.match(u.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:H.match(u.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}i()},x=function(){if(c.length){var w=c.shift();n(w.href,function(A){m(A,w.href,w.media);o[w.href]=true;k.setTimeout(function(){x()},0)})}},a=function(){for(var C=0;C<b.length;C++){var B=b[C],A=B.href,D=B.media,w=B.rel&&B.rel.toLowerCase()==="stylesheet";if(!!A&&w&&!o[A]){if(B.styleSheet&&B.styleSheet.rawCssText){m(B.styleSheet.rawCssText,A,D);o[A]=true}else{if(!/^([a-zA-Z:]*\/\/)/.test(A)&&!f||A.replace(RegExp.$1,"").split("/")[0]===k.location.host){if(A.substring(0,2)==="//"){A=k.location.protocol+A}c.push({href:A,media:D})}}}}x()};a();u.update=a;u.getEmValue=y;function v(){i(true)}if(k.addEventListener){k.addEventListener("resize",v,false)}else{if(k.attachEvent){k.attachEvent("onresize",v)}}})(this);