From a7bb33141263c17e223ff1d60f0d141e9fcf3aac Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 9 Nov 2013 17:30:06 +0000 Subject: [PATCH] Extend view widget so that it falls back to its content if the field/property is empty or missing --- core/modules/widgets/view.js | 11 ++++++++--- core/ui/PageMacros.tid | 2 +- editions/tw5.com/tiddlers/Release 5.0.0alpha13.tid | 1 + editions/tw5.com/tiddlers/widgets/ViewWidget.tid | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/modules/widgets/view.js b/core/modules/widgets/view.js index 7398a7da8..55fb51f7e 100755 --- a/core/modules/widgets/view.js +++ b/core/modules/widgets/view.js @@ -30,9 +30,14 @@ ViewWidget.prototype.render = function(parent,nextSibling) { this.parentDomNode = parent; this.computeAttributes(); this.execute(); - var textNode = this.document.createTextNode(this.text); - parent.insertBefore(textNode,nextSibling); - this.domNodes.push(textNode); + if(this.text) { + var textNode = this.document.createTextNode(this.text); + parent.insertBefore(textNode,nextSibling); + this.domNodes.push(textNode); + } else { + this.makeChildWidgets(); + this.renderChildren(parent,nextSibling); + } }; /* diff --git a/core/ui/PageMacros.tid b/core/ui/PageMacros.tid index 312312f5c..0cdaefc1f 100644 --- a/core/ui/PageMacros.tid +++ b/core/ui/PageMacros.tid @@ -1,7 +1,7 @@ title: $:/core/ui/PageMacros \define tabs(tabsList,default,state:"$:/currentTab") -
<$list filter="$tabsList$" variable="currentTab"><$button set=<> setTo=<> default="$default$" selectedClass="tw-tab-selected"><$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/> +
<$list filter="$tabsList$" variable="currentTab"><$button set=<> setTo=<> default="$default$" selectedClass="tw-tab-selected"><$view tiddler=<> field="caption"><$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/>
diff --git a/editions/tw5.com/tiddlers/Release 5.0.0alpha13.tid b/editions/tw5.com/tiddlers/Release 5.0.0alpha13.tid index b5fc5f7a8..629403382 100644 --- a/editions/tw5.com/tiddlers/Release 5.0.0alpha13.tid +++ b/editions/tw5.com/tiddlers/Release 5.0.0alpha13.tid @@ -15,3 +15,4 @@ This release has several bug fixes: * Improved deployment scripts * Made the modifier field in the subtitle be a link * 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 diff --git a/editions/tw5.com/tiddlers/widgets/ViewWidget.tid b/editions/tw5.com/tiddlers/widgets/ViewWidget.tid index 66156e63b..d365e40b3 100644 --- a/editions/tw5.com/tiddlers/widgets/ViewWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/ViewWidget.tid @@ -11,7 +11,7 @@ The view widget displays the contents of a tiddler field in a specified format. ! 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 | |tiddler |The title of the tiddler (defaults to the [[WidgetVariable: currentTiddler]]) |