@serenity-is/corelib / Dialog
Class: Dialog
Wrapper for different types of dialogs, including jQuery UI, Bootstrap modals, and Panels.
Constructors
new Dialog()
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.
Parameters
opt?
Optional configuration for the dialog
Returns
Defined in
Properties
defaults
staticdefaults:DialogOptions
Default set of dialog options
Defined in
messageDefaults
staticmessageDefaults:MessageDialogOptions
Default set of message dialog options
Defined in
Accessors
result
Get Signature
get result():
string
The result code of the button that is clicked. Also attached to the dialog element as data-dialog-result
Returns
string
Defined in
type
Get Signature
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
Returns
Defined in
Methods
close()
Call Signature
close():
this
Closes dialog setting the result to null
Returns
this
Defined in
Call Signature
close(
result):this
Closes dialog with the result set to value
Parameters
result
string
Returns
this
Defined in
dispose()
dispose():
void
Disposes the dialog, removing it from the DOM and unbinding all event handlers.
Returns
void
Defined in
getContentNode()
getContentNode():
HTMLElement
Gets the body/content element of the dialog
Returns
HTMLElement
Defined in
getDialogNode()
getDialogNode():
HTMLElement
Gets the dialog element of the dialog
Returns
HTMLElement
Defined in
getEventsNode()
getEventsNode():
HTMLElement
Gets the node that receives events for the dialog. It's .ui-dialog-content, .modal, or .panel-body
Returns
HTMLElement
Defined in
getFooterNode()
getFooterNode():
HTMLElement
Gets the footer element of the dialog
Returns
HTMLElement
Defined in
getHeaderNode()
getHeaderNode():
HTMLElement
Gets the header element of the dialog
Returns
HTMLElement
Defined in
onClose()
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.
Parameters
handler
(result?, e?) => void
The event handler function
opt?
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.
opt.before
boolean
opt.oneOff
boolean
Returns
this
The dialog instance
Defined in
onOpen()
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.
Parameters
handler
(e?) => void
The event handler function
opt?
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.
opt.before
boolean
opt.oneOff
boolean
Returns
this
The dialog instance
Defined in
open()
open():
Dialog
Opens the dialog
Returns
Defined in
title()
Call Signature
title():
string
Gets the title text of the dialog
Returns
string
Defined in
Call Signature
title(
value):this
Sets the title text of the dialog.
Parameters
value
string
Returns
this
Defined in
getInstance()
staticgetInstance(el):Dialog
Gets the dialog instance for the specified element.
Parameters
el
HTMLElement | ArrayLike<HTMLElement>
Returns
The dialog instance, or null if the element is not a dialog.
Defined in
onClose()
staticonClose(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.
Parameters
el
HTMLElement | ArrayLike<HTMLElement>
handler
(result?, e?) => void
The event handler function
opt?
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.
opt.before
boolean
opt.oneOff
boolean
Returns
void
Defined in
onOpen()
staticonOpen(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.
Parameters
el
HTMLElement | ArrayLike<HTMLElement>
handler
(e?) => void
The event handler function
opt?
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.
opt.before
boolean
opt.oneOff
boolean
Returns
void
The dialog instance