123456789101112131415161718192021222324252627282930313233343536 |
- (function(w){
- "use strict";
- w.matchMedia = w.matchMedia || (function( doc, undefined ) {
- var bool,
- docElem = doc.documentElement,
- refNode = docElem.firstElementChild || docElem.firstChild,
-
- fakeBody = doc.createElement( "body" ),
- div = doc.createElement( "div" );
- div.id = "mq-test-1";
- div.style.cssText = "position:absolute;top:-100em";
- fakeBody.style.background = "none";
- fakeBody.appendChild(div);
- return function(q){
- div.innerHTML = "­<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
- docElem.insertBefore( fakeBody, refNode );
- bool = div.offsetWidth === 42;
- docElem.removeChild( fakeBody );
- return {
- matches: bool,
- media: q
- };
- };
- }( w.document ));
- }( this ));
|