/*\ title: js/Renderer.js Renderer objects \*/ (function(){ /*jshint node: true, browser: true */ "use strict"; var utils = require("./Utils.js"); var Node = function(children) { if(this instanceof Node) { this.children = children; } else { return new Node(children); } }; Node.prototype.clone = function() { // By default we don't actually clone nodes, we just re-use them (we do clone macros and elements) return this; }; Node.prototype.execute = function(parents,tiddler) { }; Node.prototype.render = function(type) { }; Node.prototype.renderInDom = function(domNode) { }; Node.prototype.refresh = function(changes) { }; Node.prototype.refreshInDom = function(changes) { }; var MacroNode = function(macroName,paramFn,children,dependencies,store) { if(this instanceof MacroNode) { this.macroName = macroName; this.macro = store.macros[macroName]; this.paramFn = paramFn; // Can be a function yielding a hashmap, or a direct hashmap this.children = children; this.dependencies = dependencies; this.store = store; } else { return new MacroNode(macroName,paramFn,children,dependencies,store); } }; MacroNode.prototype = new Node(); MacroNode.prototype.constructor = MacroNode; MacroNode.prototype.clone = function() { return new MacroNode(this.macroName,this.paramFn,this.cloneChildren(),this.dependencies,this.store); }; MacroNode.prototype.cloneChildren = function() { var childClones; if(this.children) { childClones = []; for(var t=0; t"); } if(this.children) { for(var t=0; t"); } } return output.join(""); }; ElementNode.prototype.renderInDom = function(domNode) { var element = document.createElement(this.type); if(this.attributes) { for(var a in this.attributes) { var v = this.attributes[a]; if(v !== undefined) { if(v instanceof Array) { // Ahem, could there be arrays other than className? element.className = v.join(" "); } else if (typeof v === "object") { // ...or objects other than style? for(var p in v) { element.style[p] = v[p]; } } else { element.setAttribute(a,v); } } } } domNode.appendChild(element); if(this.children) { for(var t=0; t