Skip to content
Permalink
Browse files

Button: Don't react to keydown when disabled.

Partial fix for #5328 - button disabled only visually when disabled option set, still functional.
  • Loading branch information...
scottgonzalez committed Mar 14, 2010
1 parent c75abc5 commit 385269e3eae74ad18fa35ea77229a5555baf1884
Showing with 8 additions and 6 deletions.
  1. +8 −6 ui/jquery.ui.button.js
@@ -101,15 +101,15 @@ $.widget( "ui.button", {
});
}

if ( this.type === "checkbox") {
if ( this.type === "checkbox" ) {
this.buttonElement.bind( "click.button", function() {
if ( options.disabled ) {
return;
}
$( this ).toggleClass( "ui-state-active" );
self.buttonElement.attr( "aria-pressed", self.element[0].checked );
});
} else if ( this.type === "radio") {
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click.button", function() {
if ( options.disabled ) {
return;
@@ -145,7 +145,10 @@ $.widget( "ui.button", {
$( this ).removeClass( "ui-state-active" );
})
.bind( "keydown.button", function(event) {
if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
if ( options.disabled ) {
return;
}
if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
$( this ).addClass( "ui-state-active" );
}
})
@@ -166,8 +169,7 @@ $.widget( "ui.button", {
// TODO: pull out $.Widget's handling for the disabled option into
// $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
// be overridden by individual plugins
$.Widget.prototype._setOption.call( this, "disabled", options.disabled );
this._resetButton();
this._setOption( "disabled", options.disabled );
},

_determineButtonType: function() {
@@ -326,4 +328,4 @@ $.widget( "ui.buttonset", {
}
});

}( jQuery ));
}( jQuery ) );

0 comments on commit 385269e

Please sign in to comment.
You can’t perform that action at this time.