Update the reveal widget to allow control over content retention

Thus bringing back the animation of the opening and closing of the info
panel.
This commit is contained in:
Jermolene 2014-02-12 08:32:19 +00:00
parent dd451800c7
commit 5c66bc6dbc
3 changed files with 13 additions and 5 deletions

View File

@ -89,6 +89,7 @@ RevealWidget.prototype.execute = function() {
this["class"] = this.getAttribute("class","");
this["default"] = this.getAttribute("default","");
this.animate = this.getAttribute("animate","no");
this.retain = this.getAttribute("retain","no");
this.openAnimation = this.animate === "no" ? undefined : "open";
this.closeAnimation = this.animate === "no" ? undefined : "close";
// Compute the title of the state tiddler and read it
@ -157,9 +158,12 @@ RevealWidget.prototype.refresh = function(changedTiddlers) {
} else {
var refreshed = false;
if(changedTiddlers[this.stateTitle]) {
// this.updateState();
this.refreshSelf();
refreshed = true;
if(this.retain === "yes") {
this.updateState();
} else {
this.refreshSelf();
refreshed = true;
}
}
return this.refreshChildren(changedTiddlers) || refreshed;
}

View File

@ -8,7 +8,7 @@ fill:$(foregroundColor)$;
</span><$set name="foregroundColor" value={{!!color}}><span style=<<title-styles>>><$transclude tiddler={{!!icon}}/></span></$set> <span class="title"><$view field="title"/></span></div>
<$reveal type="nomatch" text="" default="" state=<<tiddlerInfoState>> class="tw-tiddler-info tw-popup" animate="yes">
<$reveal type="nomatch" text="" default="" state=<<tiddlerInfoState>> class="tw-tiddler-info tw-popup" animate="yes" retain="yes">
<$transclude tiddler="$:/core/ui/TiddlerInfo"/>

View File

@ -1,5 +1,5 @@
created: 20131024141900000
modified: 20131212181426191
modified: 20140211232346858
tags: widget
title: RevealWidget
type: text/vnd.tiddlywiki
@ -22,6 +22,10 @@ The content of the `<$reveal>` widget is displayed according to the rules given
|text |The text to match when the type is ''match'' and ''nomatch'' |
|position |The position used for the popup when the type is ''popup''. Can be ''left'', ''above'', ''aboveright'', ''right'', ''belowleft'' or ''below'' |
|default |Default value to use when the state tiddler |
|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