r44463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44462‎ | r44463 | r44464 >
Date:19:52, 11 December 2008
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
Set focus
Modified paths:
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -619,11 +619,21 @@
620620 if( $t != null && count($this->namespaces) === 1 ) {
621621 $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
622622 }
623 - return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
 623+ return $this->powerSearchFocus() .
 624+ Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
624625 Xml::element( 'legend', null, wfMsg('powersearch-legend') ) .
625626 $this->formHeader($term) . $out .
626627 Xml::closeElement( 'fieldset' );
627628 }
 629+
 630+ protected function searchFocus() {
 631+ global $wgJsMimeType;
 632+ return "<script type=\"$wgJsMimeType\">" .
 633+ "hookEvent(\"load\", function() {" .
 634+ "document.getElementById('searchText').focus();" .
 635+ "});" .
 636+ "</script>";
 637+ }
628638
629639 protected function powerSearchFocus() {
630640 global $wgJsMimeType;
@@ -714,7 +724,8 @@
715725 global $wgScript;
716726 $searchTitle = SpecialPage::getTitleFor( 'Search' );
717727 $searchable = SearchEngine::searchableNamespaces();
718 - $out = Xml::openElement( 'form', array( 'id' => 'search', 'method' => 'get', 'action' => $wgScript ) );
 728+ $out = $this->searchFocus();
 729+ $out .= Xml::openElement( 'form', array( 'id' => 'search', 'method' => 'get', 'action' => $wgScript ) );
719730 $out .= Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n";
720731 // If searching several, but not all namespaces, show what we are searching.
721732 if( count($this->namespaces) > 1 && $this->namespaces !== array_keys($searchable) ) {

Comments

#Comment by Brion VIBBER (talk | contribs)   22:44, 11 December 2008

Should only set focus if there are no results to show; otherwise we want the keyboard available for scrolling by default.

#Comment by Brion VIBBER (talk | contribs)   00:14, 17 December 2008

This was resolved. Yay!

Status & tagging log