Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59636


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-No9873

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, 86 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/36/59636/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index e3a83a3..a12d1bf 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -90,6 +90,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';
@@ -500,6 +501,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 daadb98..da92d9c 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();
        $( '#searchInput' ).on( 'focus', function() {
                searchOverlay.showAndFocus();
        } );
@@ -116,6 +118,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..de92ae1
--- /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="searchBtn">' ).attr( 'href', '#' ).
+               on( 'click', function() {
+                       search.overlay.showAndFocus();
+               } ).
+               appendTo( '#mw-mf-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..be16ad5
--- /dev/null
+++ b/less/specials/modules/search-btn.less
@@ -0,0 +1,16 @@
+@import "../../mf-mixins.less";
+
+#mw-mf-header {
+       .searchBtn {
+               display: inline-block; //?
+               height: @headerHeight;
+               width: @searchBarPaddingLeft;
+               position: absolute;
+               top: 0;
+               background-image: url(images/search.png);
+               .background-size( 24px, auto );
+               background-repeat: no-repeat;
+               background-position: center center;
+               right: 0;
+       }
+}
\ No newline at end of file
diff --git a/stylesheets/specials/modules/images/search.png 
b/stylesheets/specials/modules/images/search.png
new file mode 100644
index 0000000..523cc89
--- /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..2f3f6e2
--- /dev/null
+++ b/stylesheets/specials/modules/search-btn.css
@@ -0,0 +1,17 @@
+#mw-mf-header .searchBtn {
+  display: inline-block;
+  height: 46px;
+  width: 40px;
+  position: absolute;
+  top: 0;
+  background-image: url(images/search.png);
+  /* use -webkit prefix for older android browsers eg. nexus 1 */
+
+  -moz-background-size: 24px auto;
+  -o-background-size: 24px auto;
+  -webkit-background-size: 24px auto;
+  background-size: 24px auto;
+  background-repeat: no-repeat;
+  background-position: center center;
+  right: 0;
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/59636
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f5afae2ca7228578e408e25f16f489aac194d1b
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

Reply via email to