Options
All
  • Public
  • Public/Protected
  • All
Menu

Basic window inside a document.

Creating a simple window.

example
var tb = document.createElement('div');
var wnd = new mxWindow('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 mxWindow('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:

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

example
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

Index

Constructors

constructor

  • new mxWindow(title: string, content: HTMLElement, x: number, y: number, width: number, height?: number, minimizable?: boolean, movable?: boolean, replaceNode?: HTMLHRElement, style?: string): mxWindow
  • Constructs a new window with the given dimension and title to display the specified content. The window elements use the given style as a prefix for the classnames of the respective window elements, namely, the window title and window pane. The respective postfixes are appended to the given stylename as follows:

    style - Base style for the window. style+Title - Style for the window title. style+Pane - Style for the window pane.

    The default value for style is mxWindow, resulting in the following classnames for the window elements: mxWindow, mxWindowTitle and mxWindowPane.

    If replaceNode is given then the window replaces the given DOM node in the document.

    Parameters

    • title: string

      String that represents the title of the new window.

    • content: HTMLElement

      DOM node that is used as the window content.

    • x: number

      X-coordinate of the window location.

    • y: number

      Y-coordinate of the window location.

    • width: number

      Width of the window.

    • Optional height: number

      Optional height of the window. Default is to match the height of the content at the specified width.

    • Optional minimizable: boolean

      Optional boolean indicating if the window is minimizable. Default is true.

    • Optional movable: boolean

      Optional boolean indicating if the window is movable. Default is true.

    • Optional replaceNode: HTMLHRElement

      Optional DOM node that the window should replace.

    • Optional style: string

      Optional base classname for the window elements. Default is mxWindow.

    Returns mxWindow

Properties

closeImage

closeImage: string

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

content

content: HTMLElement

Reference to the DOM node that represents the window content.

contentHeightCorrection

contentHeightCorrection: number

Defines the correction factor for computing the height of the contentWrapper. Default is 6 for IE 7/8 standards mode and 2 for all other browsers and modes.

destroyOnClose

destroyOnClose: boolean

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

eventListeners

eventListeners: any[]

Variable: eventListeners

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.

eventSource

eventSource: any

Variable: eventSource

Optional source for events. Default is null.

eventsEnabled

eventsEnabled: boolean

Variable: eventsEnabled

Specifies if events can be fired. Default is true.

maximizeImage

maximizeImage: string

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

minimizeImage

minimizeImage: string

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

minimumSize

minimumSize: mxRectangle

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

normalizeImage

normalizeImage: string

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

resizeImage

resizeImage: string

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

title

title: HTMLElement

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

visible

visible: boolean

Boolean flag that represents the visible state of the window.

Methods

activate

  • activate(): void

addListener

  • addListener(name: string, funct: (...args: any[]) => any): void
  • Function: addListener

    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 .

    Parameters

    • name: string
    • funct: (...args: any[]) => any
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

destroy

  • destroy(): void
  • Destroys the window and removes all associated resources. Fires a event prior to destroying the window.

    Returns void

fireEvent

  • Function: fireEvent

    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 (see <mxUtils.bind>).

    Example:

    (code) fireEvent(new mxEventObject("eventName", key1, val1, .., keyN, valN)) (end)

    Parameters:

    evt - that represents the event. sender - Optional sender to be passed to the listener. Default value is the return value of .

    Parameters

    Returns void

fit

  • fit(): void
  • Makes sure the window is inside the client area of the window.

    Returns void

getElement

  • getElement(): HTMLElement
  • Returuns the outermost DOM node that makes up the window.

    Returns HTMLElement

getEventSource

  • getEventSource(): any

getMinimumSize

  • Returns an 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 mxRectangle

getX

  • getX(): number

getY

  • getY(): number

hide

  • hide(): void

init

  • init(x: number, y: number, width: number, height: number, style: string): void
  • Initializes the DOM tree that represents the window.

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number
    • style: string

    Returns void

installCloseHandler

  • installCloseHandler(): void

installMaximizeHandler

  • installMaximizeHandler(): void
  • Installs the event listeners required for maximizing the window.

    Returns void

installMinimizeHandler

  • installMinimizeHandler(): void
  • Installs the event listeners required for minimizing the window.

    Returns void

installMoveHandler

  • installMoveHandler(): void

isEventsEnabled

  • isEventsEnabled(): boolean

isResizable

  • isResizable(): boolean

isVisible

  • isVisible(): boolean

removeListener

  • removeListener(funct: (...args: any[]) => any): void
  • Function: removeListener

    Removes all occurrences of the given listener from .

    Parameters

    • funct: (...args: any[]) => any
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

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

setEventSource

  • setEventSource(value: any): void

setEventsEnabled

  • setEventsEnabled(value: boolean): void

setImage

  • setImage(image: string): void
  • Sets the image associated with the window.

    Parameters

    • image: string

      URL of the image to be used.

    Returns void

setLocation

  • setLocation(x: number, y: number): void
  • Sets the upper, left corner of the window.

    Parameters

    • x: number
    • y: number

    Returns void

setMaximizable

  • setMaximizable(maximizable: boolean): void
  • Sets if the window is maximizable.

    Parameters

    • maximizable: boolean

    Returns void

setMinimizable

  • setMinimizable(minimizable: boolean): void
  • Sets if the window is minimizable.

    Parameters

    • minimizable: boolean

    Returns void

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 (mxClient.IS_POINTER)
    {
      document.body.style.msTouchAction = 'none';
    }
    

    Parameters

    • resizable: boolean

    Returns void

setScrollable

  • setScrollable(scrollable: boolean): void
  • Sets if the window contents should be scrollable.

    Parameters

    • scrollable: boolean

    Returns void

setSize

  • setSize(width: number, height: number): void
  • Sets the size of the window.

    Parameters

    • width: number
    • height: number

    Returns void

setTitle

  • setTitle(title: HTMLElement): void
  • Sets the window title to the given string. HTML markup inside the title will be escaped.

    Parameters

    • title: HTMLElement

    Returns void

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

show

  • show(): void

Generated using TypeDoc