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 this.currentNode = node;
\r
35 var parentNode = node.parent();
\r
36 var parent = undefined;
\r
40 repr: parentNode.tag + (parentNode.klass ? ' / ' + parentNode.klass : ''),
\r
43 this.nodes[parentNode.id] = parentNode;
\r
47 node.children().each(function() {
\r
49 children.push({repr: child.tag + (child.klass ? ' / ' + child.klass : ''), id: child.id});
\r
50 nodes[child.id] = child;
\r
53 this.dom.append($(template({parent: parent, children: children})));
\r
55 highlightNode: function(wlxmlNode) {
\r
56 this.dom.find('a[data-id="'+wlxmlNode.id+'"]').addClass('rng-common-hoveredNode');
\r
58 dimNode: function(wlxmlNode) {
\r
59 this.dom.find('a[data-id="'+wlxmlNode.id+'"]').removeClass('rng-common-hoveredNode');
\r
67 sandbox.publish('ready');
\r
69 setNode: function(wlxmlNode) {
\r
70 if(!wlxmlNode.is(view.currentNode))
\r
71 view.setNode(wlxmlNode);
\r
73 getView: function() {
\r
76 highlightNode: function(wlxmlNode) {
\r
77 view.highlightNode(wlxmlNode);
\r
79 dimNode: function(wlxmlNode) {
\r
80 view.dimNode(wlxmlNode);
\r