1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 13:29:56 +00:00

Extended slider macro to accept a "content" parameter

It specifies wikitext to directly include within the slider, overriding
any specified targetTiddler
This commit is contained in:
Jeremy Ruston 2012-02-22 21:39:59 +00:00
parent 6a0f2006bf
commit 52c3e7a146
2 changed files with 18 additions and 10 deletions

View File

@ -19,7 +19,8 @@ exports.macro = {
state: {byPos: 0, type: "tiddler"}, state: {byPos: 0, type: "tiddler"},
targetTiddler: {byPos: 1, type: "tiddler"}, targetTiddler: {byPos: 1, type: "tiddler"},
label: {byPos: 2, type: "text"}, label: {byPos: 2, type: "text"},
tooltip: {byPos: 3, type: "text"} tooltip: {byPos: 3, type: "text"},
content: {byName: true, type: "text"}
}, },
events: { events: {
click: function(event) { click: function(event) {
@ -38,18 +39,22 @@ exports.macro = {
}, },
execute: function() { execute: function() {
var isOpen = this.params.state ? this.store.getTiddlerText(this.params.state,"").trim() === "open" : true, var isOpen = this.params.state ? this.store.getTiddlerText(this.params.state,"").trim() === "open" : true,
target = this.params.targetTiddler; target = this.params.targetTiddler,
sliderContent;
if(this.params.hasOwnProperty("content")) {
sliderContent = this.store.parseText("text/x-tiddlywiki",this.params.content).tree;
} else {
sliderContent = [Renderer.MacroNode(
"tiddler",
{target: target},
null,
this.store)];
}
var content = Renderer.SliderNode(this.params.state, var content = Renderer.SliderNode(this.params.state,
this.params.label ? this.params.label : target, this.params.label ? this.params.label : target,
this.params.tooltip, this.params.tooltip,
isOpen, isOpen,
[ sliderContent);
Renderer.MacroNode(
"tiddler",
{target: target},
null,
this.store)
]);
content.execute(this.parents,this.store.getTiddler(this.tiddlerText)); content.execute(this.parents,this.store.getTiddler(this.tiddlerText));
return [content]; return [content];
}, },

View File

@ -5,5 +5,8 @@ The status of this slider is stored in the tiddler JackSlider:
And here's another slider that is also keyed to JackSlider (<<slider JackSlider "HelloThere">>), this time inline. And here's another slider that is also keyed to JackSlider (<<slider JackSlider "HelloThere">>), this time inline.
And here's another slider that contains a video: And here's another slider that contains a video, with the state stored in VideoSlider (currently <<tiddler VideoSlider>>):
<<slider VideoSlider "VideoTests">> <<slider VideoSlider "VideoTests">>
And here's a slider that works with text, rather than a separate tiddler.
<<slider state:MiniSlider label:"Click me!" content:"This is the //content// of the slider. The state is stored in MiniSlider">>