- Change forEach for each interator
- Fix issue deleting nodes with intermediate relationships
This commit is contained in:
@@ -38,7 +38,7 @@ mindplot.layout.AbstractBasicSorter = new Class({
|
||||
result = height;
|
||||
} else {
|
||||
var childrenHeight = 0;
|
||||
children.forEach(function(child) {
|
||||
children.each(function(child) {
|
||||
childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache);
|
||||
}, this);
|
||||
|
||||
|
@@ -154,7 +154,7 @@ mindplot.layout.BalancedSorter = new Class({
|
||||
var totalPHeight = 0;
|
||||
var totalNHeight = 0;
|
||||
|
||||
heights.forEach(function (elem) {
|
||||
heights.each(function (elem) {
|
||||
if (elem.order % 2 == 0) {
|
||||
totalPHeight += elem.height;
|
||||
} else {
|
||||
|
@@ -143,7 +143,7 @@ mindplot.layout.LayoutManager = new Class({
|
||||
},
|
||||
|
||||
_flushEvents: function() {
|
||||
this._events.forEach(function(event) {
|
||||
this._events.each(function(event) {
|
||||
this.fireEvent('change', event);
|
||||
}, this);
|
||||
this._events = [];
|
||||
@@ -153,7 +153,7 @@ mindplot.layout.LayoutManager = new Class({
|
||||
if (!nodes)
|
||||
nodes = this._treeSet.getTreeRoots();
|
||||
|
||||
nodes.forEach(function(node) {
|
||||
nodes.each(function(node) {
|
||||
if (node.hasOrderChanged() || node.hasPositionChanged()) {
|
||||
|
||||
// Find or create a event ...
|
||||
|
@@ -70,7 +70,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
|
||||
layout:function () {
|
||||
var roots = this._treeSet.getTreeRoots();
|
||||
roots.forEach(function (node) {
|
||||
roots.each(function (node) {
|
||||
|
||||
// Calculate all node heights ...
|
||||
var sorter = node.getSorter();
|
||||
@@ -108,7 +108,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
var offsetById = sorter.computeOffsets(this._treeSet, node);
|
||||
var parentPosition = node.getPosition();
|
||||
|
||||
children.forEach(function (child) {
|
||||
children.each(function (child) {
|
||||
var offset = offsetById[child.getId()];
|
||||
|
||||
var childFreeDisplacement = child.getFreeDisplacement();
|
||||
@@ -133,7 +133,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
}
|
||||
|
||||
// Continue reordering the children nodes ...
|
||||
children.forEach(function (child) {
|
||||
children.each(function (child) {
|
||||
this._layoutChildren(child, heightById);
|
||||
}, this);
|
||||
},
|
||||
@@ -183,7 +183,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
this._shiftBranches(node, heightById);
|
||||
}
|
||||
|
||||
children.forEach(function (child) {
|
||||
children.each(function (child) {
|
||||
this._fixOverlapping(child, heightById);
|
||||
}, this);
|
||||
},
|
||||
@@ -193,7 +193,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
|
||||
var siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(node, node.getFreeDisplacement().y);
|
||||
var last = node;
|
||||
siblingsToShift.forEach(function (sibling) {
|
||||
siblingsToShift.each(function (sibling) {
|
||||
var overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
|
||||
return this._branchesOverlap(shiftedBranch, sibling, heightById);
|
||||
}, this);
|
||||
@@ -209,7 +209,7 @@ mindplot.layout.OriginalLayout = new Class({
|
||||
return !shiftedBranches.contains(branch);
|
||||
});
|
||||
|
||||
branchesToShift.forEach(function (branch) {
|
||||
branchesToShift.each(function (branch) {
|
||||
var bAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
|
||||
shiftedBranches.push(branch);
|
||||
|
@@ -240,7 +240,7 @@ mindplot.layout.RootedTreeSet = new Class({
|
||||
var yOffset = oldPos.y - position.y;
|
||||
|
||||
var children = this.getChildren(node);
|
||||
children.forEach(function (child) {
|
||||
children.each(function (child) {
|
||||
this.shiftBranchPosition(child, xOffset, yOffset);
|
||||
}.bind(this));
|
||||
|
||||
@@ -251,7 +251,7 @@ mindplot.layout.RootedTreeSet = new Class({
|
||||
node.setPosition({x:position.x + xOffset, y:position.y + yOffset});
|
||||
|
||||
var children = this.getChildren(node);
|
||||
children.forEach(function (child) {
|
||||
children.each(function (child) {
|
||||
this.shiftBranchPosition(child, xOffset, yOffset);
|
||||
}.bind(this));
|
||||
},
|
||||
|
@@ -133,7 +133,7 @@ mindplot.layout.SymmetricSorter = new Class({
|
||||
|
||||
// Compute the center of the branch ...
|
||||
var totalHeight = 0;
|
||||
heights.forEach(function(elem) {
|
||||
heights.each(function(elem) {
|
||||
totalHeight += elem.height;
|
||||
});
|
||||
var ysum = totalHeight / 2;
|
||||
|
Reference in New Issue
Block a user