Constructor
new Dialog(data, options)
- Implements:
Example
Constructing a custom dialog instance
let d = new Dialog({
title: "Test Dialog",
content: "<p>You must choose either Option 1, or Option 2</p>",
buttons: {
one: {
icon: '<i class="fas fa-check"></i>',
label: "Option One",
callback: () => console.log("Chose One")
},
two: {
icon: '<i class="fas fa-times"></i>',
label: "Option Two",
callback: () => console.log("Chose Two")
}
},
default: "two",
render: html => console.log("Register interactivity in the rendered dialog"),
close: html => console.log("This always is logged no matter which option is chosen")
});
d.render(true);
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | An object of dialog data which configures how the modal window is rendered Properties
|
||||||||||||||||||||||||||||
options |
Object | Dialog rendering options, see :class: Properties
|
Members
(static) defaultOptions
title :string
- Implements:
An Application window should define its own title definition logic which may be dynamic depending on its data
Type:
- string
Methods
(async, static) confirm(config) → {Promise.<*>}
A helper factory method to create simple confirmation dialog windows which consist of simple yes/no prompts. If you require more flexibility, a custom Dialog instance is preferred.
Example
let d = Dialog.confirm({
title: "A Yes or No Question",
content: "<p>Choose wisely.</p>",
yes: () => console.log("You chose ... wisely"),
no: () => console.log("You chose ... poorly"),
defaultYes: false
});
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object | Confirmation dialog configuration Properties
|
Returns:
A promise which resolves once the user makes a choice or closes the window
- Type
- Promise.<*>
(async, static) prompt(config) → {Promise.<*>}
A helper factory method to display a basic "prompt" style Dialog with a single button
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object | Dialog configuration options Properties
|
Returns:
The returned value from the provided callback function, if any
- Type
- Promise.<*>
activateListeners(html)
- Implements:
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 |
(async) close() → {Promise.<void>}
- Implements:
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>
getData() → {Object|Promise}
- Implements:
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