2 'libs/jquery-1.9.1.min',
\r
3 'libs/underscore-min',
\r
4 'libs/text!./template.html'
\r
5 ], function($, _, templateSrc) {
\r
9 return function(sandbox) {
\r
11 var template = _.template(templateSrc);
\r
14 dom: $('<div>' + template({children: null, parent: null}) + '</div>'),
\r
17 this.dom.on('click', 'a', function(e) {
\r
18 var target = $(e.target);
\r
19 sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);
\r
22 this.dom.on('mouseenter', 'a', function(e) {
\r
23 var target = $(e.target);
\r
24 sandbox.publish('nodeEntered', view.nodes[target.attr('data-id')])
\r
26 this.dom.on('mouseleave', 'a', function(e) {
\r
27 var target = $(e.target);
\r
28 sandbox.publish('nodeLeft', view.nodes[target.attr('data-id')])
\r
31 setNode: function(node) {
\r
32 console.log('familyTree sets node');
\r
33 var nodes = this.nodes = {};
\r
34 var parentNode = node.parent();
\r
35 var parent = undefined;
\r
39 repr: parentNode.tag + (parentNode.klass ? ' / ' + parentNode.klass : ''),
\r
42 this.nodes[parentNode.id] = parentNode;
\r
46 node.children().each(function() {
\r
48 children.push({repr: child.tag + (child.klass ? ' / ' + child.klass : ''), id: child.id});
\r
49 nodes[child.id] = child;
\r
52 this.dom.append($(template({parent: parent, children: children})));
\r
54 highlightNode: function(wlxmlNode) {
\r
55 this.dom.find('a[data-id="'+wlxmlNode.id+'"]').addClass('rng-common-hoveredNode');
\r
57 dimNode: function(wlxmlNode) {
\r
58 this.dom.find('a[data-id="'+wlxmlNode.id+'"]').removeClass('rng-common-hoveredNode');
\r
66 sandbox.publish('ready');
\r
68 setNode: function(node) {
\r
71 getView: function() {
\r
74 highlightNode: function(wlxmlNode) {
\r
75 view.highlightNode(wlxmlNode);
\r
77 dimNode: function(wlxmlNode) {
\r
78 view.dimNode(wlxmlNode);
\r