1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 19:39:57 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/widgets/RevealWidget.tid

90 lines
3.5 KiB
Plaintext
Raw Normal View History

2015-12-23 22:28:47 +00:00
caption: reveal
created: 20131024141900000
jeremy: tiddlywiki
modified: 20161216153618769
2014-09-10 23:06:19 +00:00
tags: Widgets
title: RevealWidget
type: text/vnd.tiddlywiki
! Introduction
The reveal widget hides or shows its content depending upon the value of a [[state tiddler|StateTiddlers]]. The type of the widget determines the condition for the content being displayed:
* type=''match'': the content is displayed if the state tiddler matches a specified value
* type=''nomatch'': the content is displayed if the state tiddler doesn't match a specified value
* type=''popup'': the content is displayed as a popup as described in the PopupMechanism
! Content and Attributes
The content of the `<$reveal>` widget is displayed according to the rules given above.
|!Attribute |!Description |
|state |A TextReference containing the state |
|tag |Overrides the default HTML element tag (`<div>` in block mode or `<span>` in inline mode) |
|type |The type of matching performed: ''match'', ''nomatch'' or ''popup'' |
|text |The text to match when the type is ''match'' and ''nomatch'' |
2015-12-23 22:28:47 +00:00
|class |An optional CSS class name to be assigned to the HTML element<br/>&raquo; Set to `tc-popup-keep` to make a popup "sticky", so it won't close when you click inside of it|
2015-03-23 15:28:26 +00:00
|style |An optional CSS style attribute to be assigned to the HTML element |
|position |The position used for the popup when the type is ''popup''. Can be ''left'', ''above'', ''aboveright'', ''right'', ''belowleft'' or ''below'' |
2014-08-19 15:08:15 +00:00
|default |Default value to use when the state tiddler is missing |
|animate |Set to "yes" to animate opening and closure (defaults to "no") |
|retain |Set to "yes" to force the content to be retained even when hidden (defaults to "no")|
Retaining the content when hidden can give poor performance since the hidden content requires refresh processing even though it is not displayed. On the other hand, the content can be revealed much more quickly. Note that setting ''animate="yes"'' will also force ''retain="yes"''.
! Examples
!! Simple content reveal
Here's a simple example of showing and hiding content with buttons:
<<wikitext-example-without-html '<$button set="$:/state/SampleReveal1" setTo="show">Show me</$button>
<$button set="$:/state/SampleReveal1" setTo="hide">Hide me</$button>
<$reveal type="match" state="$:/state/SampleReveal1" text="show">
! This is the revealed content
And this is some text
2014-05-13 13:50:45 +00:00
</$reveal>'>>
!! Accordion or Slider
An "accordion" or "slider" is a button that can be used to toggle the display of associated content.
2014-05-13 13:50:45 +00:00
<<wikitext-example-without-html '<$reveal type="nomatch" state="$:/state/SampleReveal2" text="show">
<$button set="$:/state/SampleReveal2" setTo="show">Show me</$button>
2014-05-13 13:50:45 +00:00
</$reveal>
<$reveal type="match" state="$:/state/SampleReveal2" text="show">
<$button set="$:/state/SampleReveal2" setTo="hide">Hide me</$button>
2014-05-13 13:50:45 +00:00
! This is the revealed content
And this is some text
2014-05-13 13:50:45 +00:00
</$reveal>'>>
!! Popup
Here is a simple example of a popup built with the RevealWidget:
2014-05-13 13:50:45 +00:00
<<wikitext-example-without-html '<$button popup="$:/SamplePopupState">Pop me up!</$button>
<$reveal type="popup" state="$:/SamplePopupState">
<div class="tc-drop-down">
! This is the popup
And this is some text
</div>
2014-05-13 13:50:45 +00:00
</$reveal>'>>
!! How to use text references with field content
Here is a simple example how to use text references with field content to control the RevealWidget. If the field ``jeremy`` is populated with text ``tiddlywiki``, a message will be displayed.
<<wikitext-example-without-html '<$reveal type="match" state="!!jeremy" text="tiddlywiki">
~TiddlyWiki!
</$reveal>'>>