Accordion Class
An accordion can be constructed from existing markup or from strings
containing HTML. Existing markup can be provided either by setting
contentBox
or by specifying CSS selectors. See the titles
and
sections
attributes.
When constructing from existing markup via contentBox
, use an
unordered list (<ul>). Each item must contain two <div>'s.
The first one is used as the section title, and the second one is used
as the section content.
Animation is optional. If the anim module is not available, animation is automatically turned off.
When using a horizontal accordion:
- The widget's container must have a height.
- Each title must have both a width and height.
- Each section must have a width.
IE doesn't accept zero height divs, so we use 1px height and zero opacity. IE6 doesn't always render correctly with opacity set, so if animation is turned off, we don't use opacity at all.
Constructor
Accordion
-
config
Parameters:
-
config
ObjectWidget configuration
Item Index
Methods
Attributes
Methods
_getClip
-
index
Parameters:
-
index
Intthe section index
Returns:
the clipping container for the section content
allSectionsClosed
()
Boolean
Returns:
true
if all sections are closed
allSectionsOpen
()
Boolean
Returns:
true
if all sections are open
appendSection
-
title
-
content
Appends the section to the accordion.
closeAllSections
()
Close all sections, if possible.
closeSection
-
index
Close the specified section.
Parameters:
-
index
Intthe section index
findSection
-
any
Parameters:
-
any
String | Nodeelement inside the section or title
Returns:
the index of the containing section, or -1 if not found
getSection
-
index
Parameters:
-
index
Intthe section index
Returns:
the container for the section content
getSectionCount
()
Int
Returns:
total number of sections
getTitle
-
index
Parameters:
-
index
Intthe section index
Returns:
the container for the section title
insertSection
-
index
-
title
-
content
Inserts the section into the accordion at the specified location.
isSectionOpen
()
Boolean
Returns:
true
if the section is open
openAllSections
()
Open all sections, if possible.
openSection
-
index
Open the specified section.
Parameters:
-
index
Intthe section index
prependSection
-
title
-
content
Prepends the section to the accordion.
removeSection
-
index
Removes the specified section.
Parameters:
-
index
Intthe section index
setSection
-
index
-
content
Sets the contents of the specified section.
Parameters:
-
index
Intthe section index
-
content
String | Nodethe section content
setTitle
-
index
-
title
Sets the contents of the specified section title.
Parameters:
-
index
Intthe section index
-
title
String | Nodethe title content
toggleSection
-
index
Show/hide the section content.
Parameters:
-
index
Intthe section index
Attributes
allowAllClosed
Boolean
Whether or not to allow all sections to be closed at the same time. If not, at least one section will always be open.
Default: false
allowMultipleOpen
Boolean
Whether or not to allow multiple sections to be open at the same time. If not, at most one section at a time will be open.
Default: false
animateInsertRemove
Boolean
Whether or not to animate insertion and removal of sections.
Default: true
replaceSectionContainer
Boolean
Whether or not to replace the default section container node, when the supplied title is a node. (If the supplied content is markup, it is always inserted inside the default section container.)
Default: true
replaceTitleContainer
Boolean
Whether or not to replace the default title container node, when the supplied title is a node. (If the supplied title is markup, it is always inserted inside the default title container.)
Default: true
Events
beforeClose
Fires before a section is closed.
Event Payload:
-
index
Intthe section index
beforeInsert
Fires before a section is inserted.
Event Payload:
-
index
Intthe insertion index
beforeOpen
Fires before a section is opened.
Event Payload:
-
index
Intthe section index
beforeRemove
Fires before a section is removed.
Event Payload:
-
index
Intthe section index
close
Fires after a section is closed.
Event Payload:
-
index
Intthe section index
insert
Fires after a section is inserted.
Event Payload:
-
index
Intthe insertion index
-
size
Intthe final size of the section title, after animation (if any)
open
Fires after a section is opened.
Event Payload:
-
index
Intthe section index
remove
Fires after a section is removed.
Event Payload:
-
index
Intthe section index