Window (http://prototype-window.xilinus.com/) Extension Class - Utility methods and Class wrappers
Composed of three subclasses
Extension to Windows Class
Extension to Window Class
Extension to Dialog Class
This class depends on
This class was developped to make the instantiation and manipulation of Window objects easy, uniform and DMWeb ready.
This class introduced the following new concepts/bug fixes to the original Window class.
a logical way for window recycling
for a consistant keyboard navigation
window location can be set in an absolute way. default window location (top/left) to center.
for memory reasons, closed windows will remain in the DOM but their content will be erased.
if the height of the window is not set, the window will resize to fit its content.
an easy way to set the dimensions of the window to fullscreen
windows that have their content bound to an XHR request, will have access to an in-memory hash used to store js variables.
It defines 3 classes of windows:
Window that has its content ready as an html(+javascript).
Window that would retrieve its content via XHR request.
Window that has an iframe embdedded in its content.
And 4 types of dialogs:
A dialog displaying an error message
A dialog with an alert message
A dialog with a confirmation message
A dialog with a progress indicator and an informational message
It also provides utility methods to control the application focus mainly when a window/dialog opens and closes.
Contains utility methods for showing/hiding, opening/closing ... window instances.
(Mostly used internally)
Establishes a parent/child relationship between 2 windows. This relationship will enforce the following behaviour:
parent closed -> close all children parent destroyed -> destroy all children
Details of all Window.Ext options (shared by all Window.Ext instances).
All window instances in the Window.Ext namespace share an identical set of options that is an extension to the original set defined in Window namespace.
For sake of brevity, only the extended options and the options that have been defaulted will be documented here.
For the full list of Window Options, please refer to http://prototype-window.xilinus.com/.
Window className to define its look and feel.
optional - defaulted to 'mac_os_x'
optional - defaulted to false.
flag to set whether the window opens as a modal window or not.
optional - defaulted to false.
if set to true, the window dimension/location will be overloaded.
optional - defaulted to false.
optional - defaulted to ! fullscreen
required - in case of fullscreen
optional - defaulted to height of the window content
optional - defaulted to middle
optional - defaulted to center
optional - defaulted to false
flag whether to clear the content of a window before it closes.
optional - defaulted to true
Id of the window to as a parent.
optional
string id or array of string ids of elements that the window will hand focus to when it opens.
optional
callback to executes when the window succeeds to open and to set its content
optional - defaulted to empty function
callback to execute when the user tabs out the window.
optional - defaulted to window.focusWindow()
HTML Window instantiation
/** * finds/creates a window object with given id and options. * opens/maximizes/bringsToFront the window object. * sets its content to the html provided. * evaluates the javascript (if any) that is included in the html content. * calls the onSuccess function. */ new Window.Ext.HTMLWindow('win_id', 'win_html_content', { title : 'CHANGE_ME', owner : 'owner_window_id', focus_targets : 'CHANGE_ME', modal : false, fullscreen : false, destroyOnClose : false, clearOnClose : true, width : 0, height : 0, top : null, left : null, // window events onSuccess : function(win) { // window openned successfully }, onClose : function(win) { // window closes }, onTabOut : function(win) { // user tabs out of the last input in window } });
AJAX Window instantiation
/** * finds/creates a window object with given id and options. * opens/maximizes/bringsToFront the window object. * sets its content to the response of XHR. * evaluates javascript (if any) embedded in the XHR response. * calls the onSuccess function */ new Window.Ext.AJAXWindow('win_id', 'win_url_ajax', { title : 'CHANGE_ME', owner : 'owner_window_id', focus_targets : 'CHANGE_ME', modal : false, fullscreen : false, destroyOnClose : false, clearOnClose : true, width : 0, height : 0, top : null, left : null, // window events onSuccess : function(win) { // window openned successfully }, onFailure : function(win) { // window failed to open (due to failure in AJAXRequest) }, onClose : function(win) { // window closes }, onTabOut : function(win) { // user tabs out of the last input in window } });
IFRAME Window instantiation
/** * finds/creates a window object with given id and options. * opens/maximizes/bringsToFront the window object. * sets its IFRAME src to the url provided. * calls the onSuccess function. */ new Window.Ext.IFRAMEWindow('win_id', 'win_iframe_url', { title : 'CHANGE_ME', owner : 'owner_window_id', focus_targets : 'CHANGE_ME', modal : false, fullscreen : false, destroyOnClose : false, clearOnClose : true, width : 0, height : 0, top : null, left : null, onClose : function(win) { // window closes }, onTabOut : function(win) { // user tabs out of the last input in window } });
Namespace that contains utilities to open different kind of dialogs.
Displays the error_message
in an 'error-styled' dialog.
Dialog.Ext.Error("error message");
Displays the alert_message
is an 'warning-styled' dialog.
Callback will be executed with the closure of the dialog.
Dialog.Ext.Alert("alert_message", function() { // alert window has been closed });
Opens a dialog with a progress indicator and message. Callback will be executed after a 1sec delay.
Dialog.Ext.Progress("progress_message", function() { // progress window displayed for 1sec // do this next });
// close progress window Dialog.Ext.endProgress();
Opens a dialog with confirmation message and an OK and Cancel buttons with designated callbacks.
Dialog.Ext.Confirm("conrfirmation_message", function() { // user clicked ok }, function() { // user clicked cancel } );