Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180329
Change subject: Hygiene: Move lockViewport to Browser.js
......................................................................
Hygiene: Move lockViewport to Browser.js
Change-Id: I78f988731c21aba686fc3b89c4ae833920881669
---
M javascripts/application.js
M javascripts/browser.js
2 files changed, 20 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/29/180329/1
diff --git a/javascripts/application.js b/javascripts/application.js
index 4c684c3..bf548fb 100644
--- a/javascripts/application.js
+++ b/javascripts/application.js
@@ -26,8 +26,7 @@
isIos8 = isIos && /OS 8_/.test( ua ) || /Version\/8/.test( ua ),
isIPhone4 = isIos && /OS 4_/.test( ua ),
isOldIPhone = isIos && /OS [4]_[0-2]|OS [3]_/.test( ua ),
- isIPhone5 = isIos && /OS 5_/.test( ua ),
- isAndroid2 = /Android 2/.test( ua );
+ isIPhone5 = isIos && /OS 5_/.test( ua );
/**
* Escape dots and colons in a hash, jQuery doesn't like them beause
they
@@ -41,16 +40,6 @@
*/
function escapeHash( hash ) {
return hash.replace( /(:|\.)/g, '\\$1' );
- }
-
- /**
- * Locks the viewport so that pinch zooming is disabled
- * FIXME: Move to Browser.js
- *
- * @method
- */
- function lockViewport() {
- $viewportMeta.attr( 'content', 'initial-scale=1.0,
maximum-scale=1.0, user-scalable=no' );
}
/**
@@ -131,7 +120,6 @@
// allow disabling of transitions in android ics 4.0.2
/**
- * Locks viewport and enables position fixed for Android 2
* Works around iPhone 4 and 5 bugs with the viewport.
*
* FIXME: Move to Browser.js
@@ -141,18 +129,10 @@
function fixBrowserBugs() {
// see http://adactio.com/journal/4470/ (fixed in ios 6)
if ( $viewportMeta[0] && ( isIPhone4 || isIPhone5 ) ) {
- lockViewport();
+ browser.lockViewport();
document.addEventListener( 'gesturestart',
function () {
- lockViewport();
+ browser.lockViewport();
}, false );
- }
-
- // FIXME: Android 2.x can act weird
- // (remove if we drop support for some features on it)
- if ( isAndroid2 ) {
- $body.addClass( 'android2' );
- // lock the viewport for this device - too
problematic
- lockViewport();
}
}
fixBrowserBugs();
@@ -292,8 +272,6 @@
inNamespace: inNamespace,
getCurrentPage: getCurrentPage,
getSessionId: getSessionId,
- // FIXME: Move to browser.js
- lockViewport: lockViewport,
log: log,
// FIXME: Move to browser.js
isIos: isIos,
diff --git a/javascripts/browser.js b/javascripts/browser.js
index 85f6e67..43ce69a 100644
--- a/javascripts/browser.js
+++ b/javascripts/browser.js
@@ -8,10 +8,27 @@
*/
function Browser( ua ) {
this.userAgent = ua;
+ this.$viewportMeta = $( 'meta[name="viewport"]' );
+
+ if ( this.isAndroid( 2 ) ) {
+ // FIXME: Android 2.x can act weird
+ // (remove if we drop support for some features on it)
+ if ( isAndroid2 ) {
+ $( 'body' ).addClass( 'android2' );
+ // lock the viewport for this device - too
problematic
+ this.lockViewport();
+ }
+ }
}
Browser.prototype = {
/**
+ * Locks the viewport so that pinch zooming is disabled
+ */
+ lockViewport: function () {
+ this.$viewportMeta.attr( 'content', 'initial-scale=1.0,
maximum-scale=1.0, user-scalable=no' );
+ },
+ /**
* Determine if a device has a widescreen.
* @method
* @param {Number} version to check support for
--
To view, visit https://gerrit.wikimedia.org/r/180329
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I78f988731c21aba686fc3b89c4ae833920881669
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits