1/* Enhance the server-rendered link groups on small screens; no-JS keeps every link visible. */ 2(function () { 3 'use strict'; 4 var footer = document.querySelector('[data-site-footer]'); 5 if (!footer) return; 6 var mobile = window.matchMedia('(max-width: 767px)'); 7 var groups = Array.from(footer.querySelectorAll('[data-footer-group]')).map(function (group) { 8 var heading = group.querySelector('.site-footer__heading'); 9 var links = group.querySelector('.site-footer__links'); 10 var label = heading.textContent; 11 var button = document.createElement('button'); 12 button.type = 'button'; 13 button.textContent = label; 14 button.setAttribute('aria-controls', links.id); 15 button.addEventListener('click', function () { 16 links.hidden = !links.hidden; 17 button.setAttribute('aria-expanded', String(!links.hidden)); 18 }); 19 return { heading: heading, links: links, button: button, label: label }; 20 }); 21 22 function updateLayout() { 23 groups.forEach(function (group) { 24 if (mobile.matches) { 25 // Keep a focused link visible if the viewport changes during keyboard navigation. 26 group.links.hidden = !group.links.contains(document.activeElement); 27 group.button.setAttribute('aria-expanded', String(!group.links.hidden)); 28 group.heading.replaceChildren(group.button); 29 } else { 30 var restoreFocus = document.activeElement === group.button; 31 group.links.hidden = false; 32 group.heading.textContent = group.label; 33 if (restoreFocus) group.links.querySelector('a').focus(); 34 } 35 }); 36 } 37 updateLayout(); 38 mobile.addEventListener('change', updateLayout); 39}());
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.