1/** 2 * File navigation.js. 3 * 4 * Handles toggling the navigation menu for small screens and enables TAB key 5 * navigation support for dropdown menus. 6 */ 7( function () { 8 const html = document.documentElement; 9 const siteHeader = document.getElementById( "masthead" ); 10 const toplineNav = document.getElementById( "topline-nav" ); 11 const siteNavigation = document.getElementById( "site-navigation" ); 12 const page = document.getElementById( "page" ); 13 const splashPage = document.getElementById("splash-menu"); 14 const menuToggle = document.getElementById( "menu-toggle" ); 15 const menuClose = document.getElementById( "menu-close" ); 16 var isDesktop = true; 17 const initialScroll = window.scrollY; 18 const adminBar = document.getElementById( "wpadminbar" ); 19 const adminBarHeight = adminBar 20 ? adminBar.getBoundingClientRect().height 21 : 0; 22 const siteHeaderInitialTop = 23 siteHeader.getBoundingClientRect().top + initialScroll; 24 25 const branding = document.getElementById( "branding" ); 26 const menuBackground = document.createElement( "div" ); 27 28 menuBackground.classList.add( "menu-background" ); 29 30 const handleFixedHeader = function () { 31 const currentScroll = window.scrollY; 32 if ( currentScroll + adminBarHeight > siteHeaderInitialTop ) { 33 siteHeader.classList.add( "fixed" ); 34 } else { 35 siteHeader.classList.remove( "fixed" ); 36 } 37 }; 38 39 if ( ! siteHeader.classList.contains( "splash" ) ) { 40 window.addEventListener( "scroll", handleFixedHeader ); 41 handleFixedHeader(); 42 } 43 44 const handleWindowResize = function () { 45 const threshold = 1024; 46 47 if ( window.innerWidth < threshold ) { 48 if ( isDesktop === true && !splashPage) { //Added check for splash page since toplineNav menu does not exist on the splash page 49 siteNavigation.append( toplineNav ); 50 isDesktop = false; 51 } 52 } else { 53 if ( isDesktop === false && !splashPage ) { 54 page.insertBefore( toplineNav , siteHeader ); 55 isDesktop = true; 56 } 57 } 58 }; 59 60 window.addEventListener( "resize", handleWindowResize ); 61 handleWindowResize(); 62 63 menuToggle.addEventListener( "click", function ( e ) { 64 e.preventDefault(); 65 siteNavigation.classList.add( "on" ); 66 html.classList.add( "nav-opened" ); 67 branding.insertBefore( menuBackground, siteNavigation ); 68 } ); 69 70 menuClose.addEventListener( "click", function ( e ) { 71 e.preventDefault(); 72 siteNavigation.classList.remove( "on" ); 73 html.classList.remove( "nav-opened" ); 74 menuBackground.remove(); 75 } ); 76} )();
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.