From e72ae37ac7a03f42a09b6ddbc28692e5273d215a Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Fri, 28 Sep 2012 00:07:34 -0300 Subject: [PATCH] - Remove fade event on node creation. - Node are always hidden on creation. --- mindplot/src/main/javascript/Topic.js | 10 +++++-- .../javascript/commands/AddTopicCommand.js | 14 +++++----- .../javascript/commands/DragTopicCommand.js | 2 ++ .../src/main/javascript/model/NodeModel.js | 27 ------------------- 4 files changed, 17 insertions(+), 36 deletions(-) diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index c26738d7..f287fe34 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -634,7 +634,6 @@ mindplot.Topic = new Class({ var elements = this._flatten2DElements(this); var fade = new mindplot.util.FadeEffect(elements, !value); fade.addEvent('complete', function () { - }); fade.start(); mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeShrinkEvent, model); @@ -840,7 +839,14 @@ mindplot.Topic = new Class({ // Hide all children... this._setChildrenVisibility(value); + // If there there are connection to the node, topic must be hidden. this._setRelationshipLinesVisibility(value); + + // If it's connected, the connection must be rendered. + var outgoingLine = this.getOutgoingLine(); + if (outgoingLine) { + outgoingLine.setVisibility(value); + } }, moveToBack:function () { @@ -1037,7 +1043,7 @@ mindplot.Topic = new Class({ // Create a connection line ... var outgoingLine = new mindplot.ConnectionLine(this, targetTopic); - outgoingLine.setVisibility(true); // @Todo: This must be false. Check remove of all nodes and redo. + outgoingLine.setVisibility(false); this._outgoingLine = outgoingLine; workspace.appendChild(outgoingLine); diff --git a/mindplot/src/main/javascript/commands/AddTopicCommand.js b/mindplot/src/main/javascript/commands/AddTopicCommand.js index 00665db7..be9f8475 100644 --- a/mindplot/src/main/javascript/commands/AddTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddTopicCommand.js @@ -43,14 +43,14 @@ mindplot.commands.AddTopicCommand = new Class({ } } - // Finally, focus ... + // Select just created node ... var designer = commandContext._designer; - var fade = new mindplot.util.FadeEffect([topic, topic.getOutgoingLine()], true); - fade.addEvent('complete', function () { - designer.onObjectFocusEvent(topic); - topic.setOnFocus(true); - }); - fade.start(); + designer.onObjectFocusEvent(topic); + topic.setOnFocus(true); + + // Render node ... + topic.setVisibility(true); + }.bind(this)); }, diff --git a/mindplot/src/main/javascript/commands/DragTopicCommand.js b/mindplot/src/main/javascript/commands/DragTopicCommand.js index 1f641382..bbf40119 100644 --- a/mindplot/src/main/javascript/commands/DragTopicCommand.js +++ b/mindplot/src/main/javascript/commands/DragTopicCommand.js @@ -33,6 +33,7 @@ mindplot.commands.DragTopicCommand = new Class({ execute:function (commandContext) { var topic = commandContext.findTopics(this._topicsId)[0]; + topic.setVisibility(false); // Save old position ... var origParentTopic = topic.getOutgoingConnectedTopic(); @@ -69,6 +70,7 @@ mindplot.commands.DragTopicCommand = new Class({ this._parentId = origParentTopic.getId(); } } + topic.setVisibility(true); // Store for undo ... this._order = origOrder; diff --git a/mindplot/src/main/javascript/model/NodeModel.js b/mindplot/src/main/javascript/model/NodeModel.js index 4025df14..77b95d5c 100644 --- a/mindplot/src/main/javascript/model/NodeModel.js +++ b/mindplot/src/main/javascript/model/NodeModel.js @@ -144,33 +144,6 @@ mindplot.model.NodeModel = new Class({ this._parent = parent; }, - canBeConnected:function (sourceModel, sourcePosition, targetTopicSize) { - - $assert(sourceModel != this, 'The same node can not be parent and child if itself.'); - $assert(sourcePosition, 'childPosition can not be null.'); - $assert(targetTopicSize, 'targetTopicSize can not be null.'); - var result = false; - - // Only can be connected if the node is in the left or right. - var targetModel = this; - var targetPosition = targetModel.getPosition(); - - // Finally, check current node position ... - var yDistance = Math.abs(sourcePosition.y - targetPosition.y); - var gap = 35 + targetTopicSize.height / 2; - if (targetModel.getChildren().length > 0) { - gap += Math.abs(targetPosition.y - targetModel.getChildren()[0].getPosition().y); - } - - if (yDistance <= gap) { - // Circular connection ? - var xDistance = (sourcePosition.x - targetPosition.x) * Math.sign(targetPosition.x); - result = xDistance > targetTopicSize.width; - } - - return result; - }, - _isChildNode:function (node) { var result = false; if (node == this) {