| author | rougeronj |
| Fri, 12 Jun 2015 15:41:26 +0200 | |
| changeset 479 | be510a7fc5ac |
| parent 469 | 374e17d0d96a |
| child 480 | a5da9a586297 |
| permissions | -rw-r--r-- |
| 284 | 1 |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
2 |
define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder', 'ckeditor-jquery'], function ($, _, requtils, BaseEditor, ShapeBuilder) { |
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
284
diff
changeset
|
3 |
'use strict'; |
|
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
284
diff
changeset
|
4 |
|
| 284 | 5 |
var Utils = requtils.getUtils(); |
6 |
||
7 |
/* NodeEditor Begin */ |
|
8 |
//var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor); |
|
9 |
var NodeEditor = Utils.inherit(BaseEditor); |
|
10 |
||
11 |
_(NodeEditor.prototype).extend({ |
|
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
12 |
_init: function() { |
|
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
13 |
BaseEditor.prototype._init.apply(this); |
|
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
14 |
this.template = this.options.templates['templates/nodeeditor.html']; |
| 450 | 15 |
//this.templates['default']= this.options.templates['templates/nodeeditor.html']; |
16 |
//fusionner avec this.options.node_editor_templates |
|
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
17 |
this.readOnlyTemplate = this.options.templates['templates/nodeeditor_readonly.html']; |
|
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
18 |
}, |
| 284 | 19 |
draw: function() { |
20 |
var _model = this.source_representation.model, |
|
21 |
_created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan), |
|
22 |
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), |
|
23 |
_image_placeholder = this.options.static_url + "img/image-placeholder.png", |
|
24 |
_size = (_model.get("size") || 0); |
|
25 |
this.editor_$ |
|
26 |
.html(_template({ |
|
27 |
node: { |
|
|
479
be510a7fc5ac
send the id to the template and construct an proper url for each node passing the id to the parameter idNode
rougeronj
parents:
469
diff
changeset
|
28 |
_id: _model.get("_id"), |
| 284 | 29 |
has_creator: !!_model.get("created_by"), |
30 |
title: _model.get("title"), |
|
31 |
uri: _model.get("uri"), |
|
32 |
short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
|
33 |
description: _model.get("description"), |
|
34 |
image: _model.get("image") || "", |
|
35 |
image_placeholder: _image_placeholder, |
|
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
36 |
color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
37 |
thickness: (_model.has("style") && _model.get("style").thickness) || 1, |
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
38 |
dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
| 284 | 39 |
clip_path: _model.get("clip_path") || false, |
40 |
created_by_color: _created_by.get("color"), |
|
41 |
created_by_title: _created_by.get("title"), |
|
| 330 | 42 |
size: (_size > 0 ? "+" : "") + _size, |
43 |
shape: _model.get("shape") || "circle" |
|
| 284 | 44 |
}, |
45 |
renkan: this.renkan, |
|
46 |
options: this.options, |
|
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
47 |
shortenText: Utils.shortenText, |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
48 |
shapes : _(ShapeBuilder.builders).omit('svg').keys().value(), |
| 284 | 49 |
})); |
50 |
this.redraw(); |
|
51 |
var _this = this, |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
52 |
editorInstance = _this.options.show_node_editor_description_richtext ? |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
53 |
$(".Rk-Edit-Description").ckeditor(_this.options.richtext_editor_config) : |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
54 |
false, |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
55 |
closeEditor = function() { |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
56 |
_this.editor_$.off("keyup"); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
57 |
_this.editor_$.find("input, textarea, select").off("change keyup paste"); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
58 |
_this.editor_$.find(".Rk-Edit-Image-File").off('change'); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
59 |
_this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover'); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
60 |
_this.editor_$.find(".Rk-Edit-Size-Btn").off('click'); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
61 |
_this.editor_$.find(".Rk-Edit-Image-Del").off('click'); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
62 |
_this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click'); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
63 |
_this.editor_$.find(".Rk-CloseX").off('click'); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
64 |
_this.editor_$.find(".Rk-Edit-Goto").off('click'); |
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
65 |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
66 |
if(_this.options.show_node_editor_description_richtext) { |
|
469
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
67 |
if(typeof _this.editorListeners !== 'undefined') { |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
68 |
_this.editorListeners.forEach( function(listener) { |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
69 |
listener.removeListener(); |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
70 |
}); |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
71 |
} |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
72 |
if(typeof editorInstance.editor !== 'undefined') { |
|
469
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
73 |
var _editor = editorInstance.editor; |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
74 |
delete editorInstance.editor; |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
75 |
_editor.destroy(); |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
76 |
} |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
77 |
} |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
78 |
_this.renderer.removeRepresentation(_this); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
79 |
paper.view.draw(); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
80 |
}; |
| 284 | 81 |
|
82 |
this.editor_$.find(".Rk-CloseX").click(closeEditor); |
|
83 |
||
84 |
this.editor_$.find(".Rk-Edit-Goto").click(function() { |
|
85 |
if (!_model.get("uri")) { |
|
86 |
return false; |
|
87 |
} |
|
88 |
}); |
|
89 |
||
90 |
if (this.renderer.isEditable()) { |
|
91 |
||
| 433 | 92 |
var onFieldChange = _.throttle(function() { |
93 |
_.defer(function() { |
|
94 |
if (_this.renderer.isEditable()) { |
|
95 |
var _data = { |
|
96 |
title: _this.editor_$.find(".Rk-Edit-Title").val() |
|
97 |
}; |
|
98 |
if (_this.options.show_node_editor_uri) { |
|
99 |
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val(); |
|
100 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#"); |
|
101 |
} |
|
102 |
if (_this.options.show_node_editor_image) { |
|
103 |
_data.image = _this.editor_$.find(".Rk-Edit-Image").val(); |
|
104 |
_this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); |
|
105 |
} |
|
106 |
if (_this.options.show_node_editor_description) { |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
107 |
if(_this.options.show_node_editor_description_richtext && |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
108 |
typeof editorInstance.editor !== 'undefined' && |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
109 |
editorInstance.editor.checkDirty()) |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
110 |
{ |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
111 |
_data.description = editorInstance.editor.getData(); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
112 |
editorInstance.editor.resetDirty(); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
113 |
} |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
114 |
else { |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
115 |
_data.description = _this.editor_$.find(".Rk-Edit-Description").val(); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
116 |
} |
| 433 | 117 |
} |
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
118 |
if (_this.options.show_node_editor_style) { |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
119 |
var dash = _this.editor_$.find(".Rk-Edit-Dash").is(':checked'); |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
120 |
_data.style = _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {dash: dash}); |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
121 |
} |
| 433 | 122 |
if (_this.options.change_shapes) { |
123 |
if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
|
124 |
_data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
|
| 284 | 125 |
} |
| 433 | 126 |
} |
127 |
_model.set(_data); |
|
128 |
_this.redraw(); |
|
129 |
} else { |
|
130 |
closeEditor(); |
|
131 |
} |
|
132 |
}); |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
133 |
}, 1000); |
| 433 | 134 |
|
| 284 | 135 |
this.editor_$.on("keyup", function(_e) { |
136 |
if (_e.keyCode === 27) { |
|
137 |
closeEditor(); |
|
138 |
} |
|
139 |
}); |
|
140 |
||
| 330 | 141 |
this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange); |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
142 |
if( _this.options.show_node_editor_description && |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
143 |
_this.options.show_node_editor_description_richtext && |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
144 |
typeof editorInstance.editor !== 'undefined') |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
145 |
{ |
|
469
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
146 |
_this.editorListeners = []; |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
147 |
_this.editorListeners.push(editorInstance.editor.on("change", onFieldChange)); |
|
374e17d0d96a
small adjustments to avoid editor race condition on close
ymh <ymh.work@gmail.com>
parents:
468
diff
changeset
|
148 |
_this.editorListeners.push(editorInstance.editor.on("blur", onFieldChange)); |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
149 |
} |
| 284 | 150 |
|
| 385 | 151 |
if(_this.options.allow_image_upload) { |
152 |
this.editor_$.find(".Rk-Edit-Image-File").change(function() { |
|
153 |
if (this.files.length) { |
|
154 |
var f = this.files[0], |
|
155 |
fr = new FileReader(); |
|
156 |
if (f.type.substr(0,5) !== "image") { |
|
157 |
alert(_this.renkan.translate("This file is not an image")); |
|
158 |
return; |
|
159 |
} |
|
160 |
if (f.size > (_this.options.uploaded_image_max_kb * 1024)) { |
|
161 |
alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB")); |
|
162 |
return; |
|
163 |
} |
|
164 |
fr.onload = function(e) { |
|
165 |
_this.editor_$.find(".Rk-Edit-Image").val(e.target.result); |
|
166 |
onFieldChange(); |
|
167 |
}; |
|
168 |
fr.readAsDataURL(f); |
|
| 284 | 169 |
} |
| 385 | 170 |
}); |
171 |
} |
|
| 284 | 172 |
this.editor_$.find(".Rk-Edit-Title")[0].focus(); |
173 |
||
174 |
var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker"); |
|
175 |
||
176 |
this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( |
|
177 |
function(_e) { |
|
178 |
_e.preventDefault(); |
|
179 |
_picker.show(); |
|
180 |
}, |
|
181 |
function(_e) { |
|
182 |
_e.preventDefault(); |
|
183 |
_picker.hide(); |
|
184 |
} |
|
185 |
); |
|
186 |
||
187 |
_picker.find("li").hover( |
|
188 |
function(_e) { |
|
189 |
_e.preventDefault(); |
|
190 |
_this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); |
|
191 |
}, |
|
192 |
function(_e) { |
|
193 |
_e.preventDefault(); |
|
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
194 |
_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")); |
| 284 | 195 |
} |
196 |
).click(function(_e) { |
|
197 |
_e.preventDefault(); |
|
198 |
if (_this.renderer.isEditable()) { |
|
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
199 |
_model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {color: $(this).attr("data-color")})); |
| 284 | 200 |
_picker.hide(); |
201 |
paper.view.draw(); |
|
202 |
} else { |
|
203 |
closeEditor(); |
|
204 |
} |
|
205 |
}); |
|
206 |
||
207 |
var shiftSize = function(n) { |
|
208 |
if (_this.renderer.isEditable()) { |
|
209 |
var _newsize = n+(_model.get("size") || 0); |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
210 |
_this.editor_$.find("#Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize); |
| 284 | 211 |
_model.set("size", _newsize); |
212 |
paper.view.draw(); |
|
213 |
} else { |
|
214 |
closeEditor(); |
|
215 |
} |
|
216 |
}; |
|
217 |
||
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
218 |
this.editor_$.find("#Rk-Edit-Size-Down").click(function() { |
| 284 | 219 |
shiftSize(-1); |
220 |
return false; |
|
221 |
}); |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
222 |
this.editor_$.find("#Rk-Edit-Size-Up").click(function() { |
| 284 | 223 |
shiftSize(1); |
224 |
return false; |
|
225 |
}); |
|
| 433 | 226 |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
227 |
var shiftThickness = function(n) { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
228 |
if (_this.renderer.isEditable()) { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
229 |
var _oldThickness = ((_model.has('style') && _model.get('style').thickness) || 1), |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
230 |
_newThickness = n + _oldThickness; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
231 |
if(_newThickness < 1 ) { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
232 |
_newThickness = 1; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
233 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
234 |
else if (_newThickness > _this.options.node_stroke_witdh_scale) { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
235 |
_newThickness = _this.options.node_stroke_witdh_scale; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
236 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
237 |
if (_newThickness !== _oldThickness) { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
238 |
_this.editor_$.find("#Rk-Edit-Thickness-Value").text(_newThickness); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
239 |
_model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {thickness: _newThickness})); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
240 |
paper.view.draw(); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
241 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
242 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
243 |
else { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
244 |
closeEditor(); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
245 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
246 |
}; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
247 |
|
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
248 |
this.editor_$.find("#Rk-Edit-Thickness-Down").click(function() { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
249 |
shiftThickness(-1); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
250 |
return false; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
251 |
}); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
252 |
this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
253 |
shiftThickness(1); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
254 |
return false; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
255 |
}); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
256 |
|
|
384
6a7930a0d4d1
Close #60 - Add a trash icon to delete the image URL
rougeronj
parents:
331
diff
changeset
|
257 |
this.editor_$.find(".Rk-Edit-Image-Del").click(function() { |
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
258 |
_this.editor_$.find(".Rk-Edit-Image").val(''); |
|
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
259 |
onFieldChange(); |
|
384
6a7930a0d4d1
Close #60 - Add a trash icon to delete the image URL
rougeronj
parents:
331
diff
changeset
|
260 |
return false; |
|
6a7930a0d4d1
Close #60 - Add a trash icon to delete the image URL
rougeronj
parents:
331
diff
changeset
|
261 |
}); |
| 284 | 262 |
} else { |
263 |
if (typeof this.source_representation.highlighted === "object") { |
|
264 |
var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>'); |
|
265 |
this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml); |
|
266 |
if (this.options.show_node_tooltip_description) { |
|
267 |
this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>')); |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
this.editor_$.find("img").load(function() { |
|
272 |
_this.redraw(); |
|
273 |
}); |
|
274 |
}, |
|
275 |
redraw: function() { |
|
| 447 | 276 |
if (this.options.popup_editor){ |
277 |
var _coords = this.source_representation.paper_coords; |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
278 |
Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$); |
| 447 | 279 |
} |
| 284 | 280 |
this.editor_$.show(); |
281 |
paper.view.draw(); |
|
282 |
} |
|
| 433 | 283 |
}).value(); |
|
434
0d5998b32a7c
clean, and finalize lodash migration
ymh <ymh.work@gmail.com>
parents:
433
diff
changeset
|
284 |
|
| 284 | 285 |
/* NodeEditor End */ |
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
284
diff
changeset
|
286 |
|
| 284 | 287 |
return NodeEditor; |
288 |
||
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
284
diff
changeset
|
289 |
}); |