@@ -120,7 +120,7 @@ $.widget( "ui.accordion", {
120
120
121
121
if ( options . event ) {
122
122
self . headers . bind ( options . event . split ( " " ) . join ( ".accordion " ) + ".accordion" , function ( event ) {
123
- self . _clickHandler . call ( self , event , this ) ;
123
+ self . _eventHandler ( event ) ;
124
124
event . preventDefault ( ) ;
125
125
} ) ;
126
126
}
@@ -176,7 +176,7 @@ $.widget( "ui.accordion", {
176
176
$ . Widget . prototype . _setOption . apply ( this , arguments ) ;
177
177
178
178
if ( key == "active" ) {
179
- this . activate ( value ) ;
179
+ this . _activate ( value ) ;
180
180
}
181
181
if ( key == "icons" ) {
182
182
this . _destroyIcons ( ) ;
@@ -213,7 +213,7 @@ $.widget( "ui.accordion", {
213
213
break ;
214
214
case keyCode . SPACE :
215
215
case keyCode . ENTER :
216
- this . _clickHandler ( { target : event . target } , event . target ) ;
216
+ this . _eventHandler ( event ) ;
217
217
event . preventDefault ( ) ;
218
218
}
219
219
@@ -272,14 +272,11 @@ $.widget( "ui.accordion", {
272
272
return this ;
273
273
} ,
274
274
275
- activate : function ( index ) {
276
- // TODO this gets called on init, changing the option without an explicit call for that
275
+ _activate : function ( index ) {
276
+ // TODO: handle invalid values
277
277
this . options . active = index ;
278
- // call clickHandler with custom event
279
278
var active = this . _findActive ( index ) [ 0 ] ;
280
- this . _clickHandler ( { target : active } , active ) ;
281
-
282
- return this ;
279
+ this . _eventHandler ( { target : active , currentTarget : active } ) ;
283
280
} ,
284
281
285
282
_findActive : function ( selector ) {
@@ -292,8 +289,7 @@ $.widget( "ui.accordion", {
292
289
: this . headers . filter ( ":eq(0)" ) ;
293
290
} ,
294
291
295
- // TODO isn't event.target enough? why the separate target argument?
296
- _clickHandler : function ( event , target ) {
292
+ _eventHandler : function ( event ) {
297
293
var options = this . options ;
298
294
if ( options . disabled ) {
299
295
return ;
@@ -325,7 +321,7 @@ $.widget( "ui.accordion", {
325
321
}
326
322
327
323
// get the click target
328
- var clicked = $ ( event . currentTarget || target ) ,
324
+ var clicked = $ ( event . currentTarget ) ,
329
325
clickedIsActive = clicked [ 0 ] === this . active [ 0 ] ;
330
326
331
327
// TODO the option is changed, is that correct?
@@ -683,4 +679,7 @@ $.extend( $.ui.accordion, {
683
679
} ;
684
680
} ( jQuery , jQuery . ui . accordion . prototype ) ) ;
685
681
682
+ // activate method
683
+ jQuery . ui . accordion . prototype . activate = jQuery . ui . accordion . prototype . _activate ;
684
+
686
685
} ) ( jQuery ) ;
0 commit comments