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.currentNode = node;
\r
35 this.nodes[node.id] = node;
\r
36 var parents = node.parents();
\r
37 parents.each(function() {
\r
39 nodes[parent.id] = parent;
\r
41 this.dom.html(template({node: node, parents: parents}));
\r
44 highlightNode: function(node) {
\r
45 this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');
\r
47 dimNode: function(node) {
\r
48 this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');
\r
55 start: function() { sandbox.publish('ready'); },
\r
56 getView: function() { return view.dom; },
\r
57 setNode: function(wlxmlNode) {
\r
58 if(!wlxmlNode.is(view.currentNode)) {
\r
59 view.setNode(wlxmlNode);
\r
62 highlightNode: function(id) { view.highlightNode(id); },
\r
63 dimNode: function(id) { view.dimNode(id); }
\r