diff options
Diffstat (limited to 'lib/tpl/dokuwiki')
-rw-r--r-- | lib/tpl/dokuwiki/css/mobile.css | 14 | ||||
-rw-r--r-- | lib/tpl/dokuwiki/main.php | 1 | ||||
-rw-r--r-- | lib/tpl/dokuwiki/script.js | 25 |
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); |