Home Reference Source
import Window from '@osjs/client/src/window.js'
public class | source

Window

Extends:

@osjs/event-emitter~EventEmitter → Window

Window Implementation

Static Method Summary

Static Public Methods
public static

Get a list of all windows

public static

Gets the lastly focused Window

Constructor Summary

Public Constructor
public

constructor(core: Core, options: WindowOptions)

Create window

Member Summary

Public Members
public

$content: Element

The content container

public

$element: Element

The window container

public

$header: Element

The header container

public

$icon: Element

The icon container

public

$title: Element

The title container

public

The window attributes

public

Child windows (via 'parent')

public

Core instance reference

public

The window destruction state

public

The Window ID

public

The window was inited

public

Parent Window reference

public

The window rendered state

public

The window state

public

The Window ID

Private Members
private

Last DOM update data attributes

private

Last DOM update CSS text

private

Internal timeout reference used for triggering the loading overlay.

private

Custom destructor callback

private

Internal variable to signal not to use default position given by user (used for restore)

private

The window template

Method Summary

Public Methods
public

Blur (un-focus) the window

public

Clamps the position to viewport

public

Close the window

public

Destroy window

public

Focus the window

public

Get a snapshot of the Window session

public

getState(n: *): *

Gets a astate

public

gravitate(gravity: string)

Gravitates window towards a certain area

public

init(): *

Initialize window

public

Maximize the window

public

Minimize (hide) the window

public

Raise (un-minimize) the window

public

render(callback: Function): Window

Render window

public

resizeFit(container: Element)

Resize to fit to current container

public

Restore (un-maximize) the window

public

Set the Window dimension

public

setIcon(uri: string)

Set the Window icon

public

Sets the Window to next z index

public

setPosition(position: WindowPosition, preventDefault: boolean)

Set the Window position

public

setState(name: string, value: *, update: boolean)

Set a state by value

public

setTitle(title: string)

Set the Window title

public

setZindex(zIndex: Number)

Set the Window z index

Private Methods
private

Checks the modal state of the window upon render

private

Check if we have to set next zindex

private

_focus()

Internal for focus

private

Initializes window behavior

private

Initializes window template

private

Internal for Maximize or restore

private

Sets the initial class names

private

_setState(name: string, value: *, update: boolean, updateAll: boolean)

Internal method for setting state

private

_toggleState(name: string, value: any, eventName: string, update: boolean): boolean

Internal method for toggling state

private

Updates window data in DOM

private

Updates the window buttons in DOM

private

Updates window header decoration in DOM

private

Updates window icon decoration in DOM

private

Updates window style in DOM

private

Updates window title in DOM

Static Public Methods

public static getWindows(): Window[] source

Get a list of all windows

Return:

Window[]

public static lastWindow(): Window source

Gets the lastly focused Window

Return:

Window

Public Constructors

public constructor(core: Core, options: WindowOptions) source

Create window

Params:

NameTypeAttributeDescription
core Core

Core reference

options WindowOptions
  • optional
  • default: {}

Options

Public Members

public $content: Element source

The content container

public $element: Element source

The window container

public $header: Element source

The header container

public $icon: Element source

The icon container

public $title: Element source

The title container

public attributes: WindowAttributes source

The window attributes

public children: Window[] source

Child windows (via 'parent')

public core: Core source

Core instance reference

public destroyed: boolean source

The window destruction state

public id: string source

The Window ID

public inited: boolean source

The window was inited

public parent: Window source

Parent Window reference

public rendered: boolean source

The window rendered state

public state: WindowState source

The window state

public wid: Number source

The Window ID

Private Members

private _lastAttributes: WindowAttributes source

Last DOM update data attributes

private _lastCssText: string source

Last DOM update CSS text

private _loadingDebounce: boolean source

Internal timeout reference used for triggering the loading overlay.

private _ondestroy: Function source

Custom destructor callback

private _preventDefaultPosition: boolean source

Internal variable to signal not to use default position given by user (used for restore)

