1/** 2 * Toggles the header search panel. No framework dependency on purpose â 3 * kept vanilla JS throughout. 4 */ 5( function () { 6 var toggle = document.querySelector( '.search-toggle' ); 7 var panel = document.getElementById( 'site-search' ); 8 if ( ! toggle || ! panel ) { 9 return; 10 } 11 toggle.addEventListener( 'click', function () { 12 var isOpen = ! panel.hidden; 13 panel.hidden = isOpen; 14 toggle.setAttribute( 'aria-expanded', isOpen ? 'false' : 'true' ); 15 if ( ! isOpen ) { 16 var field = panel.querySelector( 'input[type="search"]' ); 17 if ( field ) { 18 field.focus(); 19 } 20 } 21 } ); 22} )(); 23 24/** 25 * In-page anchor links (e.g. the header's "Newsletter" button linking to 26 * the homepage's signup section) get two fixes here: 27 * 28 * 1. Clicking one while already on the target page is handled entirely 29 * client-side (scrolled to, URL hash updated) instead of letting the 30 * browser decide whether that counts as "the same page" â which 31 * depends on an exact URL match (trailing slash, etc.) and can end 32 * up looking like a full reload that lands back at the top. 33 * 2. After arriving on a page with a hash in the URL (a fresh load, or 34 * a link from another page), the scroll position is corrected once 35 * more after everything â images included â has finished loading. 36 * A content-heavy homepage still loading images below the target 37 * section can shift its position after the browser's own initial 38 * jump, which looks exactly like it never scrolled at all. 39 */ 40( function () { 41 function scrollToHash( hash, smooth ) { 42 var target = document.getElementById( hash.replace( '#', '' ) ); 43 if ( target ) { 44 target.scrollIntoView( { behavior: smooth ? 'smooth' : 'auto', block: 'start' } ); 45 } 46 return target; 47 } 48 49 document.addEventListener( 'click', function ( e ) { 50 var link = e.target.closest ? e.target.closest( 'a[href*="#"]' ) : null; 51 if ( ! link ) { 52 return; 53 } 54 var url; 55 try { 56 url = new URL( link.href, window.location.href ); 57 } catch ( err ) { 58 return; 59 } 60 if ( url.pathname !== window.location.pathname || ! url.hash ) { 61 return; // Different page, or no fragment â let it navigate normally. 62 } 63 if ( scrollToHash( url.hash, true ) ) { 64 e.preventDefault(); 65 history.pushState( null, '', url.hash ); 66 } 67 } ); 68 69 window.addEventListener( 'load', function () { 70 if ( window.location.hash ) { 71 scrollToHash( window.location.hash, false ); 72 } 73 } ); 74} )(); 75 76/** 77 * Homepage hero photo carousel: crossfades between whichever recent 78 * post photos PHP found (see wakeup_hero_images() in functions.php). 79 * Pure CSS opacity transition â this just moves the .is-active class 80 * along at an interval. Does nothing if there's only one photo (or 81 * none), so nothing to configure when a site has little content yet. 82 */ 83( function () { 84 var photos = document.querySelectorAll( '.hero-photo' ); 85 if ( photos.length < 2 ) { 86 return; 87 } 88 var current = 0; 89 setInterval( function () { 90 photos[ current ].classList.remove( 'is-active' ); 91 current = ( current + 1 ) % photos.length; 92 photos[ current ].classList.add( 'is-active' ); 93 }, 5500 ); 94} )();
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.