@serenity-is/corelib / Dialog
Wrapper for different types of dialogs, including jQuery UI, Bootstrap modals, and Panels.
new Dialog(
opt
?):Dialog
Creates a new dialog. The type of the dialog will be determined based on the availability of jQuery UI, Bootstrap, and the options provided.
Optional configuration for the dialog
static
defaults:DialogOptions
Default set of dialog options
static
messageDefaults:MessageDialogOptions
Default set of message dialog options
get result():
string
The result code of the button that is clicked. Also attached to the dialog element as data-dialog-result
string
get type():
DialogProviderType
Returns the type of the dialog, or null if no dialog on the current element or if the element is null, e.g. dialog was disposed
close():
this
Closes dialog setting the result to null
this
close(
result
):this
Closes dialog with the result set to value
string
this
dispose():
void
Disposes the dialog, removing it from the DOM and unbinding all event handlers.
void
getContentNode():
HTMLElement
Gets the body/content element of the dialog
HTMLElement
getDialogNode():
HTMLElement
Gets the dialog element of the dialog
HTMLElement
getEventsNode():
HTMLElement
Gets the node that receives events for the dialog. It's .ui-dialog-content, .modal, or .panel-body
HTMLElement
getFooterNode():
HTMLElement
Gets the footer element of the dialog
HTMLElement
getHeaderNode():
HTMLElement
Gets the header element of the dialog
HTMLElement
onClose(
handler
,opt
?):this
Adds an event handler that is called when the dialog is closed. If the opt.before is true, the handler is called before the dialog is closed and the closing can be cancelled by calling preventDefault on the event object.
(result
?, e
?) => void
The event handler function
Options to determine whether the handler should be called before the dialog is closed, and whether the handler should be called only once. The default for oneOff is true unless opt.before is true.
boolean
boolean
this
The dialog instance
onOpen(
handler
,opt
?):this
Adds an event handler that is called when the dialog is opened. If the second parameter is true, the handler is called before the dialog is opened and the opening can be cancelled by calling preventDefault on the event object. Note that if the dialog is not yet initialized, the first argument must be the body element of the dialog.
(e
?) => void
The event handler function
Options to determine whether the handler should be called before the dialog is opened, and whether the handler should be called only once. The default for oneOff is true unless opt.before is true.
boolean
boolean
this
The dialog instance
open():
Dialog
Opens the dialog
title():
string
Gets the title text of the dialog
string
title(
value
):this
Sets the title text of the dialog.
string
this
static
getInstance(el
):Dialog
Gets the dialog instance for the specified element.
HTMLElement
| ArrayLike
<HTMLElement
>
The dialog instance, or null if the element is not a dialog.
static
onClose(el
,handler
,opt
?):void
Adds an event handler that is called when the dialog is closed. If the opt.before is true, the handler is called before the dialog is closed and the closing can be cancelled by calling preventDefault on the event object. Note that if the dialog is not yet initialized, the first argument must be the body element of the dialog.
HTMLElement
| ArrayLike
<HTMLElement
>
(result
?, e
?) => void
The event handler function
Options to determine whether the handler should be called before the dialog is closed, and whether the handler should be called only once. The default for oneOff is true unless opt.before is true.
boolean
boolean
void
static
onOpen(el
,handler
,opt
?):void
Adds an event handler that is called when the dialog is opened. If the second parameter is true, the handler is called before the dialog is opened and the opening can be cancelled by calling preventDefault on the event object. Note that if the dialog is not yet initialized, the first argument must be the body element of the dialog.
HTMLElement
| ArrayLike
<HTMLElement
>
(e
?) => void
The event handler function
Options to determine whether the handler should be called before the dialog is opened, and whether the handler should be called only once. The default for oneOff is true unless opt.before is true.
boolean
boolean
void
The dialog instance