Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/ui/controls/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Object.extend(Event, {
* Applies "accordion menu" behavior to an element and its contents.
*
* ##### Options
*
*
* * `defaultIndex` (Integer): Determines which content element should be
* open by default.
* * `multiple` (Boolean): Whether multiple panels can be open at once.
* Defaults to `false`.
* * `headerSelector` (String): A CSS selector that identifies the
Expand Down Expand Up @@ -68,9 +70,13 @@ Object.extend(Event, {
header.insert({ top: icon });
});

// If the user specified an active header, mark it as active.
// If the user specified a default index, mark it as active.
// Otherwise, the first one is active by default.
this._markActive(opt.active || this.headers.first(), false);
this.content.each(function(element, i){
if(opt.defaultIndex != i) {
element.hide();
}
});

// ARIA.
this.element.writeAttribute({
Expand Down Expand Up @@ -223,6 +229,7 @@ Object.extend(Event, {

Object.extend(UI.Accordion, {
DEFAULT_OPTIONS: {
defaultIndex: 0,
multiple: false, /* whether more than one pane can be open at once */
headerSelector: 'h3',

Expand Down