1document.addEventListener("DOMContentLoaded", function () { 2 const tabs = document.querySelectorAll( 3 ".w-tabs-item, .w-tabs-section-header" 4 ); 5 6 tabs.forEach((tab) => { 7 tab.addEventListener("click", function () { 8 // Piccolo timeout per dare tempo al CMS di mostrare il contenuto e aggiornare gli attributi ARIA 9 setTimeout(() => { 10 const controlsId = tab.getAttribute("aria-controls"); 11 if (!controlsId) return; 12 13 const targetSection = document.getElementById(controlsId); 14 if (!targetSection) return; 15 16 // Trova il primo elemento focalizzabile allâinterno della sezione appena aperta 17 const firstFocusable = targetSection.querySelector( 18 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])' 19 ); 20 21 // Se câè almeno un elemento focalizzabile, sposta il focus lì 22 if (firstFocusable) { 23 firstFocusable.focus(); 24 } else { 25 // Altrimenti metti il focus sul contenitore della sezione (funziona per screen reader) 26 targetSection.setAttribute("tabindex", "-1"); 27 targetSection.focus(); 28 } 29 }, 150); // 150 ms è sufficiente per la maggior parte dei temi che usano questa struttura 30 }); 31 }); 32 33 // Bonus: gestione anche con tastiera (Enter/Space su tab)
34 tabs.forEach((tab) => { 35 tab.addEventListener("keydown", function (e) { 36 if (e.key === "Enter" || e.key === " ") { 37 e.preventDefault(); 38 tab.click(); 39 } 40 }); 41 }); 42});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.