new Dialog(options) → {Class}
A dialog component to house modals, dialogs or prompts.
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for the dialog. Properties
|
- Since
- 1.0.6
- Source
The class instance.
- Type:
- Class
import Dialog from '@gravityforms/components/html/admin/modules/Dialog';
function Example() {
const dialogInstance = new Dialog( {
id: 'example-dialog',
renderOnInit: false,
target: '#example-target',
targetPosition: 'beforeend',
} );
// Some time later we can render it. This is only done if we set renderOnInit to false.
// If true it will render on initialization.
dialogInstance.init();
}
Members
(static) closeDialog
Closes the dialog and fires the onClose function that can be passed in. Can be used by external developers by firing the method on the instance. Also closes all instances if the event 'gform/dialog/close-all' is fired on the document.
- Since
- 1.0.6
- Source
(static) handleConfirm
Handles a confirm button click and closes if the option is true.
- Since
- 1.0.6
- Source
(static) handleKeyEvents
Handles accessibility focus looping on the dialog using the focusLoop util.
- Since
- 1.0.6
- Source
(static) handleMaskClick
Handles closing the dialog on mask click.
- Since
- 1.0.6
- Source
(static) handleTriggerClick
Handles opening/closing the dialog on a trigger click.
- Since
- 1.0.6
- Source
(static) maybeCloseDialog
Closes all instances except the one that gets passed the activeId when the event 'gform/dialog/close' is fired on the document.
- Since
- 1.0.6
- Source
Methods
(static) bindEvents() → {void}
Binds the events for this component.
- Since
- 1.0.6
- Source
- Type:
- void
(static) dialogTemplate(options)
The template function that returns html for the dialog. Options below are passed from constructor and described there.
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for the dialog. Properties
|
- Since
- 1.0.6
- Source
string
import { dialogTemplate } from '@gravityforms/components/html/admin/modules/Dialog';
function Example() {
const dialogHTML = dialogTemplate( options );
document.body.insertAdjacentHTML( 'beforeend', dialogHTML );
}
(static) init() → {void}
Initialize the component.
- Since
- 1.1.16
- Source
- Type:
- void
(static) render() → {void}
Renders the component into the dom.
- Since
- 1.0.6
- Source
- Type:
- void
(static) showDialog() → {void}
Opens the dialog and fires the onOpen function that can be passed in.
- Since
- 1.0.6
- Source
- Type:
- void
(static) storeElements() → {void}
Stores useful HTMLElements on the instance in the elements namespace after render
- Since
- 1.0.6
- Source
- Type:
- void