diff options
author | Scott González <scott.gonzalez@gmail.com> | 2013-04-11 14:03:51 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2013-04-11 14:03:51 -0400 |
commit | 0d0b05ec7cf702b8782b19c993eeb30398a090f4 (patch) | |
tree | c06124bf3ec7c490346f329df3bf700d80e2d4e6 /ui | |
parent | 2de31fdbf498a6c20d196a96d007ea0f069644c5 (diff) | |
download | jquery-ui-0d0b05ec7cf702b8782b19c993eeb30398a090f4.tar.gz jquery-ui-0d0b05ec7cf702b8782b19c993eeb30398a090f4.zip |
Button: Remove ui-state-focus class when becoming disabled. Fixes #9169 - Button: Disabled button maintains ui-state-focus in IE & Firefox on Windows.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.button.js | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index dd6892275..ae3b86ae9 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -16,7 +16,6 @@ var lastActive, startXPos, startYPos, clickDragged, baseClasses = "ui-button ui-widget ui-state-default ui-corner-all", - stateClasses = "ui-state-hover ui-state-active ", typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", formResetHandler = function() { var form = $( this ); @@ -71,8 +70,7 @@ $.widget( "ui.button", { var that = this, options = this.options, toggleButton = this.type === "checkbox" || this.type === "radio", - activeClass = !toggleButton ? "ui-state-active" : "", - focusClass = "ui-state-focus"; + activeClass = !toggleButton ? "ui-state-active" : ""; if ( options.label === null ) { options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html()); @@ -104,14 +102,16 @@ $.widget( "ui.button", { } }); - this.element - .bind( "focus" + this.eventNamespace, function() { - // no need to check disabled, focus won't be triggered anyway - that.buttonElement.addClass( focusClass ); - }) - .bind( "blur" + this.eventNamespace, function() { - that.buttonElement.removeClass( focusClass ); - }); + // Can't use _focusable() because the element that receives focus + // and the element that gets the ui-state-focus class are different + this._on({ + focus: function() { + this.buttonElement.addClass( "ui-state-focus" ); + }, + blur: function() { + this.buttonElement.removeClass( "ui-state-focus" ); + } + }); if ( toggleButton ) { this.element.bind( "change" + this.eventNamespace, function() { @@ -257,7 +257,7 @@ $.widget( "ui.button", { this.element .removeClass( "ui-helper-hidden-accessible" ); this.buttonElement - .removeClass( baseClasses + " " + stateClasses + " " + typeClasses ) + .removeClass( baseClasses + " ui-state-active " + typeClasses ) .removeAttr( "role" ) .removeAttr( "aria-pressed" ) .html( this.buttonElement.find(".ui-button-text").html() ); @@ -272,6 +272,9 @@ $.widget( "ui.button", { if ( key === "disabled" ) { this.widget().toggleClass( "ui-state-disabled", !!value ); this.element.prop( "disabled", !!value ); + if ( value ) { + this.buttonElement.removeClass( "ui-state-focus" ); + } return; } this._resetButton(); |