Anpassung für erweiterte Kompatibilität weiterer Browser
This commit is contained in:
@@ -14,23 +14,34 @@
|
||||
|
||||
(function() {
|
||||
'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[]"]');
|
||||
|
||||
|
||||
if (!cohortsDropdown) {
|
||||
console.log('Kohorten-Dropdown nicht gefunden');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const dropdownContainer = cohortsDropdown.closest('.btn-group.bootstrap-select');
|
||||
const searchBox = dropdownContainer.querySelector('.bs-searchbox');
|
||||
|
||||
const searchBox = dropdownContainer?.querySelector('.bs-searchbox');
|
||||
|
||||
if (!searchBox) {
|
||||
console.log('Searchbox nicht gefunden');
|
||||
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');
|
||||
actionsBox.className = 'bs-actionsbox';
|
||||
actionsBox.innerHTML = `
|
||||
@@ -39,9 +50,17 @@
|
||||
<button type="button" class="actions-btn bs-deselect-all btn btn-default">Nichts auswählen</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
searchBox.insertAdjacentElement('afterend', actionsBox);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user