2012-03-29 16:02:05 +00:00
|
|
|
/*\
|
|
|
|
title: js/macros/command.js
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2012-03-30 12:47:54 +00:00
|
|
|
/*jslint node: true, browser: true */
|
2012-03-29 16:02:05 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Renderer = require("../Renderer.js").Renderer;
|
|
|
|
|
|
|
|
exports.macro = {
|
|
|
|
name: "command",
|
|
|
|
params: {
|
|
|
|
name: {byName: "default", type: "text"},
|
|
|
|
label: {byName: true, type: "text"},
|
|
|
|
"class": {byName: true, type: "text"}
|
|
|
|
},
|
|
|
|
events: {
|
|
|
|
"click": function(event) {
|
|
|
|
var commandEvent = document.createEvent("Event");
|
|
|
|
commandEvent.initEvent("tw-" + this.params.name,true,true);
|
|
|
|
commandEvent.tiddlerTitle = this.tiddlerTitle;
|
|
|
|
commandEvent.commandOrigin = this;
|
|
|
|
event.target.dispatchEvent(commandEvent);
|
|
|
|
event.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
execute: function() {
|
|
|
|
var attributes = {};
|
|
|
|
if(this.hasParameter("class")) {
|
2012-03-30 12:47:54 +00:00
|
|
|
attributes["class"] = this.params["class"].split(" ");
|
2012-03-29 16:02:05 +00:00
|
|
|
}
|
2012-03-30 12:47:54 +00:00
|
|
|
return [Renderer.ElementNode("button",attributes,[Renderer.TextNode(this.params.label)])];
|
2012-03-29 16:02:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|