From 743164ade4b460170301654e744f3a9fc79bd2e5 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 4 Sep 2012 23:41:34 -0300 Subject: [PATCH] - Fix Uncaught Cilcular connection, line:8 error --- mindplot/src/main/javascript/RelationshipPivot.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mindplot/src/main/javascript/RelationshipPivot.js b/mindplot/src/main/javascript/RelationshipPivot.js index cd3901c8..efc63918 100644 --- a/mindplot/src/main/javascript/RelationshipPivot.js +++ b/mindplot/src/main/javascript/RelationshipPivot.js @@ -98,8 +98,11 @@ mindplot.RelationshipPivot = new Class({ var screen = this._workspace.getScreenManager(); var pos = screen.getWorkspaceMousePosition(event); + // Leave the arrow a couple of pixels away from the cursor. var gapDistance = Math.sign(pos.x - this._sourceTopic.getPosition().x) * 5; + this._pivot.setTo(pos.x - gapDistance, pos.y); + var controlPoints = this._pivot.getControlPoints(); this._startArrow.setFrom(pos.x - gapDistance, pos.y); this._startArrow.setControlPoint(controlPoints[1]); @@ -118,8 +121,12 @@ mindplot.RelationshipPivot = new Class({ _connectOnFocus:function (targetTopic) { var sourceTopic = this._sourceTopic; var mindmap = this._designer.getMindmap(); - var relModel = mindmap.createRelationship(targetTopic.getId(), sourceTopic.getId()); - this._designer._actionDispatcher.addRelationship(relModel); + + // Avoid circular connections ... + if (targetTopic.getId() != sourceTopic.getId()) { + var relModel = mindmap.createRelationship(targetTopic.getId(), sourceTopic.getId()); + this._designer._actionDispatcher.addRelationship(relModel); + } this.dispose(); },