1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 02:50:27 +00:00

Added the slider macro

This commit is contained in:
Jeremy Ruston 2012-01-23 18:31:17 +00:00
parent 12cf19e70a
commit ed87061897
2 changed files with 50 additions and 0 deletions

View File

@ -93,6 +93,7 @@ var App = function() {
this.store.installMacro(require("./macros/info.js").macro);
this.store.installMacro(require("./macros/link.js").macro);
this.store.installMacro(require("./macros/list.js").macro);
this.store.installMacro(require("./macros/slider.js").macro);
this.store.installMacro(require("./macros/story.js").macro);
this.store.installMacro(require("./macros/tiddler.js").macro);
this.store.installMacro(require("./macros/version.js").macro);

49
js/macros/slider.js Normal file
View File

@ -0,0 +1,49 @@
/*\
title: js/macros/slider.js
\*/
(function(){
/*jslint node: true */
"use strict";
var utils = require("../Utils.js");
exports.macro = {
name: "slider",
types: ["text/html","text/plain"],
params: {
name: {byPos: 0, type: "text", optional: false},
targetTiddler: {byPos: 1, type: "tiddler", optional: false},
label: {byPos: 2, type: "text", optional: false},
tooltip: {byPos: 3, type: "text", optional: true}
},
handler: function(type,tiddler,store,params) {
if(type === "text/html") {
var sliderHandle = utils.stitchElement("div",params.tooltip ? {
title: utils.htmlEncode(params.tooltip)
} : null,{
content: utils.htmlEncode(params.label),
classNames: ["tw-slider-handle"]
}),
sliderBody = utils.stitchElement("div",{
style: {
display: "block"
}
},{
content: store.renderTiddler(type,params.targetTiddler),
classNames: ["tw-slider-body"]
});
return utils.stitchElement("div",null,{
content: sliderHandle + sliderBody,
classNames: ["tw-slider"]
});
} else if(type === "text/plain") {
return store.renderTiddler(type,params.target);
}
return null;
}
};
})();