client/js/renderer/nodeeditor.js
changeset 435 e529b633c339
parent 434 0d5998b32a7c
child 445 705a2e9c6c9d
child 458 423bdf56d103
--- a/client/js/renderer/nodeeditor.js	Sat Apr 25 04:37:06 2015 +0200
+++ b/client/js/renderer/nodeeditor.js	Mon Apr 27 17:22:46 2015 +0200
@@ -9,11 +9,11 @@
     var NodeEditor = Utils.inherit(BaseEditor);
 
     _(NodeEditor.prototype).extend({
-    	_init: function() {
-    		BaseEditor.prototype._init.apply(this);
-    		this.template = this.options.templates['templates/nodeeditor.html'];
-    		this.readOnlyTemplate = this.options.templates['templates/nodeeditor_readonly.html'];
-    	},
+        _init: function() {
+            BaseEditor.prototype._init.apply(this);
+            this.template = this.options.templates['templates/nodeeditor.html'];
+            this.readOnlyTemplate = this.options.templates['templates/nodeeditor_readonly.html'];
+        },
         draw: function() {
             var _model = this.source_representation.model,
             _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
@@ -44,6 +44,17 @@
             this.redraw();
             var _this = this,
             closeEditor = function() {
+                _this.editor_$.off("keyup");
+                _this.editor_$.find("input, textarea, select").off("change keyup paste");
+                _this.editor_$.find(".Rk-Edit-Image-File").off('change');
+                _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover');
+                _this.editor_$.find(".Rk-Edit-Size-Down").off('click');
+                _this.editor_$.find(".Rk-Edit-Size-Up").off('click');
+                _this.editor_$.find(".Rk-Edit-Image-Del").off('click');
+                _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click');
+                _this.editor_$.find(".Rk-CloseX").off('click');
+                _this.editor_$.find(".Rk-Edit-Goto").off('click');
+
                 _this.renderer.removeRepresentation(_this);
                 paper.view.draw();
             };
@@ -78,15 +89,10 @@
                         if (_this.options.change_shapes) {
                             if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
                                 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
-                                _data.shape_changed = true;
                             }
                         }
                         _model.set(_data);
                         _this.redraw();
-                        // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.
-                        if(_data.shape_changed===true){
-                            _model.set(_data);
-                        }
                     } else {
                         closeEditor();
                     }
@@ -178,8 +184,8 @@
                 });
 
                 this.editor_$.find(".Rk-Edit-Image-Del").click(function() {
-                	_this.editor_$.find(".Rk-Edit-Image").val('');
-                	onFieldChange();
+                    _this.editor_$.find(".Rk-Edit-Image").val('');
+                    onFieldChange();
                     return false;
                 });
             } else {