| 20 | | // Toggle buttons and submenu items with active children menu items. |
| 21 | | container.find( '.current-menu-ancestor > button' ).addClass( 'toggled-on' ); |
| | 20 | // Set the active submenu dropdown toggle button initial state. |
| | 21 | container.find( '.current-menu-ancestor > button' ) |
| | 22 | .addClass( 'toggled-on' ) |
| | 23 | .attr( 'aria-expanded', 'true' ) |
| | 24 | .find( '.screen-reader-text' ) |
| | 25 | .text( twentyseventeenScreenReaderText.collapse ); |
| | 26 | // Set the active submenu initial state. |
| 106 | | |
| 107 | | // Add the default ARIA attributes for the menu toggle and the navigations. |
| 108 | | function onResizeARIA() { |
| 109 | | if ( 'block' === $( '.menu-toggle' ).css( 'display' ) ) { |
| 110 | | |
| 111 | | if ( menuToggle.hasClass( 'toggled-on' ) ) { |
| 112 | | menuToggle.attr( 'aria-expanded', 'true' ); |
| 113 | | } else { |
| 114 | | menuToggle.attr( 'aria-expanded', 'false' ); |
| 115 | | } |
| 116 | | |
| 117 | | if ( siteNavigation.closest( '.main-navigation' ).hasClass( 'toggled-on' ) ) { |
| 118 | | siteNavigation.attr( 'aria-expanded', 'true' ); |
| 119 | | } else { |
| 120 | | siteNavigation.attr( 'aria-expanded', 'false' ); |
| 121 | | } |
| 122 | | } else { |
| 123 | | menuToggle.removeAttr( 'aria-expanded' ); |
| 124 | | siteNavigation.removeAttr( 'aria-expanded' ); |
| 125 | | menuToggle.removeAttr( 'aria-controls' ); |
| 126 | | } |
| 127 | | } |
| 128 | | |
| 129 | | $( document ).ready( function() { |
| 130 | | $( window ).on( 'load.twentyseventeen', onResizeARIA ); |
| 131 | | $( window ).on( 'resize.twentyseventeen', onResizeARIA ); |
| 132 | | }); |
| 133 | | |