5 'libs/text!./template.html'], function($, _, wlxmlUtils, templateSrc) {
9 return function(sandbox) {
11 var template = _.template(templateSrc),
15 dom: $('<div>' + template({node:null, parents: null}) + '</div>'),
17 this.dom.on('mouseenter', 'a', function(e) {
18 var target = $(e.target);
19 sandbox.publish('elementEntered', target.data('element'));
21 this.dom.on('mouseleave', 'a', function(e) {
22 var target = $(e.target);
23 sandbox.publish('elementLeft', target.data('element'));
25 this.dom.on('click', 'a', function(e) {
27 var target = $(e.target);
28 sandbox.publish('elementClicked', target.data('element'));
32 setNodeElement: function(nodeElement) {
34 this.currentNodeElement = nodeElement;
37 parents = nodeElement.parents();
40 this.dom.html(template({node: nodeElement, parents: parents, utils: wlxmlUtils}));
42 this.dom.find('li > a[href="#"]').each(function(idx, a) {
43 $(a).data('element', parents[parents.length - 1 - idx]);
45 this.dom.find('a.active').data('element', nodeElement);
48 highlightNode: function(node) {
49 this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');
51 dimNode: function(node) {
52 this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');
59 start: function() { sandbox.publish('ready'); },
60 getView: function() { return view.dom; },
61 setNodeElement: function(nodeElement) {
62 if(!listens && nodeElement) {
63 nodeElement.document.on('change', function() {
64 if(view.currentNodeElement && !view.currentNodeElement.isInDocument()) {
65 view.setNodeElement(null);
70 view.setNodeElement(nodeElement);
72 highlightNode: function(id) { view.highlightNode(id); },
73 dimNode: function(id) { view.dimNode(id); }