client/js/paper-renderer.js
changeset 8 8e67c9f6da51
parent 7 ae86ecebb1be
child 10 96476d1fc7c0
--- a/client/js/paper-renderer.js	Tue Jul 31 18:00:13 2012 +0200
+++ b/client/js/paper-renderer.js	Tue Jul 31 18:06:29 2012 +0200
@@ -176,6 +176,13 @@
     this._renderer.redraw();
 }
 
+Rkns.Renderer.Node.prototype.openEditor = function() {
+    this._renderer.removeControllersOfType("editor");
+    var _editor = this._renderer.addController("NodeEditor",{});
+    _editor.node_controller = this;
+    _editor.redraw();
+}
+
 Rkns.Renderer.Node.prototype.select = function() {
     this.circle.strokeWidth = 3;
     this.edit_button.show();
@@ -192,10 +199,7 @@
 
 Rkns.Renderer.Node.prototype.mouseup = function(_event) {
     if (!this._renderer.is_dragging) {
-        this._renderer.removeControllersOfType("editor");
-        var _editor = this._renderer.addController("NodeEditor",{});
-        _editor.node_controller = this;
-        _editor.redraw();
+        this.openEditor();
     }
 }
 
@@ -403,6 +407,7 @@
         _this.node_controller.redraw();
         paper.view.draw();
     });
+    this.editor_$.find(".Rk-Edit-Title")[0].focus();
 }
 
 Rkns.Renderer.NodeEditor.prototype.destroy = function() {
@@ -516,7 +521,7 @@
 
 Rkns.Renderer.NodeEditButton.prototype.mouseup = function() {
     if (!this._renderer.is_dragging) {
-        this.node_controller.mouseup();
+        this.node_controller.openEditor();
     }
 }
 
@@ -752,13 +757,14 @@
         ]);
     var _hitResult = paper.project.hitTest(_point);
     if (!_hitResult || typeof _hitResult.item.__controller === "undefined") {
-        var _coords = this.toModelCoords(_point);
-        this._project.addNode({
-            position: {
-                x: _coords.x,
-                y: _coords.y
-            }
-        }, Rkns._RENDER_AND_SAVE);
+        var _coords = this.toModelCoords(_point),
+            _node = this._project.addNode({
+                position: {
+                    x: _coords.x,
+                    y: _coords.y
+                }
+            }, Rkns._RENDER_AND_SAVE);
+        _node.__controller.openEditor();
     }
     paper.view.draw();
 }