2 'libs/jquery-1.9.1.min',
4 'libs/text!./template.html'
5 ], function($, _, templateSrc) {
9 return function(sandbox) {
11 var template = _.template(templateSrc);
14 dom: $('<div>' + template({children: null, parent: null}) + '</div>'),
17 this.dom.on('click', 'a', function(e) {
18 var target = $(e.target);
19 sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);
22 this.dom.on('mouseenter', 'a', function(e) {
23 var target = $(e.target);
24 sandbox.publish('nodeEntered', view.nodes[target.attr('data-id')]);
26 this.dom.on('mouseleave', 'a', function(e) {
27 var target = $(e.target);
28 sandbox.publish('nodeLeft', view.nodes[target.attr('data-id')]);
31 setNode: function(node) {
32 console.log('familyTree sets node');
33 var nodes = this.nodes = {};
34 this.currentNode = node;
35 var parentNode = node.parent();
40 repr: parentNode.getTag() + (parentNode.getClass() ? ' / ' + parentNode.getClass() : ''),
41 id: parentNode.getId()
43 this.nodes[parentNode.getId()] = parentNode;
47 node.children().each(function() {
49 children.push({repr: child.getTag() + (child.getClass() ? ' / ' + child.getClass() : ''), id: child.getId()});
50 nodes[child.getId()] = child;
53 this.dom.append($(template({parent: parent, children: children})));
55 highlightNode: function(canvasNode) {
56 this.dom.find('a[data-id="'+canvasNode.getId()+'"]').addClass('rng-common-hoveredNode');
58 dimNode: function(canvasNode) {
59 this.dom.find('a[data-id="'+canvasNode.getId()+'"]').removeClass('rng-common-hoveredNode');
67 sandbox.publish('ready');
69 setNode: function(canvasNode) {
70 if(!canvasNode.isSame(view.currentNode))
71 view.setNode(canvasNode);
76 highlightNode: function(canvasNode) {
77 view.highlightNode(canvasNode);
79 dimNode: function(canvasNode) {
80 view.dimNode(canvasNode);