Index: lib/TWiki/Plugins/TwistyPlugin.pm
===================================================================
--- lib/TWiki/Plugins/TwistyPlugin.pm (revision 7622)
+++ lib/TWiki/Plugins/TwistyPlugin.pm (working copy)
@@ -69,6 +69,9 @@
TWiki::Func::addToHEAD('TWISTYPLUGIN_TWISTY',$header);
TWiki::Func::registerTagHandler('TWISTYSHOW',\&_TWISTYSHOW);
TWiki::Func::registerTagHandler('TWISTYHIDE',\&_TWISTYHIDE);
+ TWiki::Func::registerTagHandler('TWISTYBUTTON',\&_TWISTYBUTTON);
+ TWiki::Func::registerTagHandler('TWISTY',\&_TWISTY);
+ TWiki::Func::registerTagHandler('ENDTWISTY',\&_ENDTWISTYTOGGLE);
TWiki::Func::registerTagHandler('TWISTYTOGGLE',\&_TWISTYTOGGLE);
TWiki::Func::registerTagHandler('ENDTWISTYTOGGLE',\&_ENDTWISTYTOGGLE);
@@ -77,25 +80,25 @@
sub _TWISTYSHOW {
- return _TWISTYBUTTON(@_, 'show');
+ return _twistyImpl(@_, 'show');
}
sub _TWISTYHIDE {
- return _TWISTYBUTTON(@_, 'hide');
+ return _twistyImpl(@_, 'hide');
}
sub _TWISTYBUTTON {
- my($session, $params, $theTopic, $theWeb, $theState) = @_;
- my $id=$params->{'id'}||'';
- my $link=$params->{'link'}||'';
- my $mode=$params->{'mode'}||'span';
- my $img=$params->{'img'} || '';
- $img =~ s/['\"]//go;
- my $imgTag=($img ne '') ? '
' : '';
- my $initialHidden=($theState eq 'hide') ? 'twistyHidden ' : '';
- return '<'.$mode.' id="'.$id.$theState.'" class="'.$initialHidden.'twistyMakeVisible">'.$link.''.$imgTag.''.$mode.'>';
+ return
+ '' . # fixes "jumpy" links in some browsers
+ _twistyImpl(@_, 'show') .
+ _twistyImpl(@_, 'hide') .
+ '';
}
+sub _TWISTY {
+ return _TWISTYBUTTON(@_) . _TWISTYTOGGLE(@_);
+}
+
sub _TWISTYTOGGLE {
my($session, $params, $theTopic, $theWeb) = @_;
my $id=$params->{'id'}||'';
@@ -109,8 +112,21 @@
sub _ENDTWISTYTOGGLE {
my($session, $params, $theTopic, $theWeb) = @_;
my $mode=shift @modes;
- return ''.$mode.'>';
+ return ''.$mode.'>' if $mode;
}
+sub _twistyImpl {
+ my($session, $params, $theTopic, $theWeb, $theState) = @_;
+ my $id = $params->{'id'} || '';
+ my $link = $params->{$theState.'link'} || $params->{'link'} || '';
+ my $mode = $params->{'buttonmode'} || $params->{'mode'} || 'span';
+ my $img = $params->{$theState.'img'} || $params->{'img'} || '';
+ $img =~ s/['\"]//go;
+ my $imgTag = ($img ne '') ? '
' : '';
+ my $initialHidden = ($theState eq 'hide') ? 'twistyHidden ' : '';
+ return '<'.$mode.' id="'.$id.$theState.'" class="'.$initialHidden.'twistyMakeVisible">'.$link.''.$imgTag.''.$mode.'>';
+}
+
+
1;
Index: data/TWiki/TwistyPlugin.txt
===================================================================
--- data/TWiki/TwistyPlugin.txt (revision 7622)
+++ data/TWiki/TwistyPlugin.txt (working copy)
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="RafaelAlvarez" date="1126488524" format="1.1" version="1.2"}%
+%META:TOPICINFO{author="MichaelDaum" date="1130850299" format="1.1" version="1.2"}%
---+!! %TOPIC%
%TOC%
@@ -18,11 +18,11 @@
#VarTWISTYSHOW
---+++ TWISTYSHOW
*Show/open link*
- * Syntax: =%TWISTYSHOW{id="myid" link="Link Text"}%=
+ * Syntax: =%TWISTYSHOW{id="myid" ... }%=
* Supported parameters:
| *Parameter* | *Description* | *Value* |
| =id= | Unique identifier. Used to link [[#VarTWISTYSHOW][TWISTYSHOW]], [[#VarTWISTYHIDE ][TWISTYHIDE ]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]] | required |
- | =link="Link Text"= | The text to be used in the Twisty Show link | required |
+ | =link="Link Text"= | The text to be used in the Twisty Show link | optional |
| =mode="div/span"= | Specify if the Twisty Show link will use a =<div>= or a =<span>= tag | optional, defaults to =<span>= |
| =img="image url"= | Specify the url of an image that will be displayed at the right side of the link.
You may use [[%TWIKIWEB%.TWikiVariables#VarICONPATH][ICONPATH]] to display one of the %TWIKIWEB%.TWikiDocGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
* Example: =%TWISTYSHOW{id="demo" link=" Click to Unfold " img="%ICONPATH{toggleopen}%"}%= expands to:
@@ -32,11 +32,11 @@
#VarTWISTYHIDE
---+++ TWISTYHIDE
*Hide/close link*
- * Syntax: =%TWISTYHIDE{id="myid" link="Link Text"}%=
+ * Syntax: =%TWISTYHIDE{id="myid" ... }%=
* Supported parameters:
| *Parameter* | *Description* | *Value* |
| =id= | Unique identifier. Used to link [[#VarTWISTYSHOW][TWISTYSHOW]], [[#VarTWISTYHIDE ][TWISTYHIDE ]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]] | required |
- | =link="Link Text"= | The text to be used in the Twisty Hide link | required |
+ | =link="Link Text"= | The text to be used in the Twisty Hide link | optional |
| =mode="div/span"= | Specify if the Twisty Hide link will use a =<div>= or a =<span>= tag | optional, defaults to =<span>= |
| =img="image url"= | Specify the url of an image that will be displayed at the right side of the link.
You may use [[%TWIKIWEB%.TWikiVariables#VarICONPATH][ICONPATH]] to display one of the %TWIKIWEB%.TWikiDocGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
* Example: =%TWISTYHIDE{id="demo" link=" Click to Fold " img="%ICONPATH{toggleclose}%"}%= expands to:
@@ -64,6 +64,41 @@
* Example: =%ENDTWISTYTOGGLE%= expands to: =</div>= if =mode="div"= was used in the last [[#VarTWISTYTOGGLE][TWISTYTOGGLE]],
* Related: [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]
+#VarTWISTYBUTTON
+---+++ TWISTYBUTTON
+*Shorthand version for TWISTYSHOW & TWISTYHIDE*
+This is usefull if both the show and the hide button take the same arguments.
+ * Syntax: =%TWISTYBUTTON{id="myid" ... }%=
+ * Supported parameters:
+ | *Parameter* | *Description* | *Value* |
+ | =id= | Unique identifier. Used to link [[#VarTWISTYBUTTON][TWISTYBUTTON]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]] | required |
+ | =link="Link Text"= | The text to be used in the Twisty button link | optional |
+ | =hidelink="Link Text"= | The text to be used in the Twisty hide link | optional |
+ | =showlink="Link Text"= | The text to be used in the Twisty show link | optional |
+ | =mode="div/span"= | Specify if the Twisty link will use a =<div>= or a =<span>= tag | optional, defaults to =<span>= |
+ | =img="image url"= | Specify the url of an image that will be displayed at the right side of the link.
You may use [[%TWIKIWEB%.TWikiVariables#VarICONPATH][ICONPATH]] to display one of the %TWIKIWEB%.TWikiDocGraphics icons. Alternatively use an image attached to the topic. | optional, defaults to no image |
+ | =hideimg="image url"= | Specify the image to be show in the Twisty hide link | optiona, defaults to =img= value |
+ | =showimg="image url"= | Specify the image to be show in the Twisty show link | optional, defaults to =img= value |
+ * Related: [[#VarTWISTYSHOW][TWISTYSHOW]] and [[#VarTWISTYHIDE][TWISTYHIDE]]
+
+#VarTWISTY
+---+++ TWISTY
+*Shorthand version for TWISTYSHOW & TWISTYHIDE & TWISTYTOGGLE*
+This renders the button as well as the toggled content section contained within this and the closing ENDTWISTY tag.
+ * Syntax: =%TWISTY{id="myid" ... }%=
+ * Supported parameters:
+ | *Parameter* | *Description* | *Value* |
+ | all parameters supported by [[#VarTWISTYSHOW][TWISTYBUTTON]] |||
+ | =mode="div/span"= | Specify if the Twisty Toggle section will use a =<div>= or a =<span>= tag. | optional, defaults to =<span>= |
+ | =buttonmode="div/span"= | Specify if the Twisty link link will use a =<div>= or a =<span>= tag | optional, defaults =mode= value |
+ * Related [[#VarTWISTYSHOW][TWISTYBUTTON]] and [[#VarTWISTYTOGGLE][TWISTYTOGGLE]]
+
+#VarENDTWISTY
+---+++ ENDTWISTY
+*Twisty closure*
+
+complements the opening TWISTY tag. See [[#VarENDTWISTYTOGGLE][ENDTWISTYTOGGLE]].
+
---++ Demo & Test
If the plugin is properly installed, you should see the Twisty effect below: