Devel-NYTProf
view release on metacpan or search on metacpan
lib/Devel/NYTProf/js/jit/jit.js view on Meta::CPAN
},
/*
Method: select
Selects a sepecific node in the Spacetree without performing an animation. Useful when selecting
nodes which are currently hidden or deep inside the tree.
Parameters:
id - The id of the node to select.
onComplete - _optional_ onComplete callback.
Example:
(start code js)
st.select('mynodeid', {
onComplete: function() {
alert('complete!');
}
});
(end code)
*/
select: function(id, onComplete) {
var group = this.group, geom = this.geom;
var node= this.graph.getNode(id), canvas = this.canvas;
var root = this.graph.getNode(this.root);
var complete = $merge(this.controller, onComplete);
var that = this;
complete.onBeforeCompute(node);
this.selectPath(node);
this.clickedNode= node;
this.requestNodes(node, {
onComplete: function(){
group.hide(group.prepare(getNodesToHide.call(that)), complete);
geom.setRightLevelToShow(node, canvas);
that.compute("pos");
Graph.Util.eachNode(that.graph, function(n) {
var pos = n.pos.getc(true);
n.startPos.setc(pos.x, pos.y);
n.endPos.setc(pos.x, pos.y);
n.visited = false;
});
that.geom.translate(node.endPos.scale(-1), ["pos", "startPos", "endPos"]);
group.show(getNodesToShow.call(that));
that.plot();
complete.onAfterCompute(that.clickedNode);
complete.onComplete();
}
});
},
/*
Method: onClick
This method is called when clicking on a tree node. It mainly performs all calculations and the animation of contracting, translating and expanding pertinent nodes.
Parameters:
id - A node id.
options - A group of options and callbacks such as
- _onComplete_ an object callback called when the animation finishes.
- _Move_ an object that has as properties _offsetX_ or _offsetY_ for adding some offset position to the centered node.
Example:
(start code js)
st.onClick('mynodeid', {
Move: {
enable: true,
offsetX: 30,
offsetY: 5
},
onComplete: function() {
alert('yay!');
}
});
(end code)
*/
onClick: function (id, options) {
var canvas = this.canvas, that = this, Fx = this.fx, Util = Graph.Util, Geom = this.geom;
var innerController = {
Move: {
enable: true,
offsetX: 0,
offsetY: 0
},
onBeforeRequest: $empty,
onBeforeContract: $empty,
onBeforeMove: $empty,
onBeforeExpand: $empty
};
var complete = $merge(this.controller, innerController, options);
if(!this.busy) {
this.busy= true;
var node= this.graph.getNode(id);
this.selectPath(node, this.clickedNode);
this.clickedNode= node;
complete.onBeforeCompute(node);
complete.onBeforeRequest(node);
this.requestNodes(node, {
onComplete: function() {
complete.onBeforeContract(node);
that.contract({
onComplete: function() {
Geom.setRightLevelToShow(node, canvas);
complete.onBeforeMove(node);
that.move(node, {
Move: complete.Move,
onComplete: function() {
complete.onBeforeExpand(node);
that.expand(node, {
onComplete: function() {
that.busy = false;
complete.onAfterCompute(id);
complete.onComplete();
}
}); //expand
( run in 0.799 second using v1.01-cache-2.11-cpan-5b529ec07f3 )