X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/5be499ab63f91b65065fe34f3a6d645efc9ae7b6..ca7d9f0db18dff8083e5f06e52efec85ca522900:/modules/nodeFamilyTree/nodeFamilyTree.js diff --git a/modules/nodeFamilyTree/nodeFamilyTree.js b/modules/nodeFamilyTree/nodeFamilyTree.js index 3c78bd1..b5cb56e 100644 --- a/modules/nodeFamilyTree/nodeFamilyTree.js +++ b/modules/nodeFamilyTree/nodeFamilyTree.js @@ -31,31 +31,32 @@ return function(sandbox) { setNode: function(node) { console.log('familyTree sets node'); var nodes = this.nodes = {}; + this.currentNode = node; var parentNode = node.parent(); var parent = undefined; if(parentNode) { parent = { - repr: parentNode.tag + (parentNode.klass ? ' / ' + parentNode.klass : ''), - id: parentNode.id + repr: parentNode.getTag() + (parentNode.getClass() ? ' / ' + parentNode.getClass() : ''), + id: parentNode.getId() }; - this.nodes[parentNode.id] = parentNode; + this.nodes[parentNode.getId()] = parentNode; } var children = []; node.children().each(function() { var child = this; - children.push({repr: child.tag + (child.klass ? ' / ' + child.klass : ''), id: child.id}); - nodes[child.id] = child; + children.push({repr: child.getTag() + (child.getClass() ? ' / ' + child.getClass() : ''), id: child.getId()}); + nodes[child.getId()] = child; }); this.dom.empty(); this.dom.append($(template({parent: parent, children: children}))); }, - highlightNode: function(wlxmlNode) { - this.dom.find('a[data-id="'+wlxmlNode.id+'"]').addClass('rng-common-hoveredNode'); + highlightNode: function(canvasNode) { + this.dom.find('a[data-id="'+canvasNode.getId()+'"]').addClass('rng-common-hoveredNode'); }, - dimNode: function(wlxmlNode) { - this.dom.find('a[data-id="'+wlxmlNode.id+'"]').removeClass('rng-common-hoveredNode'); + dimNode: function(canvasNode) { + this.dom.find('a[data-id="'+canvasNode.getId()+'"]').removeClass('rng-common-hoveredNode'); } } @@ -65,17 +66,18 @@ return function(sandbox) { start: function() { sandbox.publish('ready'); }, - setNode: function(node) { - view.setNode(node); + setNode: function(canvasNode) { + if(!canvasNode.isSame(view.currentNode)) + view.setNode(canvasNode); }, getView: function() { return view.dom; }, - highlightNode: function(wlxmlNode) { - view.highlightNode(wlxmlNode); + highlightNode: function(canvasNode) { + view.highlightNode(canvasNode); }, - dimNode: function(wlxmlNode) { - view.dimNode(wlxmlNode); + dimNode: function(canvasNode) { + view.dimNode(canvasNode); } }; };