mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
button: add ui-state-focus on focus, making keyboard navigation possible, and button like 200% more accessible
This commit is contained in:
parent
d01e785c98
commit
dab6e943b3
10
ui/jquery.ui.button.js
vendored
10
ui/jquery.ui.button.js
vendored
@ -34,7 +34,8 @@ $.widget( "ui.button", {
|
|||||||
var self = this,
|
var self = this,
|
||||||
options = this.options,
|
options = this.options,
|
||||||
toggleButton = this.type === "checkbox" || this.type === "radio",
|
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 ) {
|
if ( options.label === null ) {
|
||||||
options.label = this.buttonElement.html();
|
options.label = this.buttonElement.html();
|
||||||
@ -57,6 +58,13 @@ $.widget( "ui.button", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$( this ).removeClass( hoverClass );
|
$( 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") {
|
if ( this.type === "checkbox") {
|
||||||
|
Loading…
Reference in New Issue
Block a user