From ba1842bd2162d4fa3c7189621825afd765bea5fa Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Sat, 14 Apr 2012 14:39:08 -0700 Subject: Hammer.js instead. Touch working on mobile style sheets now in main .html file. Better for mobile rather than dynamically loading in js matcMedia polyfill --- js/polyfills/matchMedia.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 js/polyfills/matchMedia.js (limited to 'js/polyfills') diff --git a/js/polyfills/matchMedia.js b/js/polyfills/matchMedia.js new file mode 100644 index 0000000..6d4d17c --- /dev/null +++ b/js/polyfills/matchMedia.js @@ -0,0 +1,30 @@ +/*! 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(doc, undefined){ + + var bool, + docElem = doc.documentElement, + refNode = docElem.firstElementChild || docElem.firstChild, + // fakeBody required for + 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 = '­'; + + docElem.insertBefore(fakeBody, refNode); + bool = div.offsetWidth == 42; + docElem.removeChild(fakeBody); + + return { matches: bool, media: q }; + }; + +})(document); + + -- cgit v1.2.3