1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-03 18:53:28 +00:00
TiddlyWiki5/core/modules/macros/color.js
Jeremy Ruston 49cc644293 Whitespace
2012-06-16 19:02:44 +01:00

41 lines
890 B
JavaScript

/*\
title: $:/core/modules/macros/color.js
type: application/javascript
module-type: macro
Color macro.
Applies the specified colour to its content. By default, the colour value is obtained from the `color` field of the current tiddler
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "color",
params: {
"default": {byName: "default", type: "text"}
}
};
exports.executeMacro = function() {
var tiddler = this.wiki.getTiddler(this.tiddlerTitle),
attributes = {
style: {
"background-color": (tiddler && tiddler.fields.color) || this.params["default"]
}
};
if(this.classes) {
attributes["class"] = this.classes.slice(0);
}
for(var t=0; t<this.content.length; t++) {
this.content[t].execute(this.parents,this.tiddlerTitle);
}
return $tw.Tree.Element("span",attributes,this.content);
};
})();