diff --git a/core/modules/widgets/setvariable.js b/core/modules/widgets/setvariable.js index af83729b8..6dbdead5b 100755 --- a/core/modules/widgets/setvariable.js +++ b/core/modules/widgets/setvariable.js @@ -1,9 +1,9 @@ /*\ -title: $:/core/modules/widgets/setvariable.js +title: $:/core/modules/widgets/set.js type: application/javascript module-type: widget -Setvariable widget +Set variable widget \*/ (function(){ @@ -14,19 +14,19 @@ Setvariable widget var Widget = require("$:/core/modules/widgets/widget.js").widget; -var SetVariableWidget = function(parseTreeNode,options) { +var SetWidget = function(parseTreeNode,options) { this.initialise(parseTreeNode,options); }; /* Inherit from the base widget class */ -SetVariableWidget.prototype = new Widget(); +SetWidget.prototype = new Widget(); /* Render this widget into the DOM */ -SetVariableWidget.prototype.render = function(parent,nextSibling) { +SetWidget.prototype.render = function(parent,nextSibling) { this.parentDomNode = parent; this.computeAttributes(); this.execute(); @@ -36,7 +36,7 @@ SetVariableWidget.prototype.render = function(parent,nextSibling) { /* Compute the internal state of the widget */ -SetVariableWidget.prototype.execute = function() { +SetWidget.prototype.execute = function() { // Get our parameters this.setName = this.getAttribute("name","currentTiddler"); this.setValue = this.getAttribute("value"); @@ -49,7 +49,7 @@ SetVariableWidget.prototype.execute = function() { /* Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering */ -SetVariableWidget.prototype.refresh = function(changedTiddlers) { +SetWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); if(changedAttributes.name || changedAttributes.value) { this.refreshSelf(); @@ -59,6 +59,7 @@ SetVariableWidget.prototype.refresh = function(changedTiddlers) { } }; -exports.setvariable = SetVariableWidget; +exports.setvariable = SetWidget; +exports.set = SetWidget; })(); diff --git a/core/modules/wiki.js b/core/modules/wiki.js index ad1bc7183..3cad3b409 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -692,7 +692,7 @@ var tweakParseTreeNodes = function(nodeList) { var tweakMacroDefinition = function(nodeList) { if(nodeList && nodeList[0] && nodeList[0].type === "macrodef") { - nodeList[0].type = "setvariable"; + nodeList[0].type = "set"; nodeList[0].attributes = { name: {type: "string", value: nodeList[0].name}, value: {type: "string", value: nodeList[0].text} @@ -764,10 +764,10 @@ exports.makeWidget = function(parser,options) { children: [] }, currWidgetNode = widgetNode; - // Create setvariable widgets for each variable + // Create set variable widgets for each variable $tw.utils.each(options.variables,function(value,name) { var setVariableWidget = { - type: "setvariable", + type: "set", attributes: { name: {type: "string", value: name}, value: {type: "string", value: value} diff --git a/core/ui/TagTemplate.tid b/core/ui/TagTemplate.tid index 9fe592cbb..a69b57545 100644 --- a/core/ui/TagTemplate.tid +++ b/core/ui/TagTemplate.tid @@ -3,7 +3,7 @@ title: $:/core/ui/TagTemplate \define tag-styles() background-color:$(backgroundColor)$; \end -<$setvariable name="backgroundColor" value={{!!color}}><$button popup=<> class="btn-invisible tw-tag-label" style=<>><$transclude tiddler={{!!icon}}/> <$view field="title" format="text" /> +<$set name="backgroundColor" value={{!!color}}><$button popup=<> class="btn-invisible tw-tag-label" style=<>><$transclude tiddler={{!!icon}}/> <$view field="title" format="text" /> <$reveal state=<> type="popup" position="below" animate="yes">
<$transclude tiddler="$:/core/ui/ListItemTemplate"/>
<$list filter="[is[current]tagging[]]" template="$:/core/ui/ListItemTemplate"/> diff --git a/core/ui/TagsEditor.tid b/core/ui/TagsEditor.tid index 78fa338f0..df6f6d378 100644 --- a/core/ui/TagsEditor.tid +++ b/core/ui/TagsEditor.tid @@ -3,7 +3,7 @@ title: $:/core/ui/TagsEditor \define tag-styles() background-color:$(backgroundColor)$; \end -<$fieldmangler>
<$list filter="[is[current]tags[]sort[title]]" storyview="pop" itemClass="tw-tag-editor-label"><$setvariable name="backgroundColor" value={{!!color}}>> class="tw-tag-label"><$view field="title" format="text" /><$button message="tw-remove-tag" param={{!!title}} class="btn-invisible tw-remove-tag-button">× +<$fieldmangler>
<$list filter="[is[current]tags[]sort[title]]" storyview="pop" itemClass="tw-tag-editor-label"><$set name="backgroundColor" value={{!!color}}>> class="tw-tag-label"><$view field="title" format="text" /><$button message="tw-remove-tag" param={{!!title}} class="btn-invisible tw-remove-tag-button">×
Add a new tag: <$edit-text tiddler="$:/NewTagName" tag="input" default="" placeholder="tag name" focusPopup=<> class="tw-edit-texteditor"/> <$button popup=<> class="btn-invisible">{{$:/core/images/down-arrow}} <$button message="tw-add-tag" param={{$:/NewTagName}} set="$:/NewTagName" setTo="" class="">add
@@ -11,7 +11,7 @@ background-color:$(backgroundColor)$;
<$reveal state=<> type="nomatch" text="" default="">
-<$linkcatcher set="$:/NewTagName" setTo="" message="tw-add-tag"><$list filter="[!is[shadow]tags[]search{$:/NewTagName}sort[title]]"><$link><$setvariable name="backgroundColor" value={{!!color}}>> class="tw-tag-label"><$view field="title" format="text"/> +<$linkcatcher set="$:/NewTagName" setTo="" message="tw-add-tag"><$list filter="[!is[shadow]tags[]search{$:/NewTagName}sort[title]]"><$link><$set name="backgroundColor" value={{!!color}}>> class="tw-tag-label"><$view field="title" format="text"/>
diff --git a/core/ui/ViewTemplate/title.tid b/core/ui/ViewTemplate/title.tid index 32d9738e1..711f65770 100644 --- a/core/ui/ViewTemplate/title.tid +++ b/core/ui/ViewTemplate/title.tid @@ -6,7 +6,7 @@ fill:$(foregroundColor)$; \end
<$button popup=<> class="btn-invisible" selectedClass="tw-selected">{{$:/core/images/info-button}}<$button message="tw-edit-tiddler" class="btn-invisible">{{$:/core/images/edit-button}}<$button message="tw-close-tiddler" class="btn-invisible">{{$:/core/images/close-button}} -<$setvariable name="foregroundColor" value={{!!color}}>>><$transclude tiddler={{!!icon}}/> <$view field="title"/>
+<$set name="foregroundColor" value={{!!color}}>>><$transclude tiddler={{!!icon}}/> <$view field="title"/>
<$reveal type="nomatch" text="" default="" state=<> class="tw-tiddler-info tw-popup" animate="yes"> diff --git a/editions/test/tiddlers/tests/test-widget.js b/editions/test/tiddlers/tests/test-widget.js index b74e572ed..03b3465b6 100755 --- a/editions/test/tiddlers/tests/test-widget.js +++ b/editions/test/tiddlers/tests/test-widget.js @@ -228,7 +228,7 @@ describe("Widget module", function() { }); }); - it("should deal with the setvariable widget", function() { + it("should deal with the set widget", function() { var wiki = new $tw.Wiki(); // Add some tiddlers wiki.addTiddlers([ @@ -238,7 +238,7 @@ describe("Widget module", function() { {title: "TiddlerFour", text: "TiddlerTwo"} ]); // Construct the widget node - var text = "My <$setvariable name='currentTiddler' value={{TiddlerFour}}><$transclude tiddler={{!!title}}/> is Jolly" + var text = "My <$set name='currentTiddler' value={{TiddlerFour}}><$transclude tiddler={{!!title}}/> is Jolly" var widgetNode = createWidgetNode(parseText(text,wiki),wiki); // Render the widget node to the DOM var wrapper = renderWidgetNode(widgetNode); diff --git a/editions/test/tiddlers/tests/test-wikitext-parser.js b/editions/test/tiddlers/tests/test-wikitext-parser.js index 7eeee6a57..24c399fbc 100644 --- a/editions/test/tiddlers/tests/test-wikitext-parser.js +++ b/editions/test/tiddlers/tests/test-wikitext-parser.js @@ -98,7 +98,7 @@ describe("WikiText parser tests", function() { it("should parse macro definitions", function() { expect(parse("\\define myMacro()\nnothing\n\\end\n")).toEqual( - [ { type : 'setvariable', name : 'myMacro', params : [ ], text : 'nothing', attributes : { name : { type : 'string', value : 'myMacro' }, value : { type : 'string', value : 'nothing' } }, children : [ ] } ] + [ { type : 'set', name : 'myMacro', params : [ ], text : 'nothing', attributes : { name : { type : 'string', value : 'myMacro' }, value : { type : 'string', value : 'nothing' } }, children : [ ] } ] ); diff --git a/editions/tw5.com/tiddlers/widgets/SetVariableWidget.tid b/editions/tw5.com/tiddlers/widgets/SetVariableWidget.tid index 64b0cbf9f..80e70cead 100644 --- a/editions/tw5.com/tiddlers/widgets/SetVariableWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/SetVariableWidget.tid @@ -1,18 +1,10 @@ title: SetVariableWidget created: 201310241419 creator: JeremyRuston -modified: 201310300837 +modified: 201311151827 modifier: JeremyRuston tags: widget -! Introduction +The `<$setvariable>` widget has been renamed `<$set/>`; see SetWidget for more details. -The set variable widget assigns a value to a specified [[variable|WidgetVariables]]. The new value of the variable is availale to the content within the set variable widget. - -! Content and Attributes - -The content of the `<$setvariable>` widget is the scope for the value assigned to the variable. - -|!Attribute |!Description | -|name |The name of the variable to assign | -|value |The value to assign to the variable | +For the moment, you can continue to use `<$setvariable>` as a synonym for `<$set/>`, but it will be removed for the beta. diff --git a/editions/tw5.com/tiddlers/widgets/SetWidget.tid b/editions/tw5.com/tiddlers/widgets/SetWidget.tid new file mode 100644 index 000000000..cd1a8953c --- /dev/null +++ b/editions/tw5.com/tiddlers/widgets/SetWidget.tid @@ -0,0 +1,18 @@ +title: SetWidget +created: 201311151827 +creator: JeremyRuston +modified: 201311151827 +modifier: JeremyRuston +tags: widget + +! Introduction + +The set variable widget assigns a value to a specified [[variable|WidgetVariables]]. The new value of the variable is availale to the content within the set variable widget. + +! Content and Attributes + +The content of the `<$set>` widget is the scope for the value assigned to the variable. + +|!Attribute |!Description | +|name |The name of the variable to assign | +|value |The value to assign to the variable |