/*\ title: $:/core/modules/macros/checkbox.js type: application/javascript module-type: macro Checkbox macro {{{ <> <> << <> >> }}} \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; exports.info = { name: "checkbox", params: { tiddler: {byName: true, type: "tiddler"}, tag: {byPos: 0, type: "text"}, "class": {byName: true, type: "text"} } }; exports.getValue = function() { var tiddler = this.wiki.getTiddler(this.targetTitle); return tiddler ? tiddler.hasTag(this.params.tag) : false; }; exports.executeMacro = function() { // Get the title of the target tiddler if(this.hasParameter("tiddler")) { this.targetTitle = this.params.tiddler; } else { this.targetTitle = this.tiddlerTitle; } // Checkbox attributes var checkboxAttributes = { type: "checkbox" }; if(this.getValue()) { checkboxAttributes.checked = "true"; } // Label attributes var labelAttributes = { "class": [] }; if(this.hasParameter("class")) { $tw.utils.pushTop(labelAttributes["class"],this.params["class"].split(" ")); } if(this.classes) { $tw.utils.pushTop(labelAttributes["class"],this.classes); } // Execute content for(var t=0; t