Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/288087
Change subject: Hygiene: Pass Router instance to SearchOverlay
......................................................................
Hygiene: Pass Router instance to SearchOverlay
Router.js should not create an instance of itself. In a
later patchset we will use the instance provided by the
mediawiki.router module.
Change-Id: Iaee1dcf351d638712dac8d54fd0fe1876e0d420f
---
M resources/mobile.search/SearchOverlay.js
M resources/skins.minerva.scripts/search.js
2 files changed, 6 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/87/288087/1
diff --git a/resources/mobile.search/SearchOverlay.js
b/resources/mobile.search/SearchOverlay.js
index 4d9553c..bceab44 100644
--- a/resources/mobile.search/SearchOverlay.js
+++ b/resources/mobile.search/SearchOverlay.js
@@ -7,7 +7,6 @@
WatchstarPageList = M.require(
'mobile.pagelist.scripts/WatchstarPageList' ),
SEARCH_DELAY = 300,
$html = $( 'html' ),
- router = M.require( 'mobile.startup/router' ),
feedbackLink = mw.config.get( 'wgCirrusSearchFeedbackLink' );
/**
@@ -23,9 +22,10 @@
this.api = options.api;
this.gateway = new options.gatewayClass( this.api );
+ this.router = options.router;
// FIXME: Remove when search registers route with overlay
manager
// we need this because of the focus/delay hack in search.js
- router.once( 'route', function () {
+ this.router.once( 'route', function () {
self._hideOnRoute();
} );
}
@@ -42,6 +42,7 @@
* @cfg {Object} defaults Default options hash.
* @cfg {SearchGateway} defaults.gatewayClass The class to use
to setup an API gateway.
* FIXME: Should be removed when wikidata descriptions in
stable (T101719)
+ * @cfg {Router} defaults.router instance
* @cfg {Object} defaults.clearIcon options for the button that
clears the search text.
* @cfg {Object} defaults.searchContentIcon options for the
button that allows you to search within content
* @cfg {String} defaults.searchTerm Search text.
@@ -104,7 +105,7 @@
*/
_hideOnRoute: function () {
var self = this;
- router.once( 'route', function ( ev ) {
+ this.router.once( 'route', function ( ev ) {
if ( !self.hide() ) {
ev.preventDefault();
self._hideOnRoute();
@@ -221,7 +222,7 @@
// FIXME: ugly hack that removes search from browser
history when navigating to search results
ev.preventDefault();
- router.back().done( function () {
+ this.router.back().done( function () {
window.location.href = $link.attr( 'href' );
} );
},
diff --git a/resources/skins.minerva.scripts/search.js
b/resources/skins.minerva.scripts/search.js
index fa29ca9..4faf0d4 100644
--- a/resources/skins.minerva.scripts/search.js
+++ b/resources/skins.minerva.scripts/search.js
@@ -26,6 +26,7 @@
SearchOverlay = M.require( moduleConfig.overlay );
new SearchOverlay( {
+ router: router,
gatewayClass: SearchGateway,
api: new mw.Api(),
searchTerm: searchTerm,
--
To view, visit https://gerrit.wikimedia.org/r/288087
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaee1dcf351d638712dac8d54fd0fe1876e0d420f
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