2026-03-02 09:30:46 -05:00
|
|
|
import * as bootstrap from 'bootstrap';
|
|
|
|
|
window.bootstrap = bootstrap;
|
2026-03-16 14:07:37 -04:00
|
|
|
import 'bootstrap/dist/js/bootstrap.bundle.min.js';
|
2026-03-02 09:30:46 -05:00
|
|
|
|
|
|
|
|
// trap browser back and close the modal if open
|
|
|
|
|
const cardModal = document.getElementById('cardModal');
|
2026-03-05 12:10:55 -05:00
|
|
|
const loadingMsg = cardModal.innerHTML;
|
2026-03-02 09:30:46 -05:00
|
|
|
// Push a new history state when the modal is shown
|
|
|
|
|
cardModal.addEventListener('shown.bs.modal', () => {
|
|
|
|
|
history.pushState({ modalOpen: true }, null, '#cardModal');
|
|
|
|
|
});
|
|
|
|
|
// Listen for the browser's back button (popstate event)
|
|
|
|
|
window.addEventListener('popstate', (e) => {
|
|
|
|
|
if (cardModal.classList.contains('show')) {
|
|
|
|
|
const modalInstance = bootstrap.Modal.getInstance(cardModal);
|
|
|
|
|
if (modalInstance) {
|
|
|
|
|
modalInstance.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// Trigger a back navigation when the modal is closed via its native controls (X, backdrop click)
|
|
|
|
|
cardModal.addEventListener('hide.bs.modal', () => {
|
2026-03-05 12:10:55 -05:00
|
|
|
cardModal.innerHTML = loadingMsg;
|
2026-03-02 09:30:46 -05:00
|
|
|
if (history.state && history.state.modalOpen) {
|
|
|
|
|
history.back();
|
|
|
|
|
}
|
2026-03-16 14:07:37 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Tooltip } from "bootstrap";
|
|
|
|
|
|
|
|
|
|
// Initialize all tooltips globally
|
|
|
|
|
const initTooltips = () => {
|
|
|
|
|
document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(el => {
|
|
|
|
|
if (!el._tooltipInstance) {
|
|
|
|
|
el._tooltipInstance = new Tooltip(el, {
|
|
|
|
|
container: 'body', // ensures tooltip is appended to body, important for modals
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Run on page load
|
|
|
|
|
if (document.readyState === 'loading') {
|
|
|
|
|
document.addEventListener('DOMContentLoaded', initTooltips);
|
|
|
|
|
} else {
|
|
|
|
|
initTooltips();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Optional: observe DOM changes for dynamically added tooltips (e.g., modals loaded later)
|
|
|
|
|
const observer = new MutationObserver(() => initTooltips());
|
|
|
|
|
observer.observe(document.body, { childList: true, subtree: true });
|