Fixing returning from source to visual editor after edit
[fnpeditor.git] / modules / nodeFamilyTree / nodeFamilyTree.js
index 3c78bd1..b5cb56e 100644 (file)
@@ -31,31 +31,32 @@ return function(sandbox) {
         setNode: function(node) {\r
             console.log('familyTree sets node');\r
             var nodes = this.nodes = {};\r
         setNode: function(node) {\r
             console.log('familyTree sets node');\r
             var nodes = this.nodes = {};\r
+            this.currentNode = node;\r
             var parentNode = node.parent();\r
             var parent = undefined;\r
             \r
             if(parentNode) {\r
                 parent = {\r
             var parentNode = node.parent();\r
             var parent = undefined;\r
             \r
             if(parentNode) {\r
                 parent = {\r
-                    repr: parentNode.tag + (parentNode.klass ? ' / ' + parentNode.klass : ''),\r
-                    id: parentNode.id\r
+                    repr: parentNode.getTag() + (parentNode.getClass() ? ' / ' + parentNode.getClass() : ''),\r
+                    id: parentNode.getId()\r
                 };\r
                 };\r
-                this.nodes[parentNode.id] = parentNode;\r
+                this.nodes[parentNode.getId()] = parentNode;\r
             }\r
         \r
             var children = [];\r
             node.children().each(function() {\r
                 var child = this;\r
             }\r
         \r
             var children = [];\r
             node.children().each(function() {\r
                 var child = this;\r
-                children.push({repr: child.tag + (child.klass ? ' / ' + child.klass : ''), id: child.id});\r
-                nodes[child.id] = child;\r
+                children.push({repr: child.getTag() + (child.getClass() ? ' / ' + child.getClass() : ''), id: child.getId()});\r
+                nodes[child.getId()] = child;\r
             });\r
             this.dom.empty();\r
             this.dom.append($(template({parent: parent, children: children})));\r
         },\r
             });\r
             this.dom.empty();\r
             this.dom.append($(template({parent: parent, children: children})));\r
         },\r
-        highlightNode: function(wlxmlNode) {\r
-            this.dom.find('a[data-id="'+wlxmlNode.id+'"]').addClass('rng-common-hoveredNode');\r
+        highlightNode: function(canvasNode) {\r
+            this.dom.find('a[data-id="'+canvasNode.getId()+'"]').addClass('rng-common-hoveredNode');\r
         },\r
         },\r
-        dimNode: function(wlxmlNode) {\r
-            this.dom.find('a[data-id="'+wlxmlNode.id+'"]').removeClass('rng-common-hoveredNode');\r
+        dimNode: function(canvasNode) {\r
+            this.dom.find('a[data-id="'+canvasNode.getId()+'"]').removeClass('rng-common-hoveredNode');\r
         }\r
     }\r
     \r
         }\r
     }\r
     \r
@@ -65,17 +66,18 @@ return function(sandbox) {
         start: function() {\r
             sandbox.publish('ready');\r
         },\r
         start: function() {\r
             sandbox.publish('ready');\r
         },\r
-        setNode: function(node) {\r
-            view.setNode(node);\r
+        setNode: function(canvasNode) {\r
+            if(!canvasNode.isSame(view.currentNode))\r
+                view.setNode(canvasNode);\r
         },\r
         getView: function() {\r
             return view.dom;\r
         },\r
         },\r
         getView: function() {\r
             return view.dom;\r
         },\r
-        highlightNode: function(wlxmlNode) {\r
-            view.highlightNode(wlxmlNode);\r
+        highlightNode: function(canvasNode) {\r
+            view.highlightNode(canvasNode);\r
         },\r
         },\r
-        dimNode: function(wlxmlNode) {\r
-            view.dimNode(wlxmlNode);\r
+        dimNode: function(canvasNode) {\r
+            view.dimNode(canvasNode);\r
         }\r
     };\r
 };\r
         }\r
     };\r
 };\r