equal
deleted
inserted
replaced
7 /* NodeEditor Begin */ |
7 /* NodeEditor Begin */ |
8 //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor); |
8 //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor); |
9 var NodeEditor = Utils.inherit(BaseEditor); |
9 var NodeEditor = Utils.inherit(BaseEditor); |
10 |
10 |
11 _(NodeEditor.prototype).extend({ |
11 _(NodeEditor.prototype).extend({ |
12 _init: function() { |
12 _init: function() { |
13 BaseEditor.prototype._init.apply(this); |
13 BaseEditor.prototype._init.apply(this); |
14 this.template = this.options.templates['templates/nodeeditor.html']; |
14 this.template = this.options.templates['templates/nodeeditor.html']; |
15 this.readOnlyTemplate = this.options.templates['templates/nodeeditor_readonly.html']; |
15 this.readOnlyTemplate = this.options.templates['templates/nodeeditor_readonly.html']; |
16 }, |
16 }, |
17 draw: function() { |
17 draw: function() { |
18 var _model = this.source_representation.model, |
18 var _model = this.source_representation.model, |
19 _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan), |
19 _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan), |
20 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
20 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
21 _image_placeholder = this.options.static_url + "img/image-placeholder.png", |
21 _image_placeholder = this.options.static_url + "img/image-placeholder.png", |
42 shortenText: Utils.shortenText |
42 shortenText: Utils.shortenText |
43 })); |
43 })); |
44 this.redraw(); |
44 this.redraw(); |
45 var _this = this, |
45 var _this = this, |
46 closeEditor = function() { |
46 closeEditor = function() { |
|
47 _this.editor_$.off("keyup"); |
|
48 _this.editor_$.find("input, textarea, select").off("change keyup paste"); |
|
49 _this.editor_$.find(".Rk-Edit-Image-File").off('change'); |
|
50 _this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover'); |
|
51 _this.editor_$.find(".Rk-Edit-Size-Down").off('click'); |
|
52 _this.editor_$.find(".Rk-Edit-Size-Up").off('click'); |
|
53 _this.editor_$.find(".Rk-Edit-Image-Del").off('click'); |
|
54 _this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click'); |
|
55 _this.editor_$.find(".Rk-CloseX").off('click'); |
|
56 _this.editor_$.find(".Rk-Edit-Goto").off('click'); |
|
57 |
47 _this.renderer.removeRepresentation(_this); |
58 _this.renderer.removeRepresentation(_this); |
48 paper.view.draw(); |
59 paper.view.draw(); |
49 }; |
60 }; |
50 |
61 |
51 this.editor_$.find(".Rk-CloseX").click(closeEditor); |
62 this.editor_$.find(".Rk-CloseX").click(closeEditor); |
76 _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
87 _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
77 } |
88 } |
78 if (_this.options.change_shapes) { |
89 if (_this.options.change_shapes) { |
79 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
90 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
80 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
91 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
81 _data.shape_changed = true; |
|
82 } |
92 } |
83 } |
93 } |
84 _model.set(_data); |
94 _model.set(_data); |
85 _this.redraw(); |
95 _this.redraw(); |
86 // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears. |
|
87 if(_data.shape_changed===true){ |
|
88 _model.set(_data); |
|
89 } |
|
90 } else { |
96 } else { |
91 closeEditor(); |
97 closeEditor(); |
92 } |
98 } |
93 }); |
99 }); |
94 }, 500); |
100 }, 500); |
176 shiftSize(1); |
182 shiftSize(1); |
177 return false; |
183 return false; |
178 }); |
184 }); |
179 |
185 |
180 this.editor_$.find(".Rk-Edit-Image-Del").click(function() { |
186 this.editor_$.find(".Rk-Edit-Image-Del").click(function() { |
181 _this.editor_$.find(".Rk-Edit-Image").val(''); |
187 _this.editor_$.find(".Rk-Edit-Image").val(''); |
182 onFieldChange(); |
188 onFieldChange(); |
183 return false; |
189 return false; |
184 }); |
190 }); |
185 } else { |
191 } else { |
186 if (typeof this.source_representation.highlighted === "object") { |
192 if (typeof this.source_representation.highlighted === "object") { |
187 var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>'); |
193 var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>'); |