diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-01-22 13:49:40 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-01-22 13:49:40 +0100 |
commit | 7218849ae2f43aee6b3462a30e07caf5bac3d22b (patch) | |
tree | 3de3b31c07e532edf7373faf4a267f313dc2ed25 /html/dialog.js | |
parent | 046b8a7b3e7259bf451926732e6221076b1d4153 (diff) | |
download | browser-extension-7218849ae2f43aee6b3462a30e07caf5bac3d22b.tar.gz browser-extension-7218849ae2f43aee6b3462a30e07caf5bac3d22b.zip |
add a mapping/resources installation dialog
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 |