University of Melbourne home page
 

Clear search field

This script takes the search form at the top of the templates, inserts default text (from the title attribute) into the text input and disables the submit button. When the input field gains focus the default text is removed. When something other than the default text or an empty string is entered into the field the submit button is enabled.

Functions

uM_search.prepare

Usage: uM_search.prepare();

Parameters: none

Effect: Disables the submit button, inserts the default text and adds listeners to the text input of the search bar

Returns: nothing

Hat-tip:

Processing:

  • finds the search form
  • disables the (first) submit button
  • inserts the default text (from the title attribute) into the (first) text input
  • adds listeners to the text input

uM_search.startCheck

Usage: uM_search.startCheck(e);

Parameters: e - event for modern (non-IE) browsers

Effect: removes the default text and starts checking for search terms

Returns: nothing

Hat-tip:

Processing:

  • if the current value is the same as the title attribute, then clear the value
  • use setInterval to regularly run toggleSubmit (below)

uM_search.toggleSubmit

Usage: uM_search.toggleSubmit(input);

Parameters: input - element reference: the text input to check the value of

Effect: enables/disables the submit button

Returns: nothing

Hat-tip:

Processing:

  • if the current value is the same as the title attribute or empty, then disable the button
  • otherwise enable it

uM_search.endCheck

Usage: uM_search.endCheck(e);

Parameters: e - event for modern (non-IE) browsers

Effect: stops checking

Returns: nothing

Hat-tip:

Processing:

  • stop the regular toggleSubmit call
  • call toggleSubmit one last time to allow for quick typists
 
templates/javascript/search.txt · Last modified: 2007/04/04 11:50 by dsweeney
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki