Yup
This commit is contained in:
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user