* (bug 9939) Special:Search now sets focus to search input box when no existing
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 3 Jan 2008 01:02:09 +0000 (01:02 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 3 Jan 2008 01:02:09 +0000 (01:02 +0000)
  search is active

RELEASE-NOTES
includes/SpecialSearch.php

index 2f33b5a..4572c98 100644 (file)
@@ -115,6 +115,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * When a user is prohibited from creating a page, a title of "View source"
   makes no sense, and there should be no "Return to [[Page]]" link.
 * (bug 12486) Protected titles now give a warning for privileged editors.
+* (bug 9939) Special:Search now sets focus to search input box when no existing
+  search is active
 
 
 === Bug fixes in 1.12 ===
index 3530ff1..e30ad08 100644 (file)
@@ -125,10 +125,11 @@ class SpecialSearch {
                global $wgOut;
                $wgOut->addWikiText( wfMsg( 'searchresulttext' ) );
 
-               #if ( !$this->parseQuery() ) {
                if( '' === trim( $term ) ) {
+                       // Empty query -- straight view of search form
                        $wgOut->setSubtitle( '' );
                        $wgOut->addHTML( $this->powerSearchBox( $term ) );
+                       $wgOut->addHTML( $this->powerSearchFocus() );
                        wfProfileOut( $fname );
                        return;
                }
@@ -400,7 +401,7 @@ class SpecialSearch {
                        : '';
                $redirect = "<input type='checkbox' value='1' name=\"redirs\"{$checked} />\n";
 
-               $searchField = '<input type="text" name="search" value="' .
+               $searchField = '<input type="text" id="powerSearchText" name="search" value="' .
                        htmlspecialchars( $term ) ."\" size=\"16\" />\n";
 
                $searchButton = '<input type="submit" name="searchx" value="' .
@@ -416,6 +417,12 @@ class SpecialSearch {
                return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " .
                  "action=\"$action\">\n{$ret}\n</form>\n";
        }
+       
+       function powerSearchFocus() {
+               return "<script type='text/javascript'>" .
+                       "document.getElementById('powerSearchText').focus();" .
+                       "</script>";
+       }
 }