From 07834a7c661d05ab5c707e1c428421c87af565bf Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Tue, 25 Sep 2012 19:47:10 +0100 Subject: de-couple mobile JS from widths to actual media query equivalent (fixes FS#2623) --- lib/tpl/dokuwiki/script.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lib/tpl/dokuwiki/script.js') 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); -- cgit v1.2.3 From 20391a36885910a616110df30f3ce30f8d23639d Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Tue, 25 Sep 2012 20:25:54 +0100 Subject: removed html dependency from media query detection JS in new template --- lib/tpl/dokuwiki/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/tpl/dokuwiki/script.js') diff --git a/lib/tpl/dokuwiki/script.js b/lib/tpl/dokuwiki/script.js index 3ed8dbabe..ec6e5285e 100644 --- a/lib/tpl/dokuwiki/script.js +++ b/lib/tpl/dokuwiki/script.js @@ -13,16 +13,16 @@ 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'); + var screen_mode = jQuery('body').css('min-height'); // determine our device pattern // TODO: consider moving into dokuwiki core switch (screen_mode) { - case '1': + case '1px': if (device_class.match(/tablet/)) return; device_class = 'mobile tablet'; break; - case '2': + case '2px': if (device_class.match(/phone/)) return; device_class = 'mobile phone'; break; -- cgit v1.2.3 From 86ca15261461b6c74f66407e7ac6992baa097d0d Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Wed, 26 Sep 2012 09:22:02 +0100 Subject: Revert "removed html dependency from media query detection JS in new template" ... because it made the solution less transparent, more error prone and even more like a hack than it already was This reverts commit 20391a36885910a616110df30f3ce30f8d23639d. --- lib/tpl/dokuwiki/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/tpl/dokuwiki/script.js') diff --git a/lib/tpl/dokuwiki/script.js b/lib/tpl/dokuwiki/script.js index ec6e5285e..3ed8dbabe 100644 --- a/lib/tpl/dokuwiki/script.js +++ b/lib/tpl/dokuwiki/script.js @@ -13,16 +13,16 @@ 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('body').css('min-height'); + var screen_mode = jQuery('#screen__mode').css('z-index'); // determine our device pattern // TODO: consider moving into dokuwiki core switch (screen_mode) { - case '1px': + case '1': if (device_class.match(/tablet/)) return; device_class = 'mobile tablet'; break; - case '2px': + case '2': if (device_class.match(/phone/)) return; device_class = 'mobile phone'; break; -- cgit v1.2.3