private _template: string | Function source

The window template

Public Methods

public blur(): boolean source

Blur (un-focus) the window

Return:

boolean

public clampToViewport(update: boolean) source

Clamps the position to viewport

Params:

NameTypeAttributeDescription
update boolean
  • optional
  • default: true

Update DOM

public close(): boolean source

Close the window

Return:

boolean

public destroy() source

Destroy window

public focus(): boolean source

Focus the window

Return:

boolean

public getSession(): WindowSession source

Get a snapshot of the Window session

Return:

WindowSession

public getState(n: *): * source

Gets a astate

Params:

NameTypeAttributeDescription
n *

Return:

*

public gravitate(gravity: string) source

Gravitates window towards a certain area

Params:

NameTypeAttributeDescription
gravity string

Gravity

public init(): * source

Initialize window

Return:

*

public maximize(): boolean source

Maximize the window

Return:

boolean

public minimize(): boolean source

Minimize (hide) the window

Return:

boolean

public raise(): boolean source

Raise (un-minimize) the window

Return:

boolean

public render(callback: Function): Window source

Render window

Params:

NameTypeAttributeDescription
callback Function
  • optional

Callback when window DOM has been constructed

Return:

Window

this instance

public resizeFit(container: Element) source

Resize to fit to current container

Params:

NameTypeAttributeDescription
container Element
  • optional

The DOM element to use

public restore(): boolean source

Restore (un-maximize) the window

Return:

boolean

public setDimension(dimension: WindowDimension) source

Set the Window dimension

Params:

NameTypeAttributeDescription
dimension WindowDimension

The dimension

public setIcon(uri: string) source

Set the Window icon

Params:

NameTypeAttributeDescription
uri string

Icon URI

public setNextZindex(force: boolean) source

Sets the Window to next z index

Params:

NameTypeAttributeDescription
force boolean
  • optional

Force next index

public setPosition(position: WindowPosition, preventDefault: boolean) source

Set the Window position

Params:

NameTypeAttributeDescription
position WindowPosition

The position

preventDefault boolean
  • optional
  • default: false

Prevents any future position setting in init procedure

public setState(name: string, value: *, update: boolean) source

Set a state by value

Params:

NameTypeAttributeDescription
name string

State name

value *

State value

update boolean
  • optional
  • default: true

Update the DOM

See:

public setTitle(title: string) source

Set the Window title

Params:

NameTypeAttributeDescription
title string

Title

public setZindex(zIndex: Number) source

Set the Window z index

Params:

NameTypeAttributeDescription
zIndex Number

the index

Private Methods

private _checkModal() source

Checks the modal state of the window upon render

private _checkNextZindex(): boolean source

Check if we have to set next zindex

Return:

boolean

private _focus() source

Internal for focus

private _initBehavior() source

Initializes window behavior

private _initTemplate() source

Initializes window template

private _maximize(toggle: boolean): boolean source

Internal for Maximize or restore

Params:

NameTypeAttributeDescription
toggle boolean

Maximize or restore

Return:

boolean

private _setClassNames() source

Sets the initial class names

private _setState(name: string, value: *, update: boolean, updateAll: boolean) source

Internal method for setting state

Params:

NameTypeAttributeDescription
name string

State name

value *

State value

update boolean
  • optional
  • default: true

Update the DOM

updateAll boolean
  • optional
  • default: true

Update the entire DOM

private _toggleState(name: string, value: any, eventName: string, update: boolean): boolean source

Internal method for toggling state

Params:

NameTypeAttributeDescription
name string

State name

value any

State value

eventName string

Name of event to emit

update boolean
  • optional
  • default: true

Update the DOM

Return:

boolean

private _updateAttributes() source

Updates window data in DOM

private _updateButtons() source

Updates the window buttons in DOM

private _updateHeaderStyles() source

Updates window header decoration in DOM

private _updateIconStyles() source

Updates window icon decoration in DOM

private _updateStyles() source

Updates window style in DOM

private _updateTitle() source

Updates window title in DOM