2015-12-23 22:28:47 +00:00
caption: reveal
2013-12-12 18:16:16 +00:00
created: 20131024141900000
2016-12-16 17:38:29 +00:00
jeremy: tiddlywiki
2020-11-21 17:19:52 +00:00
modified: 20201121100908827
2014-09-10 23:06:19 +00:00
tags: Widgets
2013-12-12 18:16:16 +00:00
title: RevealWidget
type: text/vnd.tiddlywiki
2013-10-31 22:03:40 +00:00
! 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:
2020-04-14 16:15:26 +00:00
* type=''match'': the content is displayed if the state tiddler matches the text attribute value
* type=''nomatch'': the content is displayed if the state tiddler doesn't match the text attribute value
2013-12-12 18:16:16 +00:00
* type=''popup'': the content is displayed as a popup as described in the PopupMechanism
2020-04-14 16:15:26 +00:00
* type=''lt'': the content is displayed if the state tiddler contains an integer with a value ''less than'' the text attribute value
* type=''gt'': the content is displayed if the state tiddler contains an integer with a value ''greater than'' the text attribute value
* type=''lteq'': the content is displayed if the state tiddler contains an integer with a value ''less than or equal to'' the text attribute value
* type=''gteq'': the content is displayed if the state tiddler contains an integer with a value ''greater than or equal to'' the text attribute value
2018-03-22 16:51:02 +00:00
2013-10-31 22:03:40 +00:00
! Content and Attributes
The content of the `<$reveal>` widget is displayed according to the rules given above.
|!Attribute |!Description |
2015-05-10 10:58:09 +00:00
|state |A TextReference containing the state |
2018-11-19 17:59:04 +00:00
|stateTitle |A title containing the state, ''without'' TextReference. Gets preferred over the <<.attr state>> attribute |
|stateField |A ''field name'' which is used to look for the state, if the attribute <<.attr stateTitle>> is present |
|stateIndex |An ''index'' which is used to look for the state, if the attribute <<.attr stateTitle>> is present |
2015-03-10 12:44:47 +00:00
|tag |Overrides the default HTML element tag (`<div>` in block mode or `<span>` in inline mode) |
2018-04-07 11:49:12 +00:00
|type |The type of matching performed: ''match'', ''nomatch'', ''popup'', ''lt'', ''gt'', ''lteq'' or ''gteq'' |
2018-11-06 15:34:21 +00:00
|text |The text to match when the type is ''match'', ''nomatch'', ''lt'', ''gt'', ''lteq'' or ''gteq'' |
2015-12-23 22:28:47 +00:00
|class |An optional CSS class name to be assigned to the HTML element<br/>» 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 |
2020-11-21 17:19:52 +00:00
|position |The position used for the popup when the type is ''popup''. Can be ''left'', ''above'', ''aboveleft'', ''aboveright'', ''right'', ''belowleft'', ''belowright'' or ''below'' |
2019-07-04 14:58:27 +00:00
|positionAllowNegative |Set to "yes" to prevent computed popup positions from being clamped to be above zero |
2014-08-19 15:08:15 +00:00
|default |Default value to use when the state tiddler is missing |
2019-09-10 15:07:36 +00:00
|animate |Set to "yes" to animate opening and closure (defaults to "no"; requires "retain" to be set to "yes") |
2018-11-19 17:59:04 +00:00
|retain |Set to "yes" to force the content to be retained even when hidden (defaults to "no") |
2020-11-21 17:19:52 +00:00
|updatePopupPosition|<<.from-version "5.1.23">>Set to "yes" to update the popup position when the state tiddler is updated (defaults to "no")|
2014-02-12 08:32:19 +00:00
2018-11-19 17:59:04 +00:00
<<.tip """<$macrocall $name=".from-version" version="5.1.18"/> <$macrocall $name=".attr" _="stateTitle"/>, <$macrocall $name=".attr" _="stateField"/> and <$macrocall $name=".attr" _="stateIndex"/> attributes allow specifying Tiddler states ''directly'', without interpreting them as [[TextReferences|TextReference]].
This is useful for edge-cases where titles may contain characters that are used to denote Tiddler fields or indices (`!!`, `##`)""">>
2019-09-10 15:07:36 +00:00
<<.tip """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 require ''retain="yes"''""">>
2013-12-12 18:16:16 +00:00
! Examples
!! Simple content reveal
Here's a simple example of showing and hiding content with buttons:
2014-12-21 16:21:18 +00:00
<<wikitext-example-without-html '<$button set="$:/state/SampleReveal1" setTo="show">Show me</$button>
<$button set="$:/state/SampleReveal1" setTo="hide">Hide me</$button>
2013-12-12 18:16:16 +00:00
2014-12-21 16:21:18 +00:00
<$reveal type="match" state="$:/state/SampleReveal1" text="show">
2014-02-27 18:21:04 +00:00
2013-12-12 18:16:16 +00:00
! This is the revealed content
And this is some text
2014-02-27 18:21:04 +00:00
2014-05-13 13:50:45 +00:00
</$reveal>'>>
2015-05-18 16:34:03 +00:00
!! Accordion or Slider
2013-12-12 18:16:16 +00:00
2015-05-18 16:34:03 +00:00
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
2014-12-21 16:21:18 +00:00
<<wikitext-example-without-html '<$reveal type="nomatch" state="$:/state/SampleReveal2" text="show">
2013-12-12 18:16:16 +00:00
2014-12-21 16:21:18 +00:00
<$button set="$:/state/SampleReveal2" setTo="show">Show me</$button>
2013-12-12 18:16:16 +00:00
2014-05-13 13:50:45 +00:00
</$reveal>
2014-12-21 16:21:18 +00:00
<$reveal type="match" state="$:/state/SampleReveal2" text="show">
2014-02-27 18:21:04 +00:00
2014-12-21 16:21:18 +00:00
<$button set="$:/state/SampleReveal2" setTo="hide">Hide me</$button>
2014-05-13 13:50:45 +00:00
2013-12-12 18:16:16 +00:00
! This is the revealed content
And this is some text
2014-02-27 18:21:04 +00:00
2014-05-13 13:50:45 +00:00
</$reveal>'>>
2013-12-12 18:16:16 +00:00
!! 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>
2013-12-12 18:16:16 +00:00
<$reveal type="popup" state="$:/SamplePopupState">
2014-08-28 17:21:08 +00:00
<div class="tc-drop-down">
2014-02-27 18:21:04 +00:00
2013-12-12 18:16:16 +00:00
! This is the popup
And this is some text
2014-02-27 18:21:04 +00:00
2013-12-12 18:16:16 +00:00
</div>
2014-05-13 13:50:45 +00:00
</$reveal>'>>
2016-12-16 17:38:29 +00:00
!! 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!
2018-04-07 11:49:12 +00:00
</$reveal>'>>