Base

Base

new Base()

Source:

This is the base class for all AUX widgets. It provides an API for event handling and options.

Methods

addEventListener(event, func)

Source:

Register an event handler.

Parameters:
Name Type Description
event string

The event descriptor.

func function

The function to call when the event happens.

delegateEvents(element) → {HTMLElement}

Source:

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:

Destroys all event handlers and the options object.

dispatchEvent(event, …args)

Source:

Fires an event.

Parameters:
Name Type Attributes Description
event string

The event descriptor.

args * <repeatable>

Event arguments.

get(key)

Source:

Get the value of an option.

Parameters:
Name Type Description
key string

The option name.

getDefault()

Source:

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

getOptionType()

Source:

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

hasEventListeners(event) → {boolean}

Source:

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

off(event, fun)

Source:

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.

reset(key)

Source:

Resets an option to its default value.

Parameters:
Name Type Description
key string

The option name.

set(key, value)

Source:

Sets an option. Fires both the events set with arguments key and value; and the event 'set_'+key with arguments value and key.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:

update(key, value)

Source:

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:

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

Events

delegated

Source:

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.

initialized

Source:

Is fired when an instance is initialized.

set

Source:

Is fired when an option is set.

Parameters:
Name Type Description
name string

The name of the option.

value mixed

The value of the option.

set_[option]

Source:

Is fired when an option is set.

Parameters:
Name Type Description
value mixed

The value of the option.