1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 10:00:34 +00:00
TiddlyWiki5/core/modules/treenodes/node.js
Jeremy Ruston 9c7a6e5973 Firefox fix
Was preventing zoomin animations working properly
2012-07-07 18:44:27 +01:00

123 lines
2.8 KiB
JavaScript

/*\
title: $:/core/modules/treenodes/node.js
type: application/javascript
module-type: treenode
Base class for all other tree nodes
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false, Node: false */
"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) {
};
/*
Add a class to the node
*/
Node.prototype.addClass = function(className) {
};
/*
Add styles to a node
*/
Node.prototype.addStyles = function(styles) {
};
/*
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
bounds = this.domNode.parentNode.getBoundingClientRect();
} else {
bounds = this.domNode.getBoundingClientRect();
}
// Absurdly, Firefox requires us to do this, otherwise JSON.stringify() gets confused
return {
top: bounds.top,
left: bounds.left,
right: bounds.right,
bottom: bounds.bottom,
width: bounds.width,
height: bounds.height
};
} 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;
}
}
}
}
return null;
};
exports.Node = Node;
})();