Widget

Widget

new Widget(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
element HTMLElement

The main element.

options.title String <optional>
""

A string to be set as title attribute on the main element to be displayed as tooltip.

options.disabled Boolean <optional>
false

Toggles the class .aux-disabled. By default it disables all pointer events on the widget via CSS to make it unusable to the user.

options.active Boolean <optional>

Toggles the class .aux-inactive.

options.visible Boolean <optional>

Toggles the class .aux-hide and .aux-show. This option also enables and disabled rendering by calling Widget#hide and Widget#show.

options.dblclick Boolean <optional>
400

Set a time in milliseconds for triggering double click event. If 0, no double click events are fired.

options.preset String <optional>

Set a preset. This string gets set as class attribute aux-preset-[preset]. If options.presets has a member of this name, all options of its option object are set on the Widget. Non-existent options are reset to the default. Defaults are updated on initialization and runtime.

options.presets Object <optional>
{}

An object with available preset specific options. Refer to options.preset for more information.

options.notransitions_duration number <optional>
500

A time in milliseconds until transitions are activated.

options.tabindex number | boolean <optional>
false

Set tabindex to activate focus on widgets. Tabindex is set on the element returned by getFocusElement. Try to only use false or 0, avoiding positive integers. To set a hierarchy for the tabindex, better create an appropriate DOM structure.

options.aria_targets array | boolean <optional>
false

Set an array of targets for ARIA values.

options.focus Boolean <optional>
false

Toggles the class .aux-focus.

Widget is the base class for all widgets drawing DOM elements. It provides basic functionality like delegating events, setting options and firing some events.

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

An object containing initial options.

Properties
Name Type Attributes Default Description
class String <optional>
""

A class to add to the class attribute of the main element.

id String <optional>
""

A string to be set as id attribute on the main element.

container HTMLElement <optional>

A container the main element shall be added to.

styles Object <optional>
""

An object containing CSS declarations to be added directly to the main element.

element HTMLElement <optional>

An element to be used as the main element.

Extends

Methods

addChild(child)

Source:
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:

Registers an array of widgets as children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

addEventListener(event, func)

Source:
Inherited From:

Register an event handler.

Parameters:
Name Type Description
event string

The event descriptor.

func function

The function to call when the event happens.

allChildren()

Source:

Returns an array of all children.

appendChild(child)

Source:

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:

Calls Widget#appendChild for an array of widgets.

Parameters:
Name Type Description
children Array.<Widget>

The child widgets to append.

delegateEvents(element) → {HTMLElement}

Source:
Inherited From:

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

Parameters:
Name Type Description
element HTMLElement

The element all native events of the widget should be bound to.

Fires:
Returns:

The element

Type
HTMLElement

destroy()

Source:
Overrides:

Dispose of this Widget.

destroyAndRemove()

Source:

Dispose of this Widget and remove it from the DOM.

disableTansitions()

Source:

Disable CSS transitions.

dispatchEvent(event, …args)

Source:
Inherited From:

Fires an event.

Parameters:
Name Type Attributes Description
event string

The event descriptor.

args * <repeatable>

Event arguments.

enableDraw()

Source:

Schedules this widget for drawing.

Fires:

enableDraw()

Source:

Stop drawing this widget.

Fires:

enableDrawChildren()

Source:

Enables rendering for all children of this widget.

enableTransitions()

Source:

Enable CSS transitions.

forceHide()

Source:

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

forceShow()

Source:

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

get(key)

Source:
Inherited From:

Get the value of an option.

Parameters:
Name Type Description
key string

The option name.

getDefault()

Source:
Inherited From:

Returns the default value of a given option. If the option does not exist, an exception is thrown.

getOptionType()

Source:
Inherited From:

Returns the type of an option. If the given option does not exist, 'undefined' is returned.

getStyle()

Source:

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

hasEventListeners(event) → {boolean}

Source:
Inherited From:

Test if the event descriptor has some handler functions in the queue.

Parameters:
Name Type Description
event string

The event desriptor.

Returns:

True if the event has some handler functions in the queue, false if not.

Type
boolean

hidden()

Source:

Returns the current hidden status.

hide()

Source:

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

invalidate(key)

Source:

Invalidates an option and triggers a redraw() call.

Parameters:
Name Type Description
key string

invalidateAll()

Source:

Invalidates all dependencies which will trigger all renderers to rerun.

observeResize(cb)

Source:

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

Parameters:
Name Type Description
cb function

off(event, fun)

Source:
Inherited From:

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

Parameters:
Name Type Description
event string

The event descriptor.

fun function

The function to remove.

removeChild(child)

Source:

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:

Removes an array of children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

reset(key)

Source:
Inherited From:

Resets an option to its default value.

Parameters:
Name Type Description
key string

The option name.

set(key, value)

Source:
Overrides:

Sets an option.

Parameters:
Name Type Description
key string

The option name.

value

The option value.

setStyle()

Source:

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

show()

Source:

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

toggleHidden()

Source:

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

transitionsDisabled()

Source:

Returns true if transitions are currently disabled on this widget.

update(key, value)

Source:
Inherited From:

Conditionally sets an option unless it already has the requested value.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:

userset(key, value)

Source:
Inherited From:

Sets an option by user interaction. Emits the userset event. The userset event can be cancelled (if an event handler returns false), in which case the option is not set. Returns true if the option was set, false otherwise. If the option was set, it will emit a useraction event.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:
  • Base#event:userset
  • Base#event:useraction

visibleChildren()

Source:

Returns an array of all visible children.

Events

GenericDOMEvents

Source:

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

delegated

Source:
Inherited From:

Is fired when an element is delegated.

Parameters:
Name Type Description
element HTMLElement | Array

The element which receives all native DOM events.

old_element HTMLElement | Array

The element which previously received all native DOM events.

destroy

Source:

Is fired when a widget is destroyed.

doubleclick

Source:

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.

hide

Source:

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:
Overrides:

Is fired when a widget is initialized.

resize

Source:

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:

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

set

Source:
Overrides:

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.

set_[option]

Source:
Inherited From:

Is fired when an option is set.

Parameters:
Name Type Description
value mixed

The value of the option.

show

Source:

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

visibility

Source:

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