Class: UWA.Controls.DropDown

UWA/Controls/DropDown. UWA.Controls.DropDown

new UWA.Controls.DropDown(options)

Base class for a positionned dropdown.

Available Events
Event Description
onClick When the user clicks on the dropdown (default: hide the dropdown)
onClickOutside When the user clicks outside the dropdown (default: nothing)
onMouseLeave When the mouse leaves the dropdown (default: nothing)
onShow When the dropdown is shown
onHide When the dropdown is hidden
Example
var dropdown = new UWA.Controls.DropDown({
    position: myElement.getPosition(null, {x: 'left', y: 'bottom'})
}).inject(myElement, 'after');
myElement.addEvent('click', dropdown.show.bind(dropdown));
Parameters
Name Type Description
options Object

Options hash or a option/value pair.

Properties
Name Type Argument Default Description
position Object | Function <optional>
null

The position to pass to UWA.Element#setPosition. If this is a function, it will be called just before setting the position and should return the position to use.

positionOptions Object | Function <optional>
null

The position options to pass to UWA.Element#setPosition. If this is a function, it will be called just before setting the position and should return the position options to use.

Extends

  • UWA.Control.Abstract

Index

Members

name :String

The control name

Type
  • String

updatePosition

Update the position of the dropdown, using the "position" and "positionOptions" options. See UWA.Element#setPosition.

Methods

destroy()

Destroy the control elements and its children. Remove all events and remove the element from the dom. This control and its children should not be used after this.

getContent() → {HTMLElement}

Build and return input wrapper Element.

Returns
Type
HTMLElement

onClick(e)

Default onClick handler. When an event gets here, the dropdown is hidden.

Parameters
Name Type Description
e Event

The click event

onPostInject()

Default onPostInject event handler. When the dropdown is injected, update its position.

onShow()

Default onShow event handler. Initialize the "onClickOutside" event mechanism.

onHide()

Default onShow event handler. Remove the "onClickOutside" event mechanism.

isOpen() → {Boolean}

Whether or not the dropdown is visible.

Returns
Type
Boolean

toggle(force) → {this}

Toggles the visibility of the dropdown.

Parameters
Name Type Argument Default Description
force Boolean <optional>
false

Force show (if true) or hide the element

Returns
Type
this

setPosition(position, positionOptions=) → {this}

Set the "position" and "positionOptions" options and update the position of the dropdown. Arguments are merged with the current options instead of replacing them.

Parameters
Name Type Argument Description
position Object

equivalent to the position option

positionOptions= Object <optional>

equivalent to the positionOptions option

Returns
Type
this

getInnerElement() → {HTMLElement}

Get the inner element of the dropdown. Use it to set its content.

This function is the equivalent of getContent, but a class extending this control could change this.

Example
var myControl = new UWA.Controls.DropDown();
myControl.getInnerElement().empty(true).addContent('foo');
myControl.show();
Returns

A DOM element.

Type
HTMLElement