#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# WidgetModality Class

Defined in: `widget-modality/js/Widget-Modality.js:48`
Module: widget-modality

Widget extension, which can be used to add modality support to the base Widget class, through the Base.create method.

- Index
- Methods
- Properties
- Attributes

## Item Index

### Methods

- _afterFocusOnChange
- _afterHostVisibleChangeModal
- _afterHostZIndexChangeModal
- _attachUIHandlesModal
- _bindUIModal
- _blur
- _detachUIHandlesModal
- _focus
- _GET_MASK static
- _getMaskNode
- _renderUIModal
- _repositionMask
- _resyncMask
- _syncUIModal
- _uiSetHostVisibleModal
- _uiSetHostZIndexModal
- isNested

### Properties

- ATTRS static
- STACK

### Attributes

- focusOn
- maskNode
- modal

## Methods

### `_afterFocusOnChange`

()

Defined in `widget-modality/js/Widget-Modality.js:545`

Default function called when focusOn Attribute is changed. Remove existing listeners and create new listeners.

### `_afterHostVisibleChangeModal`

(

- `e`

)

Defined in `widget-modality/js/Widget-Modality.js:453`

Default function that is called when visibility is changed on the widget.

#### Parameters:

- `e` EventFacade

  The event facade of the change

### `_afterHostZIndexChangeModal`

(

- `e`

)

Defined in `widget-modality/js/Widget-Modality.js:464`

Default function that is called when z-index is changed on the widget.

#### Parameters:

- `e` EventFacade

  The event facade of the change

### `_attachUIHandlesModal`

()

Defined in `widget-modality/js/Widget-Modality.js:382`

Attaches UI Listeners for "clickoutside" and "focusoutside" on the widget. When these events occur, and the widget is modal, focus is shifted back onto the widget.

### `_bindUIModal`

() protected

Defined in `widget-modality/js/Widget-Modality.js:223`

Hooks up methods to be executed when the widget's visibility or z-index changes

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

### `_blur`

()

Defined in `widget-modality/js/Widget-Modality.js:281`

Blurs the widget.

### `_detachUIHandlesModal`

()

Defined in `widget-modality/js/Widget-Modality.js:441`

Detaches all UI Listeners that were set in _attachUIHandlesModal from the widget.

### `_focus`

()

Defined in `widget-modality/js/Widget-Modality.js:268`

Provides mouse and tab focus to the widget's bounding box.

### `_GET_MASK`

() static

Defined in `widget-modality/js/Widget-Modality.js:130`

Returns the mask if it exists on the page - otherwise creates a mask. There's only one mask on a page at a given time.

This method in invoked internally by the getter of the maskNode ATTR.

### `_getMaskNode`

() Node

Defined in `widget-modality/js/Widget-Modality.js:291`

Returns the Y.Node instance of the maskNode

#### Returns:

Node: The Y.Node instance of the mask, as returned from WidgetModal.GETMASK

### `_renderUIModal`

() protected

Defined in `widget-modality/js/Widget-Modality.js:198`

Adds modal class to the bounding box of the widget

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

### `_repositionMask`

(

- `nextElem`

)

Defined in `widget-modality/js/Widget-Modality.js:488`

Repositions the mask in the DOM for nested modality cases.

#### Parameters:

- `nextElem` Widget

  The Y.Widget instance that will be visible in the stack once the current widget is closed.

### `_resyncMask`

(

- `nextElem`

)
private

Defined in `widget-modality/js/Widget-Modality.js:522`

Resyncs the mask in the viewport for browsers that don't support fixed positioning

#### Parameters:

- `nextElem` Y.Widget

  The Y.Widget instance that will be visible in the stack once the current widget is closed.

### `_syncUIModal`

() protected

Defined in `widget-modality/js/Widget-Modality.js:251`

Syncs the mask with the widget's current state, namely the visibility and z-index of the widget

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

### `_uiSetHostVisibleModal`

(

- `Whether`

)

Defined in `widget-modality/js/Widget-Modality.js:302`

Performs events attaching/detaching, stack shifting and mask repositioning based on the visibility of the widget

#### Parameters:

- `Whether` Boolean

  the widget is visible or not

### `_uiSetHostZIndexModal`

(

- `Z-Index`

)

Defined in `widget-modality/js/Widget-Modality.js:368`

Sets the z-index of the mask node.

#### Parameters:

- `Z-Index` Number

  of the widget

### `isNested`

() public

Defined in `widget-modality/js/Widget-Modality.js:475`

Returns a boolean representing whether the current widget is in a "nested modality" state. This is done by checking the number of widgets currently on the stack.

## Properties

### `ATTRS`

Object static

Defined in `widget-modality/js/Widget-Modality.js:64`

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

### `STACK`

Unknown

Defined in `widget-modality/js/Widget-Modality.js:173`

A stack of Y.Widget objects representing the current hierarchy of modal widgets presently displayed on the screen

## Attributes

### `focusOn`

Array

Defined in `widget-modality/js/Widget-Modality.js:96`

An array of objects corresponding to the nodes and events that will trigger a re-focus back on the widget. The implementer can supply an array of objects, with each object having the following properties:

eventName: (string, required): The eventName to listen to.

node: (Y.Node, optional): The Y.Node that will fire the event (defaults to the boundingBox of the widget)

By default, this attribute consists of two objects which will cause the widget to re-focus if anything outside the widget is clicked on or focussed upon.

#### Fires event `focusOnChange`

Fires when the value for the configuration attribute `focusOn` 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:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `maskNode`

Y.Node

Defined in `widget-modality/js/Widget-Modality.js:73`

Returns a Y.Node instance of the node being used as the mask.

#### Fires event `maskNodeChange`

Fires when the value for the configuration attribute `maskNode` 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:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `modal`

Boolean

Defined in `widget-modality/js/Widget-Modality.js:85`

Whether the widget should be modal or not.

#### Fires event `modalChange`

Fires when the value for the configuration attribute `modal` 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:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.