Window Class

Window control that can be used to create dialogs, alerts, etc. The window consists of a header, body, footer, and mask.
Here's a simple example of how to instantiate a resizable window:
    var window = new javaxt.dhtml.Window(document.body, {
        title: "Window Test",
        width: 400,
        height: 200,
        modal: false,
        resizable: true
    });
  
Once the window is instantiated you can call any of the public methods. You can also add event listeners by overriding any of the public "on" or "before" methods like this:
    window.open();
    window.onResize = function(){
        console.log(window.getWidth(), window.getHeight());
    };
  

Constructors

Window( parent, config )
Used to instantiate this class
parentDOM element in which to render this component
configConfiguration settings (optional). See config options for more information.

Config Options

title
DOM element or string rendered in the header. Note that this config is optional and can be set after the Window has been instantiated. See setTitle().
body
DOM element or string rendered in the body. Note that this config is optional and can be set after the Window has been instantiated. See setBody().
footer
DOM element or string rendered in the footer. Note that this config is optional and can be set after the Window has been instantiated. See setFooter().
buttons
Buttons to put in the footer. Only rendered if no "footer" config is defined. Example:
            buttons: [
                {
                    name: "OK",
                    onclick: function(){
                        win.close();
                    }
                }
            ]
        
width
Initial width of the window, in pixels.
height
Initial height of the window, in pixels.
modal
If true, will render a mask directly behind the window to prevent users from interacting with any other part of the window's parent. Default is false.
resizable
If true, users can resize the window using resize handles along the border of the window. Default is true.
closable
If true, will add a button to the header that will close the window when clicked. Default is true.
movable
If true, will allow users to move the window around by dragging the window header. Default is true.
shrinkToFit
If true, will resize window if it is larger that the parent. Default is false.
valign
Vertical align hint used when rendering the window. Options include "top" and "middle" (default).
style
Style for individual elements within the component. Note that you can provide CSS class names instead of individual style definitions.
renderers

Events

onHeaderClick( )
Called whenever the header is clicked.
onResize( )
Called whenever the window is resized
onOpen( )
Called whenever the window is opened or made visible.
onClose( )
Called whenever the window is closed or hidden from view.

Public Methods

destroy( )
Used to destroy the window and remove it from the DOM
getTitle( )
Returns the content of the window's header/title area
setTitle( obj )
Used to update the content of the window's header/title area
getBody( )
Returns the window's body (main content panel) as a DOM element
setBody( obj )
Used to update/replace window's body (main content panel)
objAccepts strings, DOM elements, and nulls
setContent( obj )
Exactly the same as setBody()
getFooter( )
setFooter( obj )
open( animation )
Used to make the window visible.
show( animation )
Exactly the same as open()
showAt( x, y, animation )
Used to make the window visible at a given location on the screen.
close( silent )
Used to close/hide the window
silentIf true, will not fire the onClose event
hide( silent )
Exactly the same as close()
isOpen( )
Returns true if the window is open.
getWidth( )
Returns the current width of the window in pixels (number)
setWidth( width )
Used to set the width of the window
widthAccepts numbers or strings with valid CSS values ("1px, "1%")
getHeight( )
Returns the current height of the window in pixels (number)
setHeight( height )
Used to set the height of the window
heightAccepts numbers or strings with valid CSS values ("1px, "1%")
update( )
Used to update the size of the window. Called internally whenever the window is resized to insure that the window contents fit inside the window. If you are updating DOM elements within the window dynamically, you may need to call this method.
center( )
Moves the window to the center of the screen.