16
16
17
17
var lastActive , startXPos , startYPos , clickDragged ,
18
18
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all" ,
19
- stateClasses = "ui-state-hover ui-state-active " ,
20
19
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" ,
21
20
formResetHandler = function ( ) {
22
21
var form = $ ( this ) ;
@@ -71,8 +70,7 @@ $.widget( "ui.button", {
71
70
var that = this ,
72
71
options = this . options ,
73
72
toggleButton = this . type === "checkbox" || this . type === "radio" ,
74
- activeClass = ! toggleButton ? "ui-state-active" : "" ,
75
- focusClass = "ui-state-focus" ;
73
+ activeClass = ! toggleButton ? "ui-state-active" : "" ;
76
74
77
75
if ( options . label === null ) {
78
76
options . label = ( this . type === "input" ? this . buttonElement . val ( ) : this . buttonElement . html ( ) ) ;
@@ -104,14 +102,16 @@ $.widget( "ui.button", {
104
102
}
105
103
} ) ;
106
104
107
- this . element
108
- . bind ( "focus" + this . eventNamespace , function ( ) {
109
- // no need to check disabled, focus won't be triggered anyway
110
- that . buttonElement . addClass ( focusClass ) ;
111
- } )
112
- . bind ( "blur" + this . eventNamespace , function ( ) {
113
- that . buttonElement . removeClass ( focusClass ) ;
114
- } ) ;
105
+ // Can't use _focusable() because the element that receives focus
106
+ // and the element that gets the ui-state-focus class are different
107
+ this . _on ( {
108
+ focus : function ( ) {
109
+ this . buttonElement . addClass ( "ui-state-focus" ) ;
110
+ } ,
111
+ blur : function ( ) {
112
+ this . buttonElement . removeClass ( "ui-state-focus" ) ;
113
+ }
114
+ } ) ;
115
115
116
116
if ( toggleButton ) {
117
117
this . element . bind ( "change" + this . eventNamespace , function ( ) {
@@ -257,7 +257,7 @@ $.widget( "ui.button", {
257
257
this . element
258
258
. removeClass ( "ui-helper-hidden-accessible" ) ;
259
259
this . buttonElement
260
- . removeClass ( baseClasses + " " + stateClasses + " " + typeClasses )
260
+ . removeClass ( baseClasses + " ui-state-active " + typeClasses )
261
261
. removeAttr ( "role" )
262
262
. removeAttr ( "aria-pressed" )
263
263
. html ( this . buttonElement . find ( ".ui-button-text" ) . html ( ) ) ;
@@ -272,6 +272,9 @@ $.widget( "ui.button", {
272
272
if ( key === "disabled" ) {
273
273
this . widget ( ) . toggleClass ( "ui-state-disabled" , ! ! value ) ;
274
274
this . element . prop ( "disabled" , ! ! value ) ;
275
+ if ( value ) {
276
+ this . buttonElement . removeClass ( "ui-state-focus" ) ;
277
+ }
275
278
return ;
276
279
}
277
280
this . _resetButton ( ) ;
0 commit comments