mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 11:00:27 +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:
parent
6a0f2006bf
commit
52c3e7a146
@ -19,7 +19,8 @@ exports.macro = {
|
||||
state: {byPos: 0, type: "tiddler"},
|
||||
targetTiddler: {byPos: 1, type: "tiddler"},
|
||||
label: {byPos: 2, type: "text"},
|
||||
tooltip: {byPos: 3, type: "text"}
|
||||
tooltip: {byPos: 3, type: "text"},
|
||||
content: {byName: true, type: "text"}
|
||||
},
|
||||
events: {
|
||||
click: function(event) {
|
||||
@ -38,18 +39,22 @@ exports.macro = {
|
||||
},
|
||||
execute: function() {
|
||||
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,
|
||||
this.params.label ? this.params.label : target,
|
||||
this.params.tooltip,
|
||||
isOpen,
|
||||
[
|
||||
Renderer.MacroNode(
|
||||
"tiddler",
|
||||
{target: target},
|
||||
null,
|
||||
this.store)
|
||||
]);
|
||||
sliderContent);
|
||||
content.execute(this.parents,this.store.getTiddler(this.tiddlerText));
|
||||
return [content];
|
||||
},
|
||||
|
@ -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 contains a video:
|
||||
And here's another slider that contains a video, with the state stored in VideoSlider (currently <<tiddler VideoSlider>>):
|
||||
<<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">>
|
||||
|
Loading…
Reference in New Issue
Block a user