I have included Javascript, completely optional (marked as <script></script>)
sub GetSearchForm {
my ($result);
- $result = T('Search:') . ' ' . $q->textfield(-name=>'search', -size=>20);
- if ($SearchButton) {
- $result .= $q->submit('dosearch', T('Go!'));
- } else {
+ $result .= &GetFormStart();
+ $result .= $q->textfield(-name=>'search', -size=>'20', value=>'find',
+ onFocus=>"clearDefaultandCSS(this)", onBlur=>"setDefaultText(this)")
+ . T(' search');
$result .= &GetHiddenValue("dosearch", 1);
- }
+ $result .= "</form>";
return $result;
}
+ sub GetJumpForm {
+ my ($result);
+ my $id;
+ $result .= &GetFormStart();
+ $result .= $q->textfield(-name=>'id', -size=>'30%', value=>'jump',
+ onFocus=>"clearDefaultandCSS(this)", onBlur=>"setDefaultText(this)")
+ . T(' jump');
+ $result .= &GetHiddenValue("action", "browse" );
+ $result .= "</form>";
+ return $result;
+ }
+ sub GetSearchBar {
+ my $result;
+ $result .= '<script><!-- On focus, On Blur -->
+ function clearDefaultandCSS(el) {if (el.defaultValue==el.value) el.value = ""}
+ function setDefaultText(el) {el.value = el.defaultValue}
+ <!-- OnFocus, OnBlur --></script>';
+ $result .= &GetSearchForm();
+ $result .= &GetJumpForm();
+ return $result;
+ }
sub GetFooterText {
...
- $result .= &GetFormStart();
in the rest of the code, replace &GetSearchForm() with &GetSearchBar?().
This patch leaves useless the adyacent buttom "Go!" (See $SearchButton? = 0; # 1 = search button on page, 0 = old behavior in config file).
This pacht "as version 2" could be mainten this feature (as http://twiki.org/).
--JuanmaMP