summaryrefslogtreecommitdiff
path: root/lib/tpl
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2012-09-25 19:47:10 +0100
committerAnika Henke <anika@selfthinker.org>2012-09-25 19:47:10 +0100
commit07834a7c661d05ab5c707e1c428421c87af565bf (patch)
tree3cb70b54e9c792a92f2647c1ed522bfc288eb9e4 /lib/tpl
parent89fd993fad76fc527d1f0e1546043908b728547e (diff)
downloadrpg-07834a7c661d05ab5c707e1c428421c87af565bf.tar.gz
rpg-07834a7c661d05ab5c707e1c428421c87af565bf.tar.bz2
de-couple mobile JS from widths to actual media query equivalent (fixes FS#2623)
Diffstat (limited to 'lib/tpl')
-rw-r--r--lib/tpl/dokuwiki/css/mobile.css14
-rw-r--r--lib/tpl/dokuwiki/main.php1
-rw-r--r--lib/tpl/dokuwiki/script.js25
3 files changed, 30 insertions, 10 deletions
diff --git a/lib/tpl/dokuwiki/css/mobile.css b/lib/tpl/dokuwiki/css/mobile.css
index 6e07f23ec..cc61ab06c 100644
--- a/lib/tpl/dokuwiki/css/mobile.css
+++ b/lib/tpl/dokuwiki/css/mobile.css
@@ -5,10 +5,20 @@
* @author Anika Henke <anika@selfthinker.org>
*/
+/* for detecting media queries in JavaScript (see script.js): */
+#screen__mode {
+ position: relative;
+ z-index: 0;
+}
+
/* up to 979px screen widths
********************************************************************/
@media only screen and (max-width: 979px) {
+#screen__mode {
+ z-index: 1; /* for detecting media queries in JavaScript (see script.js) */
+}
+
/* structure */
#dokuwiki__aside {
width: 100%;
@@ -107,6 +117,10 @@
********************************************************************/
@media only screen and (max-width: 480px) {
+#screen__mode {
+ z-index: 2; /* for detecting media queries in JavaScript (see script.js) */
+}
+
body {
font-size: 100%;
}
diff --git a/lib/tpl/dokuwiki/main.php b/lib/tpl/dokuwiki/main.php
index 2406a206b..6b1e95d62 100644
--- a/lib/tpl/dokuwiki/main.php
+++ b/lib/tpl/dokuwiki/main.php
@@ -91,6 +91,7 @@ $showSidebar = $hasSidebar && ($ACT=='show');
</div></div><!-- /site -->
<div class="no"><?php tpl_indexerWebBug() /* provide DokuWiki housekeeping, required in all templates */ ?></div>
+ <div id="screen__mode" class="no"></div><?php /* helper to detect CSS media query in script.js */ ?></div>
<!--[if ( lte IE 7 | IE 8 ) ]></div><![endif]-->
</body>
</html>
diff --git a/lib/tpl/dokuwiki/script.js b/lib/tpl/dokuwiki/script.js
index d858bda89..3ed8dbabe 100644
--- a/lib/tpl/dokuwiki/script.js
+++ b/lib/tpl/dokuwiki/script.js
@@ -12,18 +12,23 @@ var device_classes = 'desktop mobile tablet phone';
function tpl_dokuwiki_mobile(){
+ // the z-index in mobile.css is (mis-)used purely for detecting the screen mode here
+ var screen_mode = jQuery('#screen__mode').css('z-index');
+
// determine our device pattern
// TODO: consider moving into dokuwiki core
- var w = document.body.clientWidth;
- if (w > 979) {
- if (device_class == 'desktop') return;
- device_class = 'desktop';
- } else if (w > 480) {
- if (device_class.match(/tablet/)) return;
- device_class = 'mobile tablet';
- } else {
- if (device_class.match(/phone/)) return;
- device_class = 'mobile phone';
+ switch (screen_mode) {
+ case '1':
+ if (device_class.match(/tablet/)) return;
+ device_class = 'mobile tablet';
+ break;
+ case '2':
+ if (device_class.match(/phone/)) return;
+ device_class = 'mobile phone';
+ break;
+ default:
+ if (device_class == 'desktop') return;
+ device_class = 'desktop';
}
jQuery('html').removeClass(device_classes).addClass(device_class);