GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — MaxWindow | @maxgraph/core

  • MaxWindow

Class MaxWindow

Basic window inside a document.

Creating a simple window.

Example

var tb = document.createElement('div');
var wnd = new MaxWindow('Title', tb, 100, 100, 200, 200, true, true);
wnd.setVisible(true);

Creating a window that contains an iframe.

Example

var frame = document.createElement('iframe');
frame.setAttribute('width', '192px');
frame.setAttribute('height', '172px');
frame.setAttribute('src', 'http://www.example.com/');
frame.style.backgroundColor = 'white';

var w = document.body.clientWidth;
var h = (document.body.clientHeight || document.documentElement.clientHeight);
var wnd = new MaxWindow('Title', frame, (w-200)/2, (h-200)/3, 200, 200);
wnd.setVisible(true);

To limit the movement of a window, eg. to keep it from being moved beyond the top, left corner the following method can be overridden (recommended):

wnd.setLocation(x, y)
{
x = Math.max(0, x);
y = Math.max(0, y);
setLocation.apply(this, arguments);
};

Or the following event handler can be used:

wnd.addListener(mxEvent.MOVE, function(e)
{
wnd.setLocation(Math.max(0, wnd.getX()), Math.max(0, wnd.getY()));
});

To keep a window inside the current window:

mxEvent.addListener(window, 'resize', mxUtils.bind(this, function()
{
var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var ih = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

var x = this.window.getX();
var y = this.window.getY();

if (x + this.window.table.clientWidth > iw)
{
x = Math.max(0, iw - this.window.table.clientWidth);
}

if (y + this.window.table.clientHeight > ih)
{
y = Math.max(0, ih - this.window.table.clientHeight);
}

if (this.window.getX() != x || this.window.getY() != y)
{
this.window.setLocation(x, y);
}
}));

Event: mxEvent.MOVE_START

Fires before the window is moved. The event property contains the corresponding mouse event.

Event: mxEvent.MOVE

Fires while the window is being moved. The event property contains the corresponding mouse event.

Event: mxEvent.MOVE_END

Fires after the window is moved. The event property contains the corresponding mouse event.

Event: mxEvent.RESIZE_START

Fires before the window is resized. The event property contains the corresponding mouse event.

Event: mxEvent.RESIZE

Fires while the window is being resized. The event property contains the corresponding mouse event.

Event: mxEvent.RESIZE_END

Fires after the window is resized. The event property contains the corresponding mouse event.

Event: mxEvent.MAXIMIZE

Fires after the window is maximized. The event property contains the corresponding mouse event.

Event: mxEvent.MINIMIZE

Fires after the window is minimized. The event property contains the corresponding mouse event.

Event: mxEvent.NORMALIZE

Fires after the window is normalized, that is, it returned from maximized or minimized state. The event property contains the corresponding mouse event.

Event: mxEvent.ACTIVATE

Fires after a window is activated. The previousWindow property contains the previous window. The event sender is the active window.

Event: mxEvent.SHOW

Fires after the window is shown. This event has no properties.

Event: mxEvent.HIDE

Fires after the window is hidden. This event has no properties.

Event: mxEvent.CLOSE

Fires before the window is closed. The event property contains the corresponding mouse event.

Event: mxEvent.DESTROY

Fires before the window is destroyed. This event has no properties.

Hierarchy (View Summary)

  • EventSource
    • MaxWindow
  • Defined in gui/MaxWindow.ts:178
Index

Constructors

constructor

Properties

buttons closeImage closeImg content contentWrapper destroyOnClose div eventListeners eventsEnabled eventSource image maximize maximizeImage minimize minimizeImage minimumSize normalizeImage resize resizeImage table td title visible

Methods

activate addListener destroy fireEvent fit getElement getEventSource getMinimumSize getX getY hide init installCloseHandler installMaximizeHandler installMinimizeHandler installMoveHandler isEventsEnabled isResizable isVisible removeListener setClosable setEventsEnabled setEventSource setImage setLocation setMaximizable setMinimizable setResizable setScrollable setSize setTitle setVisible show

