- Bug Cannot call method 'getChildren' of null, line:1955 fixed.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-03 20:54:18 -03:00
parent ca37d3f384
commit bcc5676b49

View File

@ -335,39 +335,43 @@ mindplot.DesignerKeyboard = new Class({
}, },
_goToBrother:function (designer, node, direction) { _goToBrother:function (designer, node, direction) {
var brothers = node.getParent().getChildren(); var parent = node.getParent();
var target = node; if (parent) {
var y = node.getPosition().y; var brothers = parent.getChildren();
var x = node.getPosition().x;
var dist = null; var target = node;
for (var i = 0; i < brothers.length; i++) { var y = node.getPosition().y;
var sameSide = (x * brothers[i].getPosition().x) >= 0; var x = node.getPosition().x;
if (brothers[i] != node && sameSide) { var dist = null;
var brother = brothers[i]; for (var i = 0; i < brothers.length; i++) {
var brotherY = brother.getPosition().y; var sameSide = (x * brothers[i].getPosition().x) >= 0;
if (direction == "DOWN" && brotherY > y) { if (brothers[i] != node && sameSide) {
var distancia = y - brotherY; var brother = brothers[i];
if (distancia < 0) { var brotherY = brother.getPosition().y;
distancia = distancia * (-1); if (direction == "DOWN" && brotherY > y) {
var distancia = y - brotherY;
if (distancia < 0) {
distancia = distancia * (-1);
}
if (dist == null || dist > distancia) {
dist = distancia;
target = brothers[i];
}
} }
if (dist == null || dist > distancia) { else if (direction == "UP" && brotherY < y) {
dist = distancia; var distance = y - brotherY;
target = brothers[i]; if (distance < 0) {
} distance = distance * (-1);
} }
else if (direction == "UP" && brotherY < y) { if (dist == null || dist > distance) {
var distance = y - brotherY; dist = distance;
if (distance < 0) { target = brothers[i];
distance = distance * (-1); }
}
if (dist == null || dist > distance) {
dist = distance;
target = brothers[i];
} }
} }
} }
this._goToNode(designer, target);
} }
this._goToNode(designer, target);
}, },