Constructor
new Dialog(data, options)
- Source:
- 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
- Source:
title :string
- Source:
- 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(title, content, yes, no, render, defaultYes, rejectClose, options) → {Promise.<*>}
- Source:
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 |
---|---|---|
title |
string | The confirmation window title |
content |
string | The confirmation message |
yes |
function | Callback function upon yes |
no |
function | Callback function upon no |
render |
function | A function to call when the dialog is rendered |
defaultYes |
boolean | Make "yes" the default choice? |
rejectClose |
boolean | Reject the Promise if the Dialog is closed without making a choice. |
options |
Object | Additional rendering options passed to the Dialog |
Returns:
A promise which resolves once the user makes a choice or closes the window
- Type
- Promise.<*>
(async, static) prompt(title, content, label, callback, render, options) → {Promise.<*>}
- Source:
A helper factory method to display a basic "prompt" style Dialog with a single button
Parameters:
Name | Type | Description |
---|---|---|
title |
string | The confirmation window title |
content |
string | The confirmation message |
label |
string | The confirmation button text |
callback |
function | A callback function to fire when the button is clicked |
render |
function | A function that fires after the dialog is rendered |
options |
object | Additional rendering options |
Returns:
A promise which resolves when clicked, or rejects if closed
- Type
- Promise.<*>
activateListeners(html)
- Source:
- Implements:
Once the HTML for an Application has been rendered, activate event listeners which provide interactivity for the application
Parameters:
Name | Type | Description |
---|---|---|
html |
jQuery |
(async) close() → {Promise.<void>}
- Source:
- 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}
- Source:
- 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