From c7dcf9faf8d568236b62b68b780f976eac35aa1f Mon Sep 17 00:00:00 2001 From: Gonzalo Bellver Date: Fri, 20 Jan 2012 11:07:44 -0300 Subject: [PATCH] Reverted unstable changes from db74c6394392fd5c03362de1d98a0c4d2880d103 --- mindplot/src/main/javascript/Designer.js | 22 +++++--- mindplot/src/main/javascript/DragManager.js | 2 +- mindplot/src/main/javascript/DragPivot.js | 60 +++++++++------------ mindplot/src/main/javascript/DragTopic.js | 11 ---- mindplot/src/main/javascript/Topic.js | 1 - 5 files changed, 41 insertions(+), 55 deletions(-) diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index 848549b7..718cab95 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -133,19 +133,29 @@ mindplot.Designer = new Class({ if (!dragTopic.isFreeLayoutOn(event)) { // The node is being drag. Is the connection still valid ? dragConnector.checkConnection(dragTopic); - - if (!dragTopic.isVisible() && dragTopic.isConnected()) { - dragTopic.setVisibility(true); - } - } }); dragger.addEvent('enddragging', function(event, dragTopic) { + // Enable all mouse events. for (var i = 0; i < topics.length; i++) { topics[i].setMouseEventsEnabled(true); } - dragTopic.applyChanges(workspace); + // Topic must be positioned in the real board postion. + if (dragTopic._isInTheWorkspace) { + var draggedTopic = dragTopic.getDraggedTopic(); + + // Hide topic during draw ... + draggedTopic.setBranchVisibility(false); + var parentNode = draggedTopic.getParent(); + dragTopic.applyChanges(workspace); + + // Make all node visible ... + draggedTopic.setVisibility(true); + if (parentNode != null) { + parentNode.setBranchVisibility(true); + } + } }); return dragger; diff --git a/mindplot/src/main/javascript/DragManager.js b/mindplot/src/main/javascript/DragManager.js index 48f843fe..3d466301 100644 --- a/mindplot/src/main/javascript/DragManager.js +++ b/mindplot/src/main/javascript/DragManager.js @@ -37,7 +37,7 @@ mindplot.DragManager = new Class({ // Set initial position. var dragNode = node.createDragNode(); var mousePos = screen.getWorkspaceMousePosition(event); -// dragNode.setPosition(mousePos.x, mousePos.y); + dragNode.setPosition(mousePos.x, mousePos.y); // Register mouse move listener ... var mouseMoveListener = dragManager._buildMouseMoveListener(workspace, dragNode, dragManager); diff --git a/mindplot/src/main/javascript/DragPivot.js b/mindplot/src/main/javascript/DragPivot.js index c1cfce04..d20fdabf 100644 --- a/mindplot/src/main/javascript/DragPivot.js +++ b/mindplot/src/main/javascript/DragPivot.js @@ -20,17 +20,13 @@ mindplot.DragPivot = new Class({ initialize:function() { this._position = new core.Point(); this._size = mindplot.DragTopic.PIVOT_SIZE; + this._line = null; this._straightLine = this._buildStraightLine(); this._curvedLine = this._buildCurvedLine(); this._dragPivot = this._buildRect(); this._connectRect = this._buildRect(); this._targetTopic = null; - this._isVisible = false; - }, - - isVisible:function() { - return this._isVisible; }, getTargetTopic : function() { @@ -69,7 +65,7 @@ mindplot.DragPivot = new Class({ // Calculate pivot connection point ... var size = this._size; var targetPosition = targetTopic.getPosition(); - var line = this._getConnectionLine(); + var line = this._line; // Update Line position. var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position); @@ -81,10 +77,14 @@ mindplot.DragPivot = new Class({ var cy = position.y - (parseInt(size.height) / 2); pivotRect.setPosition(cx, cy); - // Make line visible only when the position has been already changed. - // This solve several strange effects ;) - var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint); - line.setTo(targetPoint.x, targetPoint.y); + // Display elements if it's required... + if (!pivotRect.isVisible()) { + // Make line visible only when the position has been already changed. + // This solve several strange effects ;) + var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint); + line.setTo(targetPoint.x, targetPoint.y); + this.setVisibility(true); + } }, setPosition : function(point) { @@ -114,36 +114,16 @@ mindplot.DragPivot = new Class({ }, setVisibility : function(value) { - if (this.isVisible() != value) { + var pivotRect = this._getPivotRect(); + pivotRect.setVisibility(value); - var pivotRect = this._getPivotRect(); - pivotRect.setVisibility(value); - - var connectRect = this._connectRect; - connectRect.setVisibility(value); - - var line = this._getConnectionLine(); - if (line) { - line.setVisibility(value); - } - this._isVisible = value; + var connectRect = this._connectRect; + connectRect.setVisibility(value); + if (this._line) { + this._line.setVisibility(value); } }, - // If the node is connected, validate that there is a line connecting both... - _getConnectionLine : function() { - var result = null; - var parentTopic = this._targetTopic; - if (parentTopic) { - if (parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { - result = this._straightLine; - } else { - result = this._curvedLine; - } - } - return result; - }, - addToWorkspace : function(workspace) { var pivotRect = this._getPivotRect(); workspace.appendChild(pivotRect); @@ -193,7 +173,14 @@ mindplot.DragPivot = new Class({ $assert(targetTopic, 'parent can not be null'); this._position = position; + this._targetTopic = targetTopic; + if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) { + this._line = this._straightLine; + } else { + this._line = this._curvedLine; + } + this._line.setVisibility(true); // Connected to Rect ... var connectRect = this._connectRect; @@ -224,5 +211,6 @@ mindplot.DragPivot = new Class({ this.setVisibility(false); this._targetTopic = null; + this._line = null; } }); diff --git a/mindplot/src/main/javascript/DragTopic.js b/mindplot/src/main/javascript/DragTopic.js index 7a3aff1d..25363c3b 100644 --- a/mindplot/src/main/javascript/DragTopic.js +++ b/mindplot/src/main/javascript/DragTopic.js @@ -67,16 +67,6 @@ mindplot.DragTopic = new Class({ } }, - setVisibility:function(value) { - var dragPivot = this._getDragPivot(); - dragPivot.setVisibility(value); - }, - - isVisible:function() { - var dragPivot = this._getDragPivot(); - return dragPivot.isVisible(); - }, - getInnerShape : function() { return this._elem2d; }, @@ -120,7 +110,6 @@ mindplot.DragTopic = new Class({ var dragPivot = this._getDragPivot(); var position = predict.position; dragPivot.connectTo(parent, position); - dragPivot.setVisibility(true); this.setOrder(predict.order); }, diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 378f984e..5c609ade 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -1163,7 +1163,6 @@ mindplot.Topic = new Class({ var targetTopic = this.getOutgoingConnectedTopic(); if ($defined(targetTopic)) { result.connectTo(targetTopic); - result.setVisibility(false); } // If a drag node is create for it, let's hide the editor.