Class: WindowManager

WindowManager

Creates a windowing system to create and manage windows

new WindowManager (options, defaultOptions)

Name Type Description
options object optional
Name Type Default Description
parent HTMLElement document.body optional
quiet boolean optional suppress the simple-window-manager console message
snap boolean | SnapOptions optional turn on edge and/or screen snapping
keepInside boolean | 'horizontal' | 'vertical' true optional keep windows inside the parent in a certain direction
defaultOptions WindowOptions optional default WindowOptions used when createWindow is called
Example
var wm = new WindowManager();

wm.createWindow({ x: 20, y: 20, width: 200 })
wm.content.innerHTML = 'Hello there!'

Extends

Classes

WindowManager

Members

bounds Bounds

overlay HTMLElement readonly

This is the bottom DOM element. Use this to set a wallpaper or attach elements underneath the windows

win HTMLElement readonly

This is the top-level DOM element

Methods

_createDom (parent)

Name Type Description
parent HTMLElement

attachWindow (win)Window

Attach an existing window to the WindowManager Note: WindowManager.createWindow is the preferred way to create windows to ensure that all the defaultOptions are applied to the Window. If you use this function, then Window needs to be initialized with WindowOptions.
Name Type Description
win Window
Returns:
Type Description
Window the window

closeAll ()

close all windows

createWindow (options)Window

Create a window
Name Type Description
options WindowOptions optional
Name Type Description
title string optional
x number optional position
y number optional position
modal boolean optional
id number | * optional if not provide, id will be assigned in order of creation (0, 1, 2...)
Returns:
Type Description
Window the created window

emit (event)Boolean inherited overrides

Calls each of the listeners registered for a given event.
Name Type Description
event String | Symbol The event name.
Returns:
Type Description
Boolean `true` if the event had listeners, else `false`.

eventNames ()Array inherited overrides

Return an array listing the events for which the emitter has registered listeners.
Returns:
Type Description
Array

listenerCount (event)Number inherited overrides

Return the number of listeners listening to a given event.
Name Type Description
event String | Symbol The event name.
Returns:
Type Description
Number The number of listeners.

listeners (event)Array inherited overrides

Return the listeners registered for a given event.
Name Type Description
event String | Symbol The event name.
Returns:
Type Description
Array The registered listeners.

load (data)

restores the state of all the windows NOTE: this requires that the windows have the same id as when save() was called
Name Type Description
data object created by save()

once (event, fn, context)EventEmitter inherited overrides

Add a one-time listener for a given event.
Name Type Default Description
event String | Symbol The event name.
fn function The listener function.
context * this optional The context to invoke the listener with.
Returns:
Type Description
EventEmitter `this`.

on (event, fn, context)EventEmitter inherited overrides

Add a listener for a given event.
Name Type Default Description
event String | Symbol The event name.
fn function The listener function.
context * this optional The context to invoke the listener with.
Returns:
Type Description
EventEmitter `this`.

removeAllListeners (event)EventEmitter inherited overrides

Remove all listeners, or those of the specified event.
Name Type Description
event String | Symbol optional The event name.
Returns:
Type Description
EventEmitter `this`.

removeListener (event, fn, context, once)EventEmitter inherited overrides

Remove the listeners of a given event.
Name Type Description
event String | Symbol The event name.
fn function Only remove the listeners that match this function.
context * Only remove the listeners that have this context.
once Boolean Only remove one-time listeners.
Returns:
Type Description
EventEmitter `this`.

save ()object

save the state of all the windows
Returns:
Type Description
object use this object in load() to restore the state of all windows

sendToBack (win)

send window to back
Name Type Description
win Window

sendToFront (win)

send window to front
Name Type Description
win Window

snap (options)

enable edge and/or screen snapping
Name Type Description
options SnapOptions