| 1705 | // Close sidebar when focus moves outside of toggle and sidebar. |
| 1706 | $( '#wp-admin-bar-menu-toggle, #adminmenumain' ).on( 'focusout', function( e ) { |
| 1707 | var focusIsInToggle, focusIsInSidebar; |
| 1708 | |
| 1709 | if ( ! $wpwrap.hasClass( 'wp-responsive-open' ) || ! document.hasFocus() ) { |
| 1710 | return; |
| 1711 | } |
| 1712 | // A brief delay is required to allow focus to switch to another element. |
| 1713 | setTimeout( function() { |
| 1714 | focusIsInToggle = $.contains( $( '#wp-admin-bar-menu-toggle' )[0], $( ':focus' )[0] ); |
| 1715 | focusIsInSidebar = $.contains( $( '#adminmenumain' )[0], $( ':focus' )[0] ); |
| 1716 | |
| 1717 | if ( ! focusIsInToggle && ! focusIsInSidebar ) { |
| 1718 | $( '#wp-admin-bar-menu-toggle' ).trigger( 'click.wp-responsive' ); |
| 1719 | } |
| 1720 | }, 10 ); |
| 1721 | } ); |
| 1722 | |
| 1723 | |