diff -r 374e17d0d96a -r 47308aa6ce94 client/js/renderer/nodeeditor.js --- a/client/js/renderer/nodeeditor.js Fri Jun 12 15:13:29 2015 +0200 +++ b/client/js/renderer/nodeeditor.js Fri Jun 12 22:32:41 2015 +0200 @@ -52,33 +52,35 @@ $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) : false, 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-Btn").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'); - - if(_this.options.show_node_editor_description_richtext) { - if(typeof _this.editorListeners !== 'undefined') { - _this.editorListeners.forEach( function(listener) { - listener.removeListener(); - }); - } - if(typeof editorInstance.editor !== 'undefined') { - var _editor = editorInstance.editor; - delete editorInstance.editor; - _editor.destroy(); - } - } _this.renderer.removeRepresentation(_this); paper.view.draw(); }; - this.editor_$.find(".Rk-CloseX").click(closeEditor); + _this.cleanEditor = 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-Btn").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'); + + if(_this.options.show_node_editor_description_richtext) { + if(typeof editorInstance.editor !== 'undefined') { + var _editor = editorInstance.editor; + delete editorInstance.editor; + _editor.focusManager.blur(true); + _editor.destroy(); + } + } + }; + + this.editor_$.find(".Rk-CloseX").click(function (e) { + e.preventDefault(); + closeEditor(); + }); this.editor_$.find(".Rk-Edit-Goto").click(function() { if (!_model.get("uri")) { @@ -103,12 +105,12 @@ _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); } if (_this.options.show_node_editor_description) { - if(_this.options.show_node_editor_description_richtext && - typeof editorInstance.editor !== 'undefined' && - editorInstance.editor.checkDirty()) - { - _data.description = editorInstance.editor.getData(); - editorInstance.editor.resetDirty(); + if(_this.options.show_node_editor_description_richtext) { + if(typeof editorInstance.editor !== 'undefined' && + editorInstance.editor.checkDirty()) { + _data.description = editorInstance.editor.getData(); + editorInstance.editor.resetDirty(); + } } else { _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); @@ -142,9 +144,8 @@ _this.options.show_node_editor_description_richtext && typeof editorInstance.editor !== 'undefined') { - _this.editorListeners = []; - _this.editorListeners.push(editorInstance.editor.on("change", onFieldChange)); - _this.editorListeners.push(editorInstance.editor.on("blur", onFieldChange)); + editorInstance.editor.on("change", onFieldChange); + editorInstance.editor.on("blur", onFieldChange); } if(_this.options.allow_image_upload) { @@ -278,6 +279,13 @@ } this.editor_$.show(); paper.view.draw(); + }, + destroy: function() { + if(typeof this.cleanEditor !== 'undefined') { + this.cleanEditor(); + } + this.editor_block.remove(); + this.editor_$.remove(); } }).value();