/** * fsm/classic-menu — mobile hamburger toggle. * * The classic menu output doesn't include the wp-block-navigation * responsive container, so we wire our own tiny toggle: click the * hamburger to open/close the panel, Escape to dismiss. Pure * progressive enhancement — without JS, the panel stays visible * (CSS handles the desktop-default-visible state). */ ( function () { 'use strict'; function init( root ) { var toggle = root.querySelector( '[data-fsm-classic-menu-toggle]' ); var panel = root.querySelector( '[data-fsm-classic-menu-panel]' ); if ( ! toggle || ! panel ) { return; } // Default to closed on init. CSS shows the panel on desktop // regardless of this attribute; aria-hidden only carries meaning // once the toggle is visible (mobile). panel.setAttribute( 'aria-hidden', 'true' ); toggle.addEventListener( 'click', function ( e ) { e.preventDefault(); var isOpen = root.classList.toggle( 'is-open' ); toggle.setAttribute( 'aria-expanded', isOpen ? 'true' : 'false' ); panel.setAttribute( 'aria-hidden', isOpen ? 'false' : 'true' ); } ); // Escape closes the menu and restores focus to the toggle. document.addEventListener( 'keydown', function ( e ) { if ( e.key === 'Escape' && root.classList.contains( 'is-open' ) ) { root.classList.remove( 'is-open' ); toggle.setAttribute( 'aria-expanded', 'false' ); panel.setAttribute( 'aria-hidden', 'true' ); toggle.focus(); } } ); // Click outside the menu closes it. document.addEventListener( 'click', function ( e ) { if ( ! root.classList.contains( 'is-open' ) ) { return; } if ( root.contains( e.target ) ) { return; } root.classList.remove( 'is-open' ); toggle.setAttribute( 'aria-expanded', 'false' ); panel.setAttribute( 'aria-hidden', 'true' ); } ); } function boot() { document.querySelectorAll( '[data-fsm-classic-menu]' ).forEach( init ); } if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', boot ); } else { boot(); } }() ); ; /** * FSM submission-form anti-spam — browser proof-of-life. * * Fills the two fields `spam_gate()` layer 4 checks: * fsm_js — set to "1" the first time the visitor actually touches * the form. A headless client that fetches the page but * never interacts leaves it empty. * fsm_elapsed — ms between the form being ready and submit, so an * instant POST is distinguishable from a human filling * out a dozen fields. * * These are the cache-independent signals: the server's signed timestamp * reflects VIP page-cache time, not the visitor's page load, so it can't * carry the dwell check on its own. * * Shared by the event and club submission forms — one file rather than a * per-block view.js each, so the two endpoints can't drift apart. * * Vanilla JS, no build step, per the project convention. */ ( function () { 'use strict'; function arm( form ) { var jsField = form.querySelector( 'input[name="fsm_js"]' ); var elapsedField = form.querySelector( 'input[name="fsm_elapsed"]' ); if ( ! jsField || ! elapsedField ) { return; } var readyAt = Date.now(); function mark() { jsField.value = '1'; } [ 'focusin', 'input', 'change', 'pointerdown', 'keydown' ].forEach( function ( evt ) { form.addEventListener( evt, mark, { once: true, passive: true } ); } ); form.addEventListener( 'submit', function () { elapsedField.value = String( Date.now() - readyAt ); } ); } function boot() { var forms = document.querySelectorAll( '.fsm-event-form__form' ); Array.prototype.forEach.call( forms, arm ); } if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', boot ); } else { boot(); } }() ); ;