TK.Window

new Window(optionsopt)

This widget is a flexible overlay window.

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

An object containing initial options.

Properties:
Name Type Attributes Default Description
options.width Number <optional>
500

Initial width, can be a CSS length or an integer (pixels).

options.height Number <optional>
200

Initial height, can be a CSS length or an integer (pixels).

options.x Number <optional>
0

X position of the window.

options.y Number <optional>
0

Y position of the window.

options.min_width Number <optional>
64

Minimum width of the window.

options.max_width Number <optional>
-1

Maximum width of the window, -1 ~ infinite.

options.min_height Number <optional>
64

Minimum height of the window.

options.max_height Number <optional>
-1

Maximum height of the window, -1 ~ infinite.

options.anchor String <optional>
"top-left"

Anchor of the window, can be one out of top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right

options.modal Boolean <optional>
false

If modal window blocks all other elements

options.dock String <optional>
false

Docking of the window, can be one out of top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right

options.maximize Object | Boolean <optional>
false

Boolean or object with members x and y as boolean to determine the maximized state.

options.minimize Boolean <optional>
false

Minimize window (does only make sense with a window manager application to keep track of it)

options.shrink Boolean <optional>
false

Shrink rolls the window up into the title bar.

options.content String | HTMLElement | TK.Container <optional>
""

The content of the window. Can be either a string, a HTMLElement or a TK.Container to be appended to the content area.

options.open String <optional>
"center"

initial position of the window, can be one out of top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right

options.z_index Integer <optional>
10000

Z index for piling windows. does make more sense when used together with a window manager

options.header String | Array.<String> <optional>
["title", "maximize", "close"]

Single element or array of title, icon, close, minimize, shrink, maximize, maximizevertical, maximizehorizontal, status, resize, spacer.

options.footer String | Array.<String> <optional>
false

Single element or array of title, icon, close, minimize, shrink, maximize, maximizevertical, maximizehorizontal, status, resize, spacer.

options.title String <optional>
false

Window title.

options.status String <optional>
false

Window status.

options.icon String <optional>
false

URL to window icon.

options.fixed Boolean <optional>
true

Whether the window sticks to the viewport rather than the document

options.auto_active Boolean <optional>
false

Auto-toggle the active-class when mouseovered

options.auto_close Boolean <optional>
true

Set whether close destroys the window or not

options.auto_maximize Boolean <optional>
true

Set whether maximize toggles the window or not

options.auto_minimize Boolean <optional>
true

Set whether minimize toggles the window or not

options.auto_shrink Boolean <optional>
true

Set whether shrink toggles the window or not

options.draggable Boolean <optional>
true

Set whether the window is draggable

options.resizable Boolean <optional>
true

Set whether the window is resizable

options.resizing String <optional>
"continuous"

Resizing policy, continuous or stop. The first one resizes all children continuously while resizing.

options.header_action String <optional>
"maximize"

Action for double clicking the window header, one out of close, minimize, shrink, maximize, maximizevertical, maximizehorizontal

options.active Boolean <optional>
true

Active state of the window.

options.hide_status Integer <optional>
0

If set to !0 status message hides after [n] milliseconds.

Source:

Extends

Members

close :TK.Button

The close button.

Source:

content :TK.Container

A TK.Container for the window content.

Source:

Drag :TK.Drag

The {TK.Drag} module.

Source:

The bottom footer bar.

Source:

The top header bar.

Source:

icon :TK.Icon

A TK.Icon widget to display the window icon.

Source:

maximize :TK.Button

The maximize button.

Source:

maximizehorizontal :TK.Button

The maximizehorizontal button.

Source:

maximizevertical :TK.Button

The maximizevertical button.

Source:

minimize :TK.Button

The minimize button.

Source:

Resize :TK.Resize

The {TK.Resize} module.

Source:

shrink :TK.Button

The shrink button.

Source:

size :TK.Icon

A TK.Icon acting as handle for window resize.

Source:

status :TK.Label

A TK.Label to display the window status.

Source:

title :TK.Label

A TK.Label to display the window title.

Source:

Members inherited from TK.Container

element :HTMLDivElement

The main DIV element. Has class toolkit-container

Methods

append_child(child)

Appends a new child to the window content area.

Parameters:
Name Type Description
child TK.Widget

The child widget to add to the windows content area.

Overrides:
Source:

toggle_maximize(maximize)

Toggles the overall maximize state of the window.

Parameters:
Name Type Description
maximize Boolean

State of maximization. If window is already maximized in one or both directions it is un-maximized, otherwise maximized.

Source:

toggle_maximize_horizontal(maximize)

Toggles the horizontal maximize state of the window.

Parameters:
Name Type Description
maximize Boolean

The new horizontal maximization.

Source:

toggle_maximize_vertical(maximize)

Toggles the vertical maximize state of the window.

Parameters:
Name Type Description
maximize Boolean

The new vertical maximization.

Source:

