Skip to content

Commit

Permalink
close dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Sep 27, 2024
1 parent 6fe6ead commit 5d0a22f
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions lib/ui/elements/dialog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,21 @@ export default function dialog(dialog) {

const classList = `${dialog.modal ? 'modal' : 'dialog'} ${dialog.class || ''}`

dialog.close = e => {
if(dialog.onClose instanceof Function) dialog.onClose(e)
dialog.node.close()
dialog.node.remove()
function closeDialog(e) {
if (dialog.onClose instanceof Function) {
dialog.onClose(e)
}
}

dialog.close = closeDialog

dialog.closeBtn &&= mapp.utils.html`<button
data-id=close
class="mask-icon close"
onclick=${closeDialog}>`
onclick=${closeDialog}>`

dialog.node = mapp.utils.html.node`<dialog
onclose=${dialog.close}
onclose=${closeDialog}
style=${dialog.css_style}
data-id=${dialog.data_id}
class="${classList}">
Expand Down Expand Up @@ -112,13 +114,6 @@ export default function dialog(dialog) {
resizeObserver.observe(dialog.target);
}

// Function to handle the dialog closure
function closeDialog(e) {
e.stopPropagation();
if (dialog.onClose instanceof Function) return dialog.onClose()
dialog.close();
}

// Function to handle the start of a drag event, setting up the necessary event listeners for moving and ending the drag
function handleStartEvent(e) {

Expand Down

0 comments on commit 5d0a22f

Please sign in to comment.