Caplin Trader 5.1.0

Class: module:ct-popout/WindowService

module:ct-popout/WindowService()

new module:ct-popout/WindowService()

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

Methods

exportToMainWindow(objectToImport) → {Object}

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:
Name Type Description
objectToImport Object

An object from the current window.

Returns:

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

Type
Object

importFromMainWindow(objectToImport) → {Object}

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:
Name Type Description
objectToImport Object

An object from the application's main window.

Returns:

A copy of the object that is safe to use in the current window.

Type
Object

isPopout() → {boolean}

Used to determine if the current window is a popout.

Returns:

true if the window is a popout, otherwise false.

Type
boolean

onPopoutWindowReady(popoutWindow, 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:
Name Type Description
popoutWindow window

reference to the popout window object.

popoutService module:ct-popout/PopoutService

reference to the PopoutService inside the popout window.

open(relativeUrl, windowName, windowProperties, callbacks)

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

Parameters:
Name Type Description
relativeUrl String

relative URL of page to be opened, to be passed to window.open.

windowName String

name of window to be passed to window.open.

windowProperties String

comma-separated list of property assignments to be passed to window.open.

callbacks Object

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
}