Class Index | File Index

Classes


Class MochiKit.Widget.TextField


Extends MochiKit.Widget.
The text field widget class. Used to provide a text input field for a single line, using the <input> HTML element. The text field may also be connected to a popup (for auto- suggest or similar) and in that case the "onpopupselect" event will be triggered when an element is selected from the popup.
Defined in: Widget.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new text field widget.
Field Summary
Field Attributes Field Name and Description
 
The value to use on form reset.
 
The widget disabled flag.
 
The read-only widget focused flag.
Fields borrowed from class MochiKit.Widget:
_id, Classes
Method Summary
Method Attributes Method Name and Description
 
Handles the mouse click event on the popup.
 
Handles focus and blur events for this widget.
 
Handles the key down event for the text field.
 
Updates the display of the widget content.
 
Returns the text field value.
 
popup(create)
Returns (or creates) a popup for this text field.
 
Resets the text area form value to the initial value.
 
setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
 
showPopup(attrs, items)
Shows a popup for the text field containing the specified items.
Methods borrowed from class MochiKit.Widget:
_animQueueId, _createWidgetTreeElem, _eventHandler, _widgetMixin, addAll, addChildNode, addClass, animate, blurAll, createWidget, createWidgetTree, destroy, destroyWidget, emitSignal, getChildNodes, hasClass, hide, isFormField, isHidden, isWidget, removeAll, removeChildNode, removeClass, setStyle, show, toggleClass
Class Detail
MochiKit.Widget.TextField(attrs)
Creates a new text field widget.
var field = MochiKit.Widget.TextField({ helpText: "< Enter Data >" });
Parameters:
{Object} attrs
the widget and node attributes
{String} attrs.helpText Optional
the help text shown on empty input, defaults to ""
{String} attrs.value Optional
the field value, defaults to ""
{Object} ... Optional
the initial text content
Returns:
{Widget} the widget DOM node
Field Detail
{String} defaultValue
The value to use on form reset.

{Boolean} disabled
The widget disabled flag.

{Boolean} focused
The read-only widget focused flag.
Method Detail
_handleClick(evt)
Handles the mouse click event on the popup.
Parameters:
evt
the MochiKit.Signal.Event object

_handleFocus(evt)
Handles focus and blur events for this widget.
Parameters:
evt
the MochiKit.Signal.Event object

_handleKeyDown(evt)
Handles the key down event for the text field.
Parameters:
{Event} evt
the MochiKit.Signal.Event object

_render()
Updates the display of the widget content.

{String} getValue()
Returns the text field value. This function is slightly different from using the "value" property directly, since it will always return the actual value string instead of the temporary help text displayed when the text field is empty and unfocused.
var value = field.getValue();
value = MochiKit.Format.strip(value);
field.setAttrs({ "value": value });
Returns:
{String} the field value

{Widget} popup(create)
Returns (or creates) a popup for this text field. The popup will not be shown by this method, only returned as-is. If the create flag is specified, a new popup will be created if none has been created previuosly.
Parameters:
{Boolean} create
the create popup flag
Returns:
{Widget} the popup widget, or null if none existed or was created

reset()
Resets the text area form value to the initial value.

setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
var value = field.getValue();
value = MochiKit.Format.strip(value);
field.setAttrs({ "value": value });
Parameters:
{Object} attrs
the widget and node attributes to set
{String} attrs.helpText Optional
the help text shown on empty input
{String} attrs.value Optional
the field value

showPopup(attrs, items)
Shows a popup for the text field containing the specified items. The items specified may be either a list of HTML DOM nodes or text strings.
Parameters:
{Object} attrs Optional
the popup attributes to set
{Number} attrs.delay Optional
the popup auto-hide delay, defaults to 30 seconds
{Array} items Optional
the items to show, or null to keep the previuos popup content

Documentation generated by JsDoc Toolkit 2.0.2 on Sun May 24 2009 13:14:17 GMT+0200 (CEST)