Constructor
new Window(sessionopt, entity_idopt, node_idopt, module_nameopt, dataopt, xopt, yopt)
Constructs a Window object and displays a window corresponding to the object. All subclasses must call this constructor.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
session |
Object |
<optional> |
|
entity_id |
String |
<optional> |
The ID of an entity corresponding
to a window. This is provided by a parameter of
|
node_id |
String |
<optional> |
The ID of a node corresponding
to a window. This is provided by a parameter of
|
module_name |
String |
<optional> |
The name of a module within a node corresponding to a window. It can be undefined. |
data |
<optional> |
Arbitrary data to be passed to |
|
x |
int |
<optional> |
x-part of the initial upper-left corner
position of a window. If undefined, the value of |
y |
int |
<optional> |
y-part of the initial upper-left corner
position of a window. If undefined, the value of |
Members
instances
Static dictionary storing all instances of a Window
class (or one of its subclasses) under their IDs as returned
by getId().
Methods
(abstract) _setup(data, existing_window)
Sets up a window. This is always called when the window is opened or
refreshed. Use getContent() to get a jQuery object for manipulating
the window content.
Important: This function must call hideLoading() at some point.
Otherwise, there will be a loading indicator in the window instead
of a desired content.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Arbitrary data passed to the constructor, e.g. a dictionary. |
|
existing_window |
bool | Whether a window is already displayed. |
downloadSvg(class_nameopt, cssopt)
Downloads a given SVG object in a window as an SVG file.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
class_name |
String |
<optional> |
The class name of an SVG object. It is expected that the object has a unique class name within the window. Otherwise, the behaviour is undefined. |
css |
String |
<optional> |
The path to a CSS stylesheet to be applied to the SVG before downloading. |
(abstract) finishResize()
Called when a user finishes resizing a window.
focus()
Focuses a window.
getContent() → {Object}
Gets the content of a window in form of a jQuery object.
The return value of this function is based on your implementation
of getContentCode().
Returns:
jQuery object representing the content of a window.
- Type
- Object
(abstract) getContentCode() → {String}
Gets the content of a window in form of an HTML code.
Window header and border rendering along with basic window
operations except resizing is fully handled by Adaptyst
Analyser and you shouldn't implement it yourself. Resizing
is partially handled by Adaptyst Analyser and should also
not be implemented here, see startResize() and
finishResize() instead.
A padding of 5 pixels is applied to the content of all windows in Adaptyst Analyser.
Returns:
HTML code of the content of a window.
- Type
- String
getData() → {Object}
Gets the dictionary of a window. It can be filled with arbitrary data.
Returns:
Dictionary of a window.
- Type
- Object
getEntityId() → {String}
Gets the entity ID of a window. It can be undefined.
Returns:
Entity ID of a window.
- Type
- String
getId() → {String}
Gets the ID of a window.
Returns:
ID of a window.
- Type
- String
getLastFocusTime()
Gets the last time a window was focused.
Returns:
Last time a window was focused, as a number representing a Unix timestamp in milliseconds.
getModuleName() → {String}
Gets the module name of a window. It can be undefined.
Returns:
Module name of a window.
- Type
- String
getNodeId() → {String}
Gets the node ID of a window. It can be undefined.
Returns:
Node ID of a window.
- Type
- String
getSession() → {Object}
Gets the performance session a window is part of.
Returns:
Session of a window.
- Type
- Object
(abstract) getTitle() → {String}
Gets the title of a window.
Returns:
Title of a window.
- Type
- String
(abstract) getType() → {String}
Gets the type of a window. This is used in the ID
of a window, an HTML class of the window
(i.e. <type>_window), and an HTML class of
the window content (i.e. <type>_content).
Returns:
Type of a window.
- Type
- String
getZIndex()
Gets the value of the z-index CSS property of a window.
Returns:
Value of z-index of a window.
hideLoading()
Hides the loading indicator in a window.
(abstract) prepareClose()
Called when a user closes a window, before it is actually closed.
(abstract) prepareRefresh(data)
Called when a user refreshes a window, before the proper refresh process with the content resetup takes place.
The old window content is still available when this method is called.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Arbitrary data that have been passed to the constructor and will be available in _setup(), e.g. a dictionary. |
sendRequest(data, done_func, fail_func, content_type)
Sends a request to the server side of Adaptyst Analyser. The request will be handled by the Python code of a corresponding Adaptyst Analyser module.
Use this function only if you have constructed your object with all of an entity ID, a node ID, and a module name.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Data to be sent in form of JSON. |
done_func |
Function to be called when the request succeeds. The function must take exactly one argument which is a JSON object returned by the server side. |
|
fail_func |
Function to be called when the request fails for any reason. The function must take exactly the arguments described in the "error" entry of "settings" in the jQuery.ajax() documentation here. |
|
content_type |
String | Content type expected from the server side. Use one of the values explained in the "dataType" entry in "settings" in the jQuery.ajax documentation here. It can be undefined, this is then interpreted as 'json'. |
showLoading()
Shows the loading indicator in a window.
(abstract) startResize() → {bool}
Called when a user starts resizing a window.
Returns:
Whether finishResize() should be called after resizing is complete.
- Type
- bool
triggerResize()
Triggers window resizing event-wise.
unfocus()
Unfocuses a window.
(static) getDepsPath() → {String}
Gets the path to the server folder where JavaScript and CSS dependencies of modules are stored. Use the value returned by this method for constructing URLs to the dependencies.
Returns:
Path to the folder with JavaScript and CSS module dependencies.
- Type
- String
(static) stopPropagation(event)
Stops further propagation of an event. It may be useful e.g. for handling mouse clicks.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
Object | Event which propagation should be stopped. |