mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
modal: Add support for modal event handlers.
This commit is contained in:
@@ -81,6 +81,10 @@ export function launch(conf) {
|
||||
// * id: Custom id to the container element to modify styles.
|
||||
// * single_footer_button: If true, don't include the "Cancel" button.
|
||||
// * form_id: Id of the form element in the modal if it exists.
|
||||
// * on_show: Callback to run when the modal is triggered to show.
|
||||
// * on_shown: Callback to run when the modal is shown.
|
||||
// * on_hide: Callback to run when the modal is triggered to hide.
|
||||
// * on_hidden: Callback to run when the modal is hidden.
|
||||
|
||||
for (const f of mandatory_fields) {
|
||||
if (conf[f] === undefined) {
|
||||
@@ -133,12 +137,16 @@ export function launch(conf) {
|
||||
overlays.open_modal("dialog_widget_modal", {
|
||||
autoremove: true,
|
||||
micromodal: true,
|
||||
micromodal_opts: {
|
||||
onShow: () => {
|
||||
if (conf.focus_submit_on_open) {
|
||||
submit_button.trigger("focus");
|
||||
}
|
||||
},
|
||||
on_show: () => {
|
||||
if (conf.focus_submit_on_open) {
|
||||
submit_button.trigger("focus");
|
||||
}
|
||||
if (conf.on_show) {
|
||||
conf.on_show();
|
||||
}
|
||||
},
|
||||
on_hide: conf?.on_hide,
|
||||
on_shown: conf?.on_shown,
|
||||
on_hidden: conf?.on_hidden,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user