// Clicks outside of a menu collapse any open menus
this._on( this.document, {
click: function( event ) {
- if ( !$( event.target ).closest( ".ui-menu" ).length ) {
+ if ( this._closeOnDocumentClick( event ) ) {
this.collapseAll( event );
}
.removeClass( "ui-state-active" );
},
+ _closeOnDocumentClick: function( event ) {
+ return !$( event.target ).closest( ".ui-menu" ).length;
+ },
+
collapse: function( event ) {
var newItem = this.active &&
this.active.parent().closest( ".ui-menu-item", this.element );