r29202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29201‎ | r29202 | r29203 >
Date:01:12, 3 January 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 9939) Put focus in the search box when going to Special:Search with no active search
Modified paths:
  • /trunk/extensions/LuceneSearch/LuceneSearch_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LuceneSearch/LuceneSearch_body.php
@@ -140,7 +140,10 @@
141141 $wgOut->addWikiText(wfMsg('searchresulttext'));
142142 $wgOut->addHTML($this->showShortDialog($q));
143143
144 - if ($q !== false && strlen($q) > 0) {
 144+ if ($q === false || strlen($q) == 0) {
 145+ // No search active. Put input focus in the search box.
 146+ $wgOut->addHTML( $this->makeFocusJS() );
 147+ } else {
145148 if (!($wgRequest->getText('fulltext'))) {
146149 $t = SearchEngine::getNearMatch($q);
147150 if(!is_null($t)) {
@@ -610,6 +613,12 @@
611614 return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " .
612615 "action=\"$action\">\n{$ret}\n</form>\n";
613616 }
 617+
 618+ function makeFocusJS() {
 619+ return "<script type='text/javascript'>" .
 620+ "document.getElementById('lsearchbox').focus();" .
 621+ "</script>";
 622+ }
614623
615624 function makeSuggestJS() {
616625 global $wgScript, $wgArticlePath;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r29201* (bug 9939) Special:Search now sets focus to search input box when no existing...brion01:02, 3 January 2008

Status & tagging log