]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Fix line length issues
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 31 Mar 2016 03:02:12 +0000 (23:02 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 13 Apr 2016 15:31:47 +0000 (11:31 -0400)
Ref gh-1690

ui/widgets/menu.js

index 22db41988ec8a28cf0f4c4cf4abad875799ab665..329bfc6101452409dee28bdb19e913366a1a4afa 100644 (file)
@@ -81,6 +81,7 @@ return $.widget( "ui.menu", {
                        },
                        "click .ui-menu-item": function( event ) {
                                var target = $( event.target );
+                               var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
                                if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
                                        this.select( event );
 
@@ -89,10 +90,13 @@ return $.widget( "ui.menu", {
                                                this.mouseHandled = true;
                                        }
 
+
+
                                        // Open submenu on click
                                        if ( target.has( ".ui-menu" ).length ) {
                                                this.expand( event );
-                                       } else if ( !this.element.is( ":focus" ) && $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( ".ui-menu" ).length ) {
+                                       } else if ( !this.element.is( ":focus" ) &&
+                                                       active.closest( ".ui-menu" ).length ) {
 
                                                // Redirect focus to the menu
                                                this.element.trigger( "focus", [ true ] );
@@ -142,7 +146,11 @@ return $.widget( "ui.menu", {
                        },
                        blur: function( event ) {
                                this._delay( function() {
-                                       if ( !$.contains( this.element[ 0 ], $.ui.safeActiveElement( this.document[ 0 ] ) ) ) {
+                                       var notContained = !$.contains(
+                                               this.element[ 0 ],
+                                               $.ui.safeActiveElement( this.document[ 0 ] )
+                                       );
+                                       if ( notContained ) {
                                                this.collapseAll( event );
                                        }
                                } );
@@ -479,7 +487,8 @@ return $.widget( "ui.menu", {
                        var currentMenu = all ? this.element :
                                $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
 
-                       // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
+                       // If we found no valid submenu ancestor, use the main menu to close all
+                       // sub menus anyway
                        if ( !currentMenu.length ) {
                                currentMenu = this.element;
                        }