toggle_minimize(minimize)

Toggles the minimize state of the window.

Parameters:
Name Type Description
minimize Boolean

The new minimization.

Source:

toggle_shrink(shrink)

Toggles the shrink state of the window.

Parameters:
Name Type Description
shrink Boolean

The new shrink state.

Source:

Methods inherited from TK.Container

append_children(children)

Calls TK.Container#append_child for an array of widgets.

force_hide()

Immediately switches the display state of this container to hide. Unlike TK.Container#hide this method does not perform the hiding transition and immediately modifies the DOM by setting the toolkit-hide class.

force_show()

Immediately switches the display state of this container to show. Unlike TK.Container#hide this method does not perform the hiding transition and immediately modifies the DOM by setting the toolkit-show class.

hide()

Starts the transition of the display_state to hide.

hide_child(child)

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

show()

Starts the transition of the display_state to show.

show_child(child)

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

toggle_child(child)

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

Methods inherited from TK.Widget

add_child(child)

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

add_children(a)

Registers an array of widgets as children.

all_children()

Returns an array of all children.

enable_draw()

Schedules this widget for drawing.

get_style()

Returns the computed style of this widgets DOM element.

hidden()

Returns the current hidden status.

remove_child(child)

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

remove_children(a)

Removes an array of children.

set(key, value)

Sets an option.

set_style()

Sets a CSS style property in this widgets DOM element.

toggle_hidden()

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

visible_children()

Returns an array of all visible children.

widgetize()

Set the DOM elements of this widgets. This method is usually only used internally. Basically it means to add the id from options and set a basic CSS class. If delegate is true, basic events will be delegated from the element to the widget instance if classify is true, CSS functions will be bound to the widget instance.

Methods inherited from TK.Base

add_event(event, func, prevent, stop)

Register an event handler.

add_events(events, func)

Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

delegate_events(element) → {HTMLElement}

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.

destroy()

Destroys all event handlers and the options object.

fire_event(event, …args)

Fires an event.

fire_events(events)

Fires several events.

get(key)

Get the value of an option.

has_event_listeners(event) → {boolean}

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

remove_event(event, fun)

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

remove_events(events, func)

Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

set_options(optionsopt)

Merges a new options object into the existing one, including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.

userset(key, value)

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.

Events

closeclicked

The user clicked the close button.

Source:

dimensionschanged

The dimensions of the window changed.

Parameters:
Name Type Description
event Object

The TK.Window#dimensions dimensions object.

Source:

dragging

The user is dragging the window.

Parameters:
Name Type Description
event DOMEvent

The DOM event.

Source:

footerchanged

The footer changed.

Source:

headeraction

The user double-clicked on the header.

Parameters:
Name Type Description
action string

The function which was executed, e.g. shrink, maximize or close.

Source:

headerchanged

The header changed.

Source:

maximizeclicked

The user clicked the maximize button.

Parameters:
Name Type Description
maximize Object

The maximize option.

Source:

maximizehorizontalclicked

The user clicked the maximize-horizontal button.

Parameters:
Name Type Description
maximize Object

The maximize option.

Source:

maximizeverticalclicked

The user clicked the maximize-vertical button.

Parameters:
Name Type Description
maximize Object

The maximize option.

Source:

minimizeclicked

The user clicked the minimize button.

Parameters:
Name Type Description
minimize Object

The minimize option.

Source:

positionchanged

The position of the window changed.

Parameters:
Name Type Description
event Object

The TK.Window#dimensions dimensions object.

Source:

resizing

The user resizes the window.

Parameters:
Name Type Description
event DOMEvent

The DOM event.

Source:

shrinkclicked

The user clicked the shrink button.

Parameters:
Name Type Description
shrink Object

The shrink option.

Source:

startdrag

The user starts dragging the window.

Parameters:
Name Type Description
event DOMEvent

The DOM event.

Source:

startresize

The user starts resizing the window.

Parameters:
Name Type Description
event DOMEvent

The DOM event.

Source:

stopdrag

The user stops dragging the window.

Parameters:
Name Type Description
event DOMEvent

The DOM event.

Source:

stopresize

The user stops resizing the window.

Parameters:
Name Type Description
event DOMEvent

The DOM event.

Source:

Events inherited from TK.Container

hide

Is fired when the container is hidden.

show

Is fired when the container is shown.

Events inherited from TK.Widget

GenericDOMEvents

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

classified

Is fired when a widget is classified.

destroy

Is fired when a widget is destroyed.

doubleclick

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

initialized

Is fired when a widget is initialized.

redraw

Is fired when a redraw is executed.

resize

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 TK.Widget#resized event can be used, instead.

resized

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

set

The set event is emitted when an option was set using the TK.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.

stylized

Is fired when a widget is stylized.

visibility

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

widgetize

Is fired when a widget is widgetized.

Events inherited from TK.Base

delegated

Is fired when an element is delegated.

set_[option]

Is fired when an option is set.