]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: use _hoverable for hover state management. Fixes #5295 - button doesn't remov...
authorCory Gackenheimer <cory.gack@gmail.com>
Sun, 1 Jan 2012 16:44:22 +0000 (11:44 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 13 Nov 2012 16:06:55 +0000 (11:06 -0500)
(cherry picked from commit 8e1ceba717b85e42a13cc1660e7c8e9e9c26c384)

tests/unit/button/button_tickets.js
ui/jquery.ui.button.js

index eb70181ec0573d7a9447ffb8a520340032bb1735..1e901f9d10c2adca304cf2f4948fd875ea1edcd9 100644 (file)
@@ -5,6 +5,17 @@
 
 module( "button: tickets" );
 
+test( "#5295 - button does not remove hoverstate if disabled" , function() {
+       expect( 1 );
+       var btn = $("#button").button();
+       btn.hover( function() {
+               btn.button( "disable" );
+       });
+       btn.trigger( "mouseenter" );
+       btn.trigger( "mouseleave" );
+       ok( !btn.is( ".ui-state-hover") );
+});
+
 test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
        expect( 2 );
        $( "#radio01" ).next().andSelf().hide();
index f253464df6a7acae2f4e20cb54acbc5ccb2cc270..6363bcdcb182aaaeec3cf78d14c83197e1e90cf5 100644 (file)
@@ -70,13 +70,15 @@ $.widget( "ui.button", {
                var that = this,
                        options = this.options,
                        toggleButton = this.type === "checkbox" || this.type === "radio",
-                       hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
+                       activeClass = !toggleButton ? "ui-state-active" : "",
                        focusClass = "ui-state-focus";
 
                if ( options.label === null ) {
                        options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
                }
 
+               this._hoverable( this.buttonElement );
+
                this.buttonElement
                        .addClass( baseClasses )
                        .attr( "role", "button" )
@@ -84,7 +86,6 @@ $.widget( "ui.button", {
                                if ( options.disabled ) {
                                        return;
                                }
-                               $( this ).addClass( "ui-state-hover" );
                                if ( this === lastActive ) {
                                        $( this ).addClass( "ui-state-active" );
                                }
@@ -93,7 +94,7 @@ $.widget( "ui.button", {
                                if ( options.disabled ) {
                                        return;
                                }
-                               $( this ).removeClass( hoverClass );
+                               $( this ).removeClass( activeClass );
                        })
                        .bind( "click" + this.eventNamespace, function( event ) {
                                if ( options.disabled ) {