Print Friendly

# Class YAHOO.widget.Module

Package: | YAHOO.widget
Class: | Module
Extends: | Object
Subclasses: | Overlay
Defined In: | container_core.js

Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.

## Public Properties

Property | Defined By
--- | ---
| CSS_BODY<static> : String | Module
<static> Constant representing the module body
| CSS_FOOTER<static> : String | Module
<static> Constant representing the module footer
| CSS_HEADER<static> : String | Module
<static> Constant representing the module header
| CSS_MODULE<static> : String | Module
<static> Constant for the default CSS class name that represents a Module
| body : HTMLElement | Module
The body element, denoted with CSS class "bd"
| browser : String | Module
String representing the current user-agent browser
| cfg : YAHOO.util.Config | Module
The Module's Config object used for monitoring configuration properties.
| contructor : Function | Module
The class's constructor function
| element : HTMLElement | Module
The main module element that contains the header, body, and footer
| footer : HTMLElement | Module
The footer element, denoted with CSS class "ft"
| header : HTMLElement | Module
The header element, denoted with CSS class "hd"
| http : String | Module
<static> Constant representing the prefix path to use for non-secure images
| https : String | Module
<static> Constant representing the prefix path to use for securely served images
| id : String | Module
The id of the element
| imageRoot : String | Module
The String representing the image root
| isSecure : Boolean | Module
Boolean representing whether or not the current browsing context is secure (https)
| javascript : String | Module
<static> Constant representing the url for the "src" attribute of the iframe used to monitor changes to the bro...
| platform : String | Module
String representing the current user-agent platform

## Public Methods

Method | Defined By
--- | ---
| Module(`String el`, `HTMLElement el`, `Object userConfig`) | Module
| appendToBody(`HTMLElement element`) : void | Module
Appends the passed element to the body. If no body is present, one will be automatically created.
| appendToFooter(`HTMLElement element`) : void | Module
Appends the passed element to the footer. If no footer is present, one will be automatically created.
| appendToHeader(`HTMLElement element`) : void | Module
Appends the passed element to the header. If no header is present, one will be automatically created.
| configMonitorResize(`String type`, `Object[] args`, `Object obj`) : void | Module
Default event handler for the "monitorresize" configuration property
| configVisible(`String type`, `Object[] args`, `Object obj`) : void | Module
Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the...
| destroy() : void | Module
Removes the Module element from the DOM and sets all child elements to null.
| hide() : void | Module
Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEve...
| init(`String el`, `HTMLElement el`, `Object userConfig`) : void | Module
The Module class's initialization method, which is executed for Module and all of its subclasses. This method is auto...
| initDefaultConfig() : void | Module
Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
| initEvents() : void | Module
Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
| initResizeMonitor() : void | Module
Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize.
| onDomResize(`DOMEvent e`, `Object obj`) : void | Module
Event handler fired when the resize monitor element is resized.
| render(`String appendToNode`, `HTMLElement appendToNode`, `HTMLElement moduleElement`) : Boolean | Module
Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optio...
| setBody(`String bodyContent`, `HTMLElement bodyContent`) : void | Module
Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is presen...
| setFooter(`String footerContent`, `HTMLElement footerContent`) : void | Module
Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is ...
| setHeader(`String headerContent`, `HTMLElement headerContent`) : void | Module
Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is ...
| show() : void | Module
Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEven...
| toString() : String | Module
Returns a String representation of the Object.

## Public Events

Event | Defined By
--- | ---
| appendEvent : () | Module
CustomEvent fired when the Module is appended to the DOM
| beforeHideEvent : () | Module
CustomEvent fired before the Module is hidden
| beforeInitEvent : (`class classRef`) | Module
CustomEvent fired prior to class initalization.
| beforeRenderEvent : () | Module
CustomEvent fired before the Module is rendered
| beforeShowEvent : () | Module
CustomEvent fired before the Module is shown
| changeBodyEvent : (`String/HTMLElement content`) | Module
CustomEvent fired when the body content of the Module is modified
| changeContentEvent : () | Module
CustomEvent fired when the content of the Module is modified
| changeFooterEvent : (`String/HTMLElement content`) | Module
CustomEvent fired when the footer content of the Module is modified
| changeHeaderEvent : (`String/HTMLElement content`) | Module
CustomEvent fired when the header content of the Module is modified
| destroyEvent : () | Module
CustomEvent fired when the Module is destroyed
| hideEvent : () | Module
CustomEvent fired after the Module is hidden
| initEvent : (`class classRef`) | Module
CustomEvent fired after class initalization.
| renderEvent : () | Module
CustomEvent fired after the Module is rendered
| showEvent : () | Module
CustomEvent fired after the Module is shown

## Property Details

### CSS_BODY<static>

`public String CSS_BODY<static>`
<static> Constant representing the module body
This property is defined by Module.

### CSS_FOOTER<static>

`public String CSS_FOOTER<static>`
<static> Constant representing the module footer
This property is defined by Module.

### CSS_HEADER<static>

`public String CSS_HEADER<static>`
<static> Constant representing the module header
This property is defined by Module.

### CSS_MODULE<static>

`public String CSS_MODULE<static>`
<static> Constant for the default CSS class name that represents a Module
This property is defined by Module.

### body

`public HTMLElement body`
The body element, denoted with CSS class "bd"
This property is defined by Module.

### browser

`public String browser`
String representing the current user-agent browser
This property is defined by Module.

### cfg

`public YAHOO.util.Config cfg`
The Module's Config object used for monitoring configuration properties.
This property is defined by Module.

### contructor

`public Function contructor`
The class's constructor function
This property is defined by Module.

### element

`public HTMLElement element`
The main module element that contains the header, body, and footer
This property is defined by Module.

### footer

`public HTMLElement footer`
The footer element, denoted with CSS class "ft"
This property is defined by Module.

### header

`public HTMLElement header`
The header element, denoted with CSS class "hd"
This property is defined by Module.

### http

`public String http`
<static> Constant representing the prefix path to use for non-secure images
This property is defined by Module.

### https

`public String https`
<static> Constant representing the prefix path to use for securely served images
This property is defined by Module.

### id

`public String id`
The id of the element
This property is defined by Module.

### imageRoot

`public String imageRoot`
The String representing the image root
This property is defined by Module.

### isSecure

`public Boolean isSecure`
Boolean representing whether or not the current browsing context is secure (https)
This property is defined by Module.

### javascript

`public String javascript`
<static> Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
This property is defined by Module.

### platform

`public String platform`
String representing the current user-agent platform
This property is defined by Module.

## Constructor Details

### Module

`public function Module(`String el`, `HTMLElement el`, `Object userConfig`)`
Parameters:

- `el` : String
  The element ID representing the Module OR
- `el` : HTMLElement
  The element representing the Module
- `userConfig` : Object
  The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.

## Method Details

### appendToBody

`public function appendToBody(`HTMLElement element`)`
Appends the passed element to the body. If no body is present, one will be automatically created.
Parameters:

- `element` : HTMLElement
  The element to append to the body

Returns:

- `void`

This method is defined by Module.

### appendToFooter

`public function appendToFooter(`HTMLElement element`)`
Appends the passed element to the footer. If no footer is present, one will be automatically created.
Parameters:

- `element` : HTMLElement
  The element to append to the footer

Returns:

- `void`

This method is defined by Module.

### appendToHeader

`public function appendToHeader(`HTMLElement element`)`
Appends the passed element to the header. If no header is present, one will be automatically created.
Parameters:

- `element` : HTMLElement
  The element to append to the header

Returns:

- `void`

This method is defined by Module.

### configMonitorResize

`public function configMonitorResize(`String type`, `Object[] args`, `Object obj`)`
Default event handler for the "monitorresize" configuration property
Parameters:

- `type` : String
  The CustomEvent type (usually the property name)
- `args` : Object[]
  The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- `obj` : Object
  The scope object. For configuration handlers, this will usually equal the owner.

Returns:

- `void`

This method is defined by Module.

### configVisible

`public function configVisible(`String type`, `Object[] args`, `Object obj`)`
Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". This method is responsible for firing showEvent and hideEvent.
Parameters:

- `type` : String
  The CustomEvent type (usually the property name)
- `args` : Object[]
  The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
- `obj` : Object
  The scope object. For configuration handlers, this will usually equal the owner.

Returns:

- `void`

This method is defined by Module.

### destroy

`public function destroy()`
Removes the Module element from the DOM and sets all child elements to null.
Parameters:

- None.

Returns:

- `void`

This method is defined by Module.

### hide

`public function hide()`
Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
Parameters:

- None.

Returns:

- `void`

This method is defined by Module.

### init

`public function init(`String el`, `HTMLElement el`, `Object userConfig`)`
The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
Parameters:

- `el` : String
  The element ID representing the Module OR
- `el` : HTMLElement
  The element representing the Module
- `userConfig` : Object
  The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.

Returns:

- `void`

This method is defined by Module.

### initDefaultConfig

`public function initDefaultConfig()`
Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
Parameters:

- None.

Returns:

- `void`

This method is defined by Module.

### initEvents

`public function initEvents()`
Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
Parameters:

- None.

Returns:

- `void`

This method is defined by Module.

### initResizeMonitor

`public function initResizeMonitor()`
Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize.
Parameters:

- None.

Returns:

- `void`

This method is defined by Module.

### onDomResize

`public function onDomResize(`DOMEvent e`, `Object obj`)`
Event handler fired when the resize monitor element is resized.
Parameters:

- `e` : DOMEvent
  The DOM resize event
- `obj` : Object
  The scope object passed to the handler

Returns:

- `void`

This method is defined by Module.

### render

`public function render(`String appendToNode`, `HTMLElement appendToNode`, `HTMLElement moduleElement`)`
Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
Parameters:

- `appendToNode` : String
  The element id to which the Module should be appended to prior to rendering OR
- `appendToNode` : HTMLElement
  The element to which the Module should be appended to prior to rendering
- `moduleElement` : HTMLElement
  OPTIONAL. The element that represents the actual Standard Module container.

Returns:

- `Boolean`
  Success or failure of the render

This method is defined by Module.

### setBody

`public function setBody(`String bodyContent`, `HTMLElement bodyContent`)`
Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
Parameters:

- `bodyContent` : String
  The HTML used to set the body OR
- `bodyContent` : HTMLElement
  The HTMLElement to append to the body

Returns:

- `void`

This method is defined by Module.

### setFooter

`public function setFooter(`String footerContent`, `HTMLElement footerContent`)`
Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
Parameters:

- `footerContent` : String
  The HTML used to set the footer OR
- `footerContent` : HTMLElement
  The HTMLElement to append to the footer

Returns:

- `void`

This method is defined by Module.

### setHeader

`public function setHeader(`String headerContent`, `HTMLElement headerContent`)`
Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
Parameters:

- `headerContent` : String
  The HTML used to set the header OR
- `headerContent` : HTMLElement
  The HTMLElement to append to the header

Returns:

- `void`

This method is defined by Module.

### show

`public function show()`
Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
Parameters:

- None.

Returns:

- `void`

This method is defined by Module.

### toString

`public function toString()`
Returns a String representation of the Object.
Parameters:

- None.

Returns:

- `String`
  The string representation of the Module

This method is defined by Module.

## Event Details

### appendEvent

`public event appendEvent`
CustomEvent fired when the Module is appended to the DOM
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### beforeHideEvent

`public event beforeHideEvent`
CustomEvent fired before the Module is hidden
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### beforeInitEvent

`public event beforeInitEvent`
CustomEvent fired prior to class initalization.
Subscribers will be called with the following parameters:

- `classRef` : class
  class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)

This event is defined by Module.

### beforeRenderEvent

`public event beforeRenderEvent`
CustomEvent fired before the Module is rendered
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### beforeShowEvent

`public event beforeShowEvent`
CustomEvent fired before the Module is shown
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### changeBodyEvent

`public event changeBodyEvent`
CustomEvent fired when the body content of the Module is modified
Subscribers will be called with the following parameters:

- `content` : String/HTMLElement
  String/element representing the new body content

This event is defined by Module.

### changeContentEvent

`public event changeContentEvent`
CustomEvent fired when the content of the Module is modified
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### changeFooterEvent

`public event changeFooterEvent`
CustomEvent fired when the footer content of the Module is modified
Subscribers will be called with the following parameters:

- `content` : String/HTMLElement
  String/element representing the new footer content

This event is defined by Module.

### changeHeaderEvent

`public event changeHeaderEvent`
CustomEvent fired when the header content of the Module is modified
Subscribers will be called with the following parameters:

- `content` : String/HTMLElement
  String/element representing the new header content

This event is defined by Module.

### destroyEvent

`public event destroyEvent`
CustomEvent fired when the Module is destroyed
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### hideEvent

`public event hideEvent`
CustomEvent fired after the Module is hidden
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### initEvent

`public event initEvent`
CustomEvent fired after class initalization.
Subscribers will be called with the following parameters:

- `classRef` : class
  class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)

This event is defined by Module.

### renderEvent

`public event renderEvent`
CustomEvent fired after the Module is rendered
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

### showEvent

`public event showEvent`
CustomEvent fired after the Module is shown
Subscribers will be called with the following parameters:

- None.

This event is defined by Module.

Copyright © 2006 Jack Slocum. All rights reserved.