1/** 2 * File primary-navigation.js. 3 * 4 * This files only gets added to themes that support the mobile nav on side 5 */ 6( function() { 7 8 /** 9 * Menu Toggle Behaviors 10 * 11 * @param {Element} element 12 */ 13 var navMenu = function ( buttonId, inputId ) { 14 var wrapper = document.body; 15 16 var toggleButton = document.getElementById( buttonId ); 17 var toggleInput = document.getElementById( inputId ); 18 19 if ( toggleButton ) { 20 toggleButton.onclick = function() { 21 if ( true == toggleInput.checked ) { 22 wrapper.classList.remove( 'lock-scrolling' ); 23 } else { 24 wrapper.classList.add( 'lock-scrolling' ); 25 } 26 27 toggleButton.focus(); 28 } 29 } 30 31 document.addEventListener( 'click', function( event ) { 32 // If target onclick is <a> with # within the href attribute 33 if ( event.target.hash && event.target.hash.includes( '#' ) ) { 34 wrapper.classList.remove( 'lock-scrolling' ); 35 if (toggleInput) { 36 toggleInput.checked = false; 37 } 38 // Wait 550 and scroll to the anchor. 39 setTimeout(function () { 40 var anchor = document.getElementById(event.target.hash.slice(1)); 41 anchor.scrollIntoView(); 42 }, 550); 43 } 44 } ); 45 } 46 47 window.addEventListener( 'load', function() { 48 navMenu( 'toggle-menu', 'toggle' ); 49 navMenu( 'toggle-cart', 'woocommerce-toggle' ); 50 } ); 51} )();
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.