jenkins-bot has submitted this change and it was merged.

Change subject: Fix position fixed handling is iOS <= 4_2
......................................................................


Fix position fixed handling is iOS <= 4_2

Seems to need to account for the height of the address bar
and the open keyboard

Cleanup user agent testing in process
Bug: 53048

Change-Id: I841ca5c6925ff189bd7a9b24e04d645d491dbf1f
---
M javascripts/common/application.js
1 file changed, 22 insertions(+), 7 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/javascripts/common/application.js 
b/javascripts/common/application.js
index 7194457..6b4f61b 100644
--- a/javascripts/common/application.js
+++ b/javascripts/common/application.js
@@ -3,7 +3,13 @@
 ( function( M, $ ) {
        var Router = M.require( 'Router' ),
                PageApi = M.require( 'PageApi' ),
-               $viewportMeta, viewport;
+               $viewportMeta, viewport,
+               ua = window.navigator.userAgent,
+               isAppleDevice = /ipad|iphone/i.test( ua ),
+               isIPhone4 = isAppleDevice && /OS 4_/.test( ua ),
+               isOldIPhone = isAppleDevice && /OS [4]_[0-2]|OS [3]_/.test( ua 
),
+               isIPhone5 = isAppleDevice && /OS 5_/.test( ua ),
+               isAndroid2 = /Android 2/.test( ua );
 
        // http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html
        // https://github.com/Modernizr/Modernizr/issues/167
@@ -65,7 +71,18 @@
 
                        $( window ).on( 'scroll', function() {
                                var scrollTop = $( window ).scrollTop(),
-                                       scrollBottom = scrollTop + $( window 
).height();
+                                       windowHeight = $( window ).height(),
+                                       activeElement = document.activeElement,
+                                       scrollBottom = scrollTop + windowHeight;
+                               if ( isOldIPhone ) {
+                                       if ( activeElement.tagName === 
'TEXTAREA' || activeElement.tagName === 'INPUT' ) {
+                                               // add the height of the open 
soft keyboard
+                                               scrollBottom -= 120;
+                                       } else {
+                                               // add the height of the 
address bar
+                                               scrollBottom += 60;
+                                       }
+                               }
 
                                if ( scrollTop === 0 ) {
                                        // special case when we're at the 
beginning of the page and many
@@ -91,9 +108,7 @@
                // allow disabling of transitions in android ics 4.0.2
                function fixBrowserBugs() {
                        // see http://adactio.com/journal/4470/ (fixed in ios 6)
-                       var
-                               ua = navigator.userAgent;
-                       if( $viewportMeta[0] && ua.match( /iPhone|iPad/i ) && 
ua.match( /OS [4-5]_0/ )  ) {
+                       if( $viewportMeta[0] && ( isIPhone4 || isIPhone5 ) ) {
                                lockViewport();
                                document.addEventListener( 'gesturestart', 
function() {
                                        lockViewport();
@@ -102,7 +117,7 @@
 
                        // FIXME: Android 2.x can act weird
                        // (remove if we drop support for some features on it)
-                       if ( /Android 2/.test( navigator.userAgent ) ) {
+                       if ( isAndroid2 ) {
                                $body.addClass( 'android2' );
                                // lock the viewport for this device - too 
problematic
                                lockViewport();
@@ -131,7 +146,7 @@
                        // don't trust Android 2.x, really
                        // animations cause textareas to misbehave on it
                        // (http://stackoverflow.com/a/5734984/365238)
-                       if ( /Android 2/.test( navigator.userAgent ) ) {
+                       if ( isAndroid2 ) {
                                return false;
                        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/86881
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I841ca5c6925ff189bd7a9b24e04d645d491dbf1f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to