| 253 | // Handle the `aria-haspopup` attribute on the current menu item when it has a sub-menu. |
| 254 | function currentMenuItemHasPopup() { |
| 255 | var respWidth, |
| 256 | $body = $( document.body ), |
| 257 | $current = $( 'a.wp-has-current-submenu' ); |
| 258 | |
| 259 | if ( window.innerWidth ) { |
| 260 | respWidth = Math.max( window.innerWidth, document.documentElement.clientWidth ); |
| 261 | } else { |
| 262 | respWidth = 961; |
| 263 | } |
| 264 | |
| 265 | if ( $body.hasClass( 'folded' ) || ( $body.hasClass( 'auto-fold' ) && respWidth && respWidth <= 960 && respWidth > 782 ) ) { |
| 266 | // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu. |
| 267 | $current.attr( 'aria-haspopup', 'true' ); |
| 268 | } else { |
| 269 | // When expanded or in responsive view, reset aria-haspopup. |
| 270 | $current.attr( 'aria-haspopup', 'false' ); |
| 271 | } |
| 272 | }; |
| 273 | |
| 274 | $document.on( 'wp-window-resized wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup ); |
| 275 | |