1 |
1 |
2 define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) { |
2 define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder'], function ($, _, requtils, BaseEditor, ShapeBuilder) { |
3 'use strict'; |
3 'use strict'; |
4 |
4 |
5 var Utils = requtils.getUtils(); |
5 var Utils = requtils.getUtils(); |
6 |
6 |
7 /* NodeEditor Begin */ |
7 /* NodeEditor Begin */ |
28 uri: _model.get("uri"), |
28 uri: _model.get("uri"), |
29 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
29 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
30 description: _model.get("description"), |
30 description: _model.get("description"), |
31 image: _model.get("image") || "", |
31 image: _model.get("image") || "", |
32 image_placeholder: _image_placeholder, |
32 image_placeholder: _image_placeholder, |
33 color: _model.get("color") || _created_by.get("color"), |
33 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
|
34 dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
34 clip_path: _model.get("clip_path") || false, |
35 clip_path: _model.get("clip_path") || false, |
35 created_by_color: _created_by.get("color"), |
36 created_by_color: _created_by.get("color"), |
36 created_by_title: _created_by.get("title"), |
37 created_by_title: _created_by.get("title"), |
37 size: (_size > 0 ? "+" : "") + _size, |
38 size: (_size > 0 ? "+" : "") + _size, |
38 shape: _model.get("shape") || "circle" |
39 shape: _model.get("shape") || "circle" |
39 }, |
40 }, |
40 renkan: this.renkan, |
41 renkan: this.renkan, |
41 options: this.options, |
42 options: this.options, |
42 shortenText: Utils.shortenText |
43 shortenText: Utils.shortenText, |
|
44 shapes : _(ShapeBuilder.builders).omit('svg').keys().value(), |
43 })); |
45 })); |
44 this.redraw(); |
46 this.redraw(); |
45 var _this = this, |
47 var _this = this, |
46 closeEditor = function() { |
48 closeEditor = function() { |
47 _this.editor_$.off("keyup"); |
49 _this.editor_$.off("keyup"); |
83 _data.image = _this.editor_$.find(".Rk-Edit-Image").val(); |
85 _data.image = _this.editor_$.find(".Rk-Edit-Image").val(); |
84 _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); |
86 _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); |
85 } |
87 } |
86 if (_this.options.show_node_editor_description) { |
88 if (_this.options.show_node_editor_description) { |
87 _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
89 _data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
|
90 } |
|
91 if (_this.options.show_node_editor_style) { |
|
92 var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked'); |
|
93 _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash}); |
88 } |
94 } |
89 if (_this.options.change_shapes) { |
95 if (_this.options.change_shapes) { |
90 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
96 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
91 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
97 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
92 } |
98 } |
148 _e.preventDefault(); |
154 _e.preventDefault(); |
149 _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); |
155 _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); |
150 }, |
156 }, |
151 function(_e) { |
157 function(_e) { |
152 _e.preventDefault(); |
158 _e.preventDefault(); |
153 _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color")); |
159 _this.editor_$.find(".Rk-Edit-Color").css("background", (_model.has("style") && _model.get("style").color) || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color")); |
154 } |
160 } |
155 ).click(function(_e) { |
161 ).click(function(_e) { |
156 _e.preventDefault(); |
162 _e.preventDefault(); |
157 if (_this.renderer.isEditable()) { |
163 if (_this.renderer.isEditable()) { |
158 _model.set("color", $(this).attr("data-color")); |
164 _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {color: $(this).attr("data-color")})); |
159 _picker.hide(); |
165 _picker.hide(); |
160 paper.view.draw(); |
166 paper.view.draw(); |
161 } else { |
167 } else { |
162 closeEditor(); |
168 closeEditor(); |
163 } |
169 } |