diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index 5a110158..18aa5845 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -91,10 +91,13 @@ mindplot.Designer = new Class({ }.bind(this)); // Create nodes on double click... - screenManager.addEvent('dblclick', function() { + screenManager.addEvent('dblclick', function(event) { if (workspace.isWorkspaceEventsEnabled()) { + + var mousePos = screenManager.getWorkspaceMousePosition(event); + var centralTopic = this.getModel().getCentralTopic(); - var model = this._createChildModel(centralTopic); + var model = this._createChildModel(centralTopic, mousePos); this._actionDispatcher.addTopic(model, centralTopic.getId()); } }.bind(this)); @@ -326,7 +329,7 @@ mindplot.Designer = new Class({ }, - _createChildModel : function(topic) { + _createChildModel : function(topic, mousePos) { // Create a new node ... var model = topic.getModel(); var mindmap = model.getMindmap(); @@ -334,8 +337,9 @@ mindplot.Designer = new Class({ // Create a new node ... var layoutManager = this._eventBussDispatcher.getLayoutManager(); - var result = layoutManager.predict(topic.getId()); + var result = layoutManager.predict(topic.getId(), mousePos); childModel.setOrder(result.order); + console.log(result.order); var position = result.position; childModel.setPosition(position.x, position.y); diff --git a/mindplot/src/main/javascript/DragPivot.js b/mindplot/src/main/javascript/DragPivot.js index 28d438f6..d20fdabf 100644 --- a/mindplot/src/main/javascript/DragPivot.js +++ b/mindplot/src/main/javascript/DragPivot.js @@ -119,7 +119,9 @@ mindplot.DragPivot = new Class({ var connectRect = this._connectRect; connectRect.setVisibility(value); - this._line.setVisibility(value); + if (this._line) { + this._line.setVisibility(value); + } }, addToWorkspace : function(workspace) { @@ -178,6 +180,7 @@ mindplot.DragPivot = new Class({ } else { this._line = this._curvedLine; } + this._line.setVisibility(true); // Connected to Rect ... var connectRect = this._connectRect; diff --git a/mindplot/src/main/javascript/layout/LayoutManager.js b/mindplot/src/main/javascript/layout/LayoutManager.js index bb049ee1..487480ed 100644 --- a/mindplot/src/main/javascript/layout/LayoutManager.js +++ b/mindplot/src/main/javascript/layout/LayoutManager.js @@ -59,7 +59,7 @@ mindplot.layout.LayoutManager = new Class({ var node = this._treeSet.find(id); node.setFree(true); - node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y-node.getPosition().y}); + node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y - node.getPosition().y}); }, connectNode: function(parentId, childId, order) {