Class YAHOO.widget.Module
- Known Subclasses:
-
YAHOO.widget.Overlay
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.
Constructor
YAHOO.widget.Module
(
el
,
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.
Properties
body
- HTMLElement
The body element, denoted with CSS class "bd"
String representing the user-agent of the browser
Deprecated: Use YAHOO.env.ua
cfg
- YAHOO.util.Config
The Module's Config object used for monitoring
configuration properties.
The class's constructor function
Constant representing the Module's configuration properties
The main module element that contains the header, body, and footer
EVENT_TYPES
- private final Object
Constant representing the name of the Module's events
footer
- HTMLElement
The footer element, denoted with CSS class "ft"
header
- HTMLElement
The header element, denoted with CSS class "hd"
A string representing the root path for all images created by
a Module instance.
Deprecated: It is recommend that any images for a Module be applied
via CSS using the "background-image" property.
Boolean representing whether or not the current browsing context is
secure (https)
String representing the current user-agent platform
Constant representing the module body
Constant representing the module footer
Constant representing the module header
Constant for the default CSS class name that represents a Module
Constant representing the prefix path to use for non-secure images
Constant representing the prefix path to use for securely served images
Constant representing the buffer amount (in pixels) to use when positioning
the text resize monitor offscreen. The resize monitor is positioned
offscreen by an amount eqaul to its offsetHeight + the buffer value.
Constant representing the url for the "src" attribute of the iframe
used to monitor changes to the browser's base font size
Methods
protected
void
_addToParent
(
The
)
This method is a protected helper, used when constructing the DOM structure for the module
to account for situations which may cause Operation Aborted errors in IE. It should not
be used for general DOM construction.
If the parentNode is not document.body, the element is appended as the last element.
If the parentNode is document.body the element is added as the first child to help
prevent Operation Aborted errors in IE.
- Parameters:
-
The
<parentNode>
HTML element to which the element will be added
-
The
<element>
HTML element to be added to parentNode's children
- Returns:
void
protected
void
_initResizeMonitor
(
)
Create and initialize the text resize monitoring iframe.
private
void
_supportsCWResize
(
)
Text resize monitor helper method.
Determines if the browser supports resize events on iframe content windows.
void
appendToBody
(
element
)
Appends the passed element to the body. If no body is present, one
will be automatically created.
- Parameters:
-
element
<HTMLElement | DocumentFragment>
The element to
append to the body. In the case of a document fragment, the
children of the fragment will be appended to the body.
- Returns:
void
void
appendToFooter
(
element
)
Appends the passed element to the footer. If no footer is present,
one will be automatically created.
- Parameters:
-
element
<HTMLElement | DocumentFragment>
The element to
append to the footer. In the case of a document fragment, the
children of the fragment will be appended to the footer
- Returns:
void
void
appendToHeader
(
element
)
Appends the passed element to the header. If no header is present,
one will be automatically created.
- Parameters:
-
element
<HTMLElement | DocumentFragment>
The element to
append to the header. In the case of a document fragment, the
children of the fragment will be appended to the header.
- Returns:
void
void
configMonitorResize
(
type
,
args
,
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
void
configVisible
(
type
,
args
,
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
void
destroy
(
)
Removes the Module element from the DOM and sets all child elements
to null.
void
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.
void
init
(
el
,
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.
If the element passed in does not have an id, one will be generated
for it.
- 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
void
initDefaultConfig
(
)
Initializes the custom events for Module which are fired
automatically at appropriate times by the Module class.
void
initEvents
(
)
Initializes the custom events for Module which are fired
automatically at appropriate times by the Module class.
void
initResizeMonitor
(
)
Initialize an empty IFRAME that is placed out of the visible area
that can be used to detect text resize.
void
onDomResize
(
e
,
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
Boolean
render
(
appendToNode
,
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.
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.
NOTE: As of 2.3.1, if the appendToNode is the document's body element
then the module is rendered as the first child of the body element,
and not appended to it, to avoid Operation Aborted errors in IE when
rendering the module before window's load event is fired. You can
use the appendtodocumentbody configuration property to change this
to append to document.body if required.
- 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
void
setBody
(
bodyContent
)
Sets the Module's body content to the HTML specified.
If no body is present, one will be automatically created.
An empty string can be passed to the method to clear the contents of the body.
- Parameters:
-
bodyContent
<String>
The HTML used to set the body.
As a convenience, non HTMLElement objects can also be passed into
the method, and will be treated as strings, with the body innerHTML
set to their default toString implementations.
OR
-
bodyContent
<HTMLElement>
The HTMLElement to add as the first and only
child of the body element.
OR
-
bodyContent
<DocumentFragment>
The document fragment
containing elements which are to be added to the body
- Returns:
void
void
setFooter
(
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. An empty string can be passed to the method
to clear the contents of the footer.
- Parameters:
-
footerContent
<String>
The HTML used to set the footer
As a convenience, non HTMLElement objects can also be passed into
the method, and will be treated as strings, with the footer innerHTML
set to their default toString implementations.
OR
-
footerContent
<HTMLElement>
The HTMLElement to append to
the footer
OR
-
footerContent
<DocumentFragment>
The document fragment containing
elements which are to be added to the footer
- Returns:
void
void
setHeader
(
headerContent
)
Sets the Module's header content to the string specified, or appends
the passed element to the header. If no header is present, one will
be automatically created. An empty string can be passed to the method
to clear the contents of the header.
- Parameters:
-
headerContent
<String>
The string used to set the header.
As a convenience, non HTMLElement objects can also be passed into
the method, and will be treated as strings, with the header innerHTML
set to their default toString implementations.
OR
-
headerContent
<HTMLElement>
The HTMLElement to append to
OR
-
headerContent
<DocumentFragment>
The document fragment
containing elements which are to be added to the header
- Returns:
void
void
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.
String
toString
(
)
Returns a String representation of the Object.
- Returns:
String
- The string representation of the Module
static
void
YAHOO.widget.Module.forceDocumentRedraw
(
)
Helper utility method, which forces a document level
redraw for Opera, which can help remove repaint
irregularities after applying DOM changes.
Events
appendEvent
(
)
CustomEvent fired when the Module is appended to the DOM
beforeHideEvent
(
)
CustomEvent fired before the Module is hidden
beforeInitEvent
(
classRef
)
CustomEvent fired prior to class initalization.
- Parameters:
-
classRef
<class>
class reference of the initializing
class, such as this.beforeInitEvent.fire(Module)
beforeRenderEvent
(
)
CustomEvent fired before the Module is rendered
beforeShowEvent
(
)
CustomEvent fired before the Module is shown
changeBodyEvent
(
content
)
CustomEvent fired when the body content of the Module is modified
- Parameters:
-
content
<String/HTMLElement>
String/element representing
the new body content
changeContentEvent
(
)
CustomEvent fired when the content of the Module is modified
changeFooterEvent
(
content
)
CustomEvent fired when the footer content of the Module
is modified
- Parameters:
-
content
<String/HTMLElement>
String/element representing
the new footer content
changeHeaderEvent
(
content
)
CustomEvent fired when the header content of the Module
is modified
- Parameters:
-
content
<String/HTMLElement>
String/element representing
the new header content
destroyEvent
(
)
CustomEvent fired when the Module is destroyed
hideEvent
(
)
CustomEvent fired after the Module is hidden
initEvent
(
classRef
)
CustomEvent fired after class initalization.
- Parameters:
-
classRef
<class>
class reference of the initializing
class, such as this.beforeInitEvent.fire(Module)
renderEvent
(
)
CustomEvent fired after the Module is rendered
showEvent
(
)
CustomEvent fired after the Module is shown
YAHOO.widget.Module.textResizeEvent
(
)
Singleton CustomEvent fired when the font size is changed in the browser.
Opera's "zoom" functionality currently does not support text
size detection.
Configuration Attributes
Specifies if the module should be rendered as the first child
of document.body or appended as the last child when render is called
with document.body as the "appendToNode".
Appending to the body while the DOM is still being constructed can
lead to Operation Aborted errors in IE hence this flag is set to
false by default.
Default Value: false
Object or array of objects representing the ContainerEffect
classes that are active for animating the container.
NOTE: Although this configuration
property is introduced at the Module level, an out of the box
implementation is not shipped for the Module class so setting
the proroperty on the Module class has no effect. The Overlay
class is the first class to provide out of the box ContainerEffect
support.
Default Value: null
Specifies whether to create a special proxy iframe to monitor
for user font resizing in the document
Default Value: true
Specifies whether the Module is visible on the page.
Default Value: true