diff options
Diffstat (limited to 'html/dialog.js')
-rw-r--r-- | html/dialog.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/html/dialog.js b/html/dialog.js index a2406e8..a4e275f 100644 --- a/html/dialog.js +++ b/html/dialog.js @@ -131,11 +131,15 @@ const loader = (ctx, ...msg) => show_dialog(ctx, null, msg); #EXPORT loader /* - * Wrapper around target.addEventListener() that makes the requested callback - * only execute if dialog is not shown. + * Wrapper the requested callback into one that only executes it if dialog is + * not shown. */ -function onevent(ctx, target, event, cb) +function when_hidden(ctx, cb) { - target.addEventListener(event, e => !ctx.shown && cb(e)); + function wrapped_cb(...args) { + if (!ctx.shown) + return cb(...args); + } + return wrapped_cb; } -#EXPORT onevent +#EXPORT when_hidden |