Constructors

constructor

  • new MaxWindow(
        title: string,
        content: HTMLElement | null,
        x: number,
        y: number,
        width?: number | null,
        height?: number | null,
        minimizable?: boolean,
        movable?: boolean,
        replaceNode?: HTMLElement | null,
        style?: string,
    ): MaxWindow

    Parameters

    • title: string
    • content: HTMLElement | null
    • x: number
    • y: number
    • width: number | null = null
    • height: number | null = null
    • minimizable: boolean = true
    • movable: boolean = true
    • replaceNode: HTMLElement | null = null
    • Optionalstyle: string

    Returns MaxWindow

    Overrides EventSource.constructor

    • Defined in gui/MaxWindow.ts:179

Properties

buttons

buttons: HTMLElement
  • Defined in gui/MaxWindow.ts:219

closeImage

closeImage: string = ...

URL of the image to be used for the close icon in the titlebar.

  • Defined in gui/MaxWindow.ts:314

closeImg

closeImg: HTMLElement
  • Defined in gui/MaxWindow.ts:222

content

content: HTMLElement

Reference to the DOM node that represents the window content.

  • Defined in gui/MaxWindow.ts:361

contentWrapper

contentWrapper: HTMLElement
  • Defined in gui/MaxWindow.ts:223

destroyOnClose

destroyOnClose: boolean = true

Specifies if the window should be destroyed when it is closed. If this is false then the window is hidden using . Default is true.

  • Defined in gui/MaxWindow.ts:351

div

div: HTMLElement
  • Defined in gui/MaxWindow.ts:216

eventListeners

eventListeners: EventListenerObject[] = []

Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.

Inherited from EventSource.eventListeners

  • Defined in view/event/EventSource.ts:58

eventsEnabled

eventsEnabled: boolean = true

Specifies if events can be fired. Default is true.

Inherited from EventSource.eventsEnabled

  • Defined in view/event/EventSource.ts:63

eventSource

eventSource: EventTarget | null = null

Optional source for events.

Default

null

Inherited from EventSource.eventSource

  • Defined in view/event/EventSource.ts:69

image

image: HTMLImageElement
  • Defined in gui/MaxWindow.ts:224

maximize

maximize: HTMLElement
  • Defined in gui/MaxWindow.ts:221

maximizeImage

maximizeImage: string = ...

URL of the image to be used for the maximize icon in the titlebar.

  • Defined in gui/MaxWindow.ts:329

minimize

minimize: HTMLElement
  • Defined in gui/MaxWindow.ts:220

minimizeImage

minimizeImage: string = ...

URL of the image to be used for the minimize icon in the titlebar.

  • Defined in gui/MaxWindow.ts:319

minimumSize

minimumSize: Rectangle = ...

Rectangle that specifies the minimum width and height of the window. Default is (50, 40).

  • Defined in gui/MaxWindow.ts:345

normalizeImage

normalizeImage: string = ...

URL of the image to be used for the normalize icon in the titlebar.

  • Defined in gui/MaxWindow.ts:324

resize

resize: HTMLElement
  • Defined in gui/MaxWindow.ts:218

resizeImage

resizeImage: string = ...

URL of the image to be used for the resize icon.

  • Defined in gui/MaxWindow.ts:334

table

table: HTMLElement
  • Defined in gui/MaxWindow.ts:217

td

td: HTMLElement
  • Defined in gui/MaxWindow.ts:215

title

title: HTMLElement

Reference to the DOM node (TD) that contains the title.

  • Defined in gui/MaxWindow.ts:356

visible

visible: boolean = false

Boolean flag that represents the visible state of the window.

  • Defined in gui/MaxWindow.ts:339

Methods

activate

  • activate(): void

    Puts the window on top of all other windows.

    Returns void

    • Defined in gui/MaxWindow.ts:402

addListener

  • addListener(name: string, funct: Function): void

    Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.

    The parameters of the listener are the sender and an EventObject.

    Parameters

    • name: string
    • funct: Function

    Returns void

    Inherited from EventSource.addListener

    • Defined in view/event/EventSource.ts:105

