This commit is contained in:
KONE SOREL 2026-01-12 14:44:36 +00:00
parent f600f8f6f6
commit d87d59face

View File

@ -129,30 +129,40 @@
</div> </div>
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
const collapses = document.querySelectorAll('.accordion-collapse'); const collapses = document.querySelectorAll('.accordion-collapse');
collapses.forEach(collapse => { collapses.forEach(collapse => {
collapse.addEventListener('show.bs.collapse', function () { collapse.addEventListener('show.bs.collapse', function () {
const fnName = this.dataset.openFn; const fnName = this.dataset.openFn;
if (fnName && typeof window[fnName] === 'function') { if (fnName && typeof window[fnName] === 'function') {
window[fnName](); window[fnName]();
} }
// Trouver le bouton lié à ce collapse const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]');
const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]'); const icon = headerBtn?.querySelector('.accordion-icon');
const icon = headerBtn?.querySelector('.accordion-icon'); if (icon) icon.classList.replace('bi-chevron-down', 'bi-chevron-up');
if (icon) icon.classList.replace('bi-chevron-down', 'bi-chevron-up'); });
});
collapse.addEventListener('hide.bs.collapse', function () { collapse.addEventListener('hide.bs.collapse', function () {
const fnName = this.dataset.closeFn; const fnName = this.dataset.closeFn;
if (fnName && typeof window[fnName] === 'function') { if (fnName && typeof window[fnName] === 'function') {
window[fnName](); window[fnName]();
} }
const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]'); const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]');
const icon = headerBtn?.querySelector('.accordion-icon'); const icon = headerBtn?.querySelector('.accordion-icon');
if (icon) icon.classList.replace('bi-chevron-up', 'bi-chevron-down'); if (icon) icon.classList.replace('bi-chevron-up', 'bi-chevron-down');
});
}); });
}); });
// Patch pour permettre le toggle même avec data-bs-parent
document.querySelectorAll('.accordion-button').forEach(btn => {
btn.addEventListener('click', function(e) {
const target = document.querySelector(this.dataset.bsTarget);
if (target.classList.contains('show')) {
e.preventDefault(); // empêche Bootstrap de forcer l'ouverture
bootstrap.Collapse.getInstance(target).hide();
}
});
});
});
</script> </script>