fr
This commit is contained in:
parent
f600f8f6f6
commit
d87d59face
|
|
@ -129,30 +129,40 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const collapses = document.querySelectorAll('.accordion-collapse');
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const collapses = document.querySelectorAll('.accordion-collapse');
|
||||
|
||||
collapses.forEach(collapse => {
|
||||
collapse.addEventListener('show.bs.collapse', function () {
|
||||
const fnName = this.dataset.openFn;
|
||||
if (fnName && typeof window[fnName] === 'function') {
|
||||
window[fnName]();
|
||||
}
|
||||
// Trouver le bouton lié à ce collapse
|
||||
const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]');
|
||||
const icon = headerBtn?.querySelector('.accordion-icon');
|
||||
if (icon) icon.classList.replace('bi-chevron-down', 'bi-chevron-up');
|
||||
});
|
||||
collapses.forEach(collapse => {
|
||||
collapse.addEventListener('show.bs.collapse', function () {
|
||||
const fnName = this.dataset.openFn;
|
||||
if (fnName && typeof window[fnName] === 'function') {
|
||||
window[fnName]();
|
||||
}
|
||||
const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]');
|
||||
const icon = headerBtn?.querySelector('.accordion-icon');
|
||||
if (icon) icon.classList.replace('bi-chevron-down', 'bi-chevron-up');
|
||||
});
|
||||
|
||||
collapse.addEventListener('hide.bs.collapse', function () {
|
||||
const fnName = this.dataset.closeFn;
|
||||
if (fnName && typeof window[fnName] === 'function') {
|
||||
window[fnName]();
|
||||
}
|
||||
const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]');
|
||||
const icon = headerBtn?.querySelector('.accordion-icon');
|
||||
if (icon) icon.classList.replace('bi-chevron-up', 'bi-chevron-down');
|
||||
});
|
||||
collapse.addEventListener('hide.bs.collapse', function () {
|
||||
const fnName = this.dataset.closeFn;
|
||||
if (fnName && typeof window[fnName] === 'function') {
|
||||
window[fnName]();
|
||||
}
|
||||
const headerBtn = document.querySelector('[data-bs-target="#' + this.id + '"]');
|
||||
const icon = headerBtn?.querySelector('.accordion-icon');
|
||||
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>
|
||||
Loading…
Reference in New Issue
Block a user