aboutsummaryrefslogtreecommitdiff
path: root/js/polyfills
diff options
context:
space:
mode:
authorEric Bidelman2012-04-14 14:39:08 -0700
committerEric Bidelman2012-04-14 14:39:08 -0700
commitba1842bd2162d4fa3c7189621825afd765bea5fa (patch)
treea001e4f56275a0c19ce889b5aa44c2d7dc34e6c7 /js/polyfills
parent92d59f701df13fe8e99d2c908dcf18450c53b762 (diff)
downloadio-slides-remote-ba1842bd2162d4fa3c7189621825afd765bea5fa.tar.gz
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
Diffstat (limited to 'js/polyfills')
-rw-r--r--js/polyfills/matchMedia.js30
1 files changed, 30 insertions, 0 deletions
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 @@
1/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
2
3window.matchMedia = window.matchMedia || (function(doc, undefined){
4
5 var bool,
6 docElem = doc.documentElement,
7 refNode = docElem.firstElementChild || docElem.firstChild,
8 // fakeBody required for <FF4 when executed in <head>
9 fakeBody = doc.createElement('body'),
10 div = doc.createElement('div');
11
12 div.id = 'mq-test-1';
13 div.style.cssText = "position:absolute;top:-100em";
14 fakeBody.style.background = "none";
15 fakeBody.appendChild(div);
16
17 return function(q){
18
19 div.innerHTML = '&shy;<style media="'+q+'"> #mq-test-1 { width: 42px; }</style>';
20
21 docElem.insertBefore(fakeBody, refNode);
22 bool = div.offsetWidth == 42;
23 docElem.removeChild(fakeBody);
24
25 return { matches: bool, media: q };
26 };
27
28})(document);
29
30