jenkins-bot has submitted this change and it was merged.
Change subject: Don't enable search enhancement on Android 2
......................................................................
Don't enable search enhancement on Android 2
The search input isn't the input that's used in the SearchOverlay
overlay. In the click handler of the former the latter can't be
focussed to bring up the virtual keyboard, so hide the search form
elements for now.
Bug: T76882
Change-Id: Ic5a3a441f8a88587282e3eda5415ee874fc96a48
---
M javascripts/browser.js
M javascripts/mainmenu.js
M javascripts/modules/editor/EditorOverlayBase.js
M javascripts/modules/search/init.js
M less/modules/editor/editor.less
M less/ui.less
6 files changed, 39 insertions(+), 14 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
Phuedx: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/javascripts/browser.js b/javascripts/browser.js
index fa3935b..ebb79ad 100644
--- a/javascripts/browser.js
+++ b/javascripts/browser.js
@@ -8,10 +8,17 @@
*/
function Browser( ua ) {
this.userAgent = ua;
- this.isAndroid2 = /Android 2/.test( ua );
}
Browser.prototype = {
+ /**
+ * Determine if a device is Android 2.
+ * @method
+ * @return {Boolean}
+ */
+ isAndroid2: function () {
+ return /Android 2/.test( this.userAgent );
+ },
/**
* Determine if a device has a widescreen.
* @method
@@ -43,7 +50,7 @@
// don't trust Android 2.x, really
// animations cause textareas to misbehave on it
// (http://stackoverflow.com/a/5734984/365238)
- if ( this.isAndroid2 ) {
+ if ( this.isAndroid2() ) {
return false;
}
diff --git a/javascripts/mainmenu.js b/javascripts/mainmenu.js
index fbd9d23..3da055c 100644
--- a/javascripts/mainmenu.js
+++ b/javascripts/mainmenu.js
@@ -39,8 +39,6 @@
function initialize() {
// make the input readonly to avoid accidental focusing when
closing menu
// (when JS is on, this input should not be used for typing
anyway)
- // FIXME: Review the need for this, especially given latest
alpha developments
- $( '#searchInput' ).prop( 'readonly', true );
$( '#mw-mf-main-menu-button' ).on( 'click', function ( ev ) {
if ( isOpen() ) {
closeNavigationDrawers();
diff --git a/javascripts/modules/editor/EditorOverlayBase.js
b/javascripts/modules/editor/EditorOverlayBase.js
index 9d4c46d..0b6d5b7 100644
--- a/javascripts/modules/editor/EditorOverlayBase.js
+++ b/javascripts/modules/editor/EditorOverlayBase.js
@@ -1,5 +1,6 @@
( function ( M, $ ) {
var Overlay = M.require( 'Overlay' ),
+ browser = M.require( 'browser' ),
schema = M.require( 'loggingSchemas/mobileWebEditing' ),
Icon = M.require( 'Icon' ),
toast = M.require( 'toast' ),
@@ -243,6 +244,10 @@
/** @inheritdoc **/
postRender: function () {
var self = this;
+ // Add a class so editor can make some Android 2
specific customisations.
+ if ( browser.isAndroid2() ) {
+ this.$el.addClass( 'android-2' );
+ }
this.$spinner = self.$( '.spinner' );
// log edit attempt
this.log( 'attempt' );
diff --git a/javascripts/modules/search/init.js
b/javascripts/modules/search/init.js
index fe3b2d7..d0450ef 100644
--- a/javascripts/modules/search/init.js
+++ b/javascripts/modules/search/init.js
@@ -1,22 +1,36 @@
( function ( M, $ ) {
var SearchOverlay = M.require( 'modules/search/SearchOverlay' ),
- schema = M.require( 'loggingSchemas/MobileWebClickTracking' );
+ schema = M.require( 'loggingSchemas/MobileWebClickTracking' ),
+ browser = M.require( 'browser' );
- //
- // don't use focus event
(https://bugzilla.wikimedia.org/show_bug.cgi?id=47499)
- //
- // focus() (see SearchOverlay#show) opens virtual keyboard only if
triggered
- // from user context event, so using it in route callback won't work
- //
http://stackoverflow.com/questions/6837543/show-virtual-keyboard-on-mobile-phones-in-javascript
- $( '#searchInput' ).on( 'click', function ( ev ) {
+ /**
+ * Reveal the search overlay
+ * @ignore
+ */
+ function openSearchOverlay( ev ) {
ev.preventDefault();
schema.log( 'UI', 'search' );
new SearchOverlay( {
searchTerm: $( this ).val()
} ).show();
M.router.navigate( '/search' );
- } );
+ }
+
+ // See https://phabricator.wikimedia.org/T76882 for why we disable
search on Android 2
+ if ( browser.isAndroid2() ) {
+ $( 'body' ).addClass( 'client-use-basic-search' );
+ } else {
+ // don't use focus event
(https://bugzilla.wikimedia.org/show_bug.cgi?id=47499)
+ //
+ // focus() (see SearchOverlay#show) opens virtual keyboard only
if triggered
+ // from user context event, so using it in route callback won't
work
+ //
http://stackoverflow.com/questions/6837543/show-virtual-keyboard-on-mobile-phones-in-javascript
+ $( '#searchInput' ).on( 'click', openSearchOverlay )
+ // FIXME: Review the need for this, especially given
latest alpha developments
+ // Apparently needed for main menu to work correctly.
+ .prop( 'readonly', true );
+ }
// FIXME: ugly hack that removes search from browser history when
navigating
// to search results (we can't rely on History API yet)
diff --git a/less/modules/editor/editor.less b/less/modules/editor/editor.less
index 5d1962f..b674cb4 100644
--- a/less/modules/editor/editor.less
+++ b/less/modules/editor/editor.less
@@ -123,7 +123,7 @@
// FIXME: high line-height (1.5) causes weird behavior in textareas on
// Android 2.x, remove this if we don't want to support editor there
-.android2 .editor-overlay textarea {
+.android2.editor-overlay textarea {
line-height: 1.2;
}
diff --git a/less/ui.less b/less/ui.less
index 0ed2879..82c66f1 100644
--- a/less/ui.less
+++ b/less/ui.less
@@ -132,6 +132,7 @@
/* Search */
+.client-use-basic-search,
.client-nojs {
.header {
.search,
--
To view, visit https://gerrit.wikimedia.org/r/179948
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic5a3a441f8a88587282e3eda5415ee874fc96a48
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits