diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2010-01-20 17:44:54 +0000 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2010-01-20 17:44:54 +0000 |
commit | dab6e943b3dc8ee7c9832ef7d06daf45ec39c4b0 (patch) | |
tree | 7be23995a0a5239d693f158145efed093cb93b7d /ui | |
parent | d01e785c988b25d584e8d2bf17cf3f1a699e263c (diff) | |
download | jquery-ui-dab6e943b3dc8ee7c9832ef7d06daf45ec39c4b0.tar.gz jquery-ui-dab6e943b3dc8ee7c9832ef7d06daf45ec39c4b0.zip |
button: add ui-state-focus on focus, making keyboard navigation possible, and button like 200% more accessible
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.button.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 451602ecc..b2ae0f9df 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -34,7 +34,8 @@ $.widget( "ui.button", { var self = this, options = this.options, toggleButton = this.type === "checkbox" || this.type === "radio", - hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ); + hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ), + focusClass = "ui-state-focus"; if ( options.label === null ) { options.label = this.buttonElement.html(); @@ -57,6 +58,13 @@ $.widget( "ui.button", { return; } $( this ).removeClass( hoverClass ); + }) + .bind( "focus.button", function() { + // no need to check disabled, focus won't be triggered anyway + $( this ).addClass( focusClass ); + }) + .bind( "blur.button", function() { + $( this ).removeClass( focusClass ); }); if ( this.type === "checkbox") { |