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