diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-01-11 20:53:31 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-01-11 20:53:31 -0500 |
commit | 8b23483c0b03369dbfc9720e2aff8de690a3b854 (patch) | |
tree | 3681d9e166ea46ba79b72f66117b76f7bac0bc59 /ui/jquery.ui.accordion.js | |
parent | b6ed9328ef5254cae18c6f96bdd467c195f1e2fa (diff) | |
download | jquery-ui-8b23483c0b03369dbfc9720e2aff8de690a3b854.tar.gz jquery-ui-8b23483c0b03369dbfc9720e2aff8de690a3b854.zip |
Accordion: First pass at deprecating the activate method. Renamed _clickHandler to _eventHandler and removed extraneous parameter. Updated all tests to use the option methods instead of the activate method.
Diffstat (limited to 'ui/jquery.ui.accordion.js')
-rw-r--r-- | ui/jquery.ui.accordion.js | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index f7d0e27b2..e58c5d621 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -120,7 +120,7 @@ $.widget( "ui.accordion", { if ( options.event ) { self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) { - self._clickHandler.call( self, event, this ); + self._eventHandler( event ); event.preventDefault(); }); } @@ -176,7 +176,7 @@ $.widget( "ui.accordion", { $.Widget.prototype._setOption.apply( this, arguments ); if ( key == "active" ) { - this.activate( value ); + this._activate( value ); } if ( key == "icons" ) { this._destroyIcons(); @@ -213,7 +213,7 @@ $.widget( "ui.accordion", { break; case keyCode.SPACE: case keyCode.ENTER: - this._clickHandler( { target: event.target }, event.target ); + this._eventHandler( event ); event.preventDefault(); } @@ -272,14 +272,11 @@ $.widget( "ui.accordion", { return this; }, - activate: function( index ) { - // TODO this gets called on init, changing the option without an explicit call for that + _activate: function( index ) { + // TODO: handle invalid values this.options.active = index; - // call clickHandler with custom event var active = this._findActive( index )[ 0 ]; - this._clickHandler( { target: active }, active ); - - return this; + this._eventHandler( { target: active, currentTarget: active } ); }, _findActive: function( selector ) { @@ -292,8 +289,7 @@ $.widget( "ui.accordion", { : this.headers.filter( ":eq(0)" ); }, - // TODO isn't event.target enough? why the separate target argument? - _clickHandler: function( event, target ) { + _eventHandler: function( event ) { var options = this.options; if ( options.disabled ) { return; @@ -325,7 +321,7 @@ $.widget( "ui.accordion", { } // get the click target - var clicked = $( event.currentTarget || target ), + var clicked = $( event.currentTarget ), clickedIsActive = clicked[0] === this.active[0]; // TODO the option is changed, is that correct? @@ -683,4 +679,7 @@ $.extend( $.ui.accordion, { }; }( jQuery, jQuery.ui.accordion.prototype ) ); +// activate method +jQuery.ui.accordion.prototype.activate = jQuery.ui.accordion.prototype._activate; + })( jQuery ); |