jenkins-bot has submitted this change and it was merged.
Change subject: Pre-fill search bar in SearchOverlay with previous contents
......................................................................
Pre-fill search bar in SearchOverlay with previous contents
Bug: 69163
Change-Id: Ic99b06be097ef990b1cad1cc473e73aa9379dbdb
---
M javascripts/modules/search/SearchOverlay.js
M javascripts/modules/search/search.js
M templates/modules/search/SearchOverlay.hogan
3 files changed, 8 insertions(+), 2 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/javascripts/modules/search/SearchOverlay.js
b/javascripts/modules/search/SearchOverlay.js
index 99633b5..8302ed8 100644
--- a/javascripts/modules/search/SearchOverlay.js
+++ b/javascripts/modules/search/SearchOverlay.js
@@ -11,6 +11,7 @@
className: 'overlay search-overlay',
template: M.template.get( 'modules/search/SearchOverlay.hogan'
),
defaults: {
+ searchTerm: '',
placeholderMsg: $( '#searchInput' ).attr( 'placeholder'
),
clearMsg: mw.msg( 'mobile-frontend-clear-search' ),
searchContentMsg: mw.msg(
'mobile-frontend-search-content' ),
@@ -94,8 +95,13 @@
},
show: function() {
+ var len = this.$input.val().length;
this._super();
this.$input.focus();
+ // Cursor to the end of the input
+ if ( this.$input[0].setSelectionRange ) {
+ this.$input[0].setSelectionRange( len, len );
+ }
},
performSearch: function() {
diff --git a/javascripts/modules/search/search.js
b/javascripts/modules/search/search.js
index 49b1f49..b036a7e 100644
--- a/javascripts/modules/search/search.js
+++ b/javascripts/modules/search/search.js
@@ -10,7 +10,7 @@
// 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( M.tapEvent( 'touchend mouseup' ), function() {
- new SearchOverlay().show();
+ new SearchOverlay( { searchTerm: $( this ).val() } ).show();
M.router.navigate( '/search' );
} );
diff --git a/templates/modules/search/SearchOverlay.hogan
b/templates/modules/search/SearchOverlay.hogan
index cb3710b..31e0214 100644
--- a/templates/modules/search/SearchOverlay.hogan
+++ b/templates/modules/search/SearchOverlay.hogan
@@ -5,7 +5,7 @@
</ul>
<div class="overlay-search">
<form method="get" action="{{action}}">
- <input class="search" type="search"
name="search" autocomplete="off" placeholder="{{placeholderMsg}}">
+ <input class="search" type="search"
name="search" autocomplete="off" placeholder="{{placeholderMsg}}"
value="{{searchTerm}}">
</form>
</div>
<ul>
--
To view, visit https://gerrit.wikimedia.org/r/160784
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic99b06be097ef990b1cad1cc473e73aa9379dbdb
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Awjrichards <[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