none
[openafs-wiki.git] / TWiki / TwistyPlugin.mdwn
1 # <a name="%TOPIC%"></a><a name=" %TOPIC%"></a> %TOPIC%
2
3 **A "twisty" is an interface toggle control to show and hide content.**
4
5 TwistyPlugin gives you several options to control the appearance of a twisty:
6
7 - use link text or buttons
8 - position an icon left or right
9 - remember the state at the next visit of the page
10 - start the Twisty open or closed
11 - start the Twisty open or closed for the first visit
12 - use a span or div for the content
13 - set a class for the content span or div
14
15 Twisty has a fallback mechanism in case JavaScript is not available: all content is displayed and the control buttons are hidden.
16
17 <div><span>On this page:</span><ul>
18     <li><a href="#Usage examples"> Usage examples</a><ul>
19         <li><a href="#Triad"> Triad</a></li>
20         <li><a href="#Shorthand"> Shorthand</a></li>
21         <li><a href="#Twisty with icons"> Twisty with icons</a></li>
22         <li><a href="#Make it remember"> Make it remember</a></li>
23         <li><a href="#Make it obey"> Make it obey</a></li>
24         <li><a href="#Make it obey only the first time"> Make it obey only the first time</a></li>
25         <li><a href="#Other use: hide interface parts"> Other use: hide interface parts in case of no JavaScript</a></li>
26         <li><a href="#Styling the Twisty"> Styling the Twisty</a></li>
27         <li><a href="#Twisty headers"> Twisty headers</a></li>
28         <li><a href="#All on, all off"> All on, all off</a></li>
29       </ul>
30     </li>
31     <li><a href="#Special syntax: format tokens"> Special syntax: format tokens</a></li>
32     <li><a href="#Syntax"> Syntax</a><ul>
33         <li><a href="#TWISTY"> TWISTY</a></li>
34         <li><a href="#ENDTWISTY"> ENDTWISTY</a></li>
35       </ul>
36     </li>
37     <li><a href="#Twisty components syntax"> Twisty components syntax</a><ul>
38         <li><a href="#TWISTYBUTTON"> TWISTYBUTTON</a></li>
39         <li><a href="#TWISTYSHOW"> TWISTYSHOW</a></li>
40         <li><a href="#TWISTYHIDE"> TWISTYHIDE</a></li>
41         <li><a href="#TWISTYTOGGLE"> TWISTYTOGGLE</a></li>
42         <li><a href="#ENDTWISTYTOGGLE"> ENDTWISTYTOGGLE</a></li>
43       </ul>
44     </li>
45     <li><a href="#The Fine Print"> The Fine Print</a></li>
46     <li><a href="#Plugin Settings"> Plugin Settings</a></li>
47     <li><a href="#Plugin Installation Instructions"> Plugin Installation Instructions</a></li>
48     <li><a href="#Plugin Info"> Plugin Info</a></li>
49   </ul>
50 </div>
51
52 ## <a name="Usage examples"></a> Usage examples
53
54 ### <a name="Triad"></a> Triad
55
56 A Twisty consists of 3 elements:
57
58 1. Show button
59 2. Hide button
60 3. Collapsing content ('Toggle')
61
62 The typical TwistyPlugin triad will look like this (pseudo code):
63
64     %TWISTYSHOW{}% %TWISTYHIDE{}%
65     (there may be other things between buttons and content)
66     %TWISTYTOGGLE{}% my content %ENDTWISTYTOGGLE%
67
68 ### <a name="Shorthand"></a> Shorthand
69
70 The Twisty triad is conveniently packed into shorthand `%TWISTY{some parameters}% Collapsing content %ENDTWISTY%`:
71
72     %TWISTY{}%
73     my twisty content
74     %ENDTWISTY%
75
76 Will generate:
77
78 <span><span>[<span></span>](#)</span><span>[<span></span>](#)</span></span>
79
80 <div style="display: inline"><span id="twistyId1toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
81
82 You may have noticed that no parameters are passed to `%TWISTY{}%` but the show and hide links _do_ have text! The default values are fetched from plugin settings `TWISTYSHOWLINK` and `TWISTYHIDELINK`, see [[Plugin Settings|Main/WebHome#PluginSettings]] below.
83
84 ### <a name="Twisty with icons"></a> Twisty with icons
85
86 We will use `mode="div"` to put the collapsing content below the button (the default mode is `"span"`).
87
88     %TWISTY{
89     mode="div"
90     showlink="Show..."
91     hidelink="Hide"
92     showimgleft="%ICONURLPATH{toggleopen-small}%"
93     hideimgleft="%ICONURLPATH{toggleclose-small}%"
94     }%
95     my twisty content
96     %ENDTWISTY%
97
98 It will look like this:
99
100 <span><span>[![](http://www.dementia.org/twiki//view/Main/WebHome/toggleopen-small.gif)<span>Show...</span>](#)</span><span>[![](http://www.dementia.org/twiki//view/Main/WebHome/toggleclose-small.gif)<span>Hide</span>](#)</span></span>
101
102 <div style="display: inline">
103   <div id="twistyId2toggle"> %GREEN% my twisty content %ENDCOLOR% </div>
104 </div>
105
106 To put icons at the right side, write
107
108     %TWISTY{
109     mode="div"
110     showlink="Show&nbsp;"
111     hidelink="Hide&nbsp;"
112     showimgright="%ICONURLPATH{toggleopen-small}%"
113     hideimgright="%ICONURLPATH{toggleclose-small}%"
114     }%
115     my twisty content
116     %ENDTWISTY%
117
118 <span><span>[<span>Show </span>![](http://www.dementia.org/twiki//view/Main/WebHome/toggleopen-small.gif)](#)</span><span>[<span>Hide </span>![](http://www.dementia.org/twiki//view/Main/WebHome/toggleclose-small.gif)](#)</span></span>
119
120 <div style="display: inline">
121   <div id="twistyId3toggle"> %GREEN% my twisty content %ENDCOLOR% </div>
122 </div>
123
124 ### <a name="Make it remember"></a> Make it remember
125
126 To store the last state in a TWIKIPREF cookie, add the parameter `remember="on"`.%BR% To test this, reload the page after toggling.
127
128     %TWISTY{
129     showlink="Show..."
130     hidelink="Hide"
131     remember="on"
132     }%
133     my twisty content
134     %ENDTWISTY%
135
136 <span><span>[<span>Show...</span>](#)</span><span>[<span>Hide</span>](#)</span></span>
137
138 <div style="display: inline"><span id="twistyId4toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
139
140 If a Twisty state has been stored in a TWIKIPREF cookie before, it can be cleared by using `remember="off"`:
141
142     %TWISTY{
143     showlink="Show..."
144     hidelink="Hide"
145     remember="off"
146     }%
147     my twisty content
148     %ENDTWISTY%
149
150 <span><span>[<span>Show...</span>](#)</span><span>[<span>Hide</span>](#)</span></span>
151
152 <div style="display: inline"><span id="twistyId5toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
153
154 **NOTE:** Twisty ids are generated automatically. If you need control over exactly _which_ Twisty should be remembered, add the parameter `id`:
155
156     %TWISTY{
157     id="currentCustomerList"
158     showlink="Show..."
159     hidelink="Hide"
160     remember="on"
161     }%
162     my customer list
163     %ENDTWISTY%
164
165 Note that `id` sets a sitewide cookie. To create a unique id, add topic or web variables:
166
167     id="%WEB%_%TOPIC%_currentCustomerList"
168
169 ### <a name="Make it obey"></a> Make it obey
170
171 To let the Twisty start with its content folded open, add parameter `start="show"`.
172
173     %TWISTY{
174     showlink="Show..."
175     hidelink="Hide"
176     start="show"
177     }%
178     my twisty content
179     %ENDTWISTY%
180
181 <span><span>[<span>Show...</span>](#)</span><span>[<span>Hide</span>](#)</span></span>
182
183 <div style="display: inline"><span id="twistyId6toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
184
185 Likewise use `start="hide"` to start with hidden content.
186
187     %TWISTY{
188     showlink="Show..."
189     hidelink="Hide
190     start="hide"
191     }%
192     my twisty content
193     %ENDTWISTY%
194
195 <span><span>[<span>Show...</span>](#)</span><span>[<span>Hide start=</span>](#)</span></span>
196
197 <div style="display: inline"><span id="twistyId7toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
198
199 ### <a name="Make it obey only the first time"></a> Make it obey only the first time
200
201 To let the Twisty start with its content folded open the first time the visitor sees the Twisty, add the parameter `firststart="show"`. If `remember="on"` is used, subsequential visits to the page will display the Twisty according the cookie setting.
202
203     %TWISTY{
204     showlink="Show..."
205     hidelink="Hide"
206     firststart="show"
207     }%
208     my twisty content
209     %ENDTWISTY%
210
211 <span><span>[<span>Show...</span>](#)</span><span>[<span>Hide</span>](#)</span></span>
212
213 <div style="display: inline"><span id="twistyId8toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
214
215 ### <a name="Other use: hide interface parts"></a><a name="Other use: hide interface parts "></a> Other use: hide interface parts in case of no JavaScript
216
217 You can use Twisty to show interface elements that should only be visible with JavaScript enabled. For instance the textbox control buttons in the edit screen need JavaScript to work. If a visitor does not have JavaScript on it would not make sense to show these buttons.
218
219 Put the "JavaScript content" in an almost bare bones Twisty. Write `showlink="" hidelink=""` to not display any default link texts.
220
221     %TWISTY{
222     link=""
223     noscript="hide"
224     start="show"
225     }%
226     <input type="submit" class="twikiButton" value="You surely have !JavaScript" />
227     %ENDTWISTY%
228
229 <span><span>[<span></span>](#)</span><span>[<span></span>](#)</span></span>
230
231 <div style="display: inline"><span id="twistyId9toggle"><input type="submit" value="You surely have JavaScript" /> </span></div>
232
233 Do not forget to set `start="show"` to show the Twisty content at all.
234
235 When JavaScript is off, the button should be invisible.
236
237 This code will show the button when JavaScript is off:
238
239     %TWISTY{
240     link=""
241     start="show"
242     }%
243     <input type="submit" class="twikiButton" value="You might have !JavaScript" />
244     %ENDTWISTY%
245
246 <span><span>[<span></span>](#)</span><span>[<span></span>](#)</span></span>
247
248 <div style="display: inline"><span id="twistyId10toggle"><input type="submit" value="You might have JavaScript" /> </span></div>
249
250 ### <a name="Styling the Twisty"></a> Styling the Twisty
251
252 Use parameter `class` to style the content div or class:
253
254     %TWISTY{
255     mode="div"
256     showlink="Show..."
257     hidelink="Hide"
258     class="twikiHelp"
259     }%
260     my twisty content
261     %ENDTWISTY%
262
263 Generates: %BR% <span><span>[<span>Show...</span>](#)</span><span>[<span>Hide</span>](#)</span></span>
264
265 <div style="display: inline">
266   <div id="twistyId11toggle"> %GREEN% my twisty content %ENDCOLOR% </div>
267 </div>
268
269 ### <a name="Twisty headers"></a> Twisty headers
270
271 To be able to use header tags like `<h2>`, use the properties `prefix` and `suffix`. Because we have identical show and hide links we can use the shorthand property `link`.
272
273     %TWISTY{
274     prefix="<h4>!!"
275     mode="div"
276     link="Header"
277     showimgleft="%ICONURLPATH{toggleopen}%"
278     hideimgleft="%ICONURLPATH{toggleclose}%"
279     suffix="</h4>"
280     }%
281     my twisty content
282     %ENDTWISTY%
283
284 Add the `!!` to prevent the twisty header appear in the table of contents when you use `%TOC%`.
285
286 Will create:
287
288 #### <a name="Header%_TWISTYSCRIPT{&quot;TWiki._Twi"></a> <span><span>[![](http://www.dementia.org/twiki//view/Main/WebHome/toggleopen.gif)<span>Header</span>](#)</span><span>[![](http://www.dementia.org/twiki//view/Main/WebHome/toggleclose.gif)<span>Header</span>](#)</span></span>
289
290 <div style="display: inline"><span id="twistyId12toggle"> %GREEN% my twisty content %ENDCOLOR% </span></div>
291
292 ### <a name="All on, all off"></a> All on, all off
293
294 You can toggle all Twisties on or off at once by putting a link or button on the page with class `twistyExpandAll` or `twistyCollapseAll`.
295
296     <button class="twistyExpandAll twikiButton">Expand all</button> &nbsp; <button class="twistyCollapseAll twikiButton">Collapse all</button>
297
298 Creates these controls:
299
300 <button>Expand all</button>
301
302 <button>Collapse all</button>
303
304 When you want to use links, write:
305
306     #VarTOGGLE
307
308     <a href="#TOGGLE" class="twistyExpandAll">Expand all</a> &nbsp;
309     <a href="#TOGGLE" class="twistyCollapseAll">Collapse all</a>
310
311 <a name="VarTOGGLE"></a>
312
313 [Expand all](#TOGGLE)   [Collapse all](#TOGGLE)
314
315 ## <a name="Special syntax: format tokens"></a> Special syntax: format tokens
316
317 If you use TWiki variables inside TWISTY parameters chances are it will mess up the variable, or the rendered html. Use format tokens to 'delay' rendering of these variables until the Twisty parameters are parsed.
318
319 The format tokens are the same as with [[FormattedSearch]]:
320
321 <table border="1" cellpadding="0" cellspacing="0">
322   <tr>
323     <th bgcolor="#99CCCC"><strong> Escape: </strong></th>
324     <th bgcolor="#99CCCC"><strong> Expands To: </strong></th>
325   </tr>
326   <tr>
327     <td><code>$n</code> or <code>$n()</code></td>
328     <td> New line. Use <code>$n()</code> if followed by alphanumeric character, e.g. write <code>Foo$n()Bar</code> instead of <code>Foo$nBar</code></td>
329   </tr>
330   <tr>
331     <td><code>$nop</code> or <code>$nop()</code></td>
332     <td> Is a "no operation". </td>
333   </tr>
334   <tr>
335     <td><code>$quot</code></td>
336     <td> Double quote (<code>"</code>) </td>
337   </tr>
338   <tr>
339     <td><code>$percnt</code></td>
340     <td> Percent sign (<code>%</code>) </td>
341   </tr>
342   <tr>
343     <td><code>$dollar</code></td>
344     <td> Dollar sign (<code>$</code>) </td>
345   </tr>
346 </table>
347
348 For example, to show an icon inside the link, do not write:
349
350     link="%Y%"
351
352 but use format tokens:
353
354     link="$percntY$percnt"
355
356 ... to get:
357
358 <span><span>[![](http://www.dementia.org/twiki//view/Main/WebHome/toggleopen-small.gif)<span>$percntY$percnt</span>](#)</span><span>[![](http://www.dementia.org/twiki//view/Main/WebHome/toggleclose-small.gif)<span>$percntY$percnt</span>](#)</span></span>
359
360 <div style="display: inline">
361   <div id="twistyId13toggle"> my twisty content </div>
362 </div>
363
364 Or a more complex example using [[SpreadsheetPlugin]]; do not write:
365
366     link="Count: (%CALC{"$GET(infoCount)"}%)"
367
368 but use format tokens:
369
370     link="Count: ($percntCALC{$quot$dollarGET(infoCount)$quot}$percnt)"
371
372 ## <a name="Syntax"></a> Syntax
373
374 <a name="VarTWISTY"></a>
375
376 ### <a name="TWISTY"></a> TWISTY
377
378 This renders the button as well as the toggled content section contained within this and the closing ENDTWISTY tag. %BR% Usage: `%TWISTY{ ... }% Toggable contents %ENDTWISTY%`
379
380 <table border="1" cellpadding="0" cellspacing="0">
381   <tr>
382     <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
383     <th bgcolor="#99CCCC"><strong> Value </strong></th>
384     <th bgcolor="#99CCCC"><strong> Description </strong></th>
385     <th bgcolor="#99CCCC"><strong> Remark </strong></th>
386   </tr>
387   <tr>
388     <td><code>id</code></td>
389     <td> Unique identifier </td>
390     <td> Used to link [[Main/WebHome#VarTWISTYBUTTON]] and [[Main/WebHome#VarTWISTYTOGGLE]]</td>
391     <td> optional </td>
392   </tr>
393   <tr>
394     <td><code>link</code></td>
395     <td> Link label </td>
396     <td> Link label for both show and hide links </td>
397     <td> optional </td>
398   </tr>
399   <tr>
400     <td><code>hidelink</code></td>
401     <td> Link label </td>
402     <td> Hide link label </td>
403     <td> optional </td>
404   </tr>
405   <tr>
406     <td><code>showlink</code></td>
407     <td> Link label </td>
408     <td> Show link label </td>
409     <td> optional </td>
410   </tr>
411   <tr>
412     <td><code>mode</code></td>
413     <td><code>"div"</code> or <code>"span"</code></td>
414     <td> Specify if the Twisty Toggle section will use a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code> tag. </td>
415     <td> optional, defaults to <code>&lt;span&gt;</code></td>
416   </tr>
417   <tr>
418     <td><code>showimgleft</code></td>
419     <td> Image url </td>
420     <td> Specify the url of an image that will be displayed with the show link at the left side of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
421     <td> optional, defaults to no image </td>
422   </tr>
423   <tr>
424     <td><code>hideimgleft</code></td>
425     <td> Image url </td>
426     <td> Specify the url of an image that will be displayed with the hide link at the left side of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
427     <td> optional, defaults to no image </td>
428   </tr>
429   <tr>
430     <td><code>showimgright</code></td>
431     <td> Image url </td>
432     <td> Specify the url of an image that will be displayed with the show link at the right side of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
433     <td> optional, defaults to no image </td>
434   </tr>
435   <tr>
436     <td><code>hideimgright</code></td>
437     <td> Image url </td>
438     <td> Specify the url of an image that will be displayed with the hide link at the right side of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
439     <td> optional, defaults to no image </td>
440   </tr>
441   <tr>
442     <td><code>remember</code></td>
443     <td><code>"on"</code>, <code>"off"</code></td>
444     <td> If <code>"on"</code>, the Twisty state is remembered the next time the page is shown. If <code>"off"</code>, the stored setting will be cleared.<br /><strong>Note:</strong> when used, think carefully about a unique name (id) for the Twisty, otherwise the cookie that is set might affect other Twisties with the same name. Also note that only interaction is stored, not the state of the Twisty when left unclicked. </td>
445     <td> optional, no default </td>
446   </tr>
447   <tr>
448     <td><code>start</code></td>
449     <td><code>"hide"</code> or <code>"show"</code></td>
450     <td> Initial state of the Twisty; this will override any setting stored in a cookie (see <code>remember</code>). </td>
451     <td> optional, default no initial state </td>
452   </tr>
453   <tr>
454     <td><code>firststart</code></td>
455     <td><code>"hide"</code> or <code>"show"</code></td>
456     <td> Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see <code>remember</code>). </td>
457     <td> optional, default no initial state </td>
458   </tr>
459   <tr>
460     <td><code>noscript</code></td>
461     <td><code>"hide"</code></td>
462     <td> Make content hidden in case use does not have JavaScript on </td>
463     <td> optional, default content is shown in case JavaScript if off </td>
464   </tr>
465   <tr>
466     <td><code>class</code></td>
467     <td> CSS class name </td>
468     <td> Class for Twisty div or span </td>
469     <td> optional, default none </td>
470   </tr>
471   <tr>
472     <td><code>prefix</code></td>
473     <td> Text </td>
474     <td> Text to display before the show/hide links </td>
475     <td> optional, default none </td>
476   </tr>
477   <tr>
478     <td><code>suffix</code></td>
479     <td> Text </td>
480     <td> Text to display after the show/hide links </td>
481     <td> optional, default none </td>
482   </tr>
483   <tr>
484     <td><code>img</code></td>
485     <td> Image url </td>
486     <td> %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% </td>
487     <td> optional, defaults to no image </td>
488   </tr>
489   <tr>
490     <td><code>imgleft</code></td>
491     <td> Image url </td>
492     <td> %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% </td>
493     <td> optional, defaults to no image </td>
494   </tr>
495   <tr>
496     <td><code>imgright</code></td>
497     <td> Image url </td>
498     <td> %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% </td>
499     <td> optional, defaults to no image </td>
500   </tr>
501   <tr>
502     <td><code>hideimg</code></td>
503     <td> Image url </td>
504     <td> %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% </td>
505     <td> optional, defaults to no image </td>
506   </tr>
507   <tr>
508     <td><code>showimg</code></td>
509     <td> Image url </td>
510     <td> %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% </td>
511     <td> optional, defaults to no image </td>
512   </tr>
513 </table>
514
515 - Related [[TWISTYBUTTON|Main/WebHome#VarTWISTYSHOW]] and [[TWISTYTOGGLE|Main/WebHome#VarTWISTYTOGGLE]]
516
517 <a name="VarENDTWISTY"></a>
518
519 ### <a name="ENDTWISTY"></a> ENDTWISTY
520
521 **Twisty closure, complements the opening TWISTY tag.**
522
523 - Syntax: `%ENDTWISTY%`
524
525 See [[ENDTWISTYTOGGLE|Main/WebHome#VarENDTWISTYTOGGLE]].
526
527 ## <a name="Twisty components syntax"></a> Twisty components syntax
528
529 <div style="background-color: #eee; padding: .5em; margin: -.5em">
530   <p> Ocassionally you might need to create a custom set of individual Twisty components: </p>
531   <p><a name="VarTWISTYBUTTON"></a></p>
532   <h3><a name="TWISTYBUTTON"></a> TWISTYBUTTON </h3><strong>Shorthand version for TWISTYSHOW &amp; TWISTYHIDE</strong> This is useful if both the show and the hide button take the same arguments. <ul>
533     <li> Supported parameters: all parameters supported by [[Main/WebHome#VarTWISTYSHOW]], except for <code>noscript</code> and <code>class</code> (only used for 'toggle' content) </li>
534     <li> Parameter differences: <ul>
535         <li><code>mode</code>: button mode defaults to span </li>
536       </ul>
537     </li>
538     <li> Syntax: <code>%TWISTYBUTTON{id="myid" ... }%</code></li>
539     <li> Supported parameters: <table border="1" cellpadding="0" cellspacing="0">
540         <tr>
541           <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
542           <th bgcolor="#99CCCC"><strong> Value </strong></th>
543           <th bgcolor="#99CCCC"><strong> Description </strong></th>
544           <th bgcolor="#99CCCC"><strong> Remark </strong></th>
545         </tr>
546         <tr>
547           <td><code>mode</code></td>
548           <td><code>"div"</code> or <code>"span"</code></td>
549           <td> Specify if the <strong>Twisty button</strong> will use a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code> tag </td>
550           <td> optional, defaults to <code>&lt;span&gt;</code></td>
551         </tr>
552       </table>
553     </li>
554     <li> Related: [[Main/WebHome#VarTWISTYSHOW]] and [[Main/WebHome#VarTWISTYHIDE]]</li>
555   </ul>
556   <p><a name="VarTWISTYSHOW"></a></p>
557   <h3><a name="TWISTYSHOW"></a> TWISTYSHOW </h3><strong>Show/open link</strong><ul>
558     <li> Syntax: <code>%TWISTYSHOW{id="myid" ... }%</code></li>
559     <li> Supported parameters: <table border="1" cellpadding="0" cellspacing="0">
560         <tr>
561           <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
562           <th bgcolor="#99CCCC"><strong> Value </strong></th>
563           <th bgcolor="#99CCCC"><strong> Description </strong></th>
564           <th bgcolor="#99CCCC"><strong> Remark </strong></th>
565         </tr>
566         <tr>
567           <td><code>id</code></td>
568           <td> Unique identifier </td>
569           <td> Used to link [[Main/WebHome#VarTWISTYSHOW]], [[Main/WebHome#VarTWISTYHIDE]] and [[Main/WebHome#VarTWISTYTOGGLE]]</td>
570           <td> required </td>
571         </tr>
572         <tr>
573           <td><code>link</code></td>
574           <td> Link label </td>
575           <td> Show link label </td>
576           <td> optional </td>
577         </tr>
578         <tr>
579           <td><code>mode</code></td>
580           <td><code>"div"</code> or <code>"span"</code></td>
581           <td> Specify if the Twisty Show link will use a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code> tag </td>
582           <td> optional, defaults to <code>&lt;span&gt;</code></td>
583         </tr>
584         <tr>
585           <td><code>img</code></td>
586           <td> Image url </td>
587           <td> Specify the url of an image that will be displayed at the <strong>right side</strong> of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
588           <td> optional, defaults to no image </td>
589         </tr>
590         <tr>
591           <td><code>imgleft</code></td>
592           <td> Image url </td>
593           <td> Specify the url of an image that will be displayed at the left side of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
594           <td> optional, defaults to no image </td>
595         </tr>
596         <tr>
597           <td><code>imgright</code></td>
598           <td> Image url </td>
599           <td> Specify the url of an image that will be displayed at the right side of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
600           <td> optional, defaults to no image </td>
601         </tr>
602         <tr>
603           <td><code>remember</code></td>
604           <td><code>"on"</code>, <code>"off"</code></td>
605           <td> If <code>"on"</code>, the Twisty state is remembered the next time the page is shown. If <code>"off"</code>, the stored setting will be cleared.<br /><strong>Note:</strong> when used, think carefully about a unique name (id) for the Twisty, otherwise the cookie that is set might affect other Twisties with the same name. Also note that only interaction is stored, not the state of the Twisty when left unclicked. </td>
606           <td> optional, no default </td>
607         </tr>
608         <tr>
609           <td><code>start</code></td>
610           <td><code>"hide"</code> or <code>"show"</code></td>
611           <td> Initial state of the Twisty; this will override any setting stored in a cookie (see <code>remember</code>). </td>
612           <td> optional, default no initial state </td>
613         </tr>
614         <tr>
615           <td><code>firststart</code></td>
616           <td><code>"hide"</code> or <code>"show"</code></td>
617           <td> Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see <code>remember</code>). </td>
618           <td> optional, default no initial state </td>
619         </tr>
620       </table>
621     </li>
622     <li> Example: <code>%TWISTYSHOW{id="demo" link=" Click to Unfold " imgleft="%ICONURLPATH{toggleopen}%"}%</code></li>
623     <li> Related: [[Main/WebHome#VarTWISTYHIDE]] and [[Main/WebHome#VarTWISTYTOGGLE]]</li>
624   </ul>
625   <p><a name="VarTWISTYHIDE"></a></p>
626   <h3><a name="TWISTYHIDE"></a> TWISTYHIDE </h3><strong>Hide/close link</strong><ul>
627     <li> Syntax: <code>%TWISTYHIDE{id="myid" ... }%</code></li>
628     <li> Supported parameters: <table border="1" cellpadding="0" cellspacing="0">
629         <tr>
630           <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
631           <th bgcolor="#99CCCC"><strong> Value </strong></th>
632           <th bgcolor="#99CCCC"><strong> Description </strong></th>
633           <th bgcolor="#99CCCC"><strong> Remark </strong></th>
634         </tr>
635         <tr>
636           <td><code>id</code></td>
637           <td> Unique identifier </td>
638           <td> Used to link [[Main/WebHome#VarTWISTYSHOW]], [[Main/WebHome#VarTWISTYHIDE]] and [[Main/WebHome#VarTWISTYTOGGLE]]</td>
639           <td> required </td>
640         </tr>
641         <tr>
642           <td><code>link</code></td>
643           <td> Link label </td>
644           <td> Hide link label </td>
645           <td> optional </td>
646         </tr>
647         <tr>
648           <td><code>mode</code></td>
649           <td><code>"div"</code> or <code>"span"</code></td>
650           <td> Specify if the Twisty Hide link will use a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code> tag </td>
651           <td> optional, defaults to <code>&lt;span&gt;</code></td>
652         </tr>
653         <tr>
654           <td><code>img</code></td>
655           <td> Image url </td>
656           <td> Specify the url of an image that will be displayed at the <strong>right side</strong> of the link. <br />You may use [[TWiki/TWikiVariables#VarICONURLPATH]] to display one of the [[TWiki/TWikiDocGraphics]] icons. Alternatively use an image attached to the topic. </td>
657           <td> optional, defaults to no image </td>
658         </tr>
659         <tr>
660           <td><code>remember</code></td>
661           <td><code>"on"</code>, <code>"off"</code></td>
662           <td> If <code>"on"</code>, the Twisty state is remembered the next time the page is shown. If <code>"off"</code>, the stored setting will be cleared.<br /><strong>Note:</strong> when used, think carefully about a unique name (id) for the Twisty, otherwise the cookie that is set might affect other Twisties with the same name. Also note that only interaction is stored, not the state of the Twisty when left unclicked. </td>
663           <td> optional, no default </td>
664         </tr>
665         <tr>
666           <td><code>start</code></td>
667           <td><code>"hide"</code> or <code>"show"</code></td>
668           <td> Initial state of the Twisty; this will override any setting stored in a cookie (see <code>remember</code>). </td>
669           <td> optional, default no initial state </td>
670         </tr>
671         <tr>
672           <td><code>firststart</code></td>
673           <td><code>"hide"</code> or <code>"show"</code></td>
674           <td> Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see <code>remember</code>). </td>
675           <td> optional, default no initial state </td>
676         </tr>
677       </table>
678     </li>
679     <li> Example: <code>%TWISTYHIDE{id="demo" link=" Click to Fold " imgleft="%ICONURLPATH{toggleclose}%"}%</code></li>
680     <li> Related: [[Main/WebHome#VarTWISTYSHOW]] and [[Main/WebHome#VarTWISTYTOGGLE]]</li>
681   </ul>
682   <p><a name="VarTWISTYTOGGLE"></a></p>
683   <h3><a name="TWISTYTOGGLE"></a> TWISTYTOGGLE </h3><strong>Twisty Toggle contents section</strong><ul>
684     <li> Syntax: <code>%TWISTYTOGGLE{id="myid"}%</code></li>
685     <li> Supported parameters: <table border="1" cellpadding="0" cellspacing="0">
686         <tr>
687           <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
688           <th bgcolor="#99CCCC"><strong> Value </strong></th>
689           <th bgcolor="#99CCCC"><strong> Description </strong></th>
690           <th bgcolor="#99CCCC"><strong> Remark </strong></th>
691         </tr>
692         <tr>
693           <td><code>id</code></td>
694           <td> Unique identifier </td>
695           <td> Used to link [[Main/WebHome#VarTWISTYSHOW]], [[Main/WebHome#VarTWISTYHIDE]] and [[Main/WebHome#VarTWISTYTOGGLE]]. </td>
696           <td> required </td>
697         </tr>
698         <tr>
699           <td><code>mode</code></td>
700           <td><code>"div"</code> or <code>"span"</code></td>
701           <td> Specify if the Twisty Toggle section will use a <code>&lt;div&gt;</code> or a <code>&lt;span&gt;</code> tag. </td>
702           <td> optional, defaults to <code>&lt;span&gt;</code></td>
703         </tr>
704         <tr>
705           <td><code>class</code></td>
706           <td> CSS class name </td>
707           <td> Class for content div or span </td>
708           <td> optional, default none </td>
709         </tr>
710         <tr>
711           <td><code>remember</code></td>
712           <td><code>"on"</code>, <code>"off"</code></td>
713           <td> If <code>"on"</code>, the Twisty state is remembered the next time the page is shown. If <code>"off"</code>, the stored setting will be cleared.<br /><strong>Note:</strong> when used, think carefully about a unique name (id) for the Twisty, otherwise the cookie that is set might affect other Twisties with the same name. Also note that only interaction is stored, not the state of the Twisty when left unclicked. </td>
714           <td> optional, no default </td>
715         </tr>
716         <tr>
717           <td><code>start</code></td>
718           <td><code>"hide"</code> or <code>"show"</code></td>
719           <td> Initial state of the Twisty; this will override any setting stored in a cookie (see <code>remember</code>). </td>
720           <td> optional, default no initial state </td>
721         </tr>
722         <tr>
723           <td><code>firststart</code></td>
724           <td><code>"hide"</code> or <code>"show"</code></td>
725           <td> Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see <code>remember</code>). </td>
726           <td> optional, default no initial state </td>
727         </tr>
728         <tr>
729           <td><code>noscript</code></td>
730           <td><code>"hide"</code></td>
731           <td> Make content hidden in case use does not have JavaScript on </td>
732           <td> optional, default content is shown with no JavaScript </td>
733         </tr>
734       </table>
735     </li>
736     <li> Example: <code>%TWISTYTOGGLE{id="demo" mode="div" remember="on"}%My content%ENDTWISTYTOGGLE%</code></li>
737     <li> Related: [[Main/WebHome#VarTWISTYHIDE]], [[Main/WebHome#VarTWISTYHIDE]] an [[Main/WebHome#VarENDTWISTYTOGGLE]]</li>
738   </ul>
739   <p><a name="VarENDTWISTYTOGGLE"></a></p>
740   <h3><a name="ENDTWISTYTOGGLE"></a> ENDTWISTYTOGGLE </h3><strong>The Twisty closure</strong><ul>
741     <li> Syntax: <code>%ENDTWISTYTOGGLE%</code><ul>
742         <li> Will end the most inner unclosed Twisty Toggle section, using the proper tag </li>
743       </ul>
744     </li>
745     <li> Example: <code>%ENDTWISTYTOGGLE%</code></li>
746     <li> Related: [[Main/WebHome#VarTWISTYTOGGLE]]</li>
747   </ul>
748 </div>
749
750 ## <a name="The Fine Print"></a> The Fine Print
751
752 TwistyPlugin is a convenience plugin for TWiki:Plugins.TwistyContrib.
753
754 Major features are:
755
756 - When active, the Twisty JavaScript library is included in every topic
757 - Provides a convenience syntax to define Twisty areas
758 - Automatically generates ids
759 - Automatically fills in default values
760 - Global preference settings can be set in this topic or locally in individual topics
761
762 <a name="PluginSettings"></a>
763
764 ## <a name="Plugin Settings"></a> Plugin Settings
765
766 Plugin settings are stored as preferences variables. To reference a plugin setting write <code>**%&lt;plugin&gt;\_&lt;setting&gt;%**</code>, i.e. <code>**%TWISTYPLUGIN\_SHORTDESCRIPTION%**</code>
767
768 - Set TWISTYSHOWLINK = More...
769   - For example: `More...`
770 - Set TWISTYHIDELINK = Close
771   - For example: `Close`
772 - Set TWISTYMODE =
773   - Either `div` or `span`; `span` if nothing set
774 - Set TWISTYREMEMBER =
775   - Either `on` or `off`; default is not specified. If set to `on` all Twisty states will be stored in a TWIKIPREF cookie; if set to `off` the TWIKIPREF cookie will be cleared
776
777 - Set SHORTDESCRIPTION = Twisty section JavaScript library to open/close content dynamically
778 - Set DEBUG = 0
779
780 ## <a name="Plugin Installation Instructions"></a> Plugin Installation Instructions
781
782 - Download the ZIP file from the Plugin web (see below)
783 - Unzip <code>**%TOPIC%.zip**</code> in your root ($TWIKI\_ROOT) directory. Content: <table border="1" cellpadding="0" cellspacing="0">
784   <tr>
785     <th bgcolor="#99CCCC"><strong> File: </strong></th>
786     <th bgcolor="#99CCCC"><strong> Description: </strong></th>
787   </tr>
788   <tr>
789     <td><code><b>TwistyBundleTWiki04x02_installer</b></code></td>
790     <td>   </td>
791   </tr>
792   <tr>
793     <td><code><b>TwistyBundleTWiki04x02_installer.pl</b></code></td>
794     <td>   </td>
795   </tr>
796   <tr>
797     <td><code><b>data/TWiki/TwistyBundleTWiki04x02.txt</b></code></td>
798     <td>   </td>
799   </tr>
800   <tr>
801     <td><code><b>data/TWiki/BehaviourContrib.txt</b></code></td>
802     <td>   </td>
803   </tr>
804   <tr>
805     <td><code><b>data/TWiki/TwistyContrib.txt</b></code></td>
806     <td>   </td>
807   </tr>
808   <tr>
809     <td><code><b>data/TWiki/TwistyPlugin.txt</b></code></td>
810     <td>   </td>
811   </tr>
812   <tr>
813     <td><code><b>lib/TWiki/Contrib/BehaviourContrib.pm</b></code></td>
814     <td>   </td>
815   </tr>
816   <tr>
817     <td><code><b>lib/TWiki/Contrib/TwistyBundleTWiki04x02.pm</b></code></td>
818     <td>   </td>
819   </tr>
820   <tr>
821     <td><code><b>lib/TWiki/Contrib/TwistyContrib.pm</b></code></td>
822     <td>   </td>
823   </tr>
824   <tr>
825     <td><code><b>lib/TWiki/Plugins/TwistyPlugin.pm</b></code></td>
826     <td>   </td>
827   </tr>
828   <tr>
829     <td><code><b>pub/TWiki/BehaviourContrib/behaviour.compressed.js</b></code></td>
830     <td>   </td>
831   </tr>
832   <tr>
833     <td><code><b>pub/TWiki/BehaviourContrib/behaviour.compressed_src.js</b></code></td>
834     <td>   </td>
835   </tr>
836   <tr>
837     <td><code><b>pub/TWiki/BehaviourContrib/behaviour.js</b></code></td>
838     <td>   </td>
839   </tr>
840   <tr>
841     <td><code><b>pub/TWiki/BehaviourContrib/behaviour_src.js</b></code></td>
842     <td>   </td>
843   </tr>
844   <tr>
845     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/cssQuery-p.js</b></code></td>
846     <td>   </td>
847   </tr>
848   <tr>
849     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/src/cssQuery-level2.js</b></code></td>
850     <td>   </td>
851   </tr>
852   <tr>
853     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/src/cssQuery-level3.js</b></code></td>
854     <td>   </td>
855   </tr>
856   <tr>
857     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/src/cssQuery-standard.js</b></code></td>
858     <td>   </td>
859   </tr>
860   <tr>
861     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/src/cssQuery.js</b></code></td>
862     <td>   </td>
863   </tr>
864   <tr>
865     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/src/test.html</b></code></td>
866     <td>   </td>
867   </tr>
868   <tr>
869     <td><code><b>pub/TWiki/BehaviourContrib/cssQuery/test.html</b></code></td>
870     <td>   </td>
871   </tr>
872   <tr>
873     <td><code><b>pub/TWiki/TwistyContrib/twist.compressed.js</b></code></td>
874     <td>   </td>
875   </tr>
876   <tr>
877     <td><code><b>pub/TWiki/TwistyContrib/twist.compressed_src.js</b></code></td>
878     <td>   </td>
879   </tr>
880   <tr>
881     <td><code><b>pub/TWiki/TwistyContrib/twist.css</b></code></td>
882     <td>   </td>
883   </tr>
884   <tr>
885     <td><code><b>pub/TWiki/TwistyContrib/twist.js</b></code></td>
886     <td>   </td>
887   </tr>
888   <tr>
889     <td><code><b>pub/TWiki/TwistyContrib/twist_src.js</b></code></td>
890     <td>   </td>
891   </tr>
892 </table>
893
894 - Optionally, if it exists, run <code>**%TOPIC%\_installer**</code> to automatically check and install other TWiki modules that this module depends on. You can also do this step manually.
895 - Alternatively, manually make sure the dependencies listed in the table below are resolved. None
896 - Visit `configure` in your TWiki installation, and enable the plugin in the \{Plugins\} section.
897
898 ## <a name="Plugin Info"></a> Plugin Info
899
900 <table border="1" cellpadding="0" cellspacing="0">
901   <tr>
902     <td align="right"> Authors: </td>
903     <td> TWiki:Main.RafaelAlvarez, TWiki:Main.ArthurClemens </td>
904   </tr>
905   <tr>
906     <td align="right"> Copyright ©: </td>
907     <td> 2005 Rafael Alvarez; 2006, 2007 Arthur Clemens </td>
908   </tr>
909   <tr>
910     <td align="right"> License: </td>
911     <td><a href="http://www.gnu.org/copyleft/gpl.html" target="_top">GPL</a></td>
912   </tr>
913   <tr>
914     <td align="right"> Dependencies: </td>
915     <td> None </td>
916   </tr>
917   <tr>
918     <td align="right"> Plugin Version: </td>
919     <td> 03 Aug 2008 (version 1.4.10) </td>
920   </tr>
921   <tr>
922     <td align="right"> Change History: </td>
923     <td>  </td>
924   </tr>
925   <tr>
926     <td align="right"> 03 Aug 2008 </td>
927     <td> 1.4.10 TWiki 4.2.1 release version </td>
928   </tr>
929   <tr>
930     <td align="right"> 13 Dec 2007 </td>
931     <td> 1.4.9 fix to the loading order of javascript files in head </td>
932   </tr>
933   <tr>
934     <td align="right"> 24 Nov 2007 </td>
935     <td> 1.4.6 - 1.4.8 Arthur Clemens - Added format tokens. </td>
936   </tr>
937   <tr>
938     <td align="right"> 07 Oct 2007 </td>
939     <td> 1.4.5 Arthur Clemens - Fix html tag with show/hide controls. </td>
940   </tr>
941   <tr>
942     <td align="right"> 25 Sep 2007 </td>
943     <td> 1.4.4 Arthur Clemens - Fix rendering of headers when <code>prefix</code> is used. </td>
944   </tr>
945   <tr>
946     <td align="right"> 11 Jul 2007 </td>
947     <td> 1.4.3 Arthur Clemens - Fix invalid html when <code>prefix</code> and <code>suffix</code> is used. </td>
948   </tr>
949   <tr>
950     <td align="right"> 23 Jun 2007 </td>
951     <td> 1.4.2 Arthur Clemens - Fixed bugs with parameters <code>firststart</code> and <code>noscript</code> (since version 1.4). </td>
952   </tr>
953   <tr>
954     <td align="right"> 20 Jun 2007 </td>
955     <td> 1.4 Arthur Clemens - Updated to work without ugly inserted javascript 'init' calls. This will change nothing to the functionality, but it will produce cleaner HTML, while at the same time the twisty is still set immediately (not at page onload) and graceful fallback in case of no javascript is maintained. </td>
956   </tr>
957   <tr>
958     <td align="right"> 19 Jun 2006 </td>
959     <td> 1.3 Arthur Clemens - Updated with TWiki 4 JavaScript files. </td>
960   </tr>
961   <tr>
962     <td align="right"> 25 Oct 2006 </td>
963     <td> 1.2 New variables to set default values: <code>TWISTYSHOWLINK</code>, <code>TWISTYHIDELINK</code>, <code>TWISTYMODE</code>, <code>TWISTYREMEMBER</code>; property <code>id</code> is no longer required as this is automatically set (still recommended in some cases with <code>remember="on"</code>); property value <code>remember="off"</code> will clear a previously stored cookie; new properties <code>prefix</code> and <code>suffix</code>; JavaScript to collapse or expand all Twisties on the page. </td>
964   </tr>
965   <tr>
966     <td align="right"> 27 Sep 2006 </td>
967     <td> 1.101 Fixes JavaScript handling when AllowInlineScript in configure is not set </td>
968   </tr>
969   <tr>
970     <td align="right"> 11 June 2006 </td>
971     <td> 1.100 Added parameters <code>start</code>, <code>firststart</code>, <code>noscript</code> and <code>class</code>; complete JavaScript rewrite for speed </td>
972   </tr>
973   <tr>
974     <td align="right"> 12 Sep 2005 </td>
975     <td> 1.000 First Version </td>
976   </tr>
977   <tr>
978     <td align="right"> Home: </td>
979     <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%</a></td>
980   </tr>
981   <tr>
982     <td align="right"> Feedback: </td>
983     <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev</a></td>
984   </tr>
985   <tr>
986     <td align="right"> Appraisal: </td>
987     <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal</a></td>
988   </tr>
989 </table>