Yahoo! UI Library

widget-stdmod  3.3.0pr1

Yahoo! UI Library > widget-stdmod > WidgetStdMod
Search:
 
Filters

Class WidgetStdMod

Widget extension, which can be used to add Standard Module support to the base Widget class, through the Base.build method.

The extension adds header, body and footer sections to the Widget's content box and provides the corresponding methods and attributes to modify the contents of these sections.

Properties

WidgetStdMod.AFTER - static String

Constant used to specify insertion position, when adding content to sections of the standard module in methods which expect a "where" argument.

Inserts new content before the sections existing content.


WidgetStdMod.ATTRS - static Object

Static property used to define the default attribute configuration introduced by WidgetStdMod.

WidgetStdMod.BEFORE - static String

Constant used to specify insertion position, when adding content to sections of the standard module in methods which expect a "where" argument.

Inserts new content before the sections existing content.


WidgetStdMod.BODY - static String

Constant used to refer the the standard module body, in methods which expect a section specifier

WidgetStdMod.FOOTER - static String

Constant used to refer the the standard module footer, in methods which expect a section specifier

WidgetStdMod.HEADER - static String

Constant used to refer the the standard module header, in methods which expect a section specifier

WidgetStdMod.HTML_PARSER - static Object

The HTML parsing rules for the WidgetStdMod class.

WidgetStdMod.REPLACE - static String

Constant used to specify insertion position, when adding content to sections of the standard module in methods which expect a "where" argument.

Replaces the sections existing content, with new content.


WidgetStdMod.SECTION_CLASS_NAMES - static Object

Static hash of default class names used for the header, body and footer sections of the standard module, keyed by the section identifier (WidgetStdMod.STD_HEADER, WidgetStdMod.STD_BODY, WidgetStdMod.STD_FOOTER)

WidgetStdMod.TEMPLATES - static Object

The template HTML strings for each of the standard module sections. Section entries are keyed by the section constants, WidgetStdMod.HEADER, WidgetStdMod.BODY, WidgetStdMod.FOOTER, and contain the HTML to be added for each section. e.g.
{
header : '<div class="yui-widget-hd"></div>',
body : '<div class="yui-widget-bd"></div>',
footer : '<div class="yui-widget-ft"></div>'
}

Methods

_addNodeHTML

private void _addNodeHTML ( node , html , where )
Helper method to add the given HTML string to the node reference provided. The HTML is added either before, after or replaces the existing node content based on the value of the where argument.
Parameters:
node <Node> The section Node to be updated.
html <String> The new content HTML string to be added to the section Node.
where <String> Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. If not provided, the content will replace Nodes existing content.

_addNodeRef

private void _addNodeRef ( node , children , where )
Helper method to add nodes, to another node. The child node(s) are added either before, after or replaces the existing node content based on the value of the where argument.
Parameters:
node <Node> The section Node to be updated.
children <Node|NodeList> The new content Node, or NodeList to be added to section Node provided.
where <String> Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. If not provided, the content will replace existing content in the Node.

_afterBodyChange

protected void _afterBodyChange ( e )
Default attribute change listener for the bodyContent attribute, responsible for updating the UI, in response to attribute changes.
Parameters:
e <EventFacade> The event facade for the attribute change

_afterFillHeightChange

protected void _afterFillHeightChange ( e )
Default attribute change listener for the fillHeight attribute, responsible for updating the UI, in response to attribute changes.
Parameters:
e <EventFacade> The event facade for the attribute change

_afterFooterChange

protected void _afterFooterChange ( e )
Default attribute change listener for the footerContent attribute, responsible for updating the UI, in response to attribute changes.
Parameters:
e <EventFacade> The event facade for the attribute change

_afterHeaderChange

protected void _afterHeaderChange ( e )
Default attribute change listener for the headerContent attribute, responsible for updating the UI, in response to attribute changes.
Parameters:
e <EventFacade> The event facade for the attribute change

_applyStdModParsedConfig

private void _applyStdModParsedConfig ( )
This method is injected before the _applyParsedConfig step in the application of HTML_PARSER, and sets up the state to identify whether or not we should remove the current DOM content or not, based on whether or not the current content attribute value was extracted from the DOM, or provided by the user configuration

_bindUIStdMod

protected void _bindUIStdMod ( )
Binds event listeners responsible for updating the UI state in response to Widget standard module related state changes.

This method is invoked after bindUI is invoked for the Widget class using YUI's aop infrastructure.


_eraseStdMod

protected void _eraseStdMod ( section )
Removes the DOM node for the given section.
Parameters:
section <String> The section to remove. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.

_fillHeight

private void _fillHeight ( )
Updates the rendered UI, to resize the current section specified by the fillHeight attribute, so that the standard module fills out the Widget height. If a height has not been set on Widget, the section is not resized (height is set to "auto").

_findStdModSection

private Node _findStdModSection ( section )
Helper method to to find the rendered node for the given section, if it exists.
Parameters:
section <String> The section for which the render Node is to be found. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
Returns: Node
The rendered node for the given section, or null if not found.

_getPreciseHeight

private Number _getPreciseHeight ( node )
Helper method to obtain the precise height of the node provided, including padding and border. The height could be a sub-pixel value for certain browsers, such as Firefox 3.
Parameters:
node <Node> The node for which the precise height is required.
Returns: Number
The height of the Node including borders and padding, possibly a float.

_getStdModContent

private Node _getStdModContent ( section )
Retrieves the child nodes (content) of a standard module section
Parameters:
section <String> The standard module section whose child nodes are to be retrieved. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
Returns: Node
The child node collection of the standard module section.

_getStdModTemplate

protected Node _getStdModTemplate ( section )
Gets a new Node reference for the given standard module section, by cloning the stored template node.
Parameters:
section <String> The section to create a new node for. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
Returns: Node
The new Node instance for the section

_insertStdModSection

private void _insertStdModSection ( contentBox , section , sectionNode )
Helper method to insert the Node for the given section into the correct location in the contentBox.
Parameters:
contentBox <Node> A reference to the Widgets content box.
section <String> The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
sectionNode <Node> The Node for the section.

_parseStdModHTML

private String _parseStdModHTML ( section )
Utility method, used by WidgetStdMods HTML_PARSER implementation to extract data for each section from markup.
Parameters:
section <String>
Returns: String
Inner HTML string with the contents of the section

_renderStdMod

protected Node _renderStdMod ( section )
Creates the DOM node for the given section, and inserts it into the correct location in the contentBox.
Parameters:
section <String> The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
Returns: Node
A reference to the added section node

_renderUIStdMod

protected void _renderUIStdMod ( )
Creates/Initializes the DOM for standard module support.

This method is invoked after renderUI is invoked for the Widget class using YUI's aop infrastructure.


_syncUIStdMod

protected void _syncUIStdMod ( )
Synchronizes the UI to match the Widgets standard module state.

This method is invoked after syncUI is invoked for the Widget class using YUI's aop infrastructure.


_uiSetFillHeight

protected void _uiSetFillHeight ( fillSection )
Updates the rendered UI, to resize the provided section so that the standard module fills out the specified widget height. Note: This method does not check whether or not a height is set on the Widget.
Parameters:
fillSection <String> A valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER

_uiSetStdMod

protected void _uiSetStdMod ( section , content , where )
Updates the rendered UI, adding the provided content (either an HTML string, or node reference), to the specified section. The content is either added before, after or replaces existing content in the section, based on the value of the where argument.
Parameters:
section <String> The section to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
content <String | Node> The new content (either as an HTML string, or Node reference) to add to the section
where <String> Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. If not provided, the content will replace existing content in the section.

_validateFillHeight

protected _validateFillHeight ( val )
Default validator for the fillHeight attribute. Verifies that the value set is a valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER, or a falsey value if fillHeight is to be disabled.
Parameters:
val <String> The section which should be setup to fill height, or false/null to disable fillHeight
Returns:
true if valid, false if not

fillHeight

void fillHeight ( node )
Sets the height on the provided header, body or footer element to fill out the height of the Widget. It determines the height of the widgets bounding box, based on it's configured height value, and sets the height of the provided section to fill out any space remaining after the other standard module section heights have been accounted for.

NOTE: This method is not designed to work if an explicit height has not been set on the Widget, since for an "auto" height Widget, the heights of the header/body/footer will drive the height of the Widget.

Parameters:
node <Node> The node which should be resized to fill out the height of the Widget bounding box. Should be a standard module section node which belongs to the widget.

getStdModNode

Node getStdModNode ( section )
Returns the node reference for the given section. Note: The DOM is not queried for the node reference. The reference stored by the widget instance is returned if set.
Parameters:
section <String> The section whose node reference is required. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
Returns: Node
The node reference for the section, or null if not set.

setStdModContent

void setStdModContent ( section , content , where )
Updates the body section of the standard module with the content provided (either an HTML string, or node reference).

This method can be used instead of the corresponding section content attribute if you'd like to retain the current content of the section, and insert content before or after it, by specifying the where argument.

Parameters:
section <String> The standard module section whose content is to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
content <String | Node> The content to be added, either an HTML string or a Node reference.
where <String> Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE. If not provided, the content will replace existing content in the section.

Events

bodyContentChange

bodyContentChange ( event )
Fires when the value for the configuration attribute 'bodyContent' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

fillHeightChange

fillHeightChange ( event )
Fires when the value for the configuration attribute 'fillHeight' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

footerContentChange

footerContentChange ( event )
Fires when the value for the configuration attribute 'footerContent' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

headerContentChange

headerContentChange ( event )
Fires when the value for the configuration attribute 'headerContent' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

Configuration Attributes

bodyContent - {String | Node}

The content to be added to the body section. This will replace any existing content in the body. If you want to append, or insert new content, use the setStdModContent method.
Default Value: undefined

fillHeight - {String}

The section (WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER) which should be resized to fill the height of the standard module, when a height is set on the Widget. If a height is not set on the widget, then all sections are sized based on their content.
Default Value: WidgetStdMod.BODY

footerContent - {String | Node}

The content to be added to the footer section. This will replace any existing content in the footer. If you want to append, or insert new content, use the setStdModContent method.
Default Value: undefined

headerContent - {String | Node}

The content to be added to the header section. This will replace any existing content in the header. If you want to append, or insert new content, use the setStdModContent method.
Default Value: undefined


Copyright © 2010 Yahoo! Inc. All rights reserved.