-
Notifications
You must be signed in to change notification settings - Fork 38
/
TwistyPlugin.txt
623 lines (504 loc) · 26.5 KB
/
TwistyPlugin.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
%META:TOPICINFO{author="ProjectContributor" date="1195487956" format="1.1" version="1.1"}%
---+!! <nop>%TOPIC%
*A "twisty" is an interface toggle control to show and hide content.*
!TwistyPlugin gives you several options to control the appearance of a twisty:
* use link text or buttons
* position an icon left or right
* remember the state at the next visit of the page
* start the Twisty open or closed
* start the Twisty open or closed for the first visit
* use a span or div for the content
* set a class for the content span or div
Twisty has a fallback mechanism in case !JavaScript is not available: all content is displayed and the control buttons are hidden.
%TOC{title="On this page:"}%
---++ Usage examples
---+++ Triad
A Twisty consists of 3 elements:
1 Show button
1 Hide button
1 Collapsing content ('Toggle')
The typical !TwistyPlugin triad will look like this (pseudo code):
<verbatim>
%TWISTYSHOW{}% %TWISTYHIDE{}%
(there may be other things between buttons and content)
%TWISTYTOGGLE{}% my content %ENDTWISTYTOGGLE%
</verbatim>
---+++ Shorthand
The Twisty triad is conveniently packed into shorthand =%<nop>TWISTY{some parameters}% Collapsing content %<nop>ENDTWISTY%=:
<verbatim>
%TWISTY{}%
my twisty content
%ENDTWISTY%
</verbatim>
Will generate:
%TWISTY{}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
You may have noticed that no parameters are passed to =%<nop>TWISTY{}%= but the show and hide links _do_ have text! The default values are fetched from plugin settings =TWISTYSHOWLINK= and =TWISTYHIDELINK=, see [[#PluginSettings][Plugin Settings]] below.
---+++ Twisty with icons
We will use =mode="div"= to put the collapsing content below the button (the default mode is ="span"=).
<verbatim>
%TWISTY{
mode="div"
showlink="Show..."
hidelink="Hide"
showimgleft="%ICONURLPATH{toggleopen-small}%"
hideimgleft="%ICONURLPATH{toggleclose-small}%"
}%
my twisty content
%ENDTWISTY%
</verbatim>
It will look like this:
%TWISTY{
mode="div"
showlink="Show..."
hidelink="Hide"
showimgleft="%ICONURLPATH{toggleopen-small}%"
hideimgleft="%ICONURLPATH{toggleclose-small}%"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
To put icons at the right side, write
<verbatim>
%TWISTY{
mode="div"
showlink="Show "
hidelink="Hide "
showimgright="%ICONURLPATH{toggleopen-small}%"
hideimgright="%ICONURLPATH{toggleclose-small}%"
}%
my twisty content
%ENDTWISTY%
</verbatim>
%TWISTY{
mode="div"
showlink="Show "
hidelink="Hide "
showimgright="%ICONURLPATH{toggleopen-small}%"
hideimgright="%ICONURLPATH{toggleclose-small}%"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
---+++ Make it remember
To store the last state in a FOSWIKIPREF cookie, add the parameter =remember="on"=.%BR%
To test this, reload the page after toggling.
<verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
remember="on"
}%
my twisty content
%ENDTWISTY%
</verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
remember="on"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
If a Twisty state has been stored in a FOSWIKIPREF cookie before, it can be cleared by using =remember="off"=:
<verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
remember="off"
}%
my twisty content
%ENDTWISTY%
</verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
remember="off"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
*NOTE:* Twisty ids are generated automatically. If you need control over exactly _which_ Twisty should be remembered, add the parameter =id=:
<verbatim>
%TWISTY{
id="currentCustomerList"
showlink="Show..."
hidelink="Hide"
remember="on"
}%
my customer list
%ENDTWISTY%
</verbatim>
Note that =id= sets a sitewide cookie. To create a unique id, add topic or web macros:
<verbatim>
id="%WEB%_%TOPIC%_currentCustomerList"
</verbatim>
---+++ Make it obey
To let the Twisty start with its content folded open, add parameter =start="show"=.
<verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
start="show"
}%
my twisty content
%ENDTWISTY%
</verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
start="show"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
Likewise use =start="hide"= to start with hidden content.
<verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
start="hide"
}%
my twisty content
%ENDTWISTY%
</verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
start="hide"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
---+++ Make it obey only the first time
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.
<verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
firststart="show"
}%
my twisty content
%ENDTWISTY%
</verbatim>
%TWISTY{
showlink="Show..."
hidelink="Hide"
firststart="show"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
---+++ Other use: hide interface parts in case of no !JavaScript
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.
Put the "JavaScript content" in an almost bare bones Twisty. Write =showlink="" hidelink=""= to not display any default link texts.
<verbatim>
%TWISTY{
link=""
noscript="hide"
start="show"
}%
<input type="submit" class="foswikiButton" value="You surely have !JavaScript" />
%ENDTWISTY%
</verbatim>
%TWISTY{
link=""
noscript="hide"
start="show"
}%
<input type="submit" class="foswikiButton" value="You surely have !JavaScript" />
%ENDTWISTY%
Do not forget to set =start="show"= to show the Twisty content at all.
When !JavaScript is off, the button should be invisible.
This code will show the button when !JavaScript is off:
<verbatim>
%TWISTY{
link=""
start="show"
}%
<input type="submit" class="foswikiButton" value="You might have !JavaScript" />
%ENDTWISTY%
</verbatim>
%TWISTY{
link=""
start="show"
}%
<input type="submit" class="foswikiButton" value="You might have !JavaScript" />
%ENDTWISTY%
---+++ Styling the Twisty
Use parameter =class= to style the content div or class:
<verbatim>
%TWISTY{
mode="div"
showlink="Show..."
hidelink="Hide"
class="foswikiHelp"
}%
my twisty content
%ENDTWISTY%
</verbatim>
Generates: %BR%
%TWISTY{
mode="div"
showlink="Show..."
hidelink="Hide"
class="foswikiHelp"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
---+++ Styling the Twisty link or button
Use parameter =linkclass= to style the twisty links:
<verbatim>
%TWISTY{
mode="div"
showlink="Show..."
hidelink="Hide"
linkclass="foswikiButton"
}%
my twisty content
%ENDTWISTY%
</verbatim>
Generates: %BR%
%TWISTY{
mode="div"
showlink="Show..."
hidelink="Hide"
linkclass="foswikiButton"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
---+++ Twisty headers
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=.
<verbatim>
%TWISTY{
prefix="<h4>"
mode="div"
link="Twisty Header"
showimgleft="%ICONURLPATH{toggleopen}%"
hideimgleft="%ICONURLPATH{toggleclose}%"
suffix="</h4>"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
</verbatim>
Will create:
%TWISTY{
prefix="<h4>"
mode="div"
link="Twisty Header"
showimgleft="%ICONURLPATH{toggleopen}%"
hideimgleft="%ICONURLPATH{toggleclose}%"
suffix="</h4>"
}%
%GREEN% my twisty content %ENDCOLOR%
%ENDTWISTY%
---+++ All on, all off
You can toggle all Twisties on or off at once by putting a link or button on the page with class =twistyExpandAll= or =twistyCollapseAll=.
<verbatim>
<button class="twistyExpandAll foswikiButton">Expand all</button> <button class="twistyCollapseAll foswikiButton">Collapse all</button>
</verbatim>
Creates these controls:
<button class="twistyExpandAll foswikiButton">Expand all</button>
<button class="twistyCollapseAll foswikiButton">Collapse all</button>
When you want to use links, write:
<verbatim>
#VarTOGGLE
<a href="#TOGGLE" class="twistyExpandAll">Expand all</a>
<a href="#TOGGLE" class="twistyCollapseAll">Collapse all</a>
</verbatim>
#VarTOGGLE
<a href="#TOGGLE" class="twistyExpandAll">Expand all</a>
<a href="#TOGGLE" class="twistyCollapseAll">Collapse all</a>
---++ Special syntax: format tokens
If you use other macros inside TWISTY parameters chances are it will mess up the macro, or the rendered html. Use format tokens to 'delay' rendering of these variables until the Twisty parameters are parsed.
The format tokens are the same as with %SYSTEMWEB%.FormattedSearch:
| *Escape:* | *Expands To:* |
| =$n= or =$n()= | New line. Use =$n()= if followed by alphanumeric character, e.g. write =Foo$n()Bar= instead of =Foo$nBar= |
| =$nop= or =$nop()= | Is a "no operation". |
| =$quot= | Double quote (="=) |
| =$percnt= | Percent sign (=%=) |
| =$dollar= | Dollar sign (=$=) |
For example, to show an icon inside the link, do not write:
<verbatim>
link="%Y%"
</verbatim>
but use format tokens:
<verbatim>
link="$percntY$percnt"
</verbatim>
... to get:
%TWISTY{
mode="div"
link="$percntY$percnt"
showimgleft="%ICONURLPATH{toggleopen-small}%"
hideimgleft="%ICONURLPATH{toggleclose-small}%"
}%
my twisty content
%ENDTWISTY%
Or a more complex example using %SYSTEMWEB%.SpreadSheetPlugin; do not write:
<verbatim>
link="Count: (%CALC{"$GET(infoCount)"}%)"
</verbatim>
but use format tokens:
<verbatim>
link="Count: ($percntCALC{$quot$dollarGET(infoCount)$quot}$percnt)"
</verbatim>
---++ Syntax
#VarTWISTY
---+++ TWISTY
This renders the button as well as the toggled content section contained within this and the closing ENDTWISTY tag. %BR%
Usage: =%<nop>TWISTY{ ... }% Toggable contents %<nop>ENDTWISTY%=
| *Parameter* | *Value* | *Description* | *Remark* |
| =id= | Unique identifier | Used to link [[#VarTWISTYBUTTON][TWISTYBUTTON]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]] | optional |
| =link= | Link label | Link label for both show and hide links | optional |
| =hidelink= | Link label | Hide link label | optional |
| =showlink= | Link label | Show link label | optional |
| =mode= | ="div"= or ="span"= | Specify if the Twisty Toggle section will use a =<div>= or a =<span>= tag. Note that if the contents contains block elements such as =div=, =mode= should be =div= as well to create valid HTML markup. | optional, defaults to =<span>= |
| =showimgleft= | Image url | 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 [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =hideimgleft= | Image url | 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 [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =showimgright= | Image url | 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 [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =hideimgright= | Image url | 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 [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =remember= | ="on"=, ="off"= | If ="on"=, the Twisty state is remembered the next time the page is shown. If ="off"=, the stored setting will be cleared.<br /> *Note:* 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. | optional, no default |
| =start= | ="hide"= or ="show"= | Initial state of the Twisty; this will override any setting stored in a cookie (see =remember=). | optional, default no initial state |
| =firststart= | ="hide"= or ="show"= | Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see =remember=). | optional, default no initial state |
| =noscript= | ="hide"= | Make content hidden in case use does not have !JavaScript on | optional, default content is shown in case !JavaScript if off |
| =class= | CSS class name | Class for Twisty div or span | optional, default none |
| =linkclass= | CSS class name | Class for link | optional, default none |
| =prefix= | Text | Text to display before the show/hide links | optional, default none |
| =suffix= | Text | Text to display after the show/hide links | optional, default none |
| =img= | Image url | %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% | optional, defaults to no image |
| =imgleft= | Image url | %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% | optional, defaults to no image |
| =imgright= | Image url | %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% | optional, defaults to no image |
| =hideimg= | Image url | %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% | optional, defaults to no image |
| =showimg= | Image url | %GREEN%Deprecated, use showimgleft, hideimgleft, showimgright or hideimgright.%ENDCOLOR% | optional, defaults to no image |
* Related [[#VarTWISTYSHOW][TWISTYBUTTON]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]
#VarENDTWISTY
---+++ ENDTWISTY
*Twisty closure, complements the opening TWISTY tag.*
* Syntax: =%<nop>ENDTWISTY%=
See [[#VarENDTWISTYTOGGLE][ENDTWISTYTOGGLE]].
---++ Twisty components syntax
<div style="background-color:#eee; padding:.5em; margin:-.5em;">
Ocassionally you might need to create a custom set of individual Twisty components:
#VarTWISTYBUTTON
---+++ TWISTYBUTTON
*Shorthand version for TWISTYSHOW & TWISTYHIDE*
This is useful if both the show and the hide button take the same arguments.
* Supported parameters: all parameters supported by [[#VarTWISTYSHOW][TWISTY]], except for =noscript= and =class= (only used for 'toggle' content)
* Parameter differences:
* =mode=: button mode defaults to span
* Syntax: =%<nop>TWISTYBUTTON{id="myid" ... }%=
* Supported parameters:
| *Parameter* | *Value* | *Description* | *Remark* |
| =mode= | ="div"= or ="span"= | Specify if the *Twisty button* will use a =<div>= or a =<span>= tag. Note that if the contents contains block elements such as =div=, =mode= should be =div= as well to create valid HTML markup. | optional, defaults to =<span>= |
* Example: =%<nop>TWISTYBUTTON{id="myid" link="more"}%%<nop>TWISTYTOGGLE{id="myid"}%content%<nop>ENDTWISTYTOGGLE%=
* Related: [[#VarTWISTYSHOW][TWISTYSHOW]] and [[#VarTWISTYHIDE][TWISTYHIDE]]
#VarTWISTYSHOW
---+++ TWISTYSHOW
*Show/open link*
* Syntax: =%<nop>TWISTYSHOW{id="myid" ... }%=
* Supported parameters:
| *Parameter* | *Value* | *Description* | *Remark* |
| =id= | Unique identifier | Used to link [[#VarTWISTYSHOW][TWISTYSHOW]], [[#VarTWISTYHIDE ][TWISTYHIDE ]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]] | required |
| =link= | Link label | Show link label | optional |
| =mode= | ="div"= or ="span"= | Specify if the Twisty Show link will use a =<div>= or a =<span>= tag. Note that if the contents contains block elements such as =div=, =mode= should be =div= as well to create valid HTML markup. | optional, defaults to =<span>= |
| =img= | Image url | Specify the url of an image that will be displayed at the *right side* of the link. <br />You may use [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =imgleft=| Image url | Specify the url of an image that will be displayed at the left side of the link. <br />You may use [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =imgright= | Image url | Specify the url of an image that will be displayed at the right side of the link. <br />You may use [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =remember= | ="on"=, ="off"= | If ="on"=, the Twisty state is remembered the next time the page is shown. If ="off"=, the stored setting will be cleared.<br /> *Note:* 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. | optional, no default |
| =start= | ="hide"= or ="show"= | Initial state of the Twisty; this will override any setting stored in a cookie (see =remember=). | optional, default no initial state |
| =firststart= | ="hide"= or ="show"= | Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see =remember=). | optional, default no initial state |
* Example: =%<nop>TWISTYSHOW{id="demo" link=" Click to Unfold " imgleft="%<nop>ICONURLPATH{toggleopen}%"}%=
* Related: [[#VarTWISTYHIDE][TWISTYHIDE]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]
#VarTWISTYHIDE
---+++ TWISTYHIDE
*Hide/close link*
* Syntax: =%<nop>TWISTYHIDE{id="myid" ... }%=
* Supported parameters:
| *Parameter* | *Value* | *Description* | *Remark* |
| =id= | Unique identifier | Used to link [[#VarTWISTYSHOW][TWISTYSHOW]], [[#VarTWISTYHIDE ][TWISTYHIDE ]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]] | required |
| =link= | Link label | Hide link label | optional |
| =mode= | ="div"= or ="span"= | Specify if the Twisty Hide link will use a =<div>= or a =<span>= tag. Note that if the contents contains block elements such as =div=, =mode= should be =div= as well to create valid HTML markup. | optional, defaults to =<span>= |
| =img= | Image url | Specify the url of an image that will be displayed at the *right side* of the link. <br />You may use [[%SYSTEMWEB%.Macros#VarICONURLPATH][ICONURLPATH]] to display one of the %SYSTEMWEB%.DocumentGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
| =remember= | ="on"=, ="off"= | If ="on"=, the Twisty state is remembered the next time the page is shown. If ="off"=, the stored setting will be cleared.<br /> *Note:* 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. | optional, no default |
| =start= | ="hide"= or ="show"= | Initial state of the Twisty; this will override any setting stored in a cookie (see =remember=). | optional, default no initial state |
| =firststart= | ="hide"= or ="show"= | Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see =remember=). | optional, default no initial state |
* Example: =%<nop>TWISTYHIDE{id="demo" link=" Click to Fold " imgleft="%<nop>ICONURLPATH{toggleclose}%"}%=
* Related: [[#VarTWISTYSHOW][TWISTYSHOW]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]
#VarTWISTYTOGGLE
---+++ TWISTYTOGGLE
*Twisty Toggle contents section*
* Syntax: =%<nop>TWISTYTOGGLE{id="myid"}%=
* Supported parameters:
| *Parameter* | *Value* | *Description* | *Remark* |
| =id= | Unique identifier | Used to link [[#VarTWISTYSHOW][TWISTYSHOW]], [[#VarTWISTYHIDE ][TWISTYHIDE ]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]. | required |
| =mode= | ="div"= or ="span"= | Specify if the Twisty Toggle section will use a =<div>= or a =<span>= tag. Note that if the contents contains block elements such as =div=, =mode= should be =div= as well to create valid HTML markup. | optional, defaults to =<span>= |
| =class= | CSS class name | Class for content div or span | optional, default none |
| =linkclass= | CSS class name | Class for link | optional, default none |
| =remember= | ="on"=, ="off"= | If ="on"=, the Twisty state is remembered the next time the page is shown. If ="off"=, the stored setting will be cleared.<br /> *Note:* 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. | optional, no default |
| =start= | ="hide"= or ="show"= | Initial state of the Twisty; this will override any setting stored in a cookie (see =remember=). | optional, default no initial state |
| =firststart= | ="hide"= or ="show"= | Initial state of the Twisty the first time the visitor gets to see the Twisty; this will NOT override cookie settings (see =remember=). | optional, default no initial state |
| =noscript= | ="hide"= | Make content hidden in case use does not have !JavaScript on | optional, default content is shown with no !JavaScript |
* Example: =%<nop>TWISTYTOGGLE{id="demo" mode="div" remember="on"}%My content%<nop>ENDTWISTYTOGGLE%=
* Related: [[#VarTWISTYHIDE][TWISTYHIDE]], [[#VarTWISTYHIDE][TWISTYHIDE]] an [[#VarENDTWISTYTOGGLE][ENDTWISTYTOGGLE]]
#VarENDTWISTYTOGGLE
---+++ ENDTWISTYTOGGLE
*The Twisty closure*
* Syntax: =%<nop>ENDTWISTYTOGGLE%=
* Will end the most inner unclosed Twisty Toggle section, using the proper tag
* Example: =%<nop>ENDTWISTYTOGGLE%=
* Related: [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]
</div>
---++ Working with other Javascript libraries
If you want to use a different Javascript library than the default Foswiki Javascripts, add to the skin path:
* =jquery= to use [[http://jquery.com/][JQuery]]
* For example, append to the url: =?skin=jquery,nat= %BR%
or write: =Set SKIN = jquery,nat=
* For this, Foswiki:Extensions/JQueryPlugin needs to be installed
* =dojo= to use [[http://jquery.com/][JQuery]]
* For example, append to the url: =?skin=dojo,pattern= %BR%
or write: =Set SKIN = dojo,pattern=
* For this, Foswiki:Extensions/DojoToolkitContrib needs to be installed
#PluginSettings
---++ Plugin Settings
Plugin settings are stored as [[%SYSTEMWEB%.PreferenceSettings][preference settings]]. To reference
a plugin setting write ==%<nop><plugin>_<setting>%==, i.e. ==%<nop>TWISTYPLUGIN_SHORTDESCRIPTION%==
* Set TWISTYSHOWLINK = %MAKETEXT{"More..."}%
* For example: =More...=
* Set TWISTYHIDELINK = %MAKETEXT{"Close"}%
* For example: =Close=
* Set TWISTYMODE =
* Either =div= or =span=; =span= if nothing set
* Set TWISTYREMEMBER =
* Either =on= or =off=; default is not specified. If set to =on= all Twisty states will be stored in a FOSWIKIPREF cookie; if set to =off= the FOSWIKIPREF cookie will be cleared
* Set SHORTDESCRIPTION = Twisty section !JavaScript library to open/close content dynamically
* Set DEBUG = 0
---++ Plugin Installation Instructions
* Download the ZIP file from the Plugin web (see below)
* Unzip it in your Foswiki installation directory. Content:
| *File:* | *Description:* |
%$MANIFEST%
* Optionally, if it exists, run ==%TOPIC%_installer== to automatically check and install other Foswiki modules that this module depends on. You can also do this step manually.
* Alternatively, manually make sure the dependencies listed in the table below are resolved.
%$DEPENDECIES%
* Visit =configure= in your Foswiki installation, and enable the plugin in the {Plugins} section.
---++ Plugin Info
| Authors: | Foswiki:Main.RafaelAlvarez, Foswiki:Main.MichaelDaum, Foswiki:Main.ArthurClemens |
| Copyright | Copyright (C) Rafael Alvarez; Michael Daum, Arthur Clemens |
| License: | [[http://www.gnu.org/copyleft/gpl.html][GPL]] |
| Plugin Version: | 29 Jan 2009 (version 1.5.2) |
| Change History: | <!-- versions below in reverse order --> |
| 03 Dec 2008 | 1.5.1 Added parameter =linkclass=. Foswiki version |
| 27 Nov 2008 | 1.5 Foswiki release; added option to use other Javascript libraries. |
| 08 Oct 2008 | 1.4.11, 1.4.12 It is now possible to have a twisty on the same line without a linebreak. |
| 03 Aug 2008 | 1.4.10 TWiki 4.2.1 release version |
| 13 Dec 2007 | 1.4.9 fix to the loading order of javascript files in head |
| 24 Nov 2007 | 1.4.6 - 1.4.8 Arthur Clemens - Added format tokens. |
| 07 Oct 2007 | 1.4.5 Arthur Clemens - Fix html tag with show/hide controls. |
| 25 Sep 2007 | 1.4.4 Arthur Clemens - Fix rendering of headers when =prefix= is used. |
| 11 Jul 2007 | 1.4.3 Arthur Clemens - Fix invalid html when =prefix= and =suffix= is used. |
| 23 Jun 2007 | 1.4.2 Arthur Clemens - Fixed bugs with parameters =firststart= and =noscript= (since version 1.4). |
| 20 Jun 2007 | 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. |
| 19 Jun 2006 | 1.3 Arthur Clemens - Updated with TWiki 4 !JavaScript files. |
| 25 Oct 2006 | 1.2 New variables to set default values: =TWISTYSHOWLINK=, =TWISTYHIDELINK=, =TWISTYMODE=, =TWISTYREMEMBER=; property =id= is no longer required as this is automatically set (still recommended in some cases with =remember="on"=); property value =remember="off"= will clear a previously stored cookie; new properties =prefix= and =suffix=; !JavaScript to collapse or expand all Twisties on the page. |
| 27 Sep 2006 | 1.101 Fixes !JavaScript handling when !AllowInlineScript in configure is not set |
| 11 June 2006 | 1.100 Added parameters =start=, =firststart=, =noscript= and =class=; complete !JavaScript rewrite for speed |
| 12 Sep 2005 | 1.000 First Version |
| Dependencies: | None |
| Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% |