@@ -415,3 +415,72 @@ function performInstall() {
415415 // Trigger the itms-services install
416416 window . location . href = link ;
417417}
418+
419+
420+
421+ // SIDEBAR TOGGLE \\
422+ ( function ( ) {
423+ const body = document . body ;
424+ const hamburger = document . querySelector ( '.hamburger' ) ;
425+ if ( ! hamburger ) return ;
426+ // create overlay node (used on mobile)
427+ let overlay = document . querySelector ( '.sidebar-overlay' ) ;
428+ if ( ! overlay ) {
429+ overlay = document . createElement ( 'div' ) ;
430+ overlay . className = 'sidebar-overlay' ;
431+ document . body . appendChild ( overlay ) ;
432+ }
433+
434+ function openSidebar ( ) {
435+ body . classList . add ( 'sidebar-open' ) ;
436+ hamburger . setAttribute ( 'aria-expanded' , 'true' ) ;
437+ // trap focus simple-ish - set focus to first sidebar item
438+ const firstItem = document . querySelector ( '.sidebar .sidebar-item' ) ;
439+ if ( firstItem ) firstItem . focus ( ) ;
440+ }
441+ function closeSidebar ( ) {
442+ body . classList . remove ( 'sidebar-open' ) ;
443+ hamburger . setAttribute ( 'aria-expanded' , 'false' ) ;
444+ hamburger . focus ( ) ;
445+ }
446+ function toggleSidebar ( ) {
447+ if ( body . classList . contains ( 'sidebar-open' ) ) closeSidebar ( ) ;
448+ else openSidebar ( ) ;
449+ }
450+
451+ hamburger . addEventListener ( 'click' , function ( e ) {
452+ e . stopPropagation ( ) ;
453+ toggleSidebar ( ) ;
454+ } ) ;
455+
456+ overlay . addEventListener ( 'click' , function ( ) {
457+ closeSidebar ( ) ;
458+ } ) ;
459+
460+ // close on escape
461+ document . addEventListener ( 'keydown' , function ( e ) {
462+ if ( e . key === 'Escape' && body . classList . contains ( 'sidebar-open' ) ) {
463+ closeSidebar ( ) ;
464+ }
465+ } ) ;
466+
467+ // If a sidebar item is clicked on mobile, auto-close (and navigate)
468+ document . addEventListener ( 'click' , function ( e ) {
469+ const item = e . target . closest ( '.sidebar-item' ) ;
470+ if ( ! item ) return ;
471+ // only auto-close on small screens (avoid closing on desktop)
472+ if ( window . innerWidth <= 860 ) {
473+ // Slight delay to allow navigation/href to trigger
474+ setTimeout ( closeSidebar , 160 ) ;
475+ }
476+ } ) ;
477+
478+ // ensure state updates on resize (e.g., when rotating device)
479+ window . addEventListener ( 'resize' , function ( ) {
480+ if ( window . innerWidth > 860 ) {
481+ // ensure sidebar visible on desktop
482+ body . classList . remove ( 'sidebar-open' ) ;
483+ hamburger . setAttribute ( 'aria-expanded' , 'false' ) ;
484+ }
485+ } ) ;
486+ } ) ( ) ;
0 commit comments