Notifications

Notifications

A common framework for displaying notifications to the client. Submitted notifications are added to a queue, and up to 3 notifications are displayed at once. Each notification is displayed for 5 seconds at which point further notifications are pulled from the queue.

Constructor

new Notifications()

Example
ui.notifications.info("This is an info message");
ui.notifications.warn("This is a warning message");
ui.notifications.error("This is an error message");
ui.notifications.info("This is a 4th message which will not be shown until the first info message is done");

Extends

Members

(static) defaultOptions

_dragDrop :Array.<DragDrop>

Overrides:

DragDrop workflow handlers which are active for this Application

Type:

_element :jQuery

Overrides:

An internal reference to the HTML element this application renders

Type:
  • jQuery

_minimized :boolean

Overrides:

Track whether the Application is currently minimized

Type:
  • boolean

(protected) _priorState :number

Overrides:
See:
  • {Application.RENDER_STATES}

The prior render state of this Application. This allows for rendering logic to understand if the application is being rendered for the first time.

Type:
  • number

_scrollPositions :Object|null

Overrides:

Track the most recent scroll positions for any vertically scrolling containers

Type:
  • Object | null

_searchFilters :Array.<SearchFilter>

Overrides:

SearchFilter handlers which are active for this Application

Type:

(protected) _state :number

Overrides:
See:
  • {Application.RENDER_STATES}

The current render state of the Application

Type:
  • number

_tabs :Array.<Tabs>

Overrides:

Tab navigation handlers which are active for this Application

Type:

active :Array.<object>

Notifications which are currently displayed

Type:

appId :number

Overrides:

The application ID is a unique incrementing integer which is used to identify every application window drawn by the VTT

Type:
  • number

element :jQuery|HTMLElement

Overrides:

Return the active application element, if it currently exists in the DOM

Type:
  • jQuery | HTMLElement

id :string

Overrides:

Return the CSS application ID which uniquely references this UI element

Type:
  • string

options :Object

Overrides:

The options provided to this application upon initialization

Type:
  • Object

popOut :boolean

Overrides:

Control the rendering style of the application. If popOut is true, the application is rendered in its own wrapper window, otherwise only the inner app content is rendered

Type:
  • boolean

position :Object

Overrides:

Track the current position and dimensions of the Application UI

Type:
  • Object

queue :Array.<object>

Submitted notifications which are queued for display

Type:

RENDER_STATES :number

Overrides:

The sequence of rendering states that track the Application life-cycle.

Type:
  • number

rendered :boolean

Overrides:

Return a flag for whether the Application instance is currently rendered

Type:
  • boolean

template :string

Overrides:

The path to the HTML template file which should be used to render the inner content of the app

Type:
  • string

title :string

Overrides:

An Application window should define its own title definition logic which may be dynamic depending on its data

Type:
  • string

Methods

(protected) _activateCoreListeners(html)

Overrides:

Activate required listeners which must be enabled on every Application. These are internal interactions which should not be overridden by downstream subclasses.

Parameters:
Name Type Description
html jQuery

(async, protected) _render(force, options) → {Promise.<void>}

Overrides:

An asynchronous inner function which handles the rendering of the Application

Parameters:
Name Type Default Description
force boolean false

Render and display the application even if it is not currently displayed.

options Object

New Application options which update the current values of the Application#options object

Returns:

A Promise that resolves to the Application once rendering is complete

Type
Promise.<void>

activateListeners(html)

Overrides:

After rendering, activate event listeners which provide interactivity for the Application. This is where user-defined Application subclasses should attach their event-handling logic.

Parameters:
Name Type Description
html jQuery

bringToTop()

Overrides:

Bring the application to the top of the rendering stack

(async) close() → {Promise.<void>}

Overrides:

Close the application and un-register references to it within UI mappings This function returns a Promise which resolves once the window closing animation concludes

Returns:

A Promise which resolves once the application is closed

Type
Promise.<void>

error(message, options) → {void}

Display a notification with the "error" type

Parameters:
Name Type Description
message string

The content of the notification message

options Object

Notification options passed to the notify function

Returns:
Type
void

getData() → {Object|Promise}

Overrides:

An application should define the data object used to render its template. This function may either return an Object directly, or a Promise which resolves to an Object If undefined, the default implementation will return an empty object allowing only for rendering of static HTML

Returns:
Type
Object | Promise

info(message, options) → {void}

Display a notification with the "info" type

Parameters:
Name Type Description
message string

The content of the notification message

options Object

Notification options passed to the notify function

Returns:
Type
void

initialize()

Initialize the Notifications system by displaying any system-generated messages which were passed from the server.

(async) maximize() → {Promise.<void>}

Overrides:

Maximize the pop-out window, expanding it to its original size Take no action for applications which are not of the pop-out variety or are already maximized

Returns:

A Promise which resolves once the maximization action has completed

Type
Promise.<void>

(async) minimize() → {Promise.<void>}

Overrides:

Minimize the pop-out window, collapsing it to a small tab Take no action for applications which are not of the pop-out variety or apps which are already minimized

Returns:

A Promise which resolves once the minimization action has completed

Type
Promise.<void>

notify(message, type, optionsopt)

Push a new notification into the queue

Parameters:
Name Type Attributes Default Description
message string

The content of the notification message

type string info

The type of notification, currently "info", "warning", and "error" are supported

options object <optional>
{}

Additional options which affect the notification

Properties
Name Type Attributes Default Description
permanent boolean <optional>
false

Whether the notification should be permanently displayed unless otherwise dismissed

localize boolean <optional>
false

Whether to localize the message content before displaying it

render(force, options) → {Application}

Overrides:

Render the Application by evaluating it's HTML template against the object of data provided by the getData method If the Application is rendered as a pop-out window, wrap the contained HTML in an outer frame with window controls

Parameters:
Name Type Default Description
force boolean false

Add the rendered application to the DOM if it is not already present. If false, the Application will only be re-rendered if it is already present.

options Object

Additional rendering options which are applied to customize the way that the Application is rendered in the DOM.

Properties
Name Type Attributes Default Description
left number <optional>

The left positioning attribute

top number <optional>

The top positioning attribute

width number <optional>

The rendered width

height number <optional>

The rendered height

scale number <optional>

The rendered transformation scale

focus boolean <optional>
false

Apply focus to the application, maximizing it and bringing it to the top of the vertical stack.

renderContext string <optional>

A context-providing string which suggests what event triggered the render

renderData object <optional>

The data change which motivated the render request

Returns:

The rendered Application instance

Type
Application

setPosition(left, top, width, height, scale) → {Object}

Overrides:

Set the application position and store it's new location.

Parameters:
Name Type Description
left number | null

The left offset position in pixels

top number | null

The top offset position in pixels

width number | null

The application width in pixels

height number | string | null

The application height in pixels

scale number | null

The application scale as a numeric factor where 1.0 is default

Returns:

The updated position object for the application containing the new values

Type
Object

warn(message, options) → {void}

Display a notification with the "warning" type

Parameters:
Name Type Description
message string

The content of the notification message

options Object

Notification options passed to the notify function

Returns:
Type
void