1/** 2 * Mobile navigation 3 * 4 * @package Icelander 5 * @copyright WebMan Design, Oliver Juhas 6 * 7 * @since 1.0.0 8 * @version 1.6.0 9 */ 10 11( function( $ ) { 12 'use strict'; 13 14 var 15 $siteNavigation = $( document.getElementById( 'site-navigation' ) ), 16 $menuToggleButton = $( '#menu-toggle, #menu-toggle-bar' ), 17 $breakpoints = ( 'undefined' !== typeof $icelanderBreakpoints ) ? ( $icelanderBreakpoints ) : ( { 'l' : 880 } ); 18 19 function mobileMenuActions() { 20 21 // Processing 22 23 if ( ! $siteNavigation.hasClass( 'is-active' ) ) { 24 $menuToggleButton 25 .attr( 'aria-expanded', 'false' ); 26 } 27 28 $siteNavigation 29 .on( 'keydown', function( e ) { 30 if ( e.which === 27 ) { 31 32 // ESC key 33 e.preventDefault(); 34 35 $siteNavigation 36 .removeClass( 'is-active' ); 37 38 $menuToggleButton 39 .attr( 'aria-expanded', 'false' ); 40 41 $menuToggleButton 42 .focus(); 43 } 44 } ); 45 46 } // /mobileMenuActions 47 48 if ( parseInt( $breakpoints['l'] ) >= window.innerWidth ) { 49 50 $siteNavigation 51 .removeClass( 'is-active' ); 52 53 mobileMenuActions(); 54 } 55 56 $menuToggleButton 57 .on( 'click', function( e ) { 58 59 e.preventDefault(); 60 61 $siteNavigation 62 .toggleClass( 'is-active' ); 63 64 if ( $siteNavigation.hasClass( 'is-active' ) ) { 65 $menuToggleButton 66 .attr( 'aria-expanded', 'true' ); 67 } else { 68 $menuToggleButton 69 .attr( 'aria-expanded', 'false' ); 70 } 71 } ); 72 73 /** 74 * Refocus to menu toggle button once the end of the menu is reached 75 */ 76 $siteNavigation 77 .on( 'focus.aria', '.menu-toggle-skip-link', function( e ) { 78 79 $menuToggleButton 80 .focus(); 81 } ); 82 83 /** 84 * Disable mobile navigation on wider screens 85 */ 86 $( window ) 87 .on( 'resize orientationchange', function( e ) { 88 if ( parseInt( $breakpoints['l'] ) < window.innerWidth ) { 89 90 // On desktops 91 $siteNavigation 92 .removeClass( 'is-active' ); 93 94 $menuToggleButton 95 .attr( 'aria-expanded', 'true' ); 96 97 } else { 98 99 // On mobiles 100 mobileMenuActions(); 101 } 102 } ); 103 104} )( jQuery );
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.