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

Rename the 'setvariable' widget to 'set'

Sleeker.
This commit is contained in:
Jermolene 2013-11-15 18:31:39 +00:00
parent 6785c49734
commit 939ad11eae
9 changed files with 40 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/*\
title: $:/core/modules/widgets/setvariable.js
title: $:/core/modules/widgets/set.js
type: application/javascript
module-type: widget
@ -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;
})();

View File

@ -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}
@ -767,7 +767,7 @@ exports.makeWidget = function(parser,options) {
// 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}

View File

@ -3,7 +3,7 @@ title: $:/core/ui/TagTemplate
\define tag-styles()
background-color:$(backgroundColor)$;
\end
<span class="tw-tag-list-item"><$setvariable name="backgroundColor" value={{!!color}}><$button popup=<<qualify "$:/state/tagpopup">> class="btn-invisible tw-tag-label" style=<<tag-styles>>><$transclude tiddler={{!!icon}}/> <$view field="title" format="text" /></$button></$setvariable>
<span class="tw-tag-list-item"><$set name="backgroundColor" value={{!!color}}><$button popup=<<qualify "$:/state/tagpopup">> class="btn-invisible tw-tag-label" style=<<tag-styles>>><$transclude tiddler={{!!icon}}/> <$view field="title" format="text" /></$button></$set>
<$reveal state=<<qualify "$:/state/tagpopup">> type="popup" position="below" animate="yes"><div class="tw-drop-down"><$transclude tiddler="$:/core/ui/ListItemTemplate"/>
<hr>
<$list filter="[is[current]tagging[]]" template="$:/core/ui/ListItemTemplate"/>

View File

@ -3,7 +3,7 @@ title: $:/core/ui/TagsEditor
\define tag-styles()
background-color:$(backgroundColor)$;
\end
<$fieldmangler><div class="tw-edit-tags-list"><$list filter="[is[current]tags[]sort[title]]" storyview="pop" itemClass="tw-tag-editor-label"><$setvariable name="backgroundColor" value={{!!color}}><span style=<<tag-styles>> class="tw-tag-label"><$view field="title" format="text" /><$button message="tw-remove-tag" param={{!!title}} class="btn-invisible tw-remove-tag-button">&times;</$button></span></$setvariable>
<$fieldmangler><div class="tw-edit-tags-list"><$list filter="[is[current]tags[]sort[title]]" storyview="pop" itemClass="tw-tag-editor-label"><$set name="backgroundColor" value={{!!color}}><span style=<<tag-styles>> class="tw-tag-label"><$view field="title" format="text" /><$button message="tw-remove-tag" param={{!!title}} class="btn-invisible tw-remove-tag-button">&times;</$button></span></$set>
</$list></div>
<div class="tw-add-tag">Add a new tag: <span class="tw-add-tag-name"><$edit-text tiddler="$:/NewTagName" tag="input" default="" placeholder="tag name" focusPopup=<<qualify "$:/state/tagsAutoComplete">> class="tw-edit-texteditor"/></span> <$button popup=<<qualify "$:/state/tagsAutoComplete">> class="btn-invisible">{{$:/core/images/down-arrow}}</$button> <span class="tw-add-tag-button"><$button message="tw-add-tag" param={{$:/NewTagName}} set="$:/NewTagName" setTo="" class="">add</$button></span></div>
@ -11,7 +11,7 @@ background-color:$(backgroundColor)$;
<div class="tw-tags-autocomplete-wrapper">
<$reveal state=<<qualify "$:/state/tagsAutoComplete">> type="nomatch" text="" default="">
<div class="tw-tags-autocomplete">
<$linkcatcher set="$:/NewTagName" setTo="" message="tw-add-tag"><$list filter="[!is[shadow]tags[]search{$:/NewTagName}sort[title]]"><$link><$setvariable name="backgroundColor" value={{!!color}}><span style=<<tag-styles>> class="tw-tag-label"><$view field="title" format="text"/></span></$setvariable></$link>
<$linkcatcher set="$:/NewTagName" setTo="" message="tw-add-tag"><$list filter="[!is[shadow]tags[]search{$:/NewTagName}sort[title]]"><$link><$set name="backgroundColor" value={{!!color}}><span style=<<tag-styles>> class="tw-tag-label"><$view field="title" format="text"/></span></$set></$link>
</$list>
</$linkcatcher>
</div>

View File

@ -6,7 +6,7 @@ fill:$(foregroundColor)$;
\end
<div class="tw-tiddler-title"><div class="titlebar"><span class="tw-tiddler-controls"><$button popup=<<qualify "$:/state/tiddlerInfo">> class="btn-invisible" selectedClass="tw-selected">{{$:/core/images/info-button}}</$button><$button message="tw-edit-tiddler" class="btn-invisible">{{$:/core/images/edit-button}}</$button><$button message="tw-close-tiddler" class="btn-invisible">{{$:/core/images/close-button}}</$button>
</span><$setvariable name="foregroundColor" value={{!!color}}><span style=<<title-styles>>><$transclude tiddler={{!!icon}}/></span></$setvariable> <span class="title"><$view field="title"/></span></div>
</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=<<qualify "$:/state/tiddlerInfo">> class="tw-tiddler-info tw-popup" animate="yes">

View File

@ -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}}/></$setvariable> is Jolly"
var text = "My <$set name='currentTiddler' value={{TiddlerFour}}><$transclude tiddler={{!!title}}/></$set> is Jolly"
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);

View File

@ -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 : [ ] } ]
);

View File

@ -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.

View File

@ -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 |