Anpassung für erweiterte Kompatibilität weiterer Browser

This commit is contained in:
2025-11-27 12:52:16 +01:00
parent 44f3be9b1f
commit f8f9441e67

View File

@@ -15,7 +15,12 @@
(function() { (function() {
'use strict'; 'use strict';
window.addEventListener('load', function() { function addSelectButtons() {
// Prüfe ob wir auf der richtigen Seite sind
if (!window.location.href.includes('/course/planning-group/list')) {
return;
}
const cohortsDropdown = document.querySelector('select[name="cohort-ids[]"]'); const cohortsDropdown = document.querySelector('select[name="cohort-ids[]"]');
if (!cohortsDropdown) { if (!cohortsDropdown) {
@@ -24,13 +29,19 @@
} }
const dropdownContainer = cohortsDropdown.closest('.btn-group.bootstrap-select'); const dropdownContainer = cohortsDropdown.closest('.btn-group.bootstrap-select');
const searchBox = dropdownContainer.querySelector('.bs-searchbox'); const searchBox = dropdownContainer?.querySelector('.bs-searchbox');
if (!searchBox) { if (!searchBox) {
console.log('Searchbox nicht gefunden'); console.log('Searchbox nicht gefunden');
return; return;
} }
// Prüfe ob schon vorhanden
if (searchBox.nextElementSibling?.classList.contains('bs-actionsbox')) {
console.log('Select/Deselect Buttons bereits vorhanden');
return;
}
const actionsBox = document.createElement('div'); const actionsBox = document.createElement('div');
actionsBox.className = 'bs-actionsbox'; actionsBox.className = 'bs-actionsbox';
actionsBox.innerHTML = ` actionsBox.innerHTML = `
@@ -43,5 +54,13 @@
searchBox.insertAdjacentElement('afterend', actionsBox); searchBox.insertAdjacentElement('afterend', actionsBox);
console.log('Select/Deselect Buttons erfolgreich eingefügt'); console.log('Select/Deselect Buttons erfolgreich eingefügt');
}); }
// Versuche es direkt
addSelectButtons();
// Falls das Element noch nicht da ist, warte auf DOMContentLoaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', addSelectButtons);
}
})(); })();