Class: UWA.Controls.Accordion

UWA/Controls/Accordion. UWA.Controls.Accordion

new UWA.Controls.Accordion(options)

Display a vertically stacked list of items (e.g. labels or thumbnails). Each item can be "expanded" or "stretched" to reveal the content associated with that item. There can be zero or more items expanded at a time, depending on the options.

Available Events
Event Description
onPreInject Triggered before inject
onPostInject Triggered after inject
onResize Invoked when control needs to resize
onClick Invoked when a item title is clicked
onChange Invoked when a item open or close
Example
var myControl = new UWA.Controls.Accordion({
data: {
    option_a: {text: 'a'},
    option_bb: {text: 'bb'},
    option_ccc: {text: 'ccc'},
    option_dddd: {text: 'dddd'}
}
});

myControl.inject(myControlContainer);
// OR
myControlContainer.appendChild(myControl.getContent());
Parameters
Name Type Description
options Object

Options hash or a option/value pair.

Properties
Name Type Argument Default Description
title String <optional>
null

Item title

multiSelect Boolean <optional>
false

Allow selecting more than one item

constantItemWidth Boolean <optional>
false

Keep all items the same width

className String <optional>
''

Customized classname

data Object <optional>
{}

Data to fill in the control

events Object <optional>
{}

Events Callbacks

Extends

Index

Members

itemLength :Number

The items length.

Type
  • Number
Inherited From:

Methods

hasItem(name) → {Boolean}

Check if accordion has an item

Parameters
Name Type Description
name String

internal item Id

Returns
Type
Boolean

addItem(name, itemConfig)

Add one item at the end of the control AND an item content container

Parameters
Name Type Description
name String

Internal item Id

itemConfig Object

Item configuration

removeItem(name)

Destroy an item and all its children

Parameters
Name Type Description
name String

Internal item Id

updateContent(name, content, empty) → {HTMLelement}

Add some content to an item, or replace any existing content

Parameters
Name Type Description
name String

Internal item Id

content String | HTMLelement

Content to add

empty Boolean

Empty or not item content before

Returns
Type
HTMLelement

buildSkeleton()

Build main dom elements.

onClick()

Invoked when an item is clicked.

onChange()

Invoked when a item is closed or opened

setContent(name, content) → {HTMLelement}

Set item content (removing any existing content).

Parameters
Name Type Description
name String

Internal item Id

content String | HTMLelement

New content

Returns
Type
HTMLelement

addContent(name, content) → {HTMLelement}

SAdd content to the item.

Parameters
Name Type Description
name String

Internal item Id

content String | HTMLelement

New content

Returns
Type
HTMLelement

updateItemClassNames()

Recompute items classnames, with item-first and item-last classes (called each time an item is added)

Inherited From:

createItem(name, itemConfig) → {HTMLElement}

Build an item HTMLelement and add event

Parameters
Name Type Description
name String

Internal item Id

itemConfig Object

Item configuration

Returns
Type
HTMLElement
Inherited From:

onResize()

Resize all items if needed (this.options.constantItemWidth)

Inherited From:

addItems(items)

Add some items to the control

Parameters
Name Type Description
items Object

Items to be added

Inherited From:

setItemTitle(itemName, newTitle)

Change an item title.

Parameters
Name Type Description
itemName String

Internal item Id

newTitle String

New title

Inherited From:

setItemState(name, state, notify)

Open or Close an item.

Parameters
Name Type Argument Default Description
name String

Internal item Id

state Boolean

Select/unselect item

notify Boolean <optional>
true

Should trigger onChange or not

Inherited From:

toggleItem(name, notify)

Toggle item state.

Parameters
Name Type Argument Default Description
name String

internal item Id

notify Boolean <optional>
true

should trigger onChange or not

Inherited From:

unselectItem(name, notify)

Unselect an item.

Parameters
Name Type Argument Default Description
name String

internal item Id

notify Boolean <optional>
true

should trigger onChange or not

Inherited From:

selectItem(name, notify)

Select an item.

Parameters
Name Type Argument Default Description
name String

internal item Id

notify Boolean <optional>
true

should trigger onChange or not

Inherited From:

getSelectedItems() → {Array}

Get all selected items.

Returns

an array with all currently selected IDs

Type
Array
Inherited From:

isSelected(name)

Return an element state

Parameters
Name Type Description
name String

Internal item Id

Inherited From:

unselectItems(notify, exceptedItemName)

Unselect all items

Parameters
Name Type Argument Default Description
notify Object <optional>
false

Notify or not

exceptedItemName String

You can unselect all except one item, if neeeded

Inherited From: