Files
Student-Management-System-I…/static/js/hod/utils/notifications.js
T
2025-04-20 17:46:30 +05:45

42 lines
1.5 KiB
JavaScript

// Toast notification function
export function showToast(type, message) {
const toast = document.createElement('div');
toast.className = `toast align-items-center text-white bg-${type} border-0`;
toast.setAttribute('role', 'alert');
toast.setAttribute('aria-live', 'assertive');
toast.setAttribute('aria-atomic', 'true');
toast.innerHTML = `
<div class="d-flex">
<div class="toast-body">
${message}
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
`;
const toastContainer = document.createElement('div');
toastContainer.className = 'toast-container position-fixed bottom-0 end-0 p-3';
toastContainer.appendChild(toast);
document.body.appendChild(toastContainer);
const bsToast = new bootstrap.Toast(toast);
bsToast.show();
toast.addEventListener('hidden.bs.toast', function () {
toastContainer.remove();
});
}
// Message modal functions
export function showMessageModal(title, message) {
document.getElementById('messageModalTitle').textContent = title;
document.getElementById('messageModalContent').textContent = message;
document.getElementById('messageModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
export function closeMessageModal() {
document.getElementById('messageModal').style.display = 'none';
document.body.style.overflow = '';
}