25 lines
761 B
JavaScript
25 lines
761 B
JavaScript
/**
|
|
* public/js/sidebar-lock.js
|
|
*
|
|
* Fängt Klicks auf gesperrte Menüpunkte ab und zeigt einen
|
|
* Bootstrap-Toast statt auf eine Fehlerseite zu navigieren.
|
|
*
|
|
* Voraussetzung: bootstrap.bundle.min.js ist geladen.
|
|
*/
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const toastEl = document.getElementById('lockToast');
|
|
const toastMsg = document.getElementById('lockToastMsg');
|
|
|
|
if (!toastEl || !toastMsg) return;
|
|
|
|
const toast = bootstrap.Toast.getOrCreateInstance(toastEl, { delay: 3000 });
|
|
|
|
document.querySelectorAll('.nav-item[data-locked]').forEach(function (link) {
|
|
link.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
toastMsg.textContent = link.dataset.locked;
|
|
toast.show();
|
|
});
|
|
});
|
|
});
|