# Yahoo! UI Library

### Container 2.8.0r4

Yahoo! UI Library > container > YAHOO.widget.OverlayManager
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.widget.OverlayManager

OverlayManager is used for maintaining the focus status of multiple Overlays.

### Constructor

YAHOO.widget.OverlayManager `( overlays , userConfig )`

Parameters:
  `overlays <Array>` Optional. A collection of Overlays to register with the manager.
  `userConfig <Object>` The object literal representing the user configuration of the OverlayManager

### Properties

#### activeOverlay - `private YAHOO.widget.Overlay`

The currently activated Overlay

#### cfg - `Config`

The OverlayManager's Config object used for monitoring configuration properties.

#### contructor - `Function`

The class's constructor function

#### OverlayManager.CSS_FOCUSED - `static final String`

The CSS class representing a focused Overlay

#### overlays - `YAHOO.widget.Overlay[]`

The array of Overlays that are currently registered

### Methods

#### _bindBlur

`protected void _bindBlur ( overlay )`
Subscribes to the Overlay based instance's blurEvent to allow the OverlayManager to monitor blur state. If the instance already has a blurEvent (e.g. Menu), OverlayManager will subscribe to the existing blurEvent, however if a blurEvent or blur method does not exist on the instance, the _bindBlur method will add them, and the blur method update the OverlayManager's state directly.

Parameters:
  `overlay <Overlay>` The overlay for which blur needs to be managed

Returns: `void`

#### _bindDestroy

`protected void _bindDestroy ( overlay )`
Subscribes to the Overlay based instance's destroyEvent, to allow the Overlay to be removed for the OverlayManager when destroyed.

Parameters:
  `overlay <Overlay>` The overlay instance being managed

Returns: `void`

#### _bindFocus

`protected void _bindFocus ( overlay )`
Subscribes to the Overlay based instance focusEvent, to allow the OverlayManager to monitor focus state. If the instance already has a focusEvent (e.g. Menu), OverlayManager will subscribe to the existing focusEvent, however if a focusEvent or focus method does not exist on the instance, the _bindFocus method will add them, and the focus method will update the OverlayManager's state directly.

Parameters:
  `overlay <Overlay>` The overlay for which focus needs to be managed

Returns: `void`

#### _manageBlur

`protected void _manageBlur ( overlay )`
Updates the state of the OverlayManager and overlay, as a result of the overlay being blurred.

Parameters:
  `overlay <Overlay>` The overlay instance which got blurred.

Returns: `void`

#### _manageFocus

`protected void _manageFocus ( overlay )`
Updates the state of the OverlayManager and overlay, as a result of the overlay receiving focus.

Parameters:
  `overlay <Overlay>` The overlay instance which got focus.

Returns: `void`

#### _onOverlayBlurHandler

`private void _onOverlayBlurHandler ( p_sType , p_aArgs , p_oOverlay )`
blurEvent Handler, used to delegate to _manageBlur with the correct arguments.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oOverlay <Overlay>` Object representing the overlay that fired the event.

Returns: `void`

#### _onOverlayDestroy

`private void _onOverlayDestroy ( p_sType , p_aArgs , p_oOverlay )`
"destroy" event handler for the Overlay.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oOverlay <Overlay>` Object representing the overlay that fired the event.

Returns: `void`

#### _onOverlayElementFocus

`private void _onOverlayElementFocus ( p_oEvent )`
Event handler for the DOM event that is used to focus the Overlay instance as specified by the "focusevent" configuration property.

Parameters:
  `p_oEvent <Event>` Object representing the DOM event object passed back by the event utility (Event).

Returns: `void`

#### _onOverlayFocusHandler

`private void _onOverlayFocusHandler ( p_sType , p_aArgs , p_oOverlay )`
focusEvent Handler, used to delegate to _manageFocus with the correct arguments.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oOverlay <Overlay>` Object representing the overlay that fired the event.

Returns: `void`

#### _syncZIndex

`protected void _syncZIndex ( overlay )`
Ensures the zIndex configuration property on the managed overlay based instance is set to the computed zIndex value from the DOM (with "auto" translating to 0).

Parameters:
  `overlay <Overlay>` The overlay instance being managed

Returns: `void`

#### blurAll

`void blurAll ( )`
Removes focus from all registered Overlays in the manager

Returns: `void`

#### bringToTop

`void bringToTop ( p_oOverlay )`
Places the specified Overlay instance on top of all other Overlay instances.

Parameters:
  `p_oOverlay <YAHOO.widget.Overlay>` Object representing an Overlay instance.
  `p_oOverlay <String>` String representing the id of an Overlay instance.

Returns: `void`

#### compareZIndexDesc

`private Number compareZIndexDesc ( )`
Used for sorting the manager's Overlays by z-index.

Returns: `Number`
  0, 1, or -1, depending on where the Overlay should fall in the stacking order.

#### find

`Overlay find ( overlay )`
Attempts to locate an Overlay by instance or ID.

Parameters:
  `overlay <Overlay>` An Overlay to locate within the manager
  `overlay <String>` An Overlay id to locate within the manager

Returns: `Overlay`
  The requested Overlay, if found, or null if it cannot be located.

#### focus

`void focus ( overlay )`
Focuses the specified Overlay

Parameters:
  `overlay <Overlay>` The Overlay to focus
  `overlay <String>` The id of the Overlay to focus

Returns: `void`

#### getActive

`Overlay getActive ( )`
Returns the currently focused Overlay

Returns: `Overlay`
  The currently focused Overlay

#### hideAll

`void hideAll ( )`
Hides all Overlays in the manager.

Returns: `void`

#### init

`void init ( overlays , userConfig )`
Initializes the OverlayManager

Parameters:
  `overlays <Overlay[]>` Optional. A collection of Overlays to register with the manager.
  `userConfig <Object>` The object literal representing the user configuration of the OverlayManager

Returns: `void`

#### initDefaultConfig

`void initDefaultConfig ( )`
Initializes the default configuration of the OverlayManager

Returns: `void`

#### register

`boolean register ( overlay )`
Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each.

Parameters:
  `overlay <Overlay>` An Overlay to register with the manager.
  `overlay <Overlay[]>` An array of Overlays to register with the manager.

Returns: `boolean`
  true if any Overlays are registered.

#### remove

`void remove ( overlay )`
Removes the specified Overlay from the manager

Parameters:
  `overlay <Overlay>` The Overlay to remove
  `overlay <String>` The id of the Overlay to remove

Returns: `void`

#### showAll

`void showAll ( )`
Shows all Overlays in the manager.

Returns: `void`

#### toString

`String toString ( )`
Returns a string representation of the object.

Returns: `String`
  The string representation of the OverlayManager

### Configuration Attributes

#### focusevent `- String`

The default DOM event that should be used to focus an Overlay
Default Value: "mousedown"

#### overlays `- YAHOO.widget.Overlay[]`

The collection of registered Overlays in use by the OverlayManager
Default Value: null

Copyright © 2009 Yahoo! Inc. All rights reserved.