1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-08 02:49:56 +00:00
TiddlyWiki5/js/macros/slider.js

44 lines
1010 B
JavaScript
Raw Normal View History

2012-01-23 18:31:17 +00:00
/*\
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}
},
events: {
click: function(event,node,tiddler,store,params) {
var el = node.firstChild.firstChild.nextSibling;
el.style.display = el.style.display === "block" ? "none" : "block";
event.preventDefault();
return false;
}
},
2012-01-30 20:04:47 +00:00
render: function(type,tiddler,store,params) {
2012-01-23 18:31:17 +00:00
if(type === "text/html") {
return utils.stitchSlider(type,
params.label,
params.tooltip,
store.renderTiddler(type,params.targetTiddler));
2012-01-23 18:31:17 +00:00
} else if(type === "text/plain") {
return store.renderTiddler(type,params.target);
}
return null;
}
};
})();