1(() => { 2 'use strict'; 3 4 const root = document.documentElement; 5 const coarse = matchMedia('(hover: none) and (pointer: coarse)'); 6 7 function setDeviceState() { 8 root.classList.toggle('touch-layout', coarse.matches); 9 root.classList.toggle('phone-layout', innerWidth < 768); 10 root.classList.toggle('tablet-layout', innerWidth >= 768 && (innerWidth <= 1180 || coarse.matches)); 11 root.style.setProperty('--app-height', `${window.visualViewport?.height || innerHeight}px`); 12 } 13 14 let frame = 0; 15 function scheduleDeviceState() { 16 cancelAnimationFrame(frame); 17 frame = requestAnimationFrame(setDeviceState); 18 } 19 20 setDeviceState(); 21 addEventListener('resize', scheduleDeviceState, { passive: true }); 22 addEventListener('orientationchange', scheduleDeviceState, { passive: true }); 23 window.visualViewport?.addEventListener('resize', scheduleDeviceState, { passive: true }); 24 coarse.addEventListener?.('change', setDeviceState); 25 26 const menu = document.querySelector('.menu'); 27 const nav = document.querySelector('.nav'); 28 if (menu && nav) { 29 if (!nav.id) nav.id = 'main-navigation'; 30 menu.setAttribute('aria-controls', nav.id); 31 menu.setAttribute('aria-expanded', nav.classList.contains('open') ? 'true' : 'false'); 32 33 const observer = new MutationObserver(() => { 34 menu.setAttribute('aria-expanded', nav.classList.contains('open') ? 'true' : 'false'); 35 }); 36 observer.observe(nav, { attributes: true, attributeFilter: ['class'] }); 37 38 nav.addEventListener('click', event => { 39 if (event.target.closest('a') && innerWidth <= 1180) { 40 nav.classList.remove('open'); 41 } 42 }); 43 } 44})();
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.