2012-04-30 11:23:03 +00:00
|
|
|
/*\
|
2012-05-03 20:47:16 +00:00
|
|
|
title: $:/core/modules/treenodes/node.js
|
2012-04-30 11:23:03 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: treenode
|
|
|
|
|
|
|
|
Base class for all other tree nodes
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2012-05-04 17:49:04 +00:00
|
|
|
/*jslint node: true, browser: true */
|
2012-06-26 19:50:29 +00:00
|
|
|
/*global $tw: false, Node: false */
|
2012-04-30 11:23:03 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
The virtual base class for all types of renderer nodes. It keeps track of child nodes but otherwise contains no functionality
|
|
|
|
*/
|
|
|
|
var Node = function() {
|
|
|
|
if(this instanceof Node) {
|
|
|
|
} else {
|
|
|
|
return new Node();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Makes a copy of a node, or returns the node itself if it doesn't need cloning because it doesn't have any state
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Execute a node and derive its child nodes
|
|
|
|
parents: array of titles of each transcluded parent tiddler (used for detecting recursion)
|
|
|
|
tiddlerTitle: title of the context tiddler within which this node is being executed
|
|
|
|
*/
|
|
|
|
Node.prototype.execute = function(parents,tiddlerTitle) {
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Render a node and its children to a particular MIME type
|
|
|
|
type: Content type to which the node should be rendered
|
|
|
|
*/
|
|
|
|
Node.prototype.render = function(type) {
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Render a node and its children into the DOM
|
|
|
|
parentDomNode: node that should become the parent of the rendered node
|
|
|
|
insertBefore: optional node that the node should be inserted before
|
|
|
|
*/
|
|
|
|
Node.prototype.renderInDom = function(parentDomNode,insertBefore) {
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Re-execute a node if it is impacted by a set of tiddler changes
|
|
|
|
changes: hashmap of tiddler changes in the format used by $tw.Wiki
|
|
|
|
*/
|
|
|
|
Node.prototype.refresh = function(changes) {
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Re-execute a node if it is impacted by a set of tiddler changes, and update the associated DOM elements as necessary
|
|
|
|
changes: hashmap of tiddler changes in the format used by $tw.Wiki
|
|
|
|
*/
|
|
|
|
Node.prototype.refreshInDom = function(changes) {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-06-02 12:19:32 +00:00
|
|
|
/*
|
|
|
|
Add a class to the node
|
|
|
|
*/
|
|
|
|
Node.prototype.addClass = function(className) {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-06-14 17:18:32 +00:00
|
|
|
/*
|
|
|
|
Add styles to a node
|
|
|
|
*/
|
|
|
|
Node.prototype.addStyles = function(styles) {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-06-26 19:50:29 +00:00
|
|
|
/*
|
|
|
|
Given a tree node find the bounding rectange of its first child element
|
|
|
|
*/
|
|
|
|
Node.prototype.getNodeBounds = function() {
|
|
|
|
var t,bounds;
|
|
|
|
if(this.domNode) {
|
|
|
|
if(this.domNode.nodeType === 3) { // Node.TEXT_NODE
|
|
|
|
return this.domNode.parentNode.getBoundingClientRect();
|
|
|
|
} else {
|
|
|
|
return this.domNode.getBoundingClientRect();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(this.child) {
|
|
|
|
return this.child.getNodeBounds();
|
|
|
|
} else if(this.children) {
|
|
|
|
for(t=0; t<this.children.length; t++) {
|
|
|
|
bounds = this.children[t].getNodeBounds();
|
|
|
|
if(bounds) {
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
re
|
|
|
|
}
|
|
|
|
|
2012-04-30 11:23:03 +00:00
|
|
|
exports.Node = Node;
|
|
|
|
|
|
|
|
})();
|