Cl.Accordion¶
This is a list of all relevant options, methods, events and callbacks.
Options¶
Options are set on initializing the accordion:
new Cl.Accordion({
// your options
'index': 0,
'event': 'mouseenter'
});
| Option | Default | Description |
|---|---|---|
| index | null | shows selected element[index] starting form zero. |
| expanded | false | initial visibility of all items inside the selector. |
| event | ‘click’ | the jquery element of which the accordion will listen to. |
| easing | ‘swing’ | the jquery easing method for all animations. |
| duration | 300 | the jquery duration speed for all animations. |
| grouping | true | enables all elements to be grouped together, only one will be visible at any given time. |
| forceClose | false | if enabled, allows open element to be closed again. |
| disableAnchors | true | disables descending anchors from triggering. For example if the trigger is an li wrapping an anchor. |
| autoHeight | false | sets the height for each element on initialization. |
| cls | object | the available css class getters and setters. |
| lang | object | the available language configurations. |
Option cls setters and getters:
| Option | Default | Description |
|---|---|---|
| expanded | ‘expanded’ | will be added on the trigger when expanded |
| collapsed | ‘collapsed’ | will be added on the trigger when collapsed |
| trigger | ‘.trigger’ | the element which triggers toggle |
| container | ‘.container’ | the container to be expanded and collapsed |
| text | ‘.text’ | will be used to switch language text |
Option lang strings:
| Option | Default |
|---|---|
| expanded | ‘Expanded ‘ |
| collapsed | ‘Collapsed ‘ |
Methods¶
Methods can be called using an instance of the class:
var accordion = new Cl.Accordion();
// trigger the method
accordion.toggle();
All Methods have appropriate events and callbacks.
- accordion.toggle(index)¶
Description: toggles a specified accordion entry.
Arguments: - index (number) – required the index of the element to be toggled.
Returns: toggle callback.
- accordion.show([index])¶
Description: opens an accordion entry.
Arguments: - index (number) – optional index of the element to be shown, if empty shows all.
Returns: open callback.
- accordion.hide([index])¶
Description: hides an accordion entry.
Arguments: - index (number) – optional index of the element to be shown, if empty hides all.
Returns: close callback.
Callbacks¶
Callbacks are always triggered after the method is excecuted. You can interact with callbacks as follows:
var accordion = new Cl.Accordion();
// register callback
accordion.callbacks.toggle = function () {
console.log('item has toggled');
};
Available keywords: