From eecaf759ea8ba85ed685bbf5c6bcb8afb243689a Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 1 May 2024 15:32:33 +0100 Subject: [PATCH] chore: Clarify usage of window fields in UINotification.js The click handler also makes use of the `options` parameter from UINotification(), which isn't available there, so I've commented that out. This needs more work. /puter/src/UI/UINotification.js 21:5 error 'global_element_id' is not defined no-undef 26:39 error 'global_element_id' is not defined no-undef 34:73 error 'global_element_id' is not defined no-undef 47:14 error 'toolbar_height' is not defined no-undef 55:12 error 'options' is not defined no-undef 55:36 error 'options' is not defined no-undef 56:13 error 'options' is not defined no-undef --- src/UI/UINotification.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/UI/UINotification.js b/src/UI/UINotification.js index 697d23e3..e110ea23 100644 --- a/src/UI/UINotification.js +++ b/src/UI/UINotification.js @@ -18,12 +18,12 @@ */ function UINotification(options){ - global_element_id++; + window.global_element_id++; options.content = options.content ?? ''; let h = ''; - h += `
`; + h += `
`; h += ``; h += html_encode(options.content); h += `
`; @@ -31,7 +31,7 @@ function UINotification(options){ $('body').append(h); - const el_notification = document.getElementById(`ui-notification__${global_element_id}`); + const el_notification = document.getElementById(`ui-notification__${window.global_element_id}`); $(el_notification).show(0, function(e){ // options.onAppend() @@ -44,7 +44,7 @@ function UINotification(options){ $(el_notification).delay(100).show(0). // In the right position (the mouse) css({ - top: toolbar_height + 15, + top: window.toolbar_height + 15, }); return el_notification; @@ -52,9 +52,10 @@ function UINotification(options){ $(document).on('click', '.notification', function(e){ if($(e.target).hasClass('notification')){ - if(options.click && typeof options.click === 'function'){ - options.click(e); - } + // TODO: options isn't available here + // if(options.click && typeof options.click === 'function'){ + // options.click(e); + // } window.close_notification(e.target); }else{ window.close_notification($(e.target).closest('.notification'));