2013-01-11 03:01:24 +00:00
|
|
|
/*
|
|
|
|
* @file
|
|
|
|
* This function defines all settings and event callbacks for the JIT graph. Some are found in other files
|
|
|
|
* First is the common settings (the same as arranged or chaotic)
|
|
|
|
* Then if it's a centred graph additional settings are added.
|
|
|
|
*/
|
2012-12-14 18:31:39 +00:00
|
|
|
|
2013-01-11 03:01:24 +00:00
|
|
|
function graphSettings(type) {
|
|
|
|
var t = {
|
|
|
|
//id of the visualization container
|
|
|
|
injectInto: 'infovis',
|
|
|
|
//Enable zooming and panning
|
|
|
|
//by scrolling and DnD
|
|
|
|
Navigation: {
|
|
|
|
enable: true,
|
|
|
|
type: 'HTML',
|
|
|
|
//Enable panning events only if we're dragging the empty
|
|
|
|
//canvas (and not a node).
|
|
|
|
panning: 'avoid nodes',
|
|
|
|
zooming: 15 //zoom speed. higher is more sensible
|
|
|
|
},
|
|
|
|
// Change node and edge styles such as
|
|
|
|
// color and width.
|
|
|
|
// These properties are also set per node
|
|
|
|
// with dollar prefixed data-properties in the
|
|
|
|
// JSON structure.
|
|
|
|
Node: {
|
|
|
|
overridable: true,
|
|
|
|
color: '#2D6A5D',
|
|
|
|
type: 'customNode',
|
|
|
|
dim: 25
|
|
|
|
},
|
|
|
|
Edge: {
|
|
|
|
overridable: true,
|
|
|
|
color: '#222222',
|
|
|
|
type: 'customEdge',
|
2013-01-24 04:40:06 +00:00
|
|
|
lineWidth: 2,
|
|
|
|
alpha: 0.4
|
2013-01-11 03:01:24 +00:00
|
|
|
},
|
|
|
|
//Native canvas text styling
|
|
|
|
Label: {
|
|
|
|
type: 'HTML', //Native or HTML
|
|
|
|
size: 20,
|
|
|
|
//style: 'bold'
|
|
|
|
},
|
|
|
|
//Add Tips
|
|
|
|
Tips: {
|
|
|
|
enable: false,
|
|
|
|
onShow: function (tip, node) {}
|
|
|
|
},
|
|
|
|
// Add node events
|
|
|
|
Events: {
|
|
|
|
enable: true,
|
|
|
|
enableForEdges: true,
|
|
|
|
type: 'HTML',
|
|
|
|
onMouseMove: function(node, eventInfo, e) {
|
|
|
|
onMouseMoveHandler(node, eventInfo, e);
|
|
|
|
},
|
|
|
|
//Update node positions when dragged
|
|
|
|
onDragMove: function (node, eventInfo, e) {
|
|
|
|
onDragMoveTopicHandler(node, eventInfo, e);
|
|
|
|
},
|
|
|
|
onDragEnd: function(node, eventInfo, e) {
|
|
|
|
onDragEndTopicHandler(node, eventInfo, e, false);
|
|
|
|
},
|
|
|
|
onDragCancel: function(node, eventInfo, e) {
|
|
|
|
onDragCancelHandler(node, eventInfo, e, false);
|
|
|
|
},
|
|
|
|
//Implement the same handler for touchscreens
|
|
|
|
onTouchMove: function (node, eventInfo, e) {
|
|
|
|
$jit.util.event.stop(e); //stop default touchmove event
|
|
|
|
this.onDragMove(node, eventInfo, e);
|
|
|
|
},
|
|
|
|
//Add also a click handler to nodes
|
|
|
|
onClick: function (node, eventInfo, e) {
|
|
|
|
if (e.target.id != "infovis-canvas") return false;
|
|
|
|
//clicking on a node, or clicking on blank part of canvas?
|
|
|
|
if (node.nodeFrom) {
|
|
|
|
selectEdgeOnClickHandler(node, e);
|
|
|
|
} else if (node && !node.nodeFrom) {
|
|
|
|
selectNodeOnClickHandler(node, e);
|
|
|
|
} else {
|
|
|
|
canvasDoubleClickHandler(eventInfo.getPos(), e);
|
|
|
|
}//if
|
|
|
|
}
|
2013-01-11 03:19:44 +00:00
|
|
|
},
|
|
|
|
//Number of iterations for the FD algorithm
|
|
|
|
iterations: 200,
|
|
|
|
//Edge length
|
|
|
|
levelDistance: 200,
|
|
|
|
// Add text to the labels. This method is only triggered
|
|
|
|
// on label creation and only for DOM labels (not native canvas ones).
|
|
|
|
onCreateLabel: function (domElement, node) {
|
|
|
|
onCreateLabelHandler(domElement, node);
|
|
|
|
},
|
|
|
|
// Change node styles when DOM labels are placed or moved.
|
|
|
|
onPlaceLabel: function (domElement, node) {
|
|
|
|
onPlaceLabelHandler(domElement, node);
|
|
|
|
}
|
2013-01-11 03:01:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (type == "centered") {
|
|
|
|
t.background = {
|
|
|
|
CanvasStyles: {
|
|
|
|
strokeStyle: '#333',
|
|
|
|
lineWidth: 1.5
|
|
|
|
}
|
|
|
|
};
|
|
|
|
t.Events.enableForEdges = true;
|
|
|
|
t.Events.onDragEnd = function(node, eventInfo, e) {
|
|
|
|
//different because we can't go realtime
|
|
|
|
onDragEndTopicHandler(node, eventInfo, e, false);
|
|
|
|
};
|
|
|
|
t.Events.onDragCancel = function(node, eventInfo, e) {
|
|
|
|
//different because we're centred
|
|
|
|
onDragCancelHandler(node, eventInfo, e, true);
|
|
|
|
};
|
|
|
|
t.Events.onClick = function(node, eventInfo, e) {
|
|
|
|
//this is handled mostly differently than in arranged/chaotic
|
|
|
|
if (e.target.id != "infovis-canvas") return false;
|
|
|
|
//clicking on an edge, a node, or clicking on blank part of canvas?
|
|
|
|
if (node.nodeFrom) {
|
|
|
|
selectEdgeOnClickHandler(node, e);
|
|
|
|
} else if (node && !node.nodeFrom) {
|
|
|
|
//node is actually a node :)
|
|
|
|
if (!Mconsole.busy) {
|
2013-01-25 05:47:32 +00:00
|
|
|
$('h1.index').html('Viewing Topic: ' + node.name);
|
|
|
|
window.history.pushState(node.name, "Metamaps", "/topics/" + node.id);
|
2013-01-11 03:01:24 +00:00
|
|
|
Mconsole.onClick(node.id, {
|
2013-01-24 03:05:24 +00:00
|
|
|
hideLabels: false,
|
2013-01-25 05:47:32 +00:00
|
|
|
duration: 1000,
|
2013-01-24 03:05:24 +00:00
|
|
|
onComplete: function() {
|
2013-01-25 05:47:32 +00:00
|
|
|
fetchRelatives(node);
|
2013-01-24 03:05:24 +00:00
|
|
|
}
|
2013-01-11 03:01:24 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
canvasDoubleClickHandler(eventInfo.getPos(), e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}//if
|
2013-01-06 03:40:31 +00:00
|
|
|
|
2013-01-11 03:01:24 +00:00
|
|
|
return t;
|
|
|
|
}//graphSettings
|
2012-12-15 07:39:14 +00:00
|
|
|
|
2013-01-25 05:47:32 +00:00
|
|
|
// defining code to draw edges with arrows pointing in one direction
|
2012-12-23 06:12:56 +00:00
|
|
|
var renderMidArrow = function(from, to, dim, swap, canvas){
|
|
|
|
var ctx = canvas.getCtx();
|
|
|
|
// invert edge direction
|
|
|
|
if (swap) {
|
|
|
|
var tmp = from;
|
|
|
|
from = to;
|
|
|
|
to = tmp;
|
|
|
|
}
|
|
|
|
// vect represents a line from tip to tail of the arrow
|
|
|
|
var vect = new $jit.Complex(to.x - from.x, to.y - from.y);
|
|
|
|
// scale it
|
|
|
|
vect.$scale(dim / vect.norm());
|
|
|
|
// compute the midpoint of the edge line
|
|
|
|
var midPoint = new $jit.Complex((to.x + from.x) / 2, (to.y + from.y) / 2);
|
|
|
|
// move midpoint by half the "length" of the arrow so the arrow is centered on the midpoint
|
2013-01-05 22:31:38 +00:00
|
|
|
var arrowPoint = new $jit.Complex((vect.x / 0.7) + midPoint.x, (vect.y / 0.7) + midPoint.y);
|
2012-12-23 06:12:56 +00:00
|
|
|
// compute the tail intersection point with the edge line
|
2013-01-05 22:31:38 +00:00
|
|
|
var intermediatePoint = new $jit.Complex(arrowPoint.x - vect.x,
|
|
|
|
arrowPoint.y - vect.y);
|
2012-12-23 06:12:56 +00:00
|
|
|
// vector perpendicular to vect
|
|
|
|
var normal = new $jit.Complex(-vect.y / 2, vect.x / 2);
|
|
|
|
var v1 = intermediatePoint.add(normal);
|
|
|
|
var v2 = intermediatePoint.$add(normal.$scale(-1));
|
|
|
|
|
2013-01-05 22:31:38 +00:00
|
|
|
//ctx.strokeStyle = "#222222";
|
2012-12-23 06:12:56 +00:00
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo(from.x, from.y);
|
|
|
|
ctx.lineTo(to.x, to.y);
|
|
|
|
ctx.stroke();
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo(v1.x, v1.y);
|
2013-01-05 22:31:38 +00:00
|
|
|
ctx.lineTo(arrowPoint.x, arrowPoint.y);
|
2012-12-23 06:12:56 +00:00
|
|
|
ctx.lineTo(v2.x, v2.y);
|
|
|
|
ctx.stroke();
|
|
|
|
};
|
2013-01-25 05:47:32 +00:00
|
|
|
// defining code to draw edges with arrows pointing in both directions
|
|
|
|
var renderMidArrows = function(from, to, dim, swap, canvas){
|
|
|
|
var ctx = canvas.getCtx();
|
|
|
|
// invert edge direction
|
|
|
|
if (swap) {
|
|
|
|
var tmp = from;
|
|
|
|
from = to;
|
|
|
|
to = tmp;
|
|
|
|
}
|
|
|
|
// vect represents a line from tip to tail of the arrow
|
|
|
|
var vect = new $jit.Complex(to.x - from.x, to.y - from.y);
|
|
|
|
// scale it
|
|
|
|
vect.$scale(dim / vect.norm());
|
|
|
|
// compute the midpoint of the edge line
|
|
|
|
var midPoint = new $jit.Complex((to.x + from.x) / 2, (to.y + from.y) / 2);
|
|
|
|
// move midpoint by half the "length" of the arrow so the arrow is centered on the midpoint
|
|
|
|
var arrowPoint = new $jit.Complex((vect.x / 0.7) + midPoint.x, (vect.y / 0.7) + midPoint.y);
|
|
|
|
// compute the tail intersection point with the edge line
|
|
|
|
var intermediatePoint = new $jit.Complex(arrowPoint.x - vect.x,
|
|
|
|
arrowPoint.y - vect.y);
|
|
|
|
// vector perpendicular to vect
|
|
|
|
var normal = new $jit.Complex(-vect.y / 2, vect.x / 2);
|
|
|
|
var v1 = intermediatePoint.add(normal);
|
|
|
|
var v2 = intermediatePoint.$add(normal.$scale(-1));
|
|
|
|
|
|
|
|
//ctx.strokeStyle = "#222222";
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo(v1.x, v1.y);
|
|
|
|
ctx.lineTo(arrowPoint.x, arrowPoint.y);
|
|
|
|
ctx.lineTo(v2.x, v2.y);
|
|
|
|
ctx.stroke();
|
|
|
|
};
|
2012-12-15 07:39:14 +00:00
|
|
|
|
|
|
|
// defining custom node type
|
2012-12-16 00:46:39 +00:00
|
|
|
var nodeSettings = {
|
2012-12-15 07:39:14 +00:00
|
|
|
'customNode': {
|
|
|
|
'render': function (node, canvas) {
|
|
|
|
var pos = node.pos.getc(true),
|
|
|
|
dim = node.getData('dim'),
|
2013-01-01 22:45:35 +00:00
|
|
|
cat = node.getData('metacode'),
|
2012-12-25 23:29:20 +00:00
|
|
|
inCommons = node.getData('inCommons'),
|
|
|
|
onCanvas = node.getData('onCanvas'),
|
2012-12-15 07:39:14 +00:00
|
|
|
ctx = canvas.getCtx();
|
2012-12-22 19:52:16 +00:00
|
|
|
|
2012-12-25 23:29:20 +00:00
|
|
|
// if the topic is from the Commons draw a green circle around it
|
|
|
|
if (inCommons) {
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.arc(pos.x, pos.y, dim+3, 0, 2 * Math.PI, false);
|
|
|
|
ctx.strokeStyle = '#67be5f'; // green
|
|
|
|
ctx.lineWidth = 2;
|
|
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
// if the topic is on the Canvas draw a white circle around it
|
|
|
|
if (onCanvas) {
|
2012-12-22 19:52:16 +00:00
|
|
|
ctx.beginPath();
|
|
|
|
ctx.arc(pos.x, pos.y, dim+3, 0, 2 * Math.PI, false);
|
2012-12-23 06:12:56 +00:00
|
|
|
ctx.strokeStyle = 'white';
|
|
|
|
ctx.lineWidth = 2;
|
|
|
|
ctx.stroke();
|
2012-12-22 19:52:16 +00:00
|
|
|
}
|
2012-12-15 07:39:14 +00:00
|
|
|
ctx.drawImage(imgArray[cat], pos.x - dim, pos.y - dim, dim*2, dim*2);
|
|
|
|
|
|
|
|
},
|
|
|
|
'contains': function(node, pos) {
|
|
|
|
var npos = node.pos.getc(true),
|
|
|
|
dim = node.getData('dim');
|
|
|
|
return this.nodeHelper.circle.contains(npos, pos, dim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// defining custom edges
|
|
|
|
var edgeSettings = {
|
|
|
|
'customEdge': {
|
|
|
|
'render': function(adj, canvas) {
|
|
|
|
//get nodes cartesian coordinates
|
|
|
|
var pos = adj.nodeFrom.pos.getc(true);
|
|
|
|
var posChild = adj.nodeTo.pos.getc(true);
|
|
|
|
|
|
|
|
var directionCat = adj.getData("category");
|
|
|
|
//label placement on edges
|
|
|
|
//plot arrow edge
|
|
|
|
if (directionCat == "none") {
|
|
|
|
this.edgeHelper.line.render({ x: pos.x, y: pos.y }, { x: posChild.x, y: posChild.y }, canvas);
|
|
|
|
}
|
|
|
|
else if (directionCat == "both") {
|
2013-01-25 05:47:32 +00:00
|
|
|
this.edgeHelper.line.render({ x: pos.x, y: pos.y }, { x: posChild.x, y: posChild.y }, canvas);
|
|
|
|
renderMidArrows({ x: pos.x, y: pos.y }, { x: posChild.x, y: posChild.y }, 13, true, canvas);
|
|
|
|
renderMidArrows({ x: pos.x, y: pos.y }, { x: posChild.x, y: posChild.y }, 13, false, canvas);
|
2012-12-15 07:39:14 +00:00
|
|
|
}
|
|
|
|
else if (directionCat == "from-to") {
|
|
|
|
var direction = adj.data.$direction;
|
|
|
|
var inv = (direction && direction.length>1 && direction[0] != adj.nodeFrom.id);
|
|
|
|
renderMidArrow({ x: pos.x, y: pos.y }, { x: posChild.x, y: posChild.y }, 13, inv, canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
//check for edge label in data
|
2013-01-03 08:53:25 +00:00
|
|
|
var desc = adj.getData("desc");
|
2012-12-15 07:39:14 +00:00
|
|
|
var showDesc = adj.getData("showDesc");
|
|
|
|
if( desc != "" && showDesc ) {
|
2013-01-08 01:34:47 +00:00
|
|
|
//now adjust the label placement
|
|
|
|
var ctx = canvas.getCtx();
|
2012-12-15 07:39:14 +00:00
|
|
|
var radius = canvas.getSize();
|
|
|
|
var x = parseInt((pos.x + posChild.x - (desc.length * 5)) /2);
|
|
|
|
var y = parseInt((pos.y + posChild.y) /2);
|
2013-01-08 01:34:47 +00:00
|
|
|
ctx.font = 'bold 14px arial';
|
|
|
|
|
|
|
|
//render background
|
|
|
|
ctx.fillStyle = '#FFF';
|
|
|
|
var margin = 5;
|
|
|
|
var height = 14 + margin; //font size + margin
|
|
|
|
var CURVE = height / 2; //offset for curvy corners
|
|
|
|
var width = ctx.measureText(desc).width + 2 * margin - 2 * CURVE
|
|
|
|
var labelX = x - margin + CURVE;
|
|
|
|
var labelY = y - height + margin;
|
|
|
|
ctx.fillRect(labelX, labelY, width, height);
|
|
|
|
|
|
|
|
//curvy corners woo - circles in place of last CURVE pixels of rect
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.arc(labelX, labelY + CURVE, CURVE, 0, 2 * Math.PI, false);
|
|
|
|
ctx.arc(labelX + width, labelY + CURVE, CURVE, 0, 2 * Math.PI, false);
|
|
|
|
ctx.fill();
|
|
|
|
|
|
|
|
//render text
|
|
|
|
ctx.fillStyle = '#000';
|
|
|
|
ctx.fillText(desc, x, y);
|
2012-12-15 07:39:14 +00:00
|
|
|
}
|
|
|
|
}, 'contains' : function(adj, pos) {
|
|
|
|
var from = adj.nodeFrom.pos.getc(true),
|
2012-12-26 03:47:02 +00:00
|
|
|
to = adj.nodeTo.pos.getc(true);
|
2012-12-21 00:24:27 +00:00
|
|
|
return this.edgeHelper.line.contains(from, to, pos, adj.Edge.epsilon);
|
2012-12-15 07:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-06 03:40:31 +00:00
|
|
|
|
2013-01-05 22:31:38 +00:00
|
|
|
|
2013-01-05 21:28:04 +00:00
|
|
|
function onMouseMoveHandler(node, eventInfo, e) {
|
2013-01-24 03:05:24 +00:00
|
|
|
|
|
|
|
if (Mconsole.busy) return;
|
|
|
|
|
2013-01-06 04:12:32 +00:00
|
|
|
var node = eventInfo.getNode();
|
2013-01-11 03:01:24 +00:00
|
|
|
var edge = eventInfo.getEdge();
|
2013-01-05 22:31:38 +00:00
|
|
|
|
2013-01-06 04:12:32 +00:00
|
|
|
//if we're on top of a node object, act like there aren't edges under it
|
|
|
|
if (node != false) {
|
2013-01-11 03:01:24 +00:00
|
|
|
if (MetamapsModel.edgeHoveringOver) {
|
|
|
|
onMouseLeave(MetamapsModel.edgeHoveringOver);
|
2013-01-06 04:12:32 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-11 03:01:24 +00:00
|
|
|
if (edge == false && MetamapsModel.edgeHoveringOver != false) {
|
2013-01-05 22:31:38 +00:00
|
|
|
//mouse not on an edge, but we were on an edge previously
|
2013-01-11 03:01:24 +00:00
|
|
|
onMouseLeave(MetamapsModel.edgeHoveringOver);
|
|
|
|
} else if (edge != false && MetamapsModel.edgeHoveringOver == false) {
|
2013-01-05 22:31:38 +00:00
|
|
|
//mouse is on an edge, but there isn't a stored edge
|
|
|
|
onMouseEnter(edge);
|
2013-01-11 03:01:24 +00:00
|
|
|
} else if (edge != false && MetamapsModel.edgeHoveringOver != edge) {
|
2013-01-05 22:31:38 +00:00
|
|
|
//mouse is on an edge, but a different edge is stored
|
2013-01-11 03:01:24 +00:00
|
|
|
onMouseLeave(MetamapsModel.edgeHoveringOver)
|
2013-01-06 03:40:31 +00:00
|
|
|
onMouseEnter(edge);
|
2013-01-05 21:28:04 +00:00
|
|
|
}
|
2013-01-11 03:01:24 +00:00
|
|
|
MetamapsModel.edgeHoveringOver = edge;
|
2013-01-05 22:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMouseEnter(edge) {
|
|
|
|
$('canvas').css('cursor', 'pointer');
|
2013-01-06 03:40:31 +00:00
|
|
|
var showDesc = edge.getData("showDesc");
|
|
|
|
if (!showDesc) {
|
|
|
|
edge.setDataset('end', {
|
|
|
|
lineWidth: 4,
|
2013-01-24 04:40:06 +00:00
|
|
|
color: '#222222',
|
|
|
|
alpha: 1
|
2013-01-06 03:40:31 +00:00
|
|
|
});
|
|
|
|
Mconsole.fx.animate({
|
2013-01-24 04:40:06 +00:00
|
|
|
modes: ['edge-property:lineWidth:color:alpha'],
|
2013-01-06 03:40:31 +00:00
|
|
|
duration: 100
|
|
|
|
});
|
|
|
|
Mconsole.plot();
|
|
|
|
}
|
2013-01-05 22:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMouseLeave(edge) {
|
|
|
|
$('canvas').css('cursor', 'default');
|
2013-01-06 03:40:31 +00:00
|
|
|
var showDesc = edge.getData("showDesc");
|
|
|
|
if (!showDesc) {
|
|
|
|
edge.setDataset('end', {
|
|
|
|
lineWidth: 2,
|
2013-01-24 04:40:06 +00:00
|
|
|
color: '#222222',
|
|
|
|
alpha: 0.4
|
2013-01-06 03:40:31 +00:00
|
|
|
});
|
|
|
|
Mconsole.fx.animate({
|
2013-01-24 04:40:06 +00:00
|
|
|
modes: ['edge-property:lineWidth:color:alpha'],
|
2013-01-06 03:40:31 +00:00
|
|
|
duration: 100
|
|
|
|
});
|
|
|
|
}
|
|
|
|
Mconsole.plot();
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is for hiding one topic from your canvas
|
2013-01-11 03:01:24 +00:00
|
|
|
function onDragEndTopicHandler(node, eventInfo, e, allowRealtime) {
|
|
|
|
if (tempInit && tempNode2 == null) {
|
|
|
|
$('#topic_addSynapse').val("true");
|
|
|
|
$('#new_topic').fadeIn('fast');
|
|
|
|
addMetacode();
|
|
|
|
$('#topic_name').focus();
|
|
|
|
} else if (tempInit && tempNode2 != null) {
|
|
|
|
$('#topic_addSynapse').val("false");
|
|
|
|
$('#synapse_topic1id').val(tempNode.id);
|
|
|
|
$('#synapse_topic2id').val(tempNode2.id);
|
|
|
|
$('#new_synapse').fadeIn('fast');
|
|
|
|
$('#synapse_desc').focus();
|
|
|
|
tempNode = null;
|
|
|
|
tempNode2 = null;
|
|
|
|
tempInit = false;
|
2013-01-25 05:47:32 +00:00
|
|
|
} else if (dragged != 0 && goRealtime) {
|
2013-01-11 03:01:24 +00:00
|
|
|
saveLayout(dragged);
|
2013-01-06 04:37:24 +00:00
|
|
|
}
|
2013-01-11 03:01:24 +00:00
|
|
|
}//onDragEndTopicHandler
|
|
|
|
|
|
|
|
function onDragCancelHandler(node, eventInfo, e, centred) {
|
|
|
|
tempNode = null;
|
|
|
|
tempNode2 = null;
|
|
|
|
tempInit = false;
|
|
|
|
|
|
|
|
//not sure why this doesn't happen for centred graphs
|
|
|
|
if (!centred) {
|
|
|
|
$('#topic_addSynapse').val("false");
|
|
|
|
$('#topic_topic1id').val(0);
|
|
|
|
$('#topic_topic2id').val(0);
|
2013-01-06 03:40:31 +00:00
|
|
|
}
|
2013-01-11 03:01:24 +00:00
|
|
|
Mconsole.plot();
|
2013-01-07 05:17:39 +00:00
|
|
|
}
|
|
|
|
|
2013-01-11 03:01:24 +00:00
|
|
|
function onPlaceLabelHandler(domElement, node) {
|
|
|
|
var style = domElement.style;
|
|
|
|
var left = parseInt(style.left);
|
|
|
|
var top = parseInt(style.top);
|
|
|
|
var w = domElement.offsetWidth;
|
|
|
|
style.left = (left - w / 2 + 107) + 'px';
|
|
|
|
style.top = (top-165) + 'px';
|
|
|
|
style.display = '';
|
|
|
|
var label = document.getElementById('topic_' + node.id + '_label');
|
|
|
|
w = label.offsetWidth;
|
|
|
|
style = label.style;
|
|
|
|
style.left = (-(w / 2 + 106)) + 'px';
|
2013-01-07 05:17:39 +00:00
|
|
|
}
|