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:
parent
6785c49734
commit
939ad11eae
@ -1,5 +1,5 @@
|
|||||||
/*\
|
/*\
|
||||||
title: $:/core/modules/widgets/setvariable.js
|
title: $:/core/modules/widgets/set.js
|
||||||
type: application/javascript
|
type: application/javascript
|
||||||
module-type: widget
|
module-type: widget
|
||||||
|
|
||||||
@ -14,19 +14,19 @@ Setvariable widget
|
|||||||
|
|
||||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||||
|
|
||||||
var SetVariableWidget = function(parseTreeNode,options) {
|
var SetWidget = function(parseTreeNode,options) {
|
||||||
this.initialise(parseTreeNode,options);
|
this.initialise(parseTreeNode,options);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Inherit from the base widget class
|
Inherit from the base widget class
|
||||||
*/
|
*/
|
||||||
SetVariableWidget.prototype = new Widget();
|
SetWidget.prototype = new Widget();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Render this widget into the DOM
|
Render this widget into the DOM
|
||||||
*/
|
*/
|
||||||
SetVariableWidget.prototype.render = function(parent,nextSibling) {
|
SetWidget.prototype.render = function(parent,nextSibling) {
|
||||||
this.parentDomNode = parent;
|
this.parentDomNode = parent;
|
||||||
this.computeAttributes();
|
this.computeAttributes();
|
||||||
this.execute();
|
this.execute();
|
||||||
@ -36,7 +36,7 @@ SetVariableWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
/*
|
/*
|
||||||
Compute the internal state of the widget
|
Compute the internal state of the widget
|
||||||
*/
|
*/
|
||||||
SetVariableWidget.prototype.execute = function() {
|
SetWidget.prototype.execute = function() {
|
||||||
// Get our parameters
|
// Get our parameters
|
||||||
this.setName = this.getAttribute("name","currentTiddler");
|
this.setName = this.getAttribute("name","currentTiddler");
|
||||||
this.setValue = this.getAttribute("value");
|
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
|
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();
|
var changedAttributes = this.computeAttributes();
|
||||||
if(changedAttributes.name || changedAttributes.value) {
|
if(changedAttributes.name || changedAttributes.value) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
@ -59,6 +59,7 @@ SetVariableWidget.prototype.refresh = function(changedTiddlers) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.setvariable = SetVariableWidget;
|
exports.setvariable = SetWidget;
|
||||||
|
exports.set = SetWidget;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -692,7 +692,7 @@ var tweakParseTreeNodes = function(nodeList) {
|
|||||||
|
|
||||||
var tweakMacroDefinition = function(nodeList) {
|
var tweakMacroDefinition = function(nodeList) {
|
||||||
if(nodeList && nodeList[0] && nodeList[0].type === "macrodef") {
|
if(nodeList && nodeList[0] && nodeList[0].type === "macrodef") {
|
||||||
nodeList[0].type = "setvariable";
|
nodeList[0].type = "set";
|
||||||
nodeList[0].attributes = {
|
nodeList[0].attributes = {
|
||||||
name: {type: "string", value: nodeList[0].name},
|
name: {type: "string", value: nodeList[0].name},
|
||||||
value: {type: "string", value: nodeList[0].text}
|
value: {type: "string", value: nodeList[0].text}
|
||||||
@ -767,7 +767,7 @@ exports.makeWidget = function(parser,options) {
|
|||||||
// Create set variable widgets for each variable
|
// Create set variable widgets for each variable
|
||||||
$tw.utils.each(options.variables,function(value,name) {
|
$tw.utils.each(options.variables,function(value,name) {
|
||||||
var setVariableWidget = {
|
var setVariableWidget = {
|
||||||
type: "setvariable",
|
type: "set",
|
||||||
attributes: {
|
attributes: {
|
||||||
name: {type: "string", value: name},
|
name: {type: "string", value: name},
|
||||||
value: {type: "string", value: value}
|
value: {type: "string", value: value}
|
||||||
|
@ -3,7 +3,7 @@ title: $:/core/ui/TagTemplate
|
|||||||
\define tag-styles()
|
\define tag-styles()
|
||||||
background-color:$(backgroundColor)$;
|
background-color:$(backgroundColor)$;
|
||||||
\end
|
\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"/>
|
<$reveal state=<<qualify "$:/state/tagpopup">> type="popup" position="below" animate="yes"><div class="tw-drop-down"><$transclude tiddler="$:/core/ui/ListItemTemplate"/>
|
||||||
<hr>
|
<hr>
|
||||||
<$list filter="[is[current]tagging[]]" template="$:/core/ui/ListItemTemplate"/>
|
<$list filter="[is[current]tagging[]]" template="$:/core/ui/ListItemTemplate"/>
|
||||||
|
@ -3,7 +3,7 @@ title: $:/core/ui/TagsEditor
|
|||||||
\define tag-styles()
|
\define tag-styles()
|
||||||
background-color:$(backgroundColor)$;
|
background-color:$(backgroundColor)$;
|
||||||
\end
|
\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">×</$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">×</$button></span></$set>
|
||||||
</$list></div>
|
</$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>
|
<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">
|
<div class="tw-tags-autocomplete-wrapper">
|
||||||
<$reveal state=<<qualify "$:/state/tagsAutoComplete">> type="nomatch" text="" default="">
|
<$reveal state=<<qualify "$:/state/tagsAutoComplete">> type="nomatch" text="" default="">
|
||||||
<div class="tw-tags-autocomplete">
|
<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>
|
</$list>
|
||||||
</$linkcatcher>
|
</$linkcatcher>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,7 +6,7 @@ fill:$(foregroundColor)$;
|
|||||||
\end
|
\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>
|
<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">
|
<$reveal type="nomatch" text="" default="" state=<<qualify "$:/state/tiddlerInfo">> class="tw-tiddler-info tw-popup" animate="yes">
|
||||||
|
|
||||||
|
@ -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();
|
var wiki = new $tw.Wiki();
|
||||||
// Add some tiddlers
|
// Add some tiddlers
|
||||||
wiki.addTiddlers([
|
wiki.addTiddlers([
|
||||||
@ -238,7 +238,7 @@ describe("Widget module", function() {
|
|||||||
{title: "TiddlerFour", text: "TiddlerTwo"}
|
{title: "TiddlerFour", text: "TiddlerTwo"}
|
||||||
]);
|
]);
|
||||||
// Construct the widget node
|
// 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);
|
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
|
||||||
// Render the widget node to the DOM
|
// Render the widget node to the DOM
|
||||||
var wrapper = renderWidgetNode(widgetNode);
|
var wrapper = renderWidgetNode(widgetNode);
|
||||||
|
@ -98,7 +98,7 @@ describe("WikiText parser tests", function() {
|
|||||||
it("should parse macro definitions", function() {
|
it("should parse macro definitions", function() {
|
||||||
expect(parse("\\define myMacro()\nnothing\n\\end\n")).toEqual(
|
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 : [ ] } ]
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,18 +1,10 @@
|
|||||||
title: SetVariableWidget
|
title: SetVariableWidget
|
||||||
created: 201310241419
|
created: 201310241419
|
||||||
creator: JeremyRuston
|
creator: JeremyRuston
|
||||||
modified: 201310300837
|
modified: 201311151827
|
||||||
modifier: JeremyRuston
|
modifier: JeremyRuston
|
||||||
tags: widget
|
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.
|
For the moment, you can continue to use `<$setvariable>` as a synonym for `<$set/>`, but it will be removed for the beta.
|
||||||
|
|
||||||
! 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 |
|
|
||||||
|
18
editions/tw5.com/tiddlers/widgets/SetWidget.tid
Normal file
18
editions/tw5.com/tiddlers/widgets/SetWidget.tid
Normal 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 |
|
Loading…
Reference in New Issue
Block a user