Show:

The NodeFocusManager class is a plugin for a Node instance. The class is used via the <a href="Node.html#method_plug"><code>plug</code></a> method of Node and should not be instantiated directly.

Methods

_afterActiveDescendantChange

(
  • event
)
protected

afterChange event handler for the "activeDescendant" attribute.

Parameters:

  • event Object

    Object representing the change event.

_attachKeyHandler

() protected

Attaches the "key" event handlers used to support the "keys" attribute.

_detachEventHandlers

() protected

Attaches all event handlers used by the Focus Manager.

_detachEventHandlers

() protected

Detaches all event handlers used by the Focus Manager.

_detachKeyHandler

() protected

Detaches the "key" event handlers used to support the "keys" attribute.

_fireClick

() protected

Fires the click event if the enter key is pressed while focused on an HTML element that is not natively clickable.

_focusNext

(
  • event
  • activeDescendant
)
protected

Keydown event handler that moves focus to the next enabled descendant.

Parameters:

  • event Object

    Object representing the DOM event.

  • activeDescendant Number

    Number representing the index of the next descendant to be focused

_focusPrevious

(
  • event
  • activeDescendant
)
protected

Keydown event handler that moves focus to the previous enabled descendant.

Parameters:

  • event Object

    Object representing the DOM event.

  • activeDescendant Number

    Number representing the index of the next descendant to be focused.

_initDescendants

() protected

Sets the <code>tabIndex</code> attribute of all of the descendants to -1, except the active descendant, whose <code>tabIndex</code> attribute is set to 0.

_isDescendant

(
  • node
)
Boolean protected

Determines if the specified Node instance is a descendant managed by the Focus Manager.

Parameters:

  • node Node

    Node instance to be checked.

Returns:

Boolean:

Boolean indicating if the specified Node instance is a descendant managed by the Focus Manager.

_onDocFocus

(
  • event
)
protected

"focus" event handler for the owner document of the Focus Manager's Node.

Parameters:

  • event Object

    Object representing the DOM event.

_onDocMouseDown

(
  • event
)
protected

"mousedown" event handler for the owner document of the Focus Manager's Node.

Parameters:

  • event Object

    Object representing the DOM event.

_preventScroll

() protected

Prevents the viewport from scolling when the user presses the up, down, left, or right key.

_removeFocusClass

() protected

Removes the class name representing focus (as specified by the "focusClass" attribute) from the Node instance to which it is currently applied.

blur

()

Blurs the current active descendant and sets the <code>focused</code> attribute to false.

focus

(
  • index
)

Focuses the active descendant and sets the <code>focused</code> attribute to true.

Parameters:

  • index Number | Node

    Optional. Number representing the index of the descendant to be set as the active descendant or Node instance representing the descendant to be set as the active descendant.

refresh

()

Refreshes the Focus Manager's descendants by re-executing the CSS selector query specified by the <code>descendants</code> attribute.

start

()

Enables the Focus Manager.

stop

()

Disables the Focus Manager by detaching all event handlers.

Attributes

activeDescendant

Number

<p>Node, or index of the Node, representing the descendant that is either focused or is focusable (<code>tabIndex</code> attribute is set to 0). The value cannot represent a disabled descendant Node. Use a value of -1 to remove all descendant Nodes from the default tab flow. If no value is specified, the active descendant will be inferred using the following criteria:</p> <ol> <li>Examining the <code>tabIndex</code> attribute of each descendant and using the first descendant whose <code>tabIndex</code> attribute is set to 0</li> <li>If no default can be inferred then the value is set to either 0 or the index of the first enabled descendant.</li> </ol>

circular

Boolean

Boolean indicating if focus should be set to the first/last descendant when the end or beginning of the descendants has been reached.

Default: true

descendants

Y.NodeList

String representing the CSS selector used to define the descendant Nodes whose focus should be managed.

focusClass

String | Object

String representing the name of class applied to the focused active descendant Node. Can also be an object literal used to define both the class name, and the Node to which the class should be applied. If using an object literal, the format is: <code>{ className: "focus", fn: myFunction }</code>. The function referenced by the <code>fn</code> property in the object literal will be passed a reference to the currently focused active descendant Node.

focused

Boolean readonly

Boolean indicating that one of the descendants is focused.

Default: false

keys

Object

Object literal representing the keys to be used to navigate between the next/previous descendant. The format for the attribute's value is <code>{ next: "down:40", previous: "down:38" }</code>. The value for the "next" and "previous" properties are used to attach <a href="event/#keylistener"><code>key</code></a> event listeners. See the <a href="event/#keylistener">Using the key Event</a> section of the Event documentation for more information on "key" event listeners.