From d66c3c5ba1bcd8d75c912c5f5d0a3b7765b0275d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 28 Nov 2014 20:28:26 +0100 Subject: [PATCH] Using JavaScript to detect iOS devices The "overflow: hidden" is required to fix the famous zoom bug on orientation change in iOS Safari, sadly the work-around using the event listener for device acceleration is not always reliable. The previous code caused Chrome on Android to block scrolling if a visible element with "position: fixed" is present (for whatever reason, enlight me Google!), which is for example the case if the quote overlay is present. --- wcfsetup/install/files/js/WCF.js | 21 +++++++++++++++------ wcfsetup/install/files/style/global.less | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 314b719e0b..ed8e801ece 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -158,6 +158,21 @@ function shuffle(array) { // detect smartphones jQuery.browser.smartphone = ($('html').css('caption-side') == 'bottom'); + // properly detect IE11 + if (jQuery.browser.mozilla && ua.match(/trident/)) { + jQuery.browser.mozilla = false; + jQuery.browser.msie = true; + } + + // detect iOS devices + jQuery.browser.iOS = /\((ipad|iphone|ipod);/.test(ua); + if (jQuery.browser.iOS) { + $('html').addClass('iOS'); + } + + // dectect Android + jQuery.browser.android = (ua.indexOf('android') !== -1); + // allow plugins to detect the used editor, value should be the same as the $.browser. key jQuery.browser.editor = 'redactor'; @@ -166,12 +181,6 @@ function shuffle(array) { // Redactor support jQuery.browser.redactor = true; - - // properly detect IE11 - if (jQuery.browser.mozilla && ua.match(/trident/)) { - jQuery.browser.mozilla = false; - jQuery.browser.msie = true; - } })(); /** diff --git a/wcfsetup/install/files/style/global.less b/wcfsetup/install/files/style/global.less index 3b9d761f16..90e508f1f6 100644 --- a/wcfsetup/install/files/style/global.less +++ b/wcfsetup/install/files/style/global.less @@ -448,8 +448,8 @@ a.badge:hover { } // Fixes zoom when iPhone orientation changes from portrait to landscape - html, - body { + html.iOS, + html.iOS > body { width: 100%; overflow: hidden; } -- 2.20.1