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('click', 'a', function(e) {
19 var target = $(e.target);
20 sandbox.publish('elementClicked', target.data('element'));
24 setNodeElement: function(nodeElement) {
26 this.currentNodeElement = nodeElement;
29 parents = nodeElement.parents();
32 this.dom.html(template({node: nodeElement, parents: parents, utils: wlxmlUtils}));
34 this.dom.find('li > a[href="#"]').each(function(idx, a) {
35 $(a).data('element', parents[parents.length - 1 - idx]);
37 this.dom.find('a.active').data('element', nodeElement);
40 highlightNode: function(node) {
41 this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');
43 dimNode: function(node) {
44 this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');
51 start: function() { sandbox.publish('ready'); },
52 getView: function() { return view.dom; },
53 setNodeElement: function(nodeElement) {
54 if(!listens && nodeElement) {
55 nodeElement.document.on('change', function() {
56 if(view.currentNodeElement && !view.currentNodeElement.isInDocument()) {
57 view.setNodeElement(null);
62 view.setNodeElement(nodeElement);
64 highlightNode: function(id) { view.highlightNode(id); },
65 dimNode: function(id) { view.dimNode(id); }