Enhance modal toggle functionality and update service interaction

This commit is contained in:
Will Miao
2025-03-07 09:33:58 +08:00
parent 2e47b30ed5
commit a9b3131e64
3 changed files with 46 additions and 8 deletions

View File

@@ -72,6 +72,12 @@ export class ModalManager {
}
});
// Set up event listeners for modal toggles
const supportToggle = document.getElementById('supportToggleBtn');
if (supportToggle) {
supportToggle.addEventListener('click', () => this.toggleModal('supportModal'));
}
document.addEventListener('keydown', this.boundHandleEscape);
this.initialized = true;
}
@@ -173,6 +179,20 @@ export class ModalManager {
}
}
}
toggleModal(id, content = null, onCloseCallback = null) {
const modal = this.getModal(id);
if (!modal) return;
// If this modal is already open, close it
if (modal.isOpen) {
this.closeModal(id);
return;
}
// Otherwise, show the modal
this.showModal(id, content, onCloseCallback);
}
}
// Create and export a singleton instance