MCPcopy Create free account
hub / github.com/adobe/Marinus / selectObject

Function selectObject

web_server/public/javascripts/draw_graph.js:639–697  ·  view source on GitHub ↗
(obj, el)

Source from the content-addressed store, hash-verified

637}
638
639function selectObject(obj, el) {
640 var node;
641 if (el) {
642 node = d3.select(el);
643 } else {
644 graph.node.each(function (d) {
645 if (d === obj) {
646 node = d3.select(el = this);
647 }
648 });
649 }
650 if (!node) return;
651
652 if (node.classed('selected')) {
653 deselectObject();
654 return;
655 }
656 deselectObject(false);
657
658 selected = {
659 obj: obj,
660 el: el
661 };
662
663 highlightObject(null, obj);
664
665 node.classed('selected', true);
666 if (z_type !== 'zone') {
667 $('#docs').html(obj.docs);
668 } else {
669 $('#docs').html(remoteDocs[obj.id.replace(/\./g, "!")])
670 }
671 $('#docs-container').scrollTop(0);
672 resize(true);
673
674 var $graph = $('#graph-container'),
675 nodeRect = {
676 left: obj.x + obj.extent.left + graph.margin.left,
677 top: obj.y + obj.extent.top + graph.margin.top,
678 width: obj.extent.right - obj.extent.left,
679 height: obj.extent.bottom - obj.extent.top
680 },
681 graphRect = {
682 left: $graph.scrollLeft(),
683 top: $graph.scrollTop(),
684 width: $graph.width(),
685 height: $graph.height()
686 };
687 if (nodeRect.left < graphRect.left ||
688 nodeRect.top < graphRect.top ||
689 nodeRect.left + nodeRect.width > graphRect.left + graphRect.width ||
690 nodeRect.top + nodeRect.height > graphRect.top + graphRect.height) {
691
692 $graph.animate({
693 scrollLeft: nodeRect.left + nodeRect.width / 2 - graphRect.width / 2,
694 scrollTop: nodeRect.top + nodeRect.height / 2 - graphRect.height / 2
695 }, 500);
696 }

Callers 2

draw_graph.jsFile · 0.70
drawGraphFunction · 0.70

Calls 3

deselectObjectFunction · 0.70
highlightObjectFunction · 0.70
resizeFunction · 0.70

Tested by

no test coverage detected