summaryrefslogtreecommitdiff
path: root/bower_components/respond/src/matchmedia.polyfill.js
diff options
context:
space:
mode:
Diffstat (limited to 'bower_components/respond/src/matchmedia.polyfill.js')
-rw-r--r--bower_components/respond/src/matchmedia.polyfill.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/bower_components/respond/src/matchmedia.polyfill.js b/bower_components/respond/src/matchmedia.polyfill.js
new file mode 100644
index 00000000..12d2b95f
--- /dev/null
+++ b/bower_components/respond/src/matchmedia.polyfill.js
@@ -0,0 +1,36 @@
+/*! 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(w){
+ "use strict";
+ w.matchMedia = w.matchMedia || (function( doc, undefined ) {
+
+ var bool,
+ docElem = doc.documentElement,
+ refNode = docElem.firstElementChild || docElem.firstChild,
+ // fakeBody required for <FF4 when executed in <head>
+ 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 = "&shy;<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 ));