5 'libs/text!./template.html'], function($, _, wlxmlUtils, templateSrc) {
9 return function(sandbox) {
11 var template = _.template(templateSrc);
14 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;
35 var parents = nodeElement.parents();
36 this.dom.html(template({node: nodeElement, parents: parents, tagNames: wlxmlUtils.wlxmlTagNames, classNames: wlxmlUtils.wlxmlClassNames}));
38 this.dom.find('li > a[href="#"]').each(function(idx, a) {
39 $(a).data('element', parents[parents.length - 1 - idx]);
41 this.dom.find('a.active').data('element', nodeElement);
44 highlightNode: function(node) {
45 this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');
47 dimNode: function(node) {
48 this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');
55 start: function() { sandbox.publish('ready'); },
56 getView: function() { return view.dom; },
57 setNodeElement: function(nodeElement) {
58 view.setNodeElement(nodeElement);
60 highlightNode: function(id) { view.highlightNode(id); },
61 dimNode: function(id) { view.dimNode(id); }