Improve performance of expand/close all WI button

This commit is contained in:
Wolfsblvt
2024-08-05 00:09:50 +02:00
parent eac2e3d81e
commit 4966139fd1
2 changed files with 41 additions and 5 deletions

View File

@@ -156,6 +156,7 @@ import {
ensureImageFormatSupported,
flashHighlight,
isTrueBoolean,
toggleDrawer,
} from './scripts/utils.js';
import { debounce_timeout } from './scripts/constants.js';
@@ -10591,12 +10592,19 @@ jQuery(async function () {
}
});
$(document).on('click', '#OpenAllWIEntries', function () {
$('#world_popup_entries_list').children().find('.down').click();
});
$(document).on('click', '#CloseAllWIEntries', function () {
$('#world_popup_entries_list').children().find('.up').click();
document.addEventListener('click', function (e) {
if (!(e.target instanceof HTMLElement)) return;
if (e.target.matches('#OpenAllWIEntries')) {
document.querySelectorAll('#world_popup_entries_list .inline-drawer').forEach((/** @type {HTMLElement} */ drawer) => {
toggleDrawer(drawer, true);
});
} else if (e.target.matches('#CloseAllWIEntries')) {
document.querySelectorAll('#world_popup_entries_list .inline-drawer').forEach((/** @type {HTMLElement} */ drawer) => {
toggleDrawer(drawer, false);
});
}
});
$(document).on('click', '.open_alternate_greetings', openAlternateGreetings);
/* $('#set_character_world').on('click', openCharacterWorldPopup); */