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.templates['default']= this.options.templates['templates/nodeeditor.html']; |
15 //this.templates['default']= this.options.templates['templates/nodeeditor.html']; |
16 //fusionner avec this.options.node_editor_templates |
16 //fusionner avec this.options.node_editor_templates |
17 this.readOnlyTemplate = this.options.templates['templates/nodeeditor_readonly.html']; |
17 this.readOnlyTemplate = this.options.node_editor_templates; |
18 }, |
18 }, |
19 draw: function() { |
19 draw: function() { |
20 var _model = this.source_representation.model, |
20 var _model = this.source_representation.model, |
21 _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan), |
21 _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan), |
22 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
22 _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate[_model.get("type")] || this.readOnlyTemplate["default"]), |
23 _image_placeholder = this.options.static_url + "img/image-placeholder.png", |
23 _image_placeholder = this.options.static_url + "img/image-placeholder.png", |
24 _size = (_model.get("size") || 0); |
24 _size = (_model.get("size") || 0); |
25 this.editor_$ |
25 this.editor_$ |
26 .html(_template({ |
26 .html(_template({ |
27 node: { |
27 node: { |
28 _id: _model.get("_id"), |
28 _id: _model.get("_id"), |
29 has_creator: !!_model.get("created_by"), |
29 has_creator: !!_model.get("created_by"), |
30 title: _model.get("title"), |
30 title: _model.get("title"), |
31 uri: _model.get("uri"), |
31 uri: _model.get("uri"), |
|
32 type: _model.get("type") || "default", |
32 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
33 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
33 description: _model.get("description"), |
34 description: _model.get("description"), |
34 image: _model.get("image") || "", |
35 image: _model.get("image") || "", |
35 image_placeholder: _image_placeholder, |
36 image_placeholder: _image_placeholder, |
36 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
37 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
44 }, |
45 }, |
45 renkan: this.renkan, |
46 renkan: this.renkan, |
46 options: this.options, |
47 options: this.options, |
47 shortenText: Utils.shortenText, |
48 shortenText: Utils.shortenText, |
48 shapes : _(ShapeBuilder.builders).omit('svg').keys().value(), |
49 shapes : _(ShapeBuilder.builders).omit('svg').keys().value(), |
|
50 types : _(this.options.node_editor_templates).keys().value(), |
49 })); |
51 })); |
50 this.redraw(); |
52 this.redraw(); |
51 var _this = this, |
53 var _this = this, |
52 editorInstance = _this.options.show_node_editor_description_richtext ? |
54 editorInstance = _this.options.show_node_editor_description_richtext ? |
53 $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) : |
55 $(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) : |
122 _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash}); |
124 _data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash}); |
123 } |
125 } |
124 if (_this.options.change_shapes) { |
126 if (_this.options.change_shapes) { |
125 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
127 if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
126 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
128 _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
|
129 } |
|
130 } |
|
131 if (_this.options.change_types) { |
|
132 if(_model.get("type")!==_this.editor_$.find(".Rk-Edit-Type").val()){ |
|
133 _data.type = _this.editor_$.find(".Rk-Edit-Type").val(); |
127 } |
134 } |
128 } |
135 } |
129 _model.set(_data); |
136 _model.set(_data); |
130 _this.redraw(); |
137 _this.redraw(); |
131 } else { |
138 } else { |