[Home]WikiPatches/GetJumpForm

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch adds beside GetSearchForm, a GetJumpForm? (you go straight ahead to a wikipage whose name is the text you have inserted before). See in action (search an Jump): http://twiki.org/. or http://gypark.pe.kr/wiki/.

I have included Javascript, completely optional (marked as <script></script>)

The Patch

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


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 27, 2009 2:04 am by JuanmaMP (diff)
Search: