]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Make check for click outside of menu a function which can be overridden. Fixes...
authorKris Borchers <kris.borchers@gmail.com>
Thu, 1 Aug 2013 01:20:13 +0000 (20:20 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 26 Nov 2013 19:48:14 +0000 (14:48 -0500)
(cherry picked from commit cceb163548eea78525a3a60ada95a5af6e3ddf25)

ui/jquery.ui.menu.js

index 93309f7f115780ebdc379dd217435f55e141eb92..8cb2f8ed2bb5c788410bb23991f82e5f9e640b24 100644 (file)
@@ -130,7 +130,7 @@ $.widget( "ui.menu", {
                // 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 );
                                }
 
@@ -497,6 +497,10 @@ $.widget( "ui.menu", {
                                .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 );