diff options
author | Ben Mullins <benm@umich.edu> | 2024-04-30 12:47:53 -0400 |
---|---|---|
committer | Ben Mullins <benm@umich.edu> | 2024-04-30 12:47:53 -0400 |
commit | 9b2d61c6e159ffdb62d5b6cbf2f9d1915375cbdc (patch) | |
tree | 4496b76ed4dc279cb777220e920ebfcdcbad6caa /core/modules/settings_tray | |
parent | aa2830b3b148c3003f8f05c0145f6bb7022d1646 (diff) | |
download | drupal-9b2d61c6e159ffdb62d5b6cbf2f9d1915375cbdc.tar.gz drupal-9b2d61c6e159ffdb62d5b6cbf2f9d1915375cbdc.zip |
Issue #3390549 by finnsky, nod_, smustgrave, larowlan, catch, bnjmnm: Get rid of jQuery in dialog events
Diffstat (limited to 'core/modules/settings_tray')
-rw-r--r-- | core/modules/settings_tray/js/settings_tray.js | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/core/modules/settings_tray/js/settings_tray.js b/core/modules/settings_tray/js/settings_tray.js index 70e5df5a40a..5b627eafc47 100644 --- a/core/modules/settings_tray/js/settings_tray.js +++ b/core/modules/settings_tray/js/settings_tray.js @@ -237,24 +237,22 @@ }; // Manage Active editable class on opening and closing of the dialog. - $(window).on({ - 'dialog:beforecreate': (event, dialog, $element, settings) => { - if ($element[0].id === 'drupal-off-canvas') { - $('body .settings-tray-active-editable').removeClass( - 'settings-tray-active-editable', - ); - const $activeElement = $(`#${settings.settingsTrayActiveEditableId}`); - if ($activeElement.length) { - $activeElement.addClass('settings-tray-active-editable'); - } - } - }, - 'dialog:beforeclose': (event, dialog, $element) => { - if ($element[0].id === 'drupal-off-canvas') { - $('body .settings-tray-active-editable').removeClass( - 'settings-tray-active-editable', - ); + window.addEventListener('dialog:beforecreate', (e) => { + if (e.target.id === 'drupal-off-canvas') { + $('body .settings-tray-active-editable').removeClass( + 'settings-tray-active-editable', + ); + const $activeElement = $(`#${e.settings.settingsTrayActiveEditableId}`); + if ($activeElement.length) { + $activeElement.addClass('settings-tray-active-editable'); } - }, + } + }); + window.addEventListener('dialog:beforeclose', (e) => { + if (e.target.id === 'drupal-off-canvas') { + $('body .settings-tray-active-editable').removeClass( + 'settings-tray-active-editable', + ); + } }); })(jQuery, Drupal); |