Class
caplin.popout

WindowService

Provides utility functions that assist in writing multi-window applications. This service can be accessed from the caplin.core.ServiceRegistry using the alias "caplin.window-service".

Constructor Summary

Attributes Name and Description
caplin.popout.WindowService( windowObject)

Method Summary

Attributes Name and Description
Object exportToMainWindow(Object objectToImport)

Returns a copy of an object that is safe to use in the application's main window.

Object importFromMainWindow(Object objectToImport)

Returns a copy of an object that is safe to use in the current window.

boolean isPopout()

Used to determine if the current window is a popout.

void onPopoutWindowReady(window popoutWindow, caplin.popout.PopoutService popoutService)

Called by PopoutService when the popout window has loaded.

void open(String relativeUrl, String windowName, String windowProperties, Object callbacks)

A wrapper for window.open that also accepts various callbacks.

Constructor Detail

caplin.popout.WindowService( windowObject)

Parameters
windowObject

Method Detail

Object exportToMainWindow(Object objectToImport)

Returns a copy of an object that is safe to use in the application's main window. The given object must originate from the current window, and must be convertible to a JSON string.

Parameters
Object objectToImport An object from the current window.
Returns
{Object} A copy of the object that is safe to use in the application's main window.

Object importFromMainWindow(Object objectToImport)

Returns a copy of an object that is safe to use in the current window. The given object must originate from the application's main window, and must be convertible to a JSON string.

Parameters
Object objectToImport An object from the application's main window.
Returns
{Object} A copy of the object that is safe to use in the current window.

boolean isPopout()

Used to determine if the current window is a popout.

Returns
{boolean} true if the window is a popout, otherwise false.

void onPopoutWindowReady(window popoutWindow, caplin.popout.PopoutService popoutService)

Called by PopoutService when the popout window has loaded. Calls the onReady and adds event listeners to the main window and popout windows to call the onClose and onPopoutClosed functions provided to WindowService.open().

Parameters
window popoutWindow reference to the popout window object.
caplin.popout.PopoutService popoutService reference to the PopoutService inside the popout window.

void open(String relativeUrl, String windowName, String windowProperties, Object callbacks)

A wrapper for window.open that also accepts various callbacks.

Parameters
String relativeUrl relative URL of page to be opened, to be passed to window.open.
String windowName name of window to be passed to window.open.
String windowProperties comma-separated list of property assignments to be passed to window.open.
Object callbacks A simple map of callbacks, of the form:
{
    onReady: called when the opened window is ready to be interacted with
    onClose: called when the opening window is closed
    onPopoutClosed: called when the child window is closed
}