From 829909bffa8460ac0f303b4fe5878dd491d0c4cd Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 20 Jun 2012 17:40:41 +0100 Subject: [PATCH] New hide macro Used for selectively hiding blocks of content --- core/modules/macros/hide.js | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 core/modules/macros/hide.js diff --git a/core/modules/macros/hide.js b/core/modules/macros/hide.js new file mode 100644 index 000000000..663d2be58 --- /dev/null +++ b/core/modules/macros/hide.js @@ -0,0 +1,48 @@ +/*\ +title: $:/core/modules/macros/hide.js +type: application/javascript +module-type: macro + +A macro that selectively hides its children + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.info = { + name: "hide", + params: { + tiddler: {byName: "default", type: "tiddler"}, + notequal: {byName: true, type: "text"} + } +}; + +exports.executeMacro = function() { + var attributes = {}, children, text, show = false; + if(this.classes) { + attributes["class"] = this.classes.slice(0); + } + if(this.hasParameter("tiddler")) { + text = this.wiki.getTextReference(this.params.tiddler); + if(this.hasParameter("notequal")) { + if(text === this.params.notequal) { + show = true; + } + } + if(show) { + children = this.content; + for(var t=0; t