171 Rkns.Renderer.Node.prototype._init = function() { |
171 Rkns.Renderer.Node.prototype._init = function() { |
172 this.renderer.node_layer.activate(); |
172 this.renderer.node_layer.activate(); |
173 this.type = "Node"; |
173 this.type = "Node"; |
174 this.circle = new paper.Path.Circle([0, 0], 1); |
174 this.circle = new paper.Path.Circle([0, 0], 1); |
175 this.circle.__representation = this; |
175 this.circle.__representation = this; |
176 this.circle.fillColor = this.options.node_fill_color; |
|
177 if (this.options.show_node_circles) { |
176 if (this.options.show_node_circles) { |
178 this.circle.strokeWidth = this.options.node_stroke_width; |
177 this.circle.strokeWidth = this.options.node_stroke_width; |
179 this.h_ratio = 1; |
178 this.h_ratio = 1; |
180 } else { |
179 } else { |
181 this.circle.opacity = .01; |
|
182 this.h_ratio = 0; |
180 this.h_ratio = 0; |
183 } |
181 } |
184 this.title = Rkns.$('<div class="Rk-Label">').appendTo(this.renderer.labels_$); |
182 this.title = Rkns.$('<div class="Rk-Label">').appendTo(this.renderer.labels_$); |
185 if (this.options.editor_mode) { |
183 if (this.options.editor_mode) { |
186 this.buttons = [ |
184 this.normal_buttons = [ |
187 new Rkns.Renderer.NodeEditButton(this.renderer, null), |
185 new Rkns.Renderer.NodeEditButton(this.renderer, null), |
188 new Rkns.Renderer.NodeRemoveButton(this.renderer, null), |
186 new Rkns.Renderer.NodeRemoveButton(this.renderer, null), |
189 new Rkns.Renderer.NodeLinkButton(this.renderer, null), |
187 new Rkns.Renderer.NodeLinkButton(this.renderer, null), |
190 new Rkns.Renderer.NodeEnlargeButton(this.renderer, null), |
188 new Rkns.Renderer.NodeEnlargeButton(this.renderer, null), |
191 new Rkns.Renderer.NodeShrinkButton(this.renderer, null) |
189 new Rkns.Renderer.NodeShrinkButton(this.renderer, null) |
192 ]; |
190 ]; |
193 for (var i = 0; i < this.buttons.length; i++) { |
191 this.pending_delete_buttons = [ |
194 this.buttons[i].source_representation = this; |
192 new Rkns.Renderer.NodeRevertButton(this.renderer, null) |
195 } |
193 ]; |
|
194 this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons) |
|
195 for (var i = 0; i < this.all_buttons.length; i++) { |
|
196 this.all_buttons[i].source_representation = this; |
|
197 } |
|
198 this.active_buttons = []; |
196 } else { |
199 } else { |
197 this.buttons = []; |
200 this.active_buttons = this.all_buttons = []; |
198 } |
201 } |
199 this.last_circle_radius = 1; |
202 this.last_circle_radius = 1; |
200 // this.title.paragraphStyle.justification = 'center'; |
|
201 |
203 |
202 if (this.renderer.minimap) { |
204 if (this.renderer.minimap) { |
203 this.renderer.minimap.node_layer.activate(); |
205 this.renderer.minimap.node_layer.activate(); |
204 this.minimap_circle = new paper.Path.Circle([0, 0], 1); |
206 this.minimap_circle = new paper.Path.Circle([0, 0], 1); |
205 this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation; |
207 this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation; |
213 if (!this.is_dragging || !this.paper_coords) { |
215 if (!this.is_dragging || !this.paper_coords) { |
214 this.paper_coords = this.renderer.toPaperCoords(_model_coords); |
216 this.paper_coords = this.renderer.toPaperCoords(_model_coords); |
215 } |
217 } |
216 this.circle_radius = _baseRadius * this.renderer.scale; |
218 this.circle_radius = _baseRadius * this.renderer.scale; |
217 if (this.last_circle_radius !== this.circle_radius) { |
219 if (this.last_circle_radius !== this.circle_radius) { |
218 this.buttons.forEach(function(b) { |
220 this.all_buttons.forEach(function(b) { |
219 b.setSectorSize(); |
221 b.setSectorSize(); |
220 }); |
222 }); |
221 var square = new paper.Size(this.circle_radius, this.circle_radius), |
223 var square = new paper.Size(this.circle_radius, this.circle_radius), |
222 topleft = this.paper_coords.subtract(square), |
224 topleft = this.paper_coords.subtract(square), |
223 bounds = new paper.Rectangle(topleft, square.multiply(2)); |
225 bounds = new paper.Rectangle(topleft, square.multiply(2)); |
231 this.node_image.position = this.paper_coords; |
233 this.node_image.position = this.paper_coords; |
232 } |
234 } |
233 } |
235 } |
234 this.last_circle_radius = this.circle_radius; |
236 this.last_circle_radius = this.circle_radius; |
235 |
237 |
|
238 var old_act_btn = this.active_buttons; |
|
239 |
|
240 if (this.model.get("delete_scheduled")) { |
|
241 var opacity = .33; |
|
242 this.active_buttons = this.pending_delete_buttons; |
|
243 } else { |
|
244 var opacity = 1; |
|
245 this.active_buttons = this.normal_buttons; |
|
246 } |
|
247 |
|
248 if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) { |
|
249 old_act_btn.forEach(function(b) { |
|
250 b.hide(); |
|
251 }); |
|
252 this.active_buttons.forEach(function(b) { |
|
253 b.show(); |
|
254 }); |
|
255 } |
|
256 |
|
257 if (this.node_image) { |
|
258 this.node_image.opacity = this.highlighted ? opacity * .5 : (opacity - .01); |
|
259 } |
|
260 |
|
261 this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color; |
|
262 |
|
263 this.circle.opacity = this.options.show_node_circles ? opacity : .01; |
|
264 |
236 var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || ""; |
265 var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || ""; |
237 _text = Rkns.Renderer.shortenText(_text, this.options.node_label_max_length); |
266 _text = Rkns.Renderer.shortenText(_text, this.options.node_label_max_length); |
238 this.title.text(_text); |
267 this.title.text(_text); |
239 this.title.css({ |
268 this.title.css({ |
240 left: this.paper_coords.x, |
269 left: this.paper_coords.x, |
241 top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance |
270 top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance, |
|
271 opacity: opacity |
242 }) |
272 }) |
243 var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); |
273 var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); |
244 this.circle.strokeColor = _color; |
274 this.circle.strokeColor = _color; |
245 var _pc = this.paper_coords; |
275 var _pc = this.paper_coords; |
246 this.buttons.forEach(function(b) { |
276 this.all_buttons.forEach(function(b) { |
247 b.moveTo(_pc); |
277 b.moveTo(_pc); |
248 }); |
278 }); |
249 var _img = this.model.get("image"); |
279 var _img = this.model.get("image"); |
250 if (_img && _img !== this.img) { |
280 if (_img && _img !== this.img) { |
251 var _image = new Image(), |
281 var _image = new Image(), |
353 this.minimap_circle.strokeColor = this.options.minimap_highlight_color; |
383 this.minimap_circle.strokeColor = this.options.minimap_highlight_color; |
354 } |
384 } |
355 } |
385 } |
356 |
386 |
357 Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { |
387 Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { |
358 this.selected = false; |
|
359 if (!_newTarget || _newTarget.source_representation !== this) { |
388 if (!_newTarget || _newTarget.source_representation !== this) { |
360 this.buttons.forEach(function(b) { |
389 this.selected = false; |
|
390 this.all_buttons.forEach(function(b) { |
361 b.hide(); |
391 b.hide(); |
362 }); |
392 }); |
363 this.circle.strokeWidth = this.options.node_stroke_width; |
393 this.circle.strokeWidth = this.options.node_stroke_width; |
364 Rkns.$('.Rk-Bin-Item').removeClass("selected"); |
394 Rkns.$('.Rk-Bin-Item').removeClass("selected"); |
365 if (this.renderer.minimap) { |
395 if (this.renderer.minimap) { |
367 } |
397 } |
368 } |
398 } |
369 } |
399 } |
370 |
400 |
371 Rkns.Renderer.Node.prototype.highlight = function() { |
401 Rkns.Renderer.Node.prototype.highlight = function() { |
372 this.circle.fillColor = this.options.highlighted_node_fill_color; |
402 if (this.highlighted) { |
373 if (this.node_image) { |
403 return; |
374 this.node_image.opacity = .5; |
404 } |
375 } |
405 this.highlighted = true; |
376 } |
406 this.redraw(); |
377 |
407 this.renderer.throttledPaperDraw(); |
378 Rkns.Renderer.Node.prototype.unhighlight = function(_newTarget) { |
408 } |
379 this.circle.fillColor = this.options.node_fill_color; |
409 |
380 if (this.node_image) { |
410 Rkns.Renderer.Node.prototype.unhighlight = function() { |
381 this.node_image.opacity = .99; |
411 if (!this.highlighted) { |
382 } |
412 return; |
|
413 } |
|
414 this.highlighted = false; |
|
415 this.redraw(); |
|
416 this.renderer.throttledPaperDraw(); |
383 } |
417 } |
384 |
418 |
385 Rkns.Renderer.Node.prototype.saveCoords = function() { |
419 Rkns.Renderer.Node.prototype.saveCoords = function() { |
386 var _coords = this.renderer.toModelCoords(this.paper_coords), |
420 var _coords = this.renderer.toModelCoords(this.paper_coords), |
387 _data = { |
421 _data = { |
401 this.select(); |
435 this.select(); |
402 } |
436 } |
403 } |
437 } |
404 |
438 |
405 Rkns.Renderer.Node.prototype.mouseup = function(_event, _isTouch) { |
439 Rkns.Renderer.Node.prototype.mouseup = function(_event, _isTouch) { |
406 if (this.renderer.isEditable() && this.renderer.is_dragging) { |
440 if (this.renderer.is_dragging && this.renderer.isEditable()) { |
407 this.saveCoords(); |
441 this.saveCoords(); |
408 } else { |
442 } else { |
409 if (!_isTouch) { |
443 if (!_isTouch && !this.model.get("delete_scheduled")) { |
410 this.openEditor(); |
444 this.openEditor(); |
411 } |
445 } |
412 } |
446 } |
413 this.renderer.click_target = null; |
447 this.renderer.click_target = null; |
414 this.renderer.is_dragging = false; |
448 this.renderer.is_dragging = false; |
415 this.is_dragging = false; |
449 this.is_dragging = false; |
416 } |
450 } |
417 |
451 |
418 Rkns.Renderer.Node.prototype.destroy = function(_event) { |
452 Rkns.Renderer.Node.prototype.destroy = function(_event) { |
419 this.super("destroy"); |
453 this.super("destroy"); |
420 this.buttons.forEach(function(b) { |
454 this.all_buttons.forEach(function(b) { |
421 b.destroy(); |
455 b.destroy(); |
422 }); |
456 }); |
423 this.circle.remove(); |
457 this.circle.remove(); |
424 this.title.remove(); |
458 this.title.remove(); |
425 if (this.renderer.minimap) { |
459 if (this.renderer.minimap) { |
452 ); |
486 ); |
453 this.arrow.__representation = this; |
487 this.arrow.__representation = this; |
454 this.text = Rkns.$('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$); |
488 this.text = Rkns.$('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$); |
455 this.arrow_angle = 0; |
489 this.arrow_angle = 0; |
456 if (this.options.editor_mode) { |
490 if (this.options.editor_mode) { |
457 this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, null); |
491 this.normal_buttons = [ |
458 this.edit_button.source_representation = this; |
492 new Rkns.Renderer.EdgeEditButton(this.renderer, null), |
459 this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, null); |
493 new Rkns.Renderer.EdgeRemoveButton(this.renderer, null), |
460 this.remove_button.source_representation = this; |
494 ]; |
|
495 this.pending_delete_buttons = [ |
|
496 new Rkns.Renderer.EdgeRevertButton(this.renderer, null) |
|
497 ]; |
|
498 this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons) |
|
499 for (var i = 0; i < this.all_buttons.length; i++) { |
|
500 this.all_buttons[i].source_representation = this; |
|
501 } |
|
502 this.active_buttons = []; |
|
503 } else { |
|
504 this.active_buttons = this.all_buttons = []; |
461 } |
505 } |
462 |
506 |
463 if (this.renderer.minimap) { |
507 if (this.renderer.minimap) { |
464 this.renderer.minimap.edge_layer.activate(); |
508 this.renderer.minimap.edge_layer.activate(); |
465 this.minimap_line = new paper.Path(); |
509 this.minimap_line = new paper.Path(); |
487 _p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
531 _p1b = _p1a.add(_delta), /* to differentiate bundled links */ |
488 _a = _v.angle, |
532 _a = _v.angle, |
489 _textdelta = _ortho.multiply(this.options.edge_label_distance), |
533 _textdelta = _ortho.multiply(this.options.edge_label_distance), |
490 _handle = _v.divide(3), |
534 _handle = _v.divide(3), |
491 _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); |
535 _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); |
|
536 |
|
537 var opacity = (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) ? .33 : 1; |
|
538 |
|
539 var old_act_btn = this.active_buttons; |
|
540 |
|
541 this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons; |
|
542 |
|
543 if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) { |
|
544 old_act_btn.forEach(function(b) { |
|
545 b.hide(); |
|
546 }); |
|
547 this.active_buttons.forEach(function(b) { |
|
548 b.show(); |
|
549 }); |
|
550 } |
|
551 |
492 this.paper_coords = _p0b.add(_p1b).divide(2); |
552 this.paper_coords = _p0b.add(_p1b).divide(2); |
493 this.line.strokeColor = _color; |
553 this.line.strokeColor = _color; |
|
554 this.line.opacity = opacity; |
494 this.line.segments[0].point = _p0a; |
555 this.line.segments[0].point = _p0a; |
495 this.line.segments[1].point = this.paper_coords; |
556 this.line.segments[1].point = this.paper_coords; |
496 this.line.segments[1].handleIn = _handle.multiply(-1); |
557 this.line.segments[1].handleIn = _handle.multiply(-1); |
497 this.line.segments[1].handleOut = _handle; |
558 this.line.segments[1].handleOut = _handle; |
498 this.line.segments[2].point = _p1a; |
559 this.line.segments[2].point = _p1a; |
499 this.arrow.rotate(_a - this.arrow_angle); |
560 this.arrow.rotate(_a - this.arrow_angle); |
500 this.arrow.fillColor = _color; |
561 this.arrow.fillColor = _color; |
|
562 this.arrow.opacity = opacity; |
501 this.arrow.position = this.paper_coords; |
563 this.arrow.position = this.paper_coords; |
502 this.arrow_angle = _a; |
564 this.arrow_angle = _a; |
503 if (_a > 90) { |
565 if (_a > 90) { |
504 _a -= 180; |
566 _a -= 180; |
505 _textdelta = _textdelta.multiply(-1); |
567 _textdelta = _textdelta.multiply(-1); |
515 this.text.css({ |
577 this.text.css({ |
516 left: _textpos.x, |
578 left: _textpos.x, |
517 top: _textpos.y, |
579 top: _textpos.y, |
518 transform: "rotate(" + _a + "deg)", |
580 transform: "rotate(" + _a + "deg)", |
519 "-moz-transform": "rotate(" + _a + "deg)", |
581 "-moz-transform": "rotate(" + _a + "deg)", |
520 "-webkit-transform": "rotate(" + _a + "deg)" |
582 "-webkit-transform": "rotate(" + _a + "deg)", |
|
583 opacity: opacity |
521 }); |
584 }); |
522 this.text_angle = _a; |
585 this.text_angle = _a; |
523 if (this.options.editor_mode) { |
586 |
524 this.edit_button.moveTo(this.paper_coords); |
587 var _pc = this.paper_coords; |
525 this.remove_button.moveTo(this.paper_coords); |
588 this.all_buttons.forEach(function(b) { |
526 } |
589 b.moveTo(_pc); |
|
590 }); |
527 |
591 |
528 if (this.renderer.minimap) { |
592 if (this.renderer.minimap) { |
529 this.minimap_line.strokeColor = _color; |
593 this.minimap_line.strokeColor = _color; |
530 this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))); |
594 this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))); |
531 this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))); |
595 this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))); |
541 |
605 |
542 Rkns.Renderer.Edge.prototype.select = function() { |
606 Rkns.Renderer.Edge.prototype.select = function() { |
543 this.selected = true; |
607 this.selected = true; |
544 this.line.strokeWidth = this.options.selected_edge_stroke_width; |
608 this.line.strokeWidth = this.options.selected_edge_stroke_width; |
545 if (this.renderer.isEditable()) { |
609 if (this.renderer.isEditable()) { |
546 this.edit_button.show(); |
610 this.active_buttons.forEach(function(b) { |
547 this.remove_button.show(); |
611 b.show(); |
548 } |
612 }); |
|
613 } |
549 if (!this.options.editor_mode) { |
614 if (!this.options.editor_mode) { |
550 this.openEditor(); |
615 this.openEditor(); |
551 } |
616 } |
552 } |
617 } |
553 |
618 |
554 Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) { |
619 Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) { |
555 this.selected = false; |
|
556 if (!_newTarget || _newTarget.source_representation !== this) { |
620 if (!_newTarget || _newTarget.source_representation !== this) { |
|
621 this.selected = false; |
557 if (this.options.editor_mode) { |
622 if (this.options.editor_mode) { |
558 this.edit_button.hide(); |
623 this.all_buttons.forEach(function(b) { |
559 this.remove_button.hide(); |
624 b.hide(); |
|
625 }); |
560 } |
626 } |
561 this.line.strokeWidth = this.options.edge_stroke_width; |
627 this.line.strokeWidth = this.options.edge_stroke_width; |
562 } |
628 } |
563 } |
629 } |
564 |
630 |
1136 |
1201 |
1137 Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() { |
1202 Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() { |
1138 this.renderer.click_target = null; |
1203 this.renderer.click_target = null; |
1139 this.renderer.is_dragging = false; |
1204 this.renderer.is_dragging = false; |
1140 this.renderer.removeRepresentationsOfType("editor"); |
1205 this.renderer.removeRepresentationsOfType("editor"); |
1141 if (this.renderer.isEditable() && confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) { |
1206 if (this.renderer.isEditable()) { |
1142 this.project.removeNode(this.source_representation.model); |
1207 var delid = Rkns.Utils.getUID("delete"); |
|
1208 this.renderer.delete_list.push({ |
|
1209 id: delid, |
|
1210 time: new Date().valueOf() + this.options.element_delete_delay |
|
1211 }); |
|
1212 this.source_representation.model.set("delete_scheduled", delid); |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 /* */ |
|
1217 |
|
1218 Rkns.Renderer.NodeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); |
|
1219 |
|
1220 Rkns.Renderer.NodeRevertButton.prototype._init = function() { |
|
1221 this.type = "Node-revert-button"; |
|
1222 this.lastSectorInner = 0; |
|
1223 this.startAngle = -135; |
|
1224 this.endAngle = 135; |
|
1225 this.imageName = "revert"; |
|
1226 this.text = "Cancel deletion"; |
|
1227 } |
|
1228 |
|
1229 Rkns.Renderer.NodeRevertButton.prototype.mouseup = function() { |
|
1230 this.renderer.click_target = null; |
|
1231 this.renderer.is_dragging = false; |
|
1232 if (this.renderer.isEditable()) { |
|
1233 this.source_representation.model.unset("delete_scheduled"); |
1143 } |
1234 } |
1144 } |
1235 } |
1145 |
1236 |
1146 /* */ |
1237 /* */ |
1147 |
1238 |
1237 |
1328 |
1238 Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() { |
1329 Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() { |
1239 this.renderer.click_target = null; |
1330 this.renderer.click_target = null; |
1240 this.renderer.is_dragging = false; |
1331 this.renderer.is_dragging = false; |
1241 this.renderer.removeRepresentationsOfType("editor"); |
1332 this.renderer.removeRepresentationsOfType("editor"); |
1242 if (this.renderer.isEditable() && confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) { |
1333 if (this.renderer.isEditable()) { |
1243 this.project.removeEdge(this.source_representation.model); |
1334 var delid = Rkns.Utils.getUID("delete"); |
|
1335 this.renderer.delete_list.push({ |
|
1336 id: delid, |
|
1337 time: new Date().valueOf() + this.options.element_delete_delay |
|
1338 }); |
|
1339 this.source_representation.model.set("delete_scheduled", delid); |
|
1340 } |
|
1341 } |
|
1342 |
|
1343 /* */ |
|
1344 |
|
1345 Rkns.Renderer.EdgeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); |
|
1346 |
|
1347 Rkns.Renderer.EdgeRevertButton.prototype._init = function() { |
|
1348 this.type = "Edge-revert-button"; |
|
1349 this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion")); |
|
1350 } |
|
1351 |
|
1352 Rkns.Renderer.EdgeRevertButton.prototype.mouseup = function() { |
|
1353 this.renderer.click_target = null; |
|
1354 this.renderer.is_dragging = false; |
|
1355 if (this.renderer.isEditable()) { |
|
1356 this.source_representation.model.unset("delete_scheduled"); |
1244 } |
1357 } |
1245 } |
1358 } |
1246 |
1359 |
1247 /* */ |
1360 /* */ |
1248 |
1361 |
1278 this.click_target = null; |
1391 this.click_target = null; |
1279 this.selected_target = null; |
1392 this.selected_target = null; |
1280 this.edge_layer = new paper.Layer(); |
1393 this.edge_layer = new paper.Layer(); |
1281 this.node_layer = new paper.Layer(); |
1394 this.node_layer = new paper.Layer(); |
1282 this.buttons_layer = new paper.Layer(); |
1395 this.buttons_layer = new paper.Layer(); |
|
1396 this.delete_list = []; |
1283 |
1397 |
1284 if (_renkan.options.show_minimap) { |
1398 if (_renkan.options.show_minimap) { |
1285 this.minimap = { |
1399 this.minimap = { |
1286 background_layer: new paper.Layer(), |
1400 background_layer: new paper.Layer(), |
1287 edge_layer: new paper.Layer(), |
1401 edge_layer: new paper.Layer(), |
1327 _lastTapX, |
1441 _lastTapX, |
1328 _lastTapY; |
1442 _lastTapY; |
1329 |
1443 |
1330 this.imageCache = {}; |
1444 this.imageCache = {}; |
1331 |
1445 |
1332 ['edit', 'remove', 'link', 'enlarge', 'shrink'].forEach(function(imgname) { |
1446 ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) { |
1333 var img = new Image(); |
1447 var img = new Image(); |
1334 img.src = _renkan.options.static_url + 'img/' + imgname + '.png'; |
1448 img.src = _renkan.options.static_url + 'img/' + imgname + '.png'; |
1335 _this.imageCache[imgname] = img; |
1449 _this.imageCache[imgname] = img; |
1336 }); |
1450 }); |
1337 |
1451 |
1635 ); |
1749 ); |
1636 } |
1750 } |
1637 |
1751 |
1638 this.redraw(); |
1752 this.redraw(); |
1639 |
1753 |
|
1754 window.setInterval(function() { |
|
1755 var _now = new Date().valueOf(); |
|
1756 _this.delete_list.forEach(function(d) { |
|
1757 if (_now >= d.time) { |
|
1758 var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}); |
|
1759 if (el) { |
|
1760 project.removeNode(el); |
|
1761 } |
|
1762 el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id}); |
|
1763 if (el) { |
|
1764 project.removeEdge(el); |
|
1765 } |
|
1766 } |
|
1767 }); |
|
1768 _this.delete_list = _this.delete_list.filter(function(d) { |
|
1769 return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id}) |
|
1770 }); |
|
1771 }, 500); |
|
1772 |
1640 if (this.minimap) { |
1773 if (this.minimap) { |
1641 window.setInterval(function() { |
1774 window.setInterval(function() { |
1642 _this.rescaleMinimap() |
1775 _this.rescaleMinimap() |
1643 }, 2000); |
1776 }, 2000); |
1644 } |
1777 } |