HTML |
jQuery |
A plain open/close button to the heading
<h2 id=details>Detailed description</h2>
<div>
The following will use "Part one" from the title in the open button
<div class=foo title="Part one">
augue duis dolore te feugait nulla facilisi. Nam liber tempor cum
soluta nobis eleifend option congue nihil imperdiet doming id quod mazim
placerat facer possim assum. Typi non habent claritatem insitam; est
usus legentis in iis qui
</div>
<br>
Unless specified the close button snuggles into the content.
<div class=foo title="Part two">
augue duis dolore te feugait nulla facilisi. Nam liber tempor cum
soluta nobis eleifend option congue nihil imperdiet doming id quod mazim
placerat facer possim assum. Typi non habent claritatem insitam; est
usus legentis in iis qui
</div>
</div>
|
$(document).ready(function() {
Attach inner buttons and take title from div
$('div.foo').foldButton({'closedText':'open TITLE' });
Outer button is attached direct to heading with no tweaks
$('H2#details').foldButton();
});
This sets up a nest of folds with the outer being attached to a H2 which will target the outer DIV. When closed the heading is still shown. In this example the inner DIV's title attributes are used to enhance the button titles.
|
HTML |
jQuery |
<span class="button" id="testClose">Close all</span>
<span class="button" id="testOpen">Open all</span>
(You might want some CSS on the button class.)
|
Put inside ready()
$('span#testClose').click(function(){
$('span#foldButton:visible').foldButton('close');
});
$('span#testOpen').click(function(){
$('span.foldButton:visible').foldButton('open');
});
|
Option | Default | Description |
cascadeClose | true | When button is closed any nested buttons are closed also. This doesn't become apparent until re-opening. |
cascadeOpen | false | When button is opened should nested buttons also be opened. |
closedText | "Open" | Text to display when button is closed.
|
compact | true | When true the button in the opened state is snuggled into the body of the target DIV. (This isn't applicable to buttons associated with headings.) |
open | false | Initial state |
openedText | "Close" | This is the text shown on the button when in the open state. |
radioGroup | "" | Buttons with the same radioGroup value are exclusive. ie. only one button of the set will be opened at a time. |
speed | 300 | Time to open and close sections in milliseconds. Set to 0 for instant. |
title | "" | This is used when the mouse hovers over the button in the closed state
as an automatic tool-tip. It can be sourced in these three ways (in order of precedence)
|
titleLength | 100 | What is the maximum length of title text. Typically when falling-through to reading the opening text of the target DIV |
Version 1.00 | Use and abuse as you like | Comments and bug reports to Peter Fox @ |