1 2export function primaryMenu() { 3 const listItems = document.querySelectorAll( '.menu-item-has-children' ); 4 5 if ( 0 < listItems.length ) { 6 listItems.forEach( item => { 7 item.firstChild.setAttribute( 'tabindex', 0 ); 8 item.addEventListener( 'keypress', setActiveClass ); 9 item.addEventListener( 'mouseover', hideSubMenu ); 10 }); 11 } 12} 13 14export function hideSubMenu() { 15 if ( null != document.querySelector( '.menu-item-has-children.menu-item-keypress' ) ) { 16 document.querySelector( '.menu-item-has-children.menu-item-keypress' ).classList.remove( 'menu-item-keypress' ); 17 } 18} 19 20let tgl = false; 21export function toggle( item ) { 22 true === item ? item = false : item = true; 23 return item; 24} 25 26export function setActiveClass( event ) { 27 if ( 32 == event.keyCode ) { 28 event.preventDefault(); 29 hideSubMenu(); 30 31 if ( ! tgl ) { 32 this.classList.add( 'menu-item-keypress' ); 33 } 34 tgl = toggle( tgl ); 35 } 36} 37 38export function megaMenu( ) { 39 const megaListItems = document.querySelectorAll( '.menu-item--hide-default' ); 40 if ( 0 < megaListItems.length ) { 41 42 megaListItems.forEach( item => { 43 item.addEventListener( 'keypress', showMegaMenu ); 44 }); 45 } 46} 47 48export function showMegaMenu( event ) { 49 if ( 32 == event.keyCode ) { 50 event.preventDefault(); 51 this.firstChild.click(); 52 this.classList.remove( 'menu-item-keypress' ); 53 } 54} 55 56jQuery( document ).ready( function( ) { 57 megaMenu(); 58}); 59primaryMenu(); 60
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.