]> source.dussan.org Git - jquery-ui.git/commitdiff
Accordion: First pass at deprecating the activate method. Renamed _clickHandler to...
authorScott González <scott.gonzalez@gmail.com>
Wed, 12 Jan 2011 01:53:31 +0000 (20:53 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 12 Jan 2011 01:53:31 +0000 (20:53 -0500)
tests/unit/accordion/accordion_core.js
tests/unit/accordion/accordion_events.js
tests/unit/accordion/accordion_methods.js
tests/unit/accordion/accordion_options.js
ui/jquery.ui.accordion.js

index 640427e2ec1331d168de568d58c365eb35179b64..40a711abff14c2f7ed9ec8584611670a53cc5247 100644 (file)
@@ -22,7 +22,7 @@ test("ui-accordion-heading class added to headers anchor", function() {
 
 test("accessibility", function () {
        expect(9);
-       var ac = $('#list1').accordion().accordion("activate", 1);
+       var ac = $('#list1').accordion().accordion("option", "active", 1);
        var headers = $(".ui-accordion-header");
 
        equals( headers.eq(1).attr("tabindex"), "0", "active header should have tabindex=0");
@@ -32,7 +32,7 @@ test("accessibility", function () {
        equals( headers.next().attr("role"), "tabpanel", "tabpanel roles");
        equals( headers.eq(1).attr("aria-expanded"), "true", "active tab has aria-expanded");
        equals( headers.eq(0).attr("aria-expanded"), "false", "inactive tab has aria-expanded");
-       ac.accordion("activate", 0);
+       ac.accordion("option", "active", 0);
        equals( headers.eq(0).attr("aria-expanded"), "true", "newly active tab has aria-expanded");
        equals( headers.eq(1).attr("aria-expanded"), "false", "newly inactive tab has aria-expanded");
 });
index e9e14996ce384dc02d6399078df939d20a563eb6..5793e46d012d870b59d2e86cc33257d17d6732c0 100644 (file)
@@ -17,14 +17,14 @@ test("accordionchange event, open closed and close again", function() {
                equals( ui.newHeader.size(), 1 );
                equals( ui.newContent.size(), 1 );
        })
-       .accordion("activate", 0)
+       .accordion("option", "active", 0)
        .one("accordionchange", function(event, ui) {
                equals( ui.oldHeader.size(), 1 );
                equals( ui.oldContent.size(), 1 );
                equals( ui.newHeader.size(), 0 );
                equals( ui.newContent.size(), 0 );
        })
-       .accordion("activate", 0);
+       .accordion("option", "active", 0);
 });
 
 })(jQuery);
index ed5cb37b6c28ee455d4276a230febd510cb2da29..e46dba30ada5492074880067a1ed9a0600398a1e 100644 (file)
@@ -50,10 +50,10 @@ test("disable", function() {
        equals(actual, expected, 'disable is chainable');
        
        state(expected, 1, 0, 0)
-       expected.accordion("activate", 1);
+       expected.accordion("option", "active", 1);
        state(expected, 1, 0, 0)
        expected.accordion("enable");
-       expected.accordion("activate", 1);
+       expected.accordion("option", "active", 1);
        state(expected, 0, 1, 0)
 });
 
index 331ceb92414d634c28fd64852f334def400bdc5c..abfb82d784b9e1865a24106c4e87f2e535f1bdd8 100644 (file)
@@ -61,7 +61,7 @@ test("{ active: Number }", function() {
        $('.ui-accordion-header:eq(2)', '#list1').click();
        equals( $("#list1").accordion('option', 'active'), 2);
 
-       $("#list1").accordion('activate', 0);
+       $("#list1").accordion('option', 'active', 0);
        equals( $("#list1").accordion('option', 'active'), 0);
 });
 
@@ -96,7 +96,7 @@ test("{ heightStyle: 'content' }", function() {
 });
 test("{ collapsible: false }, default", function() {
        var ac = $("#list1").accordion();
-       ac.accordion("activate", false);
+       ac.accordion("option", "active", false);
        state(ac, 1, 0, 0);
 });
 
index f7d0e27b2021c0d10e9142fee9cc3eac3edc77a3..e58c5d6211da659e989a704895e052559fda4eba 100644 (file)
@@ -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 );