Files
cms.uldp.edu.vn/public/js/custom-modal.js

32 lines
918 B
JavaScript

/**
* Custom Modal Utilities
*/
// Global function to clean up any stuck modal backdrops
window.forceCleanupModals = function() {
document.body.classList.remove('modal-open');
document.body.style.overflow = '';
document.body.style.paddingRight = '';
const backdrops = document.querySelectorAll('.modal-backdrop, .overlay, .loading');
if (backdrops.length > 0) {
console.warn('Cleanup: Removing backdrops:', backdrops.length);
backdrops.forEach(el => el.remove());
}
};
// Auto-cleanup on hide
document.addEventListener('hidden.bs.modal', () => {
setTimeout(forceCleanupModals, 100);
});
// Watchdog
setInterval(() => {
if (document.querySelectorAll('.modal.show').length === 0) {
if (document.querySelectorAll('.modal-backdrop').length > 0) {
forceCleanupModals();
}
}
}, 2000);
window.addEventListener('load', forceCleanupModals);