diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-03-07 20:00:02 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-03-07 20:00:02 +0100 |
commit | 17db755a4f04dfc7b0be8d9a5c290cc5bc48e08e (patch) | |
tree | 485db265e3f6ab29038655e1f6379949d613eebf /ui | |
parent | c7cf13f5ed42823fc52eae6f6376438af8467a00 (diff) | |
download | jquery-ui-17db755a4f04dfc7b0be8d9a5c290cc5bc48e08e.tar.gz jquery-ui-17db755a4f04dfc7b0be8d9a5c290cc5bc48e08e.zip |
Accordion: Use _bind for event option. Refactor other _bind call to go into _setupEvents as well, simplifying unbinding a lot. Also add missing semicolon
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.accordion.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index e3e09c9f4..1920063c4 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -42,9 +42,6 @@ $.widget( "ui.accordion", { .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" ); this._hoverable( this.headers ); this._focusable( this.headers ); - this._bind( this.headers, { - keydown: "_keydown" - }); this.headers.next() .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ); @@ -59,7 +56,7 @@ $.widget( "ui.accordion", { } this.active = this._findActive( options.active ) .addClass( "ui-accordion-header-active ui-state-active" ) - .toggleClass( "ui-corner-all ui-corner-top" ) + .toggleClass( "ui-corner-all ui-corner-top" ); this.active.next().addClass( "ui-accordion-content-active" ); this._createIcons(); @@ -162,7 +159,7 @@ $.widget( "ui.accordion", { if ( key === "event" ) { if ( this.options.event ) { - this.headers.unbind( this.options.event.split( " " ).join( ".accordion " ) + ".accordion", this._eventHandler ); + this.headers.unbind( ".accordion" ); } this._setupEvents( value ); } @@ -301,11 +298,15 @@ $.widget( "ui.accordion", { }, _setupEvents: function( event ) { + var events = { + keydown: "_keydown" + }; if ( event ) { - // TODO: use _bind() - this.headers.bind( event.split( " " ).join( ".accordion " ) + ".accordion", - $.proxy( this, "_eventHandler" ) ); + $.each( event.split(" "), function( index, eventName ) { + events[ eventName ] = "_eventHandler"; + }); } + this._bind( this.headers, events ); }, _eventHandler: function( event ) { @@ -325,7 +326,7 @@ $.widget( "ui.accordion", { event.preventDefault(); - if ( options.disabled || + if ( // click on active header, but not collapsible ( clickedIsActive && !options.collapsible ) || // allow canceling activation |