51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// 聊天室右侧名单/房间面板事件绑定,逐步替代 Blade 内联事件。
|
|
|
|
let rightPanelEventsBound = false;
|
|
|
|
/**
|
|
* 绑定右侧在线面板的 tab、刷新、排序和搜索事件。
|
|
*
|
|
* @returns {void}
|
|
*/
|
|
export function bindChatRightPanelControls() {
|
|
if (rightPanelEventsBound || typeof document === "undefined") {
|
|
return;
|
|
}
|
|
|
|
rightPanelEventsBound = true;
|
|
document.addEventListener("click", (event) => {
|
|
if (!(event.target instanceof Element)) {
|
|
return;
|
|
}
|
|
|
|
const tabButton = event.target.closest("[data-chat-right-tab]");
|
|
if (tabButton) {
|
|
event.preventDefault();
|
|
window.switchTab?.(tabButton.dataset.chatRightTab);
|
|
return;
|
|
}
|
|
|
|
const refreshButton = event.target.closest("[data-chat-user-list-refresh]");
|
|
if (refreshButton) {
|
|
event.preventDefault();
|
|
window.renderUserList?.();
|
|
}
|
|
});
|
|
|
|
document.addEventListener("change", (event) => {
|
|
if (!(event.target instanceof HTMLSelectElement) || event.target.id !== "user-sort-select") {
|
|
return;
|
|
}
|
|
|
|
window.renderUserList?.();
|
|
});
|
|
|
|
document.addEventListener("input", (event) => {
|
|
if (!(event.target instanceof HTMLInputElement) || event.target.id !== "user-search-input") {
|
|
return;
|
|
}
|
|
|
|
window.scheduleFilterUserList?.();
|
|
});
|
|
}
|