Container

Container

new Container(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.content String | HTMLElement <optional>

The content of the container. It can either be a string which is interpreted as HTML or a DOM node. Note that this option will remove all child nodes from the container element including those added via appendChild.

options.hiding_duration Number <optional>
0

The duration in ms of the hiding CSS transition/animation of this container. If this option is set to -1, the transition duration will be determined by the computed style, which can be rather expensive. Setting this option explicitly can therefore be an optimization.

options.showing_duration Number <optional>
0

The duration in ms of the showing CSS transition/animation of this container. If this option is set to -1, the transition duration will be determined by the computed style, which can be rather expensive. Setting this option explicitly can therefore be an optimization.

options.render_while_hiding boolean <optional>
false

If false, child widgets stops rendering while the hiding animation of this container is running.

Container represents a <DIV> element contining various other widgets or DOMNodes.

Containers have four different display states: show, hide, showing and hiding. Each of these states has a corresponding CSS class called .aux-show, .aux-hide, .aux-showing and .aux-hiding, respectively. The display state can be controlled using the methods Container#show, Container#hide and Widget#toggleHidden.

A container can keep track of the display states of its child widgets. The display state of a child can be changed using Container#hideChild, Container#showChild and Container#toggleChild.

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

An object containing initial options.

Properties
Name Type Attributes Default Description
children Array.<TK.Widget> <optional>
[]

Add child widgets on init. Will not be maintained on runtime! Just for convenience purposes on init.

Extends

Members

element :HTMLDivElement

Source:

The main DIV element. Has class .aux-container

Type:
  • HTMLDivElement

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.

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.

destroy()

Source:
Inherited From:

Dispose of this Widget.

destroyAndRemove()

Source:
Inherited From:

Dispose of this Widget and remove it from the DOM.

disableTansitions()

Source:
Inherited From:

Disable CSS transitions.

enableDraw()

Source:
Overrides:

Schedules this widget for drawing.

Fires:

enableDrawChildren()

Source:
Overrides:

Enables rendering for all children of this widget.

enableTransitions()

Source:
Inherited From:

Enable CSS transitions.

forceHide()

Source:
Overrides:

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

forceShow()

Source:
Overrides:

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

Returns the current hidden status.

hide()

Source:
Overrides:

Starts the transition of the visible to false.

hideChild(child)

Source:

Switches the hidden state of a child to hidden. The argument is either the child index or the child itself.

Parameters:
Name Type Description
child Object | integer

Child or its index.

invalidate(key)

Source:
Inherited From:

Invalidates an option and triggers a redraw() call.

Parameters:
Name Type Description
key string

invalidateAll()

Source:
Inherited From:

Invalidates all dependencies which will trigger all renderers to rerun.

isChildHidden(child) → {boolean}

Source:

Returns true if the given child is currently marked as hidden in this container.

Parameters:
Name Type Description
child number | Widget
Returns:
Type
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.

set(key, value)

Source:
Inherited From:

Sets an option.

Parameters:
Name Type Description
key string

The option name.

value

The option value.

setStyle()

Source:
Inherited From:

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

show()

Source:
Overrides:

Starts the transition of the visible to true.

showChild(child)

Source:

Switches the hidden state of a child to shown. The argument is either the child index or the child itself.

Parameters:
Name Type Description
child Object | integer

Child or its index.

toggleChild(child)

Source:

Toggles the hidden state of a child. The argument is either the child index or the child itself.

Parameters:
Name Type Description
child Object | integer

Child or its index.

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.

visibleChildren()

Source:
Overrides:

Returns an array of all visible children.

Events

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.

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.

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.

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.

visibility

Source:
Inherited From:

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