Select

Select

new Select(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.selected Integer | Boolean <optional>
false

The index of the selected SelectEntry. Set to -1 to unselect any already selected entries.

options.value mixed <optional>

The value of the selected entry.

options.selected_entry SelectEntry <optional>

The currently selected entry.

options.auto_size Boolean <optional>
true

If true, the Select is auto-sized to be as wide as the widest SelectEntry.

options.entries Array.<Object> <optional>
[]

The list of SelectEntry. Each member is an object with the two properties label and value, a string used as label for constructing a SelectEntry or an instance of SelectEntry.

options.placeholder String | Boolean <optional>
false

Placeholder for the button label. Set to false to have an empty placeholder. This placeholder is shown when no entry is selected.

options.list_class String | Boolean <optional>

A CSS class to be set on the list. This is a static option and can only be set once on initializaion.

Select provides a Button with a select list to choose from a list of SelectEntry.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Extends

Members

_list :HTMLListElement

Source:

A HTML list for displaying the entry labels. Has class .aux-selectlist.

Type:
  • HTMLListElement

element :HTMLDivElement

Source:
Overrides:

The main DIV container. Has class .aux-select.

Type:
  • HTMLDivElement

entries :Array

Source:

An array containing all entry objects with members label and value.

Type:
  • Array

icon :Icon

Source:
Inherited From:

The Icon widget.

Type:

label :Label

Source:
Inherited From:

The Label of the button.

Type:

sizer :Select

Source:

A blind element for auto_size.

Type:

Methods

addChild(child)

Source:
Overrides:
See:

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

Parameters:
Name Type Description
child Widget

The child to add.

Fires:
  • Widget#event:child_added

addChildren(a)

Source:
Inherited From:

Registers an array of widgets as children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

addEntries(entries)

Source:

Adds new SelectEntry to the end of the list to select from.

Parameters:
Name Type Description
entries Array

An array of SelectEntry to add to the end of the list of SelectEntry to select from. Please refer to Select#addEntry for more details.

addEntry(entry, positionopt)

Source:

Adds a single SelectEntry to the end of the list.

Parameters:
Name Type Attributes Description
entry mixed

A string to be displayed and used as the value, an object with members label and value or an instance of SelectEntry.

position integer <optional>

The position in the list to add the new entry at. If omitted, the entry is added at the end.

Fires:
  • Select.event:entryadded

allChildren()

Source:
Inherited From:

Returns an array of all children.

appendChild(child)

Source:
Inherited From:

Appends child.element to the widget element and registers child as a child widget.

Parameters:
Name Type Description
child Widget

The child widget to append.

appendChildren(children)

Source:
Inherited From:

Calls Widget#appendChild for an array of widgets.

Parameters:
Name Type Description
children Array.<Widget>

The child widgets to append.

clear()

Source:

Remove all SelectEntry from the list.

Fires:
  • Select#event:cleared

current() → {SelectEntry|Boolean}

Source:

Get the currently selected SelectEntry.

Returns:

The currently selected SelectEntry or null.

Type
SelectEntry | Boolean

currentIndex() → {Integer|Boolean}

Source:

Get the currently selected SelectEntry's index. Just for the sake of completeness, this function abstracts options.selected.

Returns:

The index of the currently selected SelectEntry or -1.

Type
Integer | Boolean

currentValue() → {Mixed|Boolean}

Source:

Get the currently selected SelectEntry's value.

Returns:

The value of the currently selected SelectEntry or undefined.

Type
Mixed | Boolean

disableTansitions()

Source:
Inherited From:

Disable CSS transitions.

enableDraw()

Source:
Inherited From:

Schedules this widget for drawing.

Fires:

enableDrawChildren()

Source:
Inherited From:

Enables rendering for all children of this widget.

enableTransitions()

Source:
Inherited From:

Enable CSS transitions.

entryByIndex(index) → {SelectEntry|Boolean}

Source:

Get a SelectEntry by its index.

Parameters:
Name Type Description
index Integer

The index of the SelectEntry.

Returns:

The SelectEntry or null.

Type
SelectEntry | Boolean

entryByLabel(label) → {SelectEntry|Boolean}

Source:

Get a SelectEntry by its label/label.

Parameters:
Name Type Description
label String

The label of the SelectEntry.

Returns:

The SelectEntry or null.

Type
SelectEntry | Boolean

entryByValue(value) → {SelectEntry|False}

Source:

Get a SelectEntry by its value.

Parameters:
Name Type Description
value Mixed

The value of the SelectEntry.

Returns:

The SelectEntry or null.

Type
SelectEntry | False

forceHide()

Source:
Inherited From:

Hide the widget immediately by applying the class aux-hide. Does not call disableDraw().

forceShow()

Source:
Inherited From:

Show the widget immediately by applying the class aux-show. Does not call enableDraw().

getStyle()

Source:
Inherited From:

Returns the computed style of this widget's DOM element.

hidden()

Source:
Inherited From:

Returns the current hidden status.

hide()

Source:
Inherited From:

Hide the widget. This will result in the class aux-hide being applied to this widget in the next rendering step.

indexByElement(element) → {Integer}

Source:

Get the index of a SelectEntry by its HTMLElement.

Parameters:
Name Type Description
element HTMLElement

The element of the SelectEntry.

Returns:

The index of the entry or -1.

Type
Integer

indexByEntry(entry) → {Integer|Boolean}

Source:

Get the index of a SelectEntry by the SelectEntry itself.

Parameters:
Name Type Description
entry SelectEntry

The SelectEntry.

Returns:

The index of the entry or -1.

Type
Integer | Boolean

indexByLabel(label) → {Integer}

Source:

Get the index of a SelectEntry by its label/label.

Parameters:
Name Type Description
label String

The label/label of the SelectEntry.

Returns:

The index of the entry or -1.

Type
Integer

indexByValue(value) → {Integer|Boolean}

Source:

Get the index of a SelectEntry by its value.

Parameters:
Name Type Description
value Mixed

The value of the SelectEntry.

Returns:

The index of the entry or -1.

Type
Integer | Boolean

invalidate(key)

Source:
Inherited From:

Invalidates an option and triggers a redraw() call.

Parameters:
Name Type Description
key string

nextEntryByPartialLabel(label, current) → {SelectEntry|Boolean}

Source:

Get the next SelectEntry whose label starts with the given string.

Parameters:
Name Type Description
label String

The label of the SelectEntry.

current Number

the current index to start searching.

Returns:

The SelectEntry or null.

Type
SelectEntry | Boolean

observeResize(cb)

Source:
Inherited From:

Calls a callback whenever the widget resizes. This method will trigger one resize.

Parameters:
Name Type Description
cb function

removeChild(child)

Source:
Overrides:

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

Parameters:
Name Type Description
child Widget

The child to remove.

Fires:
  • Widget#event:child_removed

removeChildren(a)

Source:
Inherited From:

Removes an array of children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

removeEntry(entry)

Source:

Remove an entry from the list.

Parameters:
Name Type Description
entry SelectEntry

The SelectEntry to be removed from the list.

Fires:
  • Select#event:entryremoved

removeIndex(index)

Source:

Remove a SelectEntry from the list by its index.

Parameters:
Name Type Description
index Integer

The index of the SelectEntry to be removed from the list.

Fires:
  • Select#event:entryremoved

removeLabel(label)

Source:

Remove an entry from the list by its label.

Parameters:
Name Type Description
label string

The label of the entry to be removed from the list.

Fires:
  • Select#event:entryremoved

removeValue(value)

Source:

Remove a SelectEntry from the list by its value.

Parameters:
Name Type Description
value mixed

The value of the SelectEntry to be removed from the list.

Fires:
  • Select#event:entryremoved

select(index)

Source:

Select a SelectEntry by its index.

Parameters:
Name Type Description
index Integer

The index of the SelectEntry to select.

selectLabel(label)

Source:

Select a SelectEntry by its label.

Parameters:
Name Type Description
label mixed

The label of the SelectEntry to select.

selectValue(value)

Source:

Select a SelectEntry by its value.

Parameters:
Name Type Description
value mixed

The value of the SelectEntry to select.

set(key, value)

Source:
Overrides:

Sets an option.

Parameters:
Name Type Description
key string

The option name.

value

The option value.

setEntries(entries)

Source:

Replaces the list of SelectEntry to select from with an entirely new one.

Parameters:
Name Type Description
entries Array

An array of SelectEntry to set as the new list to select from. Please refer to Select#addEntry for more details.

setStyle()

Source:
Inherited From:

Sets a CSS style property in this widget's DOM element.

show()

Source:
Inherited From:

Make the widget visible. This will apply the class aux-show during the next rendering step.

showList(show)

Source:

Show or hide the select list

Parameters:
Name Type Description
show boolean

true to show and false to hide the list of SelectEntry.

toggleHidden()

Source:
Inherited From:

Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

transitionsDisabled()

Source:
Inherited From:

Returns true if transitions are currently disabled on this widget.

valueByEntry(entry) → {mixed}

Source:

Get the value of a SelectEntry.

Parameters:
Name Type Description
entry SelectEntry

The SelectEntry.

Returns:

The value of the SelectEntry.

Type
mixed

valueByIndex(index) → {Mixed|Boolean}

Source:

Get a value by its SelectEntry index.

Parameters:
Name Type Description
index Integer

The index of the SelectEntry.

Returns:

The value of the SelectEntry or undefined.

Type
Mixed | Boolean

valueByLabel(label) → {Mixed|Boolean}

Source:

Get the value of a SelectEntry by its label/label.

Parameters:
Name Type Description
label String

The label of the SelectEntry.

Returns:

The value of the SelectEntry or undefined.

Type
Mixed | Boolean

visibleChildren()

Source:
Inherited From:

Returns an array of all visible children.

Events

cleared

Source:

Is fired when the list is cleared.

entryremoved

Source:

Is fired when an entry was removed from the list.

Parameters:
Name Type Description
entry SelectEntry

The removed select entry.

clicked

Source:
Inherited From:

Is fired if a delay is set, after the pointer is released and the timeout hasn't finished yet. Doesn't fire after the timeout finished.

Parameters:
Name Type Description
event Event

Either the MouseEvent or the TouchEvent.

destroy

Source:
Inherited From:

Is fired when a widget is destroyed.

doubleclick

Source:
Inherited From:

Is fired after a double click appeared. Set dblclick to 0 to disable click event handling.

Parameters:
Name Type Description
event string

The browsers MouseEvent.

entryadded

Source:

Is fired when a new SelectEntry is added to the list.

Parameters:
Name Type Description
entry SelectEntry

A new SelectEntry.

GenericDOMEvents

Source:
Inherited From:

Generic DOM events. Please refer to W3Schools for further details.

hide

Source:
Inherited From:

The hide event is emitted when a widget is hidden and is not rendered anymore. This happens both with browser visibility changes and also internally when using layout widgets such as Pager.

initialized

Source:
Inherited From:

Is fired when a widget is initialized.

press_cancel

Source:
Inherited From:

Is fired after press_start or press_delay and before a press_end was fired while the pointer is dragged outside of the button element.

Parameters:
Name Type Description
event Event

Either the MouseEvent or the TouchEvent.

press_delayed

Source:
Inherited From:

Is fired after either a mousedown or a touchstart happened but delay is set so firing press_start will be delayed.

press_end

Source:
Inherited From:

Is fired after either a mouseup or a touchend happened and the pointer didn't leave the button element after press_start or press_delayed was fired.

Parameters:
Name Type Description
event Event

Either the MouseEvent or the TouchEvent.

press_start

Source:
Inherited From:

Is fired after either a mousedown or a touchstart happened and delay is set to 0. If a delay is set, press_delayed is fired instead on mousedown/touchstart and this event gets fired as soon as the delay time is over.

Parameters:
Name Type Description
event Event

Either the MouseEvent or the TouchEvent.

pressed

Source:
Inherited From:

Is fired if delay is set and the timeout has finished.

Parameters:
Name Type Description
event Event

Either the MouseEvent or the TouchEvent.

redraw

Source:
Inherited From:

The redraw event is emitted when a widget is redrawn. This can be used to do additional DOM modifications to a Widget.

resize

Source:
Inherited From:

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the Widget#resized event can be used instead.

resized

Source:
Inherited From:

The resized event is emitted after each rendering frame, which was triggered by a resize event.

select

Source:

Is fired when a selection was made by the user. The arguments are the value of the currently selected SelectEntry, its index, its label and the SelectEntry instance.

Parameters:
Name Type Description
value mixed

The value of the selected entry.

value number

The ID of the selected entry.

value string

The label of the selected entry.

set

Source:
Inherited From:

The set event is emitted when an option was set using the Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

show

Source:
Inherited From:

The show event is emitted when a widget is shown and is being rendered. This is the counterpart to Widget#hide.

useraction

Source:

The useraction event is emitted when a widget gets modified by user interaction. The event is emitted for the options selected and value.

Parameters:
Name Type Description
name string

The name of the option which was changed due to the users action

value mixed

The new value of the option

visibility

Source:
Inherited From:

Is fired when the visibility state changes. The first argument is the visibility state, which is either true or false.