| author | ymh <ymh.work@gmail.com> |
| Wed, 29 Jun 2016 22:48:10 +0200 | |
| changeset 625 | 4d67ae41b9b3 |
| parent 600 | e12243191095 |
| child 647 | eaaa1efce396 |
| permissions | -rw-r--r-- |
| 284 | 1 |
|
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
2 |
define(['jquery', 'underscore', 'requtils', 'renderer/baseeditor', 'renderer/shapebuilder', 'ckeditor-core'], function ($, _, requtils, BaseEditor, ShapeBuilder, CKEditor) { |
|
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 |
|
| 482 | 17 |
this.readOnlyTemplate = 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
|
18 |
}, |
| 284 | 19 |
draw: function() { |
20 |
var _model = this.source_representation.model, |
|
21 |
_created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan), |
|
| 482 | 22 |
_template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate[_model.get("type")] || this.readOnlyTemplate["default"]), |
| 284 | 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"), |
|
| 482 | 32 |
type: _model.get("type") || "default", |
| 284 | 33 |
short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
34 |
description: _model.get("description"), |
|
35 |
image: _model.get("image") || "", |
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
| 284 | 40 |
clip_path: _model.get("clip_path") || false, |
41 |
created_by_color: _created_by.get("color"), |
|
42 |
created_by_title: _created_by.get("title"), |
|
| 330 | 43 |
size: (_size > 0 ? "+" : "") + _size, |
44 |
shape: _model.get("shape") || "circle" |
|
| 284 | 45 |
}, |
46 |
renkan: this.renkan, |
|
47 |
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
|
48 |
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
|
49 |
shapes : _(ShapeBuilder.builders).omit('svg').keys().value(), |
| 482 | 50 |
types : _(this.options.node_editor_templates).keys().value(), |
| 284 | 51 |
})); |
52 |
this.redraw(); |
|
53 |
var _this = this, |
|
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
54 |
editorInstance = (this.renderer.isEditable() && _this.options.show_node_editor_description_richtext) ? |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
55 |
CKEditor.inline("Rk-Edit-Description-"+_model.get("_id"), _this.options.richtext_editor_config) : |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
56 |
false, |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
57 |
editorInstanceTitle = (this.renderer.isEditable() && _this.options.show_node_editor_title_richtext) ? |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
58 |
CKEditor.inline("Rk-Edit-Title-"+_model.get("_id"), _this.options.richtext_editor_config) : |
| 530 | 59 |
false, |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
60 |
closeEditor = function() { |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
61 |
_this.renderer.removeRepresentation(_this); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
62 |
paper.view.draw(); |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
63 |
}; |
| 284 | 64 |
|
|
470
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
65 |
_this.cleanEditor = function() { |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
66 |
_this.editor_$.off("keyup"); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
67 |
_this.editor_$.find("input, textarea, select").off("change keyup paste"); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
68 |
_this.editor_$.find(".Rk-Edit-Image-File").off('change'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
69 |
_this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").off('hover'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
70 |
_this.editor_$.find(".Rk-Edit-Size-Btn").off('click'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
71 |
_this.editor_$.find(".Rk-Edit-Image-Del").off('click'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
72 |
_this.editor_$.find(".Rk-Edit-ColorPicker").find("li").off('hover click'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
73 |
_this.editor_$.find(".Rk-CloseX").off('click'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
74 |
_this.editor_$.find(".Rk-Edit-Goto").off('click'); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
75 |
|
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
76 |
if(_this.options.show_node_editor_description_richtext) { |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
77 |
if(editorInstance) { |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
78 |
editorInstance.focusManager.blur(true); |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
79 |
editorInstance.destroy(); |
|
470
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
80 |
} |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
81 |
} |
| 530 | 82 |
if(_this.options.show_node_editor_title_richtext) { |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
83 |
if(editorInstanceTitle) { |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
84 |
editorInstanceTitle.focusManager.blur(true); |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
85 |
editorInstanceTitle.destroy(); |
| 530 | 86 |
} |
87 |
} |
|
|
470
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
88 |
}; |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
89 |
|
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
90 |
this.editor_$.find(".Rk-CloseX").click(function (e) { |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
91 |
e.preventDefault(); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
92 |
closeEditor(); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
93 |
}); |
| 284 | 94 |
|
95 |
this.editor_$.find(".Rk-Edit-Goto").click(function() { |
|
96 |
if (!_model.get("uri")) { |
|
97 |
return false; |
|
98 |
} |
|
99 |
}); |
|
100 |
||
101 |
if (this.renderer.isEditable()) { |
|
102 |
||
|
625
4d67ae41b9b3
debounce node and edge edition instead of throttle
ymh <ymh.work@gmail.com>
parents:
600
diff
changeset
|
103 |
var onFieldChange = _.debounce(function() { |
| 433 | 104 |
_.defer(function() { |
105 |
if (_this.renderer.isEditable()) { |
|
| 530 | 106 |
var _data = {}; |
| 433 | 107 |
if (_this.options.show_node_editor_uri) { |
108 |
_data.uri = _this.editor_$.find(".Rk-Edit-URI").val(); |
|
109 |
_this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#"); |
|
110 |
} |
|
111 |
if (_this.options.show_node_editor_image) { |
|
112 |
_data.image = _this.editor_$.find(".Rk-Edit-Image").val(); |
|
113 |
_this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder); |
|
114 |
} |
|
115 |
if (_this.options.show_node_editor_description) { |
|
|
470
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
116 |
if(_this.options.show_node_editor_description_richtext) { |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
117 |
if(editorInstance && |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
118 |
editorInstance.checkDirty()) { |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
119 |
_data.description = editorInstance.getData(); |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
120 |
editorInstance.resetDirty(); |
|
470
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
121 |
} |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
122 |
} |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
123 |
else { |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
124 |
_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
|
125 |
} |
| 433 | 126 |
} |
| 530 | 127 |
if (_this.options.show_node_editor_title) { |
128 |
if(_this.options.show_node_editor_title_richtext) { |
|
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
129 |
if(editorInstanceTitle && |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
130 |
editorInstanceTitle.checkDirty()) { |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
131 |
_data.title = editorInstanceTitle.getData(); |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
132 |
editorInstanceTitle.resetDirty(); |
| 530 | 133 |
} |
134 |
} |
|
135 |
else { |
|
136 |
_data.title = _this.editor_$.find(".Rk-Edit-Title").val(); |
|
137 |
} |
|
138 |
} |
|
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
435
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
_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
|
142 |
} |
| 433 | 143 |
if (_this.options.change_shapes) { |
144 |
if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){ |
|
145 |
_data.shape = _this.editor_$.find(".Rk-Edit-Shape").val(); |
|
| 284 | 146 |
} |
| 433 | 147 |
} |
| 482 | 148 |
if (_this.options.change_types) { |
149 |
if(_model.get("type")!==_this.editor_$.find(".Rk-Edit-Type").val()){ |
|
150 |
_data.type = _this.editor_$.find(".Rk-Edit-Type").val(); |
|
151 |
} |
|
152 |
} |
|
| 433 | 153 |
_model.set(_data); |
154 |
_this.redraw(); |
|
155 |
} else { |
|
156 |
closeEditor(); |
|
157 |
} |
|
158 |
}); |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
159 |
}, 1000); |
| 433 | 160 |
|
| 284 | 161 |
this.editor_$.on("keyup", function(_e) { |
162 |
if (_e.keyCode === 27) { |
|
163 |
closeEditor(); |
|
164 |
} |
|
165 |
}); |
|
166 |
||
| 330 | 167 |
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
|
168 |
if( _this.options.show_node_editor_description && |
|
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
169 |
_this.options.show_node_editor_description_richtext && |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
170 |
editorInstance) |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
171 |
{ |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
172 |
editorInstance.on("change", onFieldChange); |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
173 |
editorInstance.on("blur", onFieldChange); |
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
174 |
} |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
175 |
|
| 530 | 176 |
if( _this.options.show_node_editor_title && |
177 |
_this.options.show_node_editor_title_richtext && |
|
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
178 |
editorInstanceTitle) |
| 530 | 179 |
{ |
|
600
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
180 |
editorInstanceTitle.on("change", onFieldChange); |
|
e12243191095
correct jquery dependency in renkan renderer + problem with CKEditor + version
ymh <ymh.work@gmail.com>
parents:
530
diff
changeset
|
181 |
editorInstanceTitle.on("blur", onFieldChange); |
| 530 | 182 |
} |
| 284 | 183 |
|
| 385 | 184 |
if(_this.options.allow_image_upload) { |
185 |
this.editor_$.find(".Rk-Edit-Image-File").change(function() { |
|
186 |
if (this.files.length) { |
|
187 |
var f = this.files[0], |
|
188 |
fr = new FileReader(); |
|
189 |
if (f.type.substr(0,5) !== "image") { |
|
190 |
alert(_this.renkan.translate("This file is not an image")); |
|
191 |
return; |
|
192 |
} |
|
193 |
if (f.size > (_this.options.uploaded_image_max_kb * 1024)) { |
|
194 |
alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB")); |
|
195 |
return; |
|
196 |
} |
|
197 |
fr.onload = function(e) { |
|
198 |
_this.editor_$.find(".Rk-Edit-Image").val(e.target.result); |
|
199 |
onFieldChange(); |
|
200 |
}; |
|
201 |
fr.readAsDataURL(f); |
|
| 284 | 202 |
} |
| 385 | 203 |
}); |
204 |
} |
|
| 284 | 205 |
this.editor_$.find(".Rk-Edit-Title")[0].focus(); |
206 |
||
207 |
var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker"); |
|
208 |
||
209 |
this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( |
|
210 |
function(_e) { |
|
211 |
_e.preventDefault(); |
|
212 |
_picker.show(); |
|
213 |
}, |
|
214 |
function(_e) { |
|
215 |
_e.preventDefault(); |
|
216 |
_picker.hide(); |
|
217 |
} |
|
218 |
); |
|
219 |
||
220 |
_picker.find("li").hover( |
|
221 |
function(_e) { |
|
222 |
_e.preventDefault(); |
|
223 |
_this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); |
|
224 |
}, |
|
225 |
function(_e) { |
|
226 |
_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
|
227 |
_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 | 228 |
} |
229 |
).click(function(_e) { |
|
230 |
_e.preventDefault(); |
|
231 |
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
|
232 |
_model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {color: $(this).attr("data-color")})); |
| 284 | 233 |
_picker.hide(); |
234 |
paper.view.draw(); |
|
235 |
} else { |
|
236 |
closeEditor(); |
|
237 |
} |
|
238 |
}); |
|
239 |
||
240 |
var shiftSize = function(n) { |
|
241 |
if (_this.renderer.isEditable()) { |
|
242 |
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
|
243 |
_this.editor_$.find("#Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize); |
| 284 | 244 |
_model.set("size", _newsize); |
245 |
paper.view.draw(); |
|
246 |
} else { |
|
247 |
closeEditor(); |
|
248 |
} |
|
249 |
}; |
|
250 |
||
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
251 |
this.editor_$.find("#Rk-Edit-Size-Down").click(function() { |
| 284 | 252 |
shiftSize(-1); |
253 |
return false; |
|
254 |
}); |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
255 |
this.editor_$.find("#Rk-Edit-Size-Up").click(function() { |
| 284 | 256 |
shiftSize(1); |
257 |
return false; |
|
258 |
}); |
|
| 433 | 259 |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
260 |
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
|
261 |
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
|
262 |
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
|
263 |
_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
|
264 |
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
|
265 |
_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
|
266 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
267 |
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
|
268 |
_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
|
269 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
270 |
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
|
271 |
_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
|
272 |
_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
|
273 |
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
|
274 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
275 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
276 |
else { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
277 |
closeEditor(); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
278 |
} |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
279 |
}; |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
280 |
|
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
}); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
}); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
289 |
|
|
384
6a7930a0d4d1
Close #60 - Add a trash icon to delete the image URL
rougeronj
parents:
331
diff
changeset
|
290 |
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
|
291 |
_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
|
292 |
onFieldChange(); |
|
384
6a7930a0d4d1
Close #60 - Add a trash icon to delete the image URL
rougeronj
parents:
331
diff
changeset
|
293 |
return false; |
|
6a7930a0d4d1
Close #60 - Add a trash icon to delete the image URL
rougeronj
parents:
331
diff
changeset
|
294 |
}); |
| 284 | 295 |
} else { |
296 |
if (typeof this.source_representation.highlighted === "object") { |
|
297 |
var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>'); |
|
298 |
this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml); |
|
299 |
if (this.options.show_node_tooltip_description) { |
|
300 |
this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>')); |
|
301 |
} |
|
302 |
} |
|
303 |
} |
|
304 |
this.editor_$.find("img").load(function() { |
|
305 |
_this.redraw(); |
|
306 |
}); |
|
307 |
}, |
|
308 |
redraw: function() { |
|
| 447 | 309 |
if (this.options.popup_editor){ |
310 |
var _coords = this.source_representation.paper_coords; |
|
|
468
364c367df7fc
add rich text editor for description
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
311 |
Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$); |
| 447 | 312 |
} |
| 284 | 313 |
this.editor_$.show(); |
314 |
paper.view.draw(); |
|
|
470
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
315 |
}, |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
316 |
destroy: function() { |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
317 |
if(typeof this.cleanEditor !== 'undefined') { |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
318 |
this.cleanEditor(); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
319 |
} |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
320 |
this.editor_block.remove(); |
|
47308aa6ce94
correction for rich text editor. correct problem of empty description. make sure that the editor toolbr close
ymh <ymh.work@gmail.com>
parents:
469
diff
changeset
|
321 |
this.editor_$.remove(); |
| 284 | 322 |
} |
| 433 | 323 |
}).value(); |
|
434
0d5998b32a7c
clean, and finalize lodash migration
ymh <ymh.work@gmail.com>
parents:
433
diff
changeset
|
324 |
|
| 284 | 325 |
/* NodeEditor End */ |
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
284
diff
changeset
|
326 |
|
| 284 | 327 |
return NodeEditor; |
328 |
||
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
284
diff
changeset
|
329 |
}); |