From ed6fd475ab93d9441c3a3912b08f65cf3d658bd5 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 4 Nov 2013 09:59:26 +0000 Subject: [PATCH] Add 'default' attribute to button widget This allows us to do things like tab controls properly. --- core/modules/new_widgets/button.js | 3 ++- editions/tw5.com/tiddlers/widgets/ButtonWidget.tid | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/modules/new_widgets/button.js b/core/modules/new_widgets/button.js index 3bf22eec7..5ff07e255 100644 --- a/core/modules/new_widgets/button.js +++ b/core/modules/new_widgets/button.js @@ -79,7 +79,7 @@ ButtonWidget.prototype.render = function(parent,nextSibling) { ButtonWidget.prototype.isSelected = function() { var tiddler = this.wiki.getTiddler(this.set); - return tiddler ? tiddler.fields.text === this.setTo : false; + return tiddler ? tiddler.fields.text === this.setTo : this.defaultSetValue === this.setTo; }; ButtonWidget.prototype.isPoppedUp = function() { @@ -119,6 +119,7 @@ ButtonWidget.prototype.execute = function() { this["class"] = this.getAttribute("class",""); this.style = this.getAttribute("style"); this.selectedClass = this.getAttribute("selectedClass"); + this.defaultSetValue = this.getAttribute("default"); // Make child widgets this.makeChildWidgets(); }; diff --git a/editions/tw5.com/tiddlers/widgets/ButtonWidget.tid b/editions/tw5.com/tiddlers/widgets/ButtonWidget.tid index 6dba32189..be0aa06bd 100644 --- a/editions/tw5.com/tiddlers/widgets/ButtonWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/ButtonWidget.tid @@ -26,3 +26,4 @@ The content of the `<$button>` widget is displayed within the button. |class |An optional CSS class name to be assigned to the HTML element | |style |An optional CSS style attribute to be assigned to the HTML element | |selectedClass |An optional additional CSS class to be assigned if the popup is triggered or the tiddler specified in `set` already has the value specified in `setTo` | +|default |Default value if `set` tiddler is missing for testing against `setTo` to determine `selectedClass` |