| author | ymh <ymh.work@gmail.com> |
| Tue, 10 Jan 2017 17:36:30 +0100 | |
| changeset 649 | 2b9c120dba55 |
| parent 633 | fdff56da097d |
| permissions | -rw-r--r-- |
| 284 | 1 |
|
2 |
define(['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) { |
|
|
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 |
/* Edge Class Begin */ |
|
8 |
||
9 |
//var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation); |
|
10 |
var Edge = Utils.inherit(BaseRepresentation); |
|
11 |
||
12 |
_(Edge.prototype).extend({ |
|
13 |
_init: function() { |
|
14 |
this.renderer.edge_layer.activate(); |
|
15 |
this.type = "Edge"; |
|
| 450 | 16 |
this.hidden = false; |
17 |
this.ghost = false; |
|
|
633
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
18 |
this.highlighted = false; |
| 284 | 19 |
this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from")); |
20 |
this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); |
|
21 |
this.bundle = this.renderer.addToBundles(this); |
|
22 |
this.line = new paper.Path(); |
|
23 |
this.line.add([0,0],[0,0],[0,0]); |
|
24 |
this.line.__representation = this; |
|
25 |
this.line.strokeWidth = this.options.edge_stroke_width; |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
26 |
this.arrow_scale = 1; |
| 284 | 27 |
this.arrow = new paper.Path(); |
28 |
this.arrow.add( |
|
29 |
[ 0, 0 ], |
|
30 |
[ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], |
|
31 |
[ 0, this.options.edge_arrow_width ] |
|
32 |
); |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
33 |
this.arrow.pivot = new paper.Point([ this.options.edge_arrow_length / 2, this.options.edge_arrow_width / 2 ]); |
| 284 | 34 |
this.arrow.__representation = this; |
35 |
this.text = $('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$); |
|
36 |
this.arrow_angle = 0; |
|
37 |
if (this.options.editor_mode) { |
|
38 |
var Renderer = requtils.getRenderer(); |
|
39 |
this.normal_buttons = [ |
|
40 |
new Renderer.EdgeEditButton(this.renderer, null), |
|
41 |
new Renderer.EdgeRemoveButton(this.renderer, null) |
|
42 |
]; |
|
43 |
this.pending_delete_buttons = [ |
|
44 |
new Renderer.EdgeRevertButton(this.renderer, null) |
|
45 |
]; |
|
46 |
this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons); |
|
47 |
for (var i = 0; i < this.all_buttons.length; i++) { |
|
48 |
this.all_buttons[i].source_representation = this; |
|
49 |
} |
|
50 |
this.active_buttons = []; |
|
51 |
} else { |
|
52 |
this.active_buttons = this.all_buttons = []; |
|
53 |
} |
|
54 |
||
55 |
if (this.renderer.minimap) { |
|
56 |
this.renderer.minimap.edge_layer.activate(); |
|
57 |
this.minimap_line = new paper.Path(); |
|
58 |
this.minimap_line.add([0,0],[0,0]); |
|
59 |
this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation; |
|
60 |
this.minimap_line.strokeWidth = 1; |
|
61 |
} |
|
62 |
}, |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
63 |
_getStrokeWidth: function() { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
64 |
var thickness = (this.model.has('style') && this.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
|
65 |
return this.options.edge_stroke_width + (thickness-1) * (this.options.edge_stroke_max_width - this.options.edge_stroke_width) / (this.options.edge_stroke_witdh_scale-1); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
66 |
}, |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
67 |
_getSelectedStrokeWidth: function() { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
68 |
var thickness = (this.model.has('style') && this.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
|
69 |
return this.options.selected_edge_stroke_width + (thickness-1) * (this.options.selected_edge_stroke_max_width - this.options.selected_edge_stroke_width) / (this.options.edge_stroke_witdh_scale-1); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
70 |
}, |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
71 |
_getArrowScale: function() { |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
72 |
var thickness = (this.model.has('style') && this.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
|
73 |
return 1 + (thickness-1) * ((this.options.edge_arrow_max_width / this.options.edge_arrow_width) - 1) / (this.options.edge_stroke_witdh_scale-1); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
74 |
}, |
| 284 | 75 |
redraw: function() { |
76 |
var from = this.model.get("from"), |
|
|
633
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
77 |
to = this.model.get("to"); |
| 450 | 78 |
if (!from || !to || (this.hidden && !this.ghost)) { |
| 284 | 79 |
return; |
80 |
} |
|
81 |
this.from_representation = this.renderer.getRepresentationByModel(from); |
|
82 |
this.to_representation = this.renderer.getRepresentationByModel(to); |
|
| 450 | 83 |
if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined" || |
| 453 | 84 |
(this.from_representation.hidden && !this.from_representation.ghost) || |
|
461
48235ed6b07d
Merge with a3bf10beb710d1cfdda455ab98705f9e7a631739
ymh <ymh.work@gmail.com>
diff
changeset
|
85 |
(this.to_representation.hidden && !this.to_representation.ghost)) { |
| 453 | 86 |
this.hide(); |
| 284 | 87 |
return; |
88 |
} |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
89 |
var _strokeWidth = this._getStrokeWidth(), |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
90 |
_arrow_scale = this._getArrowScale(), |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
91 |
_p0a = this.from_representation.paper_coords, |
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
92 |
_p1a = this.to_representation.paper_coords, |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
93 |
_v = _p1a.subtract(_p0a), |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
94 |
_r = _v.length, |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
95 |
_u = _v.divide(_r), |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
96 |
_ortho = new paper.Point([- _u.y, _u.x]), |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
97 |
_group_pos = this.bundle.getPosition(this), |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
98 |
_delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ), |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
99 |
_p0b = _p0a.add(_delta), /* Adding a 4 px difference */ |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
100 |
_p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
|
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
101 |
_a = _v.angle, |
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
102 |
_textdelta = _ortho.multiply(this.options.edge_label_distance + 0.5 * _arrow_scale * this.options.edge_arrow_width), |
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
103 |
_handle = _v.divide(3), |
|
633
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
104 |
_color = (this.highlighted && this.options.highlighted_edge_color) || |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
105 |
(this.model.has("style") && this.model.get("style").color) || |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
106 |
(this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"), |
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
107 |
_dash = (this.model.has("style") && this.model.get("style").dash) ? this.options.default_dash_array : null, |
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
108 |
_opacity; |
| 284 | 109 |
|
110 |
if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) { |
|
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
111 |
_opacity = 0.5; |
| 284 | 112 |
this.line.dashArray = [2, 2]; |
113 |
} else { |
|
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
114 |
_opacity = this.ghost ? this.options.ghost_opacity : 1; |
| 284 | 115 |
this.line.dashArray = null; |
116 |
} |
|
117 |
||
118 |
var old_act_btn = this.active_buttons; |
|
119 |
||
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
120 |
this.arrow.visible = |
|
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
121 |
(this.model.has("style") && this.model.get("style").arrow) || |
|
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
122 |
!this.model.has("style") || |
|
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
123 |
typeof this.model.get("style").arrow === 'undefined'; |
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
124 |
|
| 284 | 125 |
this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons; |
126 |
||
127 |
if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) { |
|
128 |
old_act_btn.forEach(function(b) { |
|
129 |
b.hide(); |
|
130 |
}); |
|
131 |
this.active_buttons.forEach(function(b) { |
|
132 |
b.show(); |
|
133 |
}); |
|
134 |
} |
|
135 |
||
136 |
this.paper_coords = _p0b.add(_p1b).divide(2); |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
137 |
this.line.strokeWidth = _strokeWidth; |
| 284 | 138 |
this.line.strokeColor = _color; |
|
458
423bdf56d103
migrated to style, added dash style to client + small refactoring for shapes + triangle
ymh <ymh.work@gmail.com>
parents:
434
diff
changeset
|
139 |
this.line.dashArray = _dash; |
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
140 |
this.line.opacity = _opacity; |
| 284 | 141 |
this.line.segments[0].point = _p0a; |
142 |
this.line.segments[1].point = this.paper_coords; |
|
143 |
this.line.segments[1].handleIn = _handle.multiply(-1); |
|
144 |
this.line.segments[1].handleOut = _handle; |
|
145 |
this.line.segments[2].point = _p1a; |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
146 |
this.arrow.scale(_arrow_scale / this.arrow_scale); |
|
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
147 |
this.arrow_scale = _arrow_scale; |
| 284 | 148 |
this.arrow.fillColor = _color; |
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
149 |
this.arrow.opacity = _opacity; |
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
150 |
this.arrow.rotate(_a - this.arrow_angle, this.arrow.bounds.center); |
| 284 | 151 |
this.arrow.position = this.paper_coords; |
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
152 |
|
| 284 | 153 |
this.arrow_angle = _a; |
154 |
if (_a > 90) { |
|
155 |
_a -= 180; |
|
156 |
_textdelta = _textdelta.multiply(-1); |
|
157 |
} |
|
158 |
if (_a < -90) { |
|
159 |
_a += 180; |
|
160 |
_textdelta = _textdelta.multiply(-1); |
|
161 |
} |
|
162 |
var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || ""; |
|
163 |
_text = Utils.shortenText(_text, this.options.node_label_max_length); |
|
|
633
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
164 |
if (typeof this.highlighted === "object") { |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
165 |
this.text.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>')); |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
166 |
} else { |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
167 |
this.text.text(_text); |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
168 |
} |
| 284 | 169 |
var _textpos = this.paper_coords.add(_textdelta); |
170 |
this.text.css({ |
|
171 |
left: _textpos.x, |
|
172 |
top: _textpos.y, |
|
173 |
transform: "rotate(" + _a + "deg)", |
|
174 |
"-moz-transform": "rotate(" + _a + "deg)", |
|
175 |
"-webkit-transform": "rotate(" + _a + "deg)", |
|
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
176 |
opacity: _opacity |
| 284 | 177 |
}); |
178 |
this.text_angle = _a; |
|
179 |
||
180 |
var _pc = this.paper_coords; |
|
181 |
this.all_buttons.forEach(function(b) { |
|
182 |
b.moveTo(_pc); |
|
183 |
}); |
|
184 |
||
185 |
if (this.renderer.minimap) { |
|
186 |
this.minimap_line.strokeColor = _color; |
|
187 |
this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))); |
|
188 |
this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))); |
|
189 |
} |
|
190 |
}, |
|
| 450 | 191 |
hide: function(){ |
192 |
this.hidden = true; |
|
193 |
this.ghost = false; |
|
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
194 |
|
| 450 | 195 |
this.text.hide(); |
196 |
this.line.visible = false; |
|
197 |
this.arrow.visible = false; |
|
198 |
this.minimap_line.visible = false; |
|
199 |
}, |
|
200 |
show: function(ghost){ |
|
201 |
this.ghost = ghost; |
|
|
461
48235ed6b07d
Merge with a3bf10beb710d1cfdda455ab98705f9e7a631739
ymh <ymh.work@gmail.com>
diff
changeset
|
202 |
if (this.ghost) { |
| 450 | 203 |
this.text.css('opacity', 0.3); |
204 |
this.line.opacity = 0.3; |
|
205 |
this.arrow.opacity = 0.3; |
|
206 |
this.minimap_line.opacity = 0.3; |
|
|
461
48235ed6b07d
Merge with a3bf10beb710d1cfdda455ab98705f9e7a631739
ymh <ymh.work@gmail.com>
diff
changeset
|
207 |
} else { |
| 450 | 208 |
this.hidden = false; |
|
462
255b66d1ce78
remove magical constant, put ghost opacity in the defaults.
ymh <ymh.work@gmail.com>
parents:
461
diff
changeset
|
209 |
|
| 450 | 210 |
this.text.css('opacity', 1); |
211 |
this.line.opacity = 1; |
|
212 |
this.arrow.opacity = 1; |
|
213 |
this.minimap_line.opacity = 1; |
|
214 |
} |
|
215 |
this.text.show(); |
|
216 |
this.line.visible = true; |
|
217 |
this.arrow.visible = true; |
|
218 |
this.minimap_line.visible = true; |
|
219 |
this.redraw(); |
|
220 |
}, |
|
| 284 | 221 |
openEditor: function() { |
222 |
this.renderer.removeRepresentationsOfType("editor"); |
|
223 |
var _editor = this.renderer.addRepresentation("EdgeEditor",null); |
|
224 |
_editor.source_representation = this; |
|
225 |
_editor.draw(); |
|
226 |
}, |
|
227 |
select: function() { |
|
228 |
this.selected = true; |
|
|
459
98cae534083d
add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents:
458
diff
changeset
|
229 |
this.line.strokeWidth = this._getSelectedStrokeWidth(); |
| 284 | 230 |
if (this.renderer.isEditable()) { |
231 |
this.active_buttons.forEach(function(b) { |
|
232 |
b.show(); |
|
233 |
}); |
|
234 |
} |
|
235 |
if (!this.options.editor_mode) { |
|
236 |
this.openEditor(); |
|
237 |
} |
|
238 |
this._super("select"); |
|
239 |
}, |
|
240 |
unselect: function(_newTarget) { |
|
241 |
if (!_newTarget || _newTarget.source_representation !== this) { |
|
242 |
this.selected = false; |
|
243 |
if (this.options.editor_mode) { |
|
244 |
this.all_buttons.forEach(function(b) { |
|
245 |
b.hide(); |
|
246 |
}); |
|
247 |
} |
|
|
532
030f2e4c0664
close the edge popup editor as soon as the edge get hidden again
rougeronj
parents:
462
diff
changeset
|
248 |
if (this.hidden){ |
|
030f2e4c0664
close the edge popup editor as soon as the edge get hidden again
rougeronj
parents:
462
diff
changeset
|
249 |
this.renderer.removeRepresentationsOfType("editor"); |
|
030f2e4c0664
close the edge popup editor as soon as the edge get hidden again
rougeronj
parents:
462
diff
changeset
|
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.line.strokeWidth = this._getStrokeWidth(); |
| 284 | 252 |
this._super("unselect"); |
253 |
} |
|
254 |
}, |
|
255 |
mousedown: function(_event, _isTouch) { |
|
256 |
if (_isTouch) { |
|
257 |
this.renderer.unselectAll(); |
|
258 |
this.select(); |
|
259 |
} |
|
260 |
}, |
|
261 |
mouseup: function(_event, _isTouch) { |
|
262 |
if (!this.renkan.read_only && this.renderer.is_dragging) { |
|
263 |
this.from_representation.saveCoords(); |
|
264 |
this.to_representation.saveCoords(); |
|
265 |
this.from_representation.is_dragging = false; |
|
266 |
this.to_representation.is_dragging = false; |
|
267 |
} else { |
|
268 |
if (!_isTouch) { |
|
269 |
this.openEditor(); |
|
270 |
} |
|
271 |
this.model.trigger("clicked"); |
|
272 |
} |
|
273 |
this.renderer.click_target = null; |
|
274 |
this.renderer.is_dragging = false; |
|
275 |
}, |
|
276 |
paperShift: function(_delta) { |
|
277 |
if (this.options.editor_mode) { |
|
278 |
if (!this.options.read_only) { |
|
279 |
this.from_representation.paperShift(_delta); |
|
280 |
this.to_representation.paperShift(_delta); |
|
281 |
} |
|
282 |
} else { |
|
283 |
this.renderer.paperShift(_delta); |
|
284 |
} |
|
285 |
}, |
|
|
633
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
286 |
highlight: function(textToReplace) { |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
287 |
var hlvalue = textToReplace || true; |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
288 |
if (this.highlighted === hlvalue) { |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
289 |
return; |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
290 |
} |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
291 |
this.highlighted = hlvalue; |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
292 |
this.redraw(); |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
293 |
this.renderer.throttledPaperDraw(); |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
294 |
}, |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
295 |
unhighlight: function() { |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
296 |
if (!this.highlighted) { |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
297 |
return; |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
298 |
} |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
299 |
this.highlighted = false; |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
300 |
this.redraw(); |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
301 |
this.renderer.throttledPaperDraw(); |
|
fdff56da097d
allow to highlight edges. Add a url selector for edge + seach edges in edge box. remove max width of title
ymh <ymh.work@gmail.com>
parents:
532
diff
changeset
|
302 |
}, |
| 284 | 303 |
destroy: function() { |
304 |
this._super("destroy"); |
|
305 |
this.line.remove(); |
|
306 |
this.arrow.remove(); |
|
307 |
this.text.remove(); |
|
308 |
if (this.renderer.minimap) { |
|
309 |
this.minimap_line.remove(); |
|
310 |
} |
|
311 |
this.all_buttons.forEach(function(b) { |
|
312 |
b.destroy(); |
|
313 |
}); |
|
314 |
var _this = this; |
|
| 433 | 315 |
this.bundle.edges = _.reject(this.bundle.edges, function(_edge) { |
| 284 | 316 |
return _this === _edge; |
317 |
}); |
|
318 |
} |
|
| 433 | 319 |
}).value(); |
| 284 | 320 |
|
321 |
return Edge; |
|
322 |
||
323 |
}); |