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");
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");
});
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);
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)
});
$('.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);
});
});
test("{ collapsible: false }, default", function() {
var ac = $("#list1").accordion();
- ac.accordion("activate", false);
+ ac.accordion("option", "active", false);
state(ac, 1, 0, 0);
});
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();
});
}
$.Widget.prototype._setOption.apply( this, arguments );
if ( key == "active" ) {
- this.activate( value );
+ this._activate( value );
}
if ( key == "icons" ) {
this._destroyIcons();
break;
case keyCode.SPACE:
case keyCode.ENTER:
- this._clickHandler( { target: event.target }, event.target );
+ this._eventHandler( event );
event.preventDefault();
}
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 ) {
: 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;
}
// 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?
};
}( jQuery, jQuery.ui.accordion.prototype ) );
+// activate method
+jQuery.ui.accordion.prototype.activate = jQuery.ui.accordion.prototype._activate;
+
})( jQuery );