1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-10-25 04:37:40 +00:00

Adjust the slider macro to the new Bootstrap styles

And fixed some indentation issues
This commit is contained in:
Jeremy Ruston
2012-03-05 15:14:24 +00:00
parent bfc1f1aaa5
commit 0f2883b75a

View File

@@ -19,7 +19,7 @@ The current state of the slider can be stored as the string "open" or "closed" i
The markup generated by the slider macro is: The markup generated by the slider macro is:
{{{ {{{
<span class="tw-slider {user defined class}"> <span class="tw-slider {user defined class}">
<a class="tw-slider-label">{slider label}</a> <a class="btn-info">{slider label}</a>
<div class="tw-slider-body" style="display:{state}">{slider content}</div> <div class="tw-slider-body" style="display:{state}">{slider content}</div>
</span> </span>
}}} }}}
@@ -104,45 +104,45 @@ exports.macro = {
} }
}, },
execute: function() { execute: function() {
this.isOpen = getOpenState(this); this.isOpen = getOpenState(this);
var sliderContent = []; var sliderContent = [];
if(this.isOpen) { if(this.isOpen) {
sliderContent = getSliderContent(this); sliderContent = getSliderContent(this);
} }
var attributes = { var attributes = {
"class": ["tw-slider"] "class": ["tw-slider"]
}; };
if(this.hasParameter("class")) { if(this.hasParameter("class")) {
attributes["class"].push(this.params["class"]); attributes["class"].push(this.params["class"]);
} }
if(this.hasParameter("state")) { if(this.hasParameter("state")) {
attributes["data-tw-slider-type"] = this.params.state; attributes["data-tw-slider-type"] = this.params.state;
} }
if(this.hasParameter("tooltip")) { if(this.hasParameter("tooltip")) {
attributes.alt = this.params.tooltip; attributes.alt = this.params.tooltip;
attributes.title = this.params.tooltip; attributes.title = this.params.tooltip;
} }
var content = Renderer.ElementNode("span", var content = Renderer.ElementNode("span",
attributes, attributes,
[ [
Renderer.ElementNode("a", Renderer.ElementNode("a",
{ {
"class": ["tw-slider-label"] "class": ["btn","btn-info"]
},[ },[
Renderer.TextNode(this.params.label ? this.params.label : this.params.target) Renderer.TextNode(this.params.label ? this.params.label : this.params.target)
] ]
), ),
Renderer.ElementNode("div", Renderer.ElementNode("div",
{ {
"class": ["tw-slider-body"], "class": ["tw-slider-body"],
"style": {"display": this.isOpen ? "block" : "none"} "style": {"display": this.isOpen ? "block" : "none"}
}, },
sliderContent sliderContent
) )
] ]
); );
content.execute(this.parents,this.store.getTiddler(this.tiddlerTitle)); content.execute(this.parents,this.store.getTiddler(this.tiddlerTitle));
return [content]; return [content];
}, },
refreshInDom: function(changes) { refreshInDom: function(changes) {
var needContentRefresh = true; // Avoid refreshing the content nodes if we don't need to var needContentRefresh = true; // Avoid refreshing the content nodes if we don't need to