# HG changeset patch # User Nobuyasu Oshiro # Date 1363732709 -32400 # Node ID 3fa1be92ab48c39674588a341ed73bbc6c83faf9 # Parent 35ee0b1d87194a7ae991aba22fbfcc439dbdaa0a modified update node.position diff -r 35ee0b1d8719 -r 3fa1be92ab48 index.html --- a/index.html Wed Mar 20 06:23:29 2013 +0900 +++ b/index.html Wed Mar 20 07:38:29 2013 +0900 @@ -15,6 +15,7 @@ +
CLOSE
@@ -35,7 +36,7 @@ traverse
-
+
CLOSE
@@ -90,10 +91,17 @@ var DragHandler = { _oElem : null, + _id : null, attach : function(oElem) { oElem.onmousedown = DragHandler._dragBegin; return oElem; }, + /* TODO: refoctoring */ + attach : function(oElem, id) { + oElem.onmousedown = DragHandler._dragBegin; + _id = id; + return oElem; + }, _dragBegin : function(e) { var oElem = DragHandler._oElem = this; if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; } @@ -112,10 +120,17 @@ var x = parseInt(oElem.style.left); var y = parseInt(oElem.style.top); e = e ? e : window.event; - oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px'; - oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px'; + var nextX = x + (e.clientX - oElem.mouseX); + var nextY = y + (e.clientY - oElem.mouseY); + oElem.style.left = nextX + 'px'; + oElem.style.top = nextY + 'px'; oElem.mouseX = e.clientX; oElem.mouseY = e.clientY; + if (_id) { + var node = GRAPH_DATA.nodes[_id]; + node.position.x = nextX; + node.position.x = nextY; + } return false; }, _dragEnd : function() { @@ -300,10 +315,6 @@ } -function returnCheckdRelation() { - -} - function createNodeDiv(node) { node.view = $("
"); node.view.click(function(){ clickNodeDiv(node.property.id) }); @@ -324,7 +335,7 @@ var div = node.view; // div.text(node.property.title); div.click(function(){showMiniDisplay(node); showTraverseDisplay(node);}); - DragHandler.attach($(node.view)[0]); + DragHandler.attach($(node.view)[0], node.property.id); var kindBackground = {agree:"#aaf", rejected:"#fff"}; var kindBorder = {agree:"#66a", rejected:"#a66"}; div.css("background", kindBackground[node.kind]||"white"); @@ -392,6 +403,21 @@ memory.nodes[node.id].both = []; memory.nodes[node.id].property = node; } + if (!jsonObj.edges) return memory; + var edges = jsonObj.edges; + for (var i=0; i