@@ -130,6 +130,8 @@ $.Widget.prototype = {
130
130
options ) ;
131
131
132
132
this . bindings = $ ( ) ;
133
+ this . hoverable = $ ( ) ;
134
+ this . focusable = $ ( ) ;
133
135
this . _bind ( { remove : "destroy" } ) ;
134
136
135
137
this . _create ( ) ;
@@ -151,6 +153,8 @@ $.Widget.prototype = {
151
153
152
154
destroy : function ( ) {
153
155
this . _destroy ( ) ;
156
+ // we can probably remove the unbind calls in 2.0
157
+ // all event bindings should go through this._bind()
154
158
this . element
155
159
. unbind ( "." + this . widgetName )
156
160
. removeData ( this . widgetName ) ;
@@ -160,7 +164,11 @@ $.Widget.prototype = {
160
164
. removeClass (
161
165
this . widgetBaseClass + "-disabled " +
162
166
"ui-state-disabled" ) ;
167
+
168
+ // clean up events and states
163
169
this . bindings . unbind ( "." + this . widgetName ) ;
170
+ this . hoverable . removeClass ( "ui-state-hover" ) ;
171
+ this . focusable . removeClass ( "ui-state-focus" ) ;
164
172
} ,
165
173
_destroy : $ . noop ,
166
174
@@ -203,6 +211,8 @@ $.Widget.prototype = {
203
211
this . widget ( )
204
212
. toggleClass ( this . widgetBaseClass + "-disabled ui-state-disabled" , ! ! value )
205
213
. attr ( "aria-disabled" , value ) ;
214
+ this . hoverable . removeClass ( "ui-state-hover" ) ;
215
+ this . focusable . removeClass ( "ui-state-focus" ) ;
206
216
}
207
217
208
218
return this ;
@@ -235,6 +245,30 @@ $.Widget.prototype = {
235
245
} ) ;
236
246
} ,
237
247
248
+ _hoverable : function ( element ) {
249
+ this . hoverable = this . hoverable . add ( element ) ;
250
+ this . _bind ( element , {
251
+ mouseenter : function ( event ) {
252
+ $ ( event . currentTarget ) . addClass ( "ui-state-hover" ) ;
253
+ } ,
254
+ mouseleave : function ( event ) {
255
+ $ ( event . currentTarget ) . removeClass ( "ui-state-hover" ) ;
256
+ }
257
+ } ) ;
258
+ } ,
259
+
260
+ _focusable : function ( element ) {
261
+ this . focusable = this . focusable . add ( element ) ;
262
+ this . _bind ( element , {
263
+ focus : function ( event ) {
264
+ $ ( event . currentTarget ) . addClass ( "ui-state-focus" ) ;
265
+ } ,
266
+ blur : function ( event ) {
267
+ $ ( event . currentTarget ) . removeClass ( "ui-state-focus" ) ;
268
+ }
269
+ } ) ;
270
+ } ,
271
+
238
272
_trigger : function ( type , event , data ) {
239
273
var callback = this . options [ type ] ;
240
274
0 commit comments