1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-04 13:19:11 +00:00

Extend view widget so that it falls back to its content if the field/property is empty or missing

This commit is contained in:
Jermolene 2013-11-09 17:30:06 +00:00
parent 6f1c9d88cc
commit a7bb331412
4 changed files with 11 additions and 5 deletions

View File

@ -30,9 +30,14 @@ ViewWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent; this.parentDomNode = parent;
this.computeAttributes(); this.computeAttributes();
this.execute(); this.execute();
var textNode = this.document.createTextNode(this.text); if(this.text) {
parent.insertBefore(textNode,nextSibling); var textNode = this.document.createTextNode(this.text);
this.domNodes.push(textNode); parent.insertBefore(textNode,nextSibling);
this.domNodes.push(textNode);
} else {
this.makeChildWidgets();
this.renderChildren(parent,nextSibling);
}
}; };
/* /*

View File

@ -1,7 +1,7 @@
title: $:/core/ui/PageMacros title: $:/core/ui/PageMacros
\define tabs(tabsList,default,state:"$:/currentTab") \define tabs(tabsList,default,state:"$:/currentTab")
<div class="tw-tab-buttons"><$list filter="$tabsList$" variable="currentTab"><$button set=<<qualify "$state$">> setTo=<<currentTab>> default="$default$" selectedClass="tw-tab-selected"><$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/> </$button> <div class="tw-tab-buttons"><$list filter="$tabsList$" variable="currentTab"><$button set=<<qualify "$state$">> setTo=<<currentTab>> default="$default$" selectedClass="tw-tab-selected"><$view tiddler=<<currentTab>> field="caption"><$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/></$view> </$button>
</$list> </$list>
</div> </div>
<div class="tw-tab-divider"> <div class="tw-tab-divider">

View File

@ -15,3 +15,4 @@ This release has several bug fixes:
* Improved deployment scripts * Improved deployment scripts
* Made the modifier field in the subtitle be a link * Made the modifier field in the subtitle be a link
* Styling improvements for the CodeMirror plugin * Styling improvements for the CodeMirror plugin
* Improved the ViewWidget so that it falls back to displaying its content if the field/property is missing or empty

View File

@ -11,7 +11,7 @@ The view widget displays the contents of a tiddler field in a specified format.
! Content and Attributes ! Content and Attributes
The content of the `<$view>` widget is ignored. The content of the `<$view>` widget is displayed if the field or property is missing or empty.
|!Attribute |!Description | |!Attribute |!Description |
|tiddler |The title of the tiddler (defaults to the [[WidgetVariable: currentTiddler]]) | |tiddler |The title of the tiddler (defaults to the [[WidgetVariable: currentTiddler]]) |