JGonera has submitted this change and it was merged. Change subject: Alpha: Allow searching from special page ......................................................................
Alpha: Allow searching from special page On alpha add a button to the top right corner of the ui on special pages so users can search from them I *want* this so bad. Image: http://thenounproject.com/noun/search/#icon-No15028 Patch Set 3: modified the search icon to match the shade of grey of the hamburger, adjusted its size to be the same as hamburger icon (jgonera) Change-Id: I3f5afae2ca7228578e408e25f16f489aac194d1b --- M MobileFrontend.php M includes/MobileFrontend.hooks.php M javascripts/modules/search-2.js A javascripts/specials/modules/search-btn.js A less/specials/modules/search-btn.less A stylesheets/specials/modules/images/search.png A stylesheets/specials/modules/search-btn.css 7 files changed, 82 insertions(+), 1 deletion(-) Approvals: JGonera: Verified; Looks good to me, approved diff --git a/MobileFrontend.php b/MobileFrontend.php index aeaaada..1252729 100644 --- a/MobileFrontend.php +++ b/MobileFrontend.php @@ -91,6 +91,7 @@ $wgHooks['OpenSearchXml'][] = 'ApiQueryExtracts::onOpenSearchXml'; $wgHooks['MakeGlobalVariablesScript'][] = 'MobileFrontendHooks::onMakeGlobalVariablesScript'; +$wgHooks['EnableMobileModules'][] = 'MobileFrontendHooks::onEnableMobileModules'; $wgHooks['RequestContextCreateSkin'][] = 'MobileFrontendHooks::onRequestContextCreateSkin'; $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'MobileFrontendHooks::onSkinTemplateOutputPageBeforeExec'; $wgHooks['BeforePageRedirect'][] = 'MobileFrontendHooks::onBeforePageRedirect'; @@ -528,6 +529,21 @@ // ensure special css is always loaded after mobile.styles for cascading purposes (keep jgonera happy) 'dependencies' => array( 'mobile.styles' ), ); + +// Special page modules we only want to load in beta/alpha: +$wgResourceModules['mobile.special.alpha.scripts'] = $wgMFMobileSpecialPageResourceScriptBoilerplate + array( + 'scripts' => array( + 'javascripts/specials/modules/search-btn.js', + ), +); + +$wgResourceModules['mobile.special.alpha.styles'] = $wgMFMobileSpecialPageResourceScriptBoilerplate + array( + 'styles' => array( + 'stylesheets/specials/modules/search-btn.css', + ), +); + + /** * Special page modules * diff --git a/includes/MobileFrontend.hooks.php b/includes/MobileFrontend.hooks.php index 4e37355..8cd4457 100644 --- a/includes/MobileFrontend.hooks.php +++ b/includes/MobileFrontend.hooks.php @@ -10,6 +10,26 @@ class MobileFrontendHooks { + /** + * EnableMobileModules hook handler + * @see http://www.mediawiki.org/wiki/Manual:Hooks/EnableMobileModules + * Adds modules depending on alpha/beta status. + * + * @param OutputPage $out + * @param string $mode + * @return boolean + */ + public static function onEnableMobileModules( $out, $mode ) { + if ( $mode === 'alpha' && $out->getTitle()->isSpecialPage() ) { + $out->addModules( + array( + 'mobile.special.alpha.scripts', + 'mobile.special.alpha.styles', + ) + ); + } + return true; + } /** * MakeGlobalVariablesScript hook handler diff --git a/javascripts/modules/search-2.js b/javascripts/modules/search-2.js index 766c50e..26d36e5 100644 --- a/javascripts/modules/search-2.js +++ b/javascripts/modules/search-2.js @@ -2,6 +2,7 @@ var Overlay = M.require( 'navigation' ).Overlay, SearchOverlay, api = M.require( 'api' ), + searchOverlay, overlayInitialize = Overlay.prototype.initialize; /** @@ -106,8 +107,9 @@ } } ); +searchOverlay = new SearchOverlay(); + function init() { - var searchOverlay = new SearchOverlay(); // don't use focus event (https://bugzilla.wikimedia.org/show_bug.cgi?id=47499) $( '#searchInput' ).on( 'touchend keydown', function( ev ) { // if touch or key not Tab or Shift @@ -120,6 +122,7 @@ M.define( 'search', { SearchOverlay: SearchOverlay, + overlay: searchOverlay, highlightSearchTerm: highlightSearchTerm } ); diff --git a/javascripts/specials/modules/search-btn.js b/javascripts/specials/modules/search-btn.js new file mode 100644 index 0000000..6a37895 --- /dev/null +++ b/javascripts/specials/modules/search-btn.js @@ -0,0 +1,13 @@ +( function( M, $ ) { + +var search = M.require( 'search' ); + +if ( mw.config.get( 'wgNamespaceNumber' ) === mw.config.get( 'wgNamespaceIds' ).special ) { + $( '<a class="search-button">' ).attr( 'href', '#' ). + on( 'click', function() { + search.overlay.showAndFocus(); + } ). + appendTo( '.header' ); +} + +}( mw.mobileFrontend, jQuery ) ); diff --git a/less/specials/modules/search-btn.less b/less/specials/modules/search-btn.less new file mode 100644 index 0000000..f3530ab --- /dev/null +++ b/less/specials/modules/search-btn.less @@ -0,0 +1,14 @@ +@import "../../mf-mixins.less"; + +.header { + .search-button { + display: inline-block; //? + height: @headerHeight; + width: @searchBarPaddingLeft; + position: absolute; + top: 0; + background: url(images/search.png) 50% 50% no-repeat; + .background-size( auto, 30px ); + right: 0; + } +} diff --git a/stylesheets/specials/modules/images/search.png b/stylesheets/specials/modules/images/search.png new file mode 100644 index 0000000..0e4f0d4 --- /dev/null +++ b/stylesheets/specials/modules/images/search.png Binary files differ diff --git a/stylesheets/specials/modules/search-btn.css b/stylesheets/specials/modules/search-btn.css new file mode 100644 index 0000000..150836b --- /dev/null +++ b/stylesheets/specials/modules/search-btn.css @@ -0,0 +1,15 @@ +.header .search-button { + display: inline-block; + height: 46px; + width: 40px; + position: absolute; + top: 0; + background: url(images/search.png) 50% 50% no-repeat; + /* use -webkit prefix for older android browsers eg. nexus 1 */ + + -moz-background-size: auto 30px; + -o-background-size: auto 30px; + -webkit-background-size: auto 30px; + background-size: auto 30px; + right: 0; +} -- To view, visit https://gerrit.wikimedia.org/r/59636 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3f5afae2ca7228578e408e25f16f489aac194d1b Gerrit-PatchSet: 3 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: MaxSem <[email protected]> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
