2 'libs/jquery-1.9.1.min',
\r
3 'libs/underscore-min',
\r
4 'libs/text!./template.html'], function($, _, templateSrc) {
\r
8 return function(sandbox) {
\r
10 var template = _.template(templateSrc);
\r
13 dom: $('<div>' + template({node:null, parents: null}) + '</div>'),
\r
16 this.dom.on('mouseenter', 'a', function(e) {
\r
17 var target = $(e.target);
\r
18 sandbox.publish('nodeHighlighted', view.nodes[target.attr('data-id')]);
\r
20 this.dom.on('mouseleave', 'a', function(e) {
\r
21 var target = $(e.target);
\r
22 sandbox.publish('nodeDimmed', view.nodes[target.attr('data-id')]);
\r
24 this.dom.on('click', 'a', function(e) {
\r
26 var target = $(e.target);
\r
27 sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);
\r
31 setNode: function(node) {
\r
33 var nodes = this.nodes = {};
\r
34 this.nodes[node.id] = node;
\r
35 var parents = node.parents();
\r
36 parents.each(function() {
\r
38 nodes[parent.id] = parent;
\r
40 this.dom.html(template({node: node, parents: parents}));
\r
43 highlightNode: function(node) {
\r
44 this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');
\r
46 dimNode: function(node) {
\r
47 this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');
\r
54 start: function() { sandbox.publish('ready'); },
\r
55 getView: function() { return view.dom; },
\r
56 setNode: function(node) { view.setNode(node); },
\r
57 highlightNode: function(id) { view.highlightNode(id); },
\r
58 dimNode: function(id) { view.dimNode(id); }
\r