From 28bbc4c8464ffca9a693f277ff7a4d9c06af9bed Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 20 Aug 2012 11:22:19 -0300 Subject: [PATCH] Fix error when press enter over a isolated node Fix prediction error when the node is a isolated node. --- mindplot/src/main/javascript/Designer.js | 2 +- .../main/javascript/layout/SymmetricSorter.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index 3e32badc..5e81f9a0 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -473,7 +473,7 @@ mindplot.Designer = new Class({ } var topic = nodes[0]; - if (topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { + if (!topic.getOutgoingConnectedTopic()) { // Central topic and isolated topics .... // Central topic doesn't have siblings ... this.createChildForSelectedNode(); diff --git a/mindplot/src/main/javascript/layout/SymmetricSorter.js b/mindplot/src/main/javascript/layout/SymmetricSorter.js index 50f28624..ea9ed3e3 100644 --- a/mindplot/src/main/javascript/layout/SymmetricSorter.js +++ b/mindplot/src/main/javascript/layout/SymmetricSorter.js @@ -86,31 +86,31 @@ mindplot.layout.SymmetricSorter = new Class({ // Try to fit within ... var result = null; var last = parentChildren.getLast(); - for (var i=0; i parentChild.getPosition().y) { - var order = graph.getParent(node).getId() == parent.getId() ? + var order = (graph.getParent(node) && graph.getParent(node).getId() == parent.getId()) ? last.getOrder() : last.getOrder() + 1; var position = { - x: parentChild.getPosition().x, - y: parentChild.getPosition().y + parentChild.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 + x:parentChild.getPosition().x, + y:parentChild.getPosition().y + parentChild.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 }; return [order, position]; } // Fit after this node if (nodeAfter && position.y > parentChild.getPosition().y && position.y < nodeAfter.getPosition().y) { - if(nodeAfter.getId() == node.getId() || parentChild.getId() == node.getId()) { + if (nodeAfter.getId() == node.getId() || parentChild.getId() == node.getId()) { return [node.getOrder(), node.getPosition()]; } else { var order = position.y > node.getPosition().y ? nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1; var position = { - x: parentChild.getPosition().x, - y: parentChild.getPosition().y + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2 + x:parentChild.getPosition().x, + y:parentChild.getPosition().y + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2 }; return [order, position]; @@ -121,7 +121,7 @@ mindplot.layout.SymmetricSorter = new Class({ // Position wasn't below any node, so it must be fitted above the first var first = parentChildren[0]; - var position = { + var position = { x:first.getPosition().x, y:first.getPosition().y - first.getSize().height - mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2 };