This commit is contained in:
2026-01-26 16:57:35 +01:00
parent 46d97d433c
commit 0f5f732b4d
43 changed files with 2657 additions and 40 deletions

View File

@ -102,4 +102,48 @@ document.addEventListener('DOMContentLoaded', () => {
photoEl.classList.toggle('full');
});
});
// Accordion functionality
// Comportement "accordion" : quand un details s'ouvre, fermer les autres
(function(){
const faqContainer = document.getElementById('faq');
if (!faqContainer) return;
const items = faqContainer.querySelectorAll('details');
items.forEach(item => {
// Mise à jour de l'attribut aria-expanded pour accessibilité
item.addEventListener('toggle', () => {
item.querySelector('summary')?.setAttribute('aria-expanded', item.open ? 'true' : 'false');
if (item.open) {
items.forEach(other => { if (other !== item) other.removeAttribute('open'); });
}
});
// Permet Enter / Espace pour déclencher l'ouverture quand summary a le focus
const summary = item.querySelector('summary');
summary.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
summary.click();
}
});
});
})();
// Link prefetching on hover
(function(){
const prefetchLinks = new Set();
document.querySelectorAll('a[href]').forEach(link => {
link.addEventListener('mouseenter', () => {
const url = link.href;
if (!prefetchLinks.has(url)) {
const linkEl = document.createElement('link');
linkEl.rel = 'prefetch';
linkEl.href = url;
document.head.appendChild(linkEl);
prefetchLinks.add(url);
}
});
});
})();
});