From bf212e649aab63674161208a1d9114581cbe72a8 Mon Sep 17 00:00:00 2001 From: Gonzalo Bellver Date: Mon, 6 Feb 2012 11:12:27 -0300 Subject: [PATCH] Fixed node insert bug --- mindplot/src/main/javascript/layout/BalancedSorter.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mindplot/src/main/javascript/layout/BalancedSorter.js b/mindplot/src/main/javascript/layout/BalancedSorter.js index 40bf1ae0..f7d70ced 100644 --- a/mindplot/src/main/javascript/layout/BalancedSorter.js +++ b/mindplot/src/main/javascript/layout/BalancedSorter.js @@ -102,6 +102,12 @@ mindplot.layout.BalancedSorter = new Class({ insert: function(treeSet, parent, child, order) { var children = this._getChildrenForOrder(parent, treeSet, order); + // If no children, return 0 or 1 depending on the side + if (children.length == 0) { + child.setOrder(order % 2); + return; + } + // Shift all the elements by two, so side is the same. // In case of balanced sorter, order don't need to be continuous... var max = 0;