1 |
74f6bef0
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
window.matchMedia = window.matchMedia || (function( doc, undefined ) {
|
4 |
|
|
|
5 |
|
|
"use strict";
|
6 |
|
|
|
7 |
|
|
var bool,
|
8 |
|
|
docElem = doc.documentElement,
|
9 |
|
|
refNode = docElem.firstElementChild || docElem.firstChild,
|
10 |
|
|
|
11 |
|
|
fakeBody = doc.createElement( "body" ),
|
12 |
|
|
div = doc.createElement( "div" );
|
13 |
|
|
|
14 |
|
|
div.id = "mq-test-1";
|
15 |
|
|
div.style.cssText = "position:absolute;top:-100em";
|
16 |
|
|
fakeBody.style.background = "none";
|
17 |
|
|
fakeBody.appendChild(div);
|
18 |
|
|
|
19 |
|
|
return function(q){
|
20 |
|
|
|
21 |
|
|
div.innerHTML = "­<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
|
22 |
|
|
|
23 |
|
|
docElem.insertBefore( fakeBody, refNode );
|
24 |
|
|
bool = div.offsetWidth === 42;
|
25 |
|
|
docElem.removeChild( fakeBody );
|
26 |
|
|
|
27 |
|
|
return {
|
28 |
|
|
matches: bool,
|
29 |
|
|
media: q
|
30 |
|
|
};
|
31 |
|
|
|
32 |
|
|
};
|
33 |
|
|
|
34 |
|
|
}( document ));
|
35 |
|
|
|