destroy

  • destroy(): void

    Destroys the window and removes all associated resources. Fires a event prior to destroying the window.

    Returns void

    Overrides EventSource.destroy

    • Defined in gui/MaxWindow.ts:939

fireEvent

  • fireEvent(evt: EventObject, sender?: EventTarget | null): void

    Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation.

    Example:

    fireEvent(new EventObject("eventName", key1, val1, .., keyN, valN))
    

    Parameters

    • evt: EventObject

      EventObject that represents the event.

    • sender: EventTarget | null = null

      Optional sender to be passed to the listener. Default value is the return value of getEventSource.

    Returns void

    Inherited from EventSource.fireEvent

    • Defined in view/event/EventSource.ts:139

fit

  • fit(): void

    Makes sure the window is inside the client area of the window.

    Returns void

    • Defined in gui/MaxWindow.ts:434

getElement

  • getElement(): HTMLElement

    Returuns the outermost DOM node that makes up the window.

    Returns HTMLElement

    • Defined in gui/MaxWindow.ts:427

getEventSource

  • getEventSource(): EventTarget | null

    Returns eventSource.

    Returns EventTarget | null

    Inherited from EventSource.getEventSource

    • Defined in view/event/EventSource.ts:88

getMinimumSize

  • getMinimumSize(): Rectangle

    Returns an Rectangle that specifies the size for the minimized window. A width or height of 0 means keep the existing width or height. This implementation returns the height of the window title and keeps the width.

    Returns Rectangle

    • Defined in gui/MaxWindow.ts:564

getX

  • getX(): number

    Returns the current position on the x-axis.

    Returns number

    • Defined in gui/MaxWindow.ts:814

getY

  • getY(): number

    Returns the current position on the y-axis.

    Returns number

    • Defined in gui/MaxWindow.ts:821

hide

  • hide(): void

    Hides the window.

    Returns void

    • Defined in gui/MaxWindow.ts:930

init

  • init(
        x: number,
        y: number,
        width?: number | null,
        height?: number | null,
        style?: string,
    ): void

    Initializes the DOM tree that represents the window.

    Parameters

    • x: number
    • y: number
    • width: number | null = null
    • height: number | null = null
    • style: string = 'mxWindow'

    Returns void

    • Defined in gui/MaxWindow.ts:229

installCloseHandler

  • installCloseHandler(): void

    Adds the as a new image node in and installs the event.

    Returns void

    • Defined in gui/MaxWindow.ts:829

installMaximizeHandler

  • installMaximizeHandler(): void

    Installs the event listeners required for maximizing the window.

    Returns void

    • Defined in gui/MaxWindow.ts:653

installMinimizeHandler

  • installMinimizeHandler(): void

    Installs the event listeners required for minimizing the window.

    Returns void

    • Defined in gui/MaxWindow.ts:571

installMoveHandler

  • installMoveHandler(): void

    Installs the event listeners required for moving the window.

    Returns void

    • Defined in gui/MaxWindow.ts:767

isEventsEnabled

  • isEventsEnabled(): boolean

    Returns eventsEnabled.

    Returns boolean

    Inherited from EventSource.isEventsEnabled

    • Defined in view/event/EventSource.ts:74

isResizable

  • isResizable(): boolean

    Returns true if the window is resizable.

    Returns boolean

    • Defined in gui/MaxWindow.ts:441

isVisible

  • isVisible(): boolean

    Returns true if the window is visible.

    Returns boolean

    • Defined in gui/MaxWindow.ts:883

removeListener

  • removeListener(funct: Function): void

    Removes all occurrences of the given listener from eventListeners.

    Parameters

    • funct: Function

    Returns void

    Inherited from EventSource.removeListener

    • Defined in view/event/EventSource.ts:112

setClosable

  • setClosable(closable: boolean): void

    Sets the image associated with the window.

    Parameters

    • closable: boolean

      Boolean specifying if the window should be closable.

    Returns void

    • Defined in gui/MaxWindow.ts:876

setEventsEnabled

  • setEventsEnabled(value: boolean): void

    Sets eventsEnabled.

    Parameters

    • value: boolean

    Returns void

    Inherited from EventSource.setEventsEnabled

    • Defined in view/event/EventSource.ts:81

setEventSource

  • setEventSource(value: EventTarget | null): void

    Sets eventSource.

    Parameters

    • value: EventTarget | null

    Returns void

    Inherited from EventSource.setEventSource

    • Defined in view/event/EventSource.ts:95

setImage

  • setImage(image: string): void

    Sets the image associated with the window.

    Parameters

    • image: string

      URL of the image to be used.

    Returns void

    • Defined in gui/MaxWindow.ts:859

setLocation

  • setLocation(x: number, y: number): void

    Sets the upper, left corner of the window.

    Parameters

    • x: number
    • y: number

    Returns void

    • Defined in gui/MaxWindow.ts:806

setMaximizable

  • setMaximizable(maximizable: boolean): void

    Sets if the window is maximizable.

    Parameters

    • maximizable: boolean

    Returns void

    • Defined in gui/MaxWindow.ts:646

setMinimizable

  • setMinimizable(minimizable: boolean): void

    Sets if the window is minimizable.

    Parameters

    • minimizable: boolean

    Returns void

    • Defined in gui/MaxWindow.ts:555

setResizable

  • setResizable(resizable: boolean): void

    Sets if the window should be resizable. To avoid interference with some built-in features of IE10 and later, the use of the following code is recommended if there are resizable s in the page:

    if (Client.IS_POINTER)
    {
    document.body.style.msTouchAction = 'none';
    }

    Parameters

    • resizable: boolean

    Returns void

    • Defined in gui/MaxWindow.ts:460

setScrollable

  • setScrollable(scrollable: boolean): void

    Sets if the window contents should be scrollable.

    Parameters

    • scrollable: boolean

    Returns void

    • Defined in gui/MaxWindow.ts:388

setSize

  • setSize(width: number, height: number): void

    Sets the size of the window.

    Parameters

    • width: number
    • height: number

    Returns void

    • Defined in gui/MaxWindow.ts:536

setTitle

  • setTitle(title: string): void

    Sets the window title to the given string. HTML markup inside the title will be escaped.

    Parameters

    • title: string

    Returns void

    • Defined in gui/MaxWindow.ts:367

setVisible

  • setVisible(visible: boolean): void

    Shows or hides the window depending on the given flag.

    Parameters

    • visible: boolean

      Boolean indicating if the window should be made visible.

    Returns void

    • Defined in gui/MaxWindow.ts:896

show

  • show(): void

    Shows the window.

    Returns void

    • Defined in gui/MaxWindow.ts:909

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Event: mxEvent.MOVE_STARTEvent: mxEvent.MOVEEvent: mxEvent.MOVE_ENDEvent: mxEvent.RESIZE_STARTEvent: mxEvent.RESIZEEvent: mxEvent.RESIZE_ENDEvent: mxEvent.MAXIMIZEEvent: mxEvent.MINIMIZEEvent: mxEvent.NORMALIZEEvent: mxEvent.ACTIVATEEvent: mxEvent.SHOWEvent: mxEvent.HIDEEvent: mxEvent.CLOSEEvent: mxEvent.DESTROY
Constructors
constructor
Properties
buttonscloseImagecloseImgcontentcontentWrapperdestroyOnClosediveventListenerseventsEnabledeventSourceimagemaximizemaximizeImageminimizeminimizeImageminimumSizenormalizeImageresizeresizeImagetabletdtitlevisible
Methods
activateaddListenerdestroyfireEventfitgetElementgetEventSourcegetMinimumSizegetXgetYhideinitinstallCloseHandlerinstallMaximizeHandlerinstallMinimizeHandlerinstallMoveHandlerisEventsEnabledisResizableisVisibleremoveListenersetClosablesetEventsEnabledsetEventSourcesetImagesetLocationsetMaximizablesetMinimizablesetResizablesetScrollablesetSizesetTitlesetVisibleshow
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.