- Known Subclasses:
-
YAHOO.widget.Panel
YAHOO.widget.Menu
YAHOO.widget.Tooltip
Overlay is a Module that is absolutely positioned above the page flow. It
has convenience methods for positioning and sizing, as well as options for
controlling zIndex and constraining the Overlay's position to the current
visible viewport. Overlay also contains a dynamicly generated IFRAME which
is placed beneath it for Internet Explorer 6 and 5.x so that it will be
properly rendered above SELECT elements.
Constructor
YAHOO.widget.Overlay
(
el
,
userConfig
)
- Parameters:
-
el
<String>
The element ID representing the Overlay OR
-
el
<HTMLElement>
The element representing the Overlay
-
userConfig
<Object>
The configuration object literal containing
the configuration that should be set for this Overlay. See configuration
documentation for more details.
Properties
Array of default event types which will trigger
context alignment for the Overlay class.
The array is empty by default for Overlay,
but maybe populated in future releases, so classes extending
Overlay which need to define their own set of CONTEXT_TRIGGERS
should concatenate their super class's prototype.CONTEXT_TRIGGERS
value with their own array of values.
E.g.:
CustomOverlay.prototype.CONTEXT_TRIGGERS = YAHOO.widget.Overlay.prototype.CONTEXT_TRIGGERS.concat(["windowScroll"]);
Constant representing the Overlay's configuration properties
EVENT_TYPES
- private final Object
Constant representing the name of the Overlay's events
A boolean that indicated whether the window resize and scroll events have
already been subscribed to.
Internal map of special event types, which are provided
by the instance. It maps the event type to the custom event
instance. Contains entries for the "windowScroll", "windowResize" and
"textResize" static container events.
Constant representing the top bottom left corner of an element, used for
configuring the context element alignment
Constant representing the bottom right corner of an element, used for
configuring the context element alignment
Constant representing the default CSS class used for an Overlay
The URL that will be placed in the iframe
Default Value: 3
Constant representing the names of the standard module elements
used in the overlay.
Constant representing the top left corner of an element, used for
configuring the context element alignment
Constant representing the top right corner of an element, used for
configuring the context element alignment
Number representing the minimum distance an Overlay instance should be
positioned relative to the boundaries of the browser's viewport, in pixels.
Default Value: 10
body,
browser,
cfg,
contructor,
DEFAULT_CONFIG,
element,
EVENT_TYPES,
footer,
header,
id,
imageRoot,
isSecure,
platform
Methods
protected
void
_alignOnTrigger
(
type
,
args
)
Custom Event handler for context alignment triggers. Invokes the align method
- Parameters:
-
type
<String>
The event type (not used by the default implementation)
-
args
<Any[]>
The array of arguments for the trigger event (not used by the default implementation)
- Returns:
void
protected
void
_autoFillOnHeightChange
(
type
,
args
,
el
)
The default custom event handler executed when the overlay's height is changed,
if the autofillheight property has been set.
- Parameters:
-
type
<String>
The event type
-
args
<Array>
The array of arguments passed to event subscribers
-
el
<HTMLElement>
The header, body or footer element which is to be resized to fill
out the containers height
- Returns:
void
private
void
_findTriggerCE
(
t
)
Helper method to locate the custom event instance for the event name string
passed in. As a convenience measure, any custom events passed in are returned.
- Parameters:
-
t
<String|CustomEvent>
Either a CustomEvent, or event type (e.g. "windowScroll") for which a
custom event instance needs to be looked up from the Overlay._TRIGGER_MAP.
- Returns:
void
private
Number
_getComputedHeight
(
el
)
Determines the content box height of the given element (height of the element, without padding or borders) in pixels.
- Parameters:
-
el
<HTMLElement>
The element for which the content height needs to be determined
- Returns:
Number
- The content box height of the given element, or null if it could not be determined.
private
Float
_getPreciseHeight
(
el
)
Returns the sub-pixel height of the el, using getBoundingClientRect, if available,
otherwise returns the offsetHeight
- Parameters:
-
el
<HTMLElement>
- Returns:
Float
- The sub-pixel height if supported by the browser, else the rounded height.
protected
void
_primeXYFromDOM
(
)
Set's the container's XY value from DOM if not already set.
Differs from syncPosition, in that the XY value is only sync'd with DOM if
not already set. The method also refire's the XY config property event, so any
beforeMove, Move event listeners are invoked.
protected
void
_processTriggers
(
triggers
,
mode
,
fn
)
Utility method that subscribes or unsubscribes the given
function from the list of trigger events provided.
- Parameters:
-
triggers
<Array[String|CustomEvent]>
An array of either CustomEvents, event type strings
(e.g. "beforeShow", "windowScroll") to/from which the provided function should be
subscribed/unsubscribed respectively.
-
mode
<String>
Either "subscribe" or "unsubscribe", specifying whether or not
we are subscribing or unsubscribing trigger listeners
-
fn
<Function>
The function to be subscribed/unsubscribed to/from the trigger event.
Context is always set to the overlay instance, and no additional object argument
get passed to the subscribed function.
- Returns:
void
protected
_validateAutoFillHeight
(
val
)
autofillheight validator. Verifies that the autofill value is either null
or one of the strings : "body", "header" or "footer".
void
align
(
elementAlign
,
contextAlign
)
Aligns the Overlay to its context element using the specified corner
points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT,
and BOTTOM_RIGHT.
- Parameters:
-
elementAlign
<String>
The String representing the corner of
the Overlay that should be aligned to the context element
-
contextAlign
<String>
The corner of the context element
that the elementAlign corner should stick to.
- Returns:
void
void
bringToTop
(
)
Places the Overlay on top of all other instances of
YAHOO.widget.Overlay.
void
center
(
)
Centers the container in the viewport.
void
configAutoFillHeight
(
type
,
args
,
obj
)
The default event handler fired when the "autofillheight" property is changed.
- 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
configConstrainToViewport
(
type
,
args
,
obj
)
The default event handler fired when the "constraintoviewport"
property is changed.
- 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
configContext
(
type
,
args
,
obj
)
The default event handler fired when the "context" property
is changed.
- 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
configFixedCenter
(
type
,
args
,
obj
)
The default event handler fired when the "fixedcenter" property
is changed.
- 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
configHeight
(
type
,
args
,
obj
)
The default event handler fired when the "height" property is changed.
- 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
configIframe
(
type
,
args
,
obj
)
The default event handler fired when the "iframe" property is changed.
- 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
)
The default event handler fired when the "visible" property is
changed. 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
configWidth
(
type
,
args
,
obj
)
The default event handler fired when the "width" property is changed.
- 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
configX
(
type
,
args
,
obj
)
The default event handler fired when the "x" property is changed.
- 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
configXY
(
type
,
args
,
obj
)
The default event handler fired when the "xy" property is changed.
- 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
configY
(
type
,
args
,
obj
)
The default event handler fired when the "y" property is changed.
- 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
configzIndex
(
type
,
args
,
obj
)
The default event handler fired when the "zIndex" property is changed.
- 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 Overlay element from the DOM and sets all child
elements to null.
void
doCenterOnDOMEvent
(
)
Center event handler used for centering on scroll/resize, but only if
the Overlay is visible
void
enforceConstraints
(
type
,
args
,
obj
)
The default event handler executed when the moveEvent is fired, if the
"constraintoviewport" is set to true.
- 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
fillHeight
(
el
)
Sets the height on the provided header, body or footer element to
fill out the height of the container. It determines the height of the
containers content box, based on it's configured height value, and
sets the height of the autofillheight element to fill out any
space remaining after the other standard module element heights
have been accounted for.
NOTE: This method is not designed to work if an explicit
height has not been set on the container, since for an "auto" height container,
the heights of the header/body/footer will drive the height of the container.
- Parameters:
-
el
<HTMLElement>
The element which should be resized to fill out the height
of the container element.
- Returns:
void
Number
getConstrainedX
(
x
)
Given x coordinate value, returns the calculated x coordinate required to
position the Overlay if it is to be constrained to the viewport, based on the
current element size, viewport dimensions and scroll values.
- Parameters:
-
x
<Number>
The X coordinate value to be constrained
- Returns:
Number
- The constrained x coordinate
Array
getConstrainedXY
(
x
,
y
)
Given x, y coordinate values, returns the calculated coordinates required to
position the Overlay if it is to be constrained to the viewport, based on the
current element size, viewport dimensions and scroll values.
- Parameters:
-
x
<Number>
The X coordinate value to be constrained
-
y
<Number>
The Y coordinate value to be constrained
- Returns:
Array