51 var _this = this, |
51 var _this = this, |
52 editorInstance = _this.options.show_node_editor_description_richtext ? |
52 editorInstance = _this.options.show_node_editor_description_richtext ? |
53 $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) : |
53 $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) : |
54 false, |
54 false, |
55 closeEditor = function() { |
55 closeEditor = function() { |
56 _this.editor_$.off("keyup"); |
|
57 _this.editor_$.find("input, textarea, select").off("change keyup paste"); |
|
58 _this.editor_$.find(".Rk-Edit-Image-File").off('change'); |
|
59 _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover'); |
|
60 _this.editor_$.find(".Rk-Edit-Size-Btn").off('click'); |
|
61 _this.editor_$.find(".Rk-Edit-Image-Del").off('click'); |
|
62 _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click'); |
|
63 _this.editor_$.find(".Rk-CloseX").off('click'); |
|
64 _this.editor_$.find(".Rk-Edit-Goto").off('click'); |
|
65 |
|
66 if(_this.options.show_node_editor_description_richtext) { |
|
67 if(typeof _this.editorListeners !== 'undefined') { |
|
68 _this.editorListeners.forEach( function(listener) { |
|
69 listener.removeListener(); |
|
70 }); |
|
71 } |
|
72 if(typeof editorInstance.editor !== 'undefined') { |
|
73 var _editor = editorInstance.editor; |
|
74 delete editorInstance.editor; |
|
75 _editor.destroy(); |
|
76 } |
|
77 } |
|
78 _this.renderer.removeRepresentation(_this); |
56 _this.renderer.removeRepresentation(_this); |
79 paper.view.draw(); |
57 paper.view.draw(); |
80 }; |
58 }; |
81 |
59 |
82 this.editor_$.find(".Rk-CloseX").click(closeEditor); |
60 _this.cleanEditor = function() { |
|
61 _this.editor_$.off("keyup"); |
|
62 _this.editor_$.find("input, textarea, select").off("change keyup paste"); |
|
63 _this.editor_$.find(".Rk-Edit-Image-File").off('change'); |
|
64 _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover'); |
|
65 _this.editor_$.find(".Rk-Edit-Size-Btn").off('click'); |
|
66 _this.editor_$.find(".Rk-Edit-Image-Del").off('click'); |
|
67 _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click'); |
|
68 _this.editor_$.find(".Rk-CloseX").off('click'); |
|
69 _this.editor_$.find(".Rk-Edit-Goto").off('click'); |
|
70 |
|
71 if(_this.options.show_node_editor_description_richtext) { |
|
72 if(typeof editorInstance.editor !== 'undefined') { |
|
73 var _editor = editorInstance.editor; |
|
74 delete editorInstance.editor; |
|
75 _editor.focusManager.blur(true); |
|
76 _editor.destroy(); |
|
77 } |
|
78 } |
|
79 }; |
|
80 |
|
81 this.editor_$.find(".Rk-CloseX").click(function (e) { |
|
82 e.preventDefault(); |
|
83 closeEditor(); |
|
84 }); |
83 |
85 |
84 this.editor_$.find(".Rk-Edit-Goto").click(function() { |
86 this.editor_$.find(".Rk-Edit-Goto").click(function() { |
85 if (!_model.get("uri")) { |
87 if (!_model.get("uri")) { |
86 return false; |
88 return false; |
87 } |
89 } |
102 if (_this.options.show_node_editor_image) { |
104 if (_this.options.show_node_editor_image) { |
103 _data.image = _this.editor_$.find(".Rk-Edit-Image").val(); |
105 _data.image = _this.editor_$.find(".Rk-Edit-Image").val(); |
104 _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); |
106 _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); |
105 } |
107 } |
106 if (_this.options.show_node_editor_description) { |
108 if (_this.options.show_node_editor_description) { |
107 if(_this.options.show_node_editor_description_richtext && |
109 if(_this.options.show_node_editor_description_richtext) { |
108 typeof editorInstance.editor !== 'undefined' && |
110 if(typeof editorInstance.editor !== 'undefined' && |
109 editorInstance.editor.checkDirty()) |
111 editorInstance.editor.checkDirty()) { |
110 { |
112 _data.description = editorInstance.editor.getData(); |
111 _data.description = editorInstance.editor.getData(); |
113 editorInstance.editor.resetDirty(); |
112 editorInstance.editor.resetDirty(); |
114 } |
113 } |
115 } |
114 else { |
116 else { |
115 _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
117 _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
116 } |
118 } |
117 } |
119 } |
141 this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange); |
143 this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange); |
142 if( _this.options.show_node_editor_description && |
144 if( _this.options.show_node_editor_description && |
143 _this.options.show_node_editor_description_richtext && |
145 _this.options.show_node_editor_description_richtext && |
144 typeof editorInstance.editor !== 'undefined') |
146 typeof editorInstance.editor !== 'undefined') |
145 { |
147 { |
146 _this.editorListeners = []; |
148 editorInstance.editor.on("change", onFieldChange); |
147 _this.editorListeners.push(editorInstance.editor.on("change", onFieldChange)); |
149 editorInstance.editor.on("blur", onFieldChange); |
148 _this.editorListeners.push(editorInstance.editor.on("blur", onFieldChange)); |
|
149 } |
150 } |
150 |
151 |
151 if(_this.options.allow_image_upload) { |
152 if(_this.options.allow_image_upload) { |
152 this.editor_$.find(".Rk-Edit-Image-File").change(function() { |
153 this.editor_$.find(".Rk-Edit-Image-File").change(function() { |
153 if (this.files.length) { |
154 if (this.files.length) { |
277 var _coords = this.source_representation.paper_coords; |
278 var _coords = this.source_representation.paper_coords; |
278 Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$); |
279 Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$); |
279 } |
280 } |
280 this.editor_$.show(); |
281 this.editor_$.show(); |
281 paper.view.draw(); |
282 paper.view.draw(); |
|
283 }, |
|
284 destroy: function() { |
|
285 if(typeof this.cleanEditor !== 'undefined') { |
|
286 this.cleanEditor(); |
|
287 } |
|
288 this.editor_block.remove(); |
|
289 this.editor_$.remove(); |
282 } |
290 } |
283 }).value(); |
291 }).value(); |
284 |
292 |
285 /* NodeEditor End */ |
293 /* NodeEditor End */ |
286 |
294 |