Refactor
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 11 Jun 2013 09:56:27 +0000 (11:56 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 11 Jun 2013 09:56:27 +0000 (11:56 +0200)
modules/documentCanvas/documentCanvas.js
modules/documentCanvas/wlxmlNode.js
modules/nodeBreadCrumbs/nodeBreadCrumbs.js
modules/nodeFamilyTree/nodeFamilyTree.js
modules/rng/rng.js

index 05fbcdd..8f3a3c6 100644 (file)
@@ -245,7 +245,8 @@ return function(sandbox) {
             view.dimNode(wlxmlNode);\r
         },\r
         selectNode: function(wlxmlNode) {\r
-            view.selectNode(wlxmlNode, {moveCarret: true});\r
+            if(!wlxmlNode.is(view.currentNode))\r
+                view.selectNode(wlxmlNode, {moveCarret: true});\r
         },\r
         toggleGrid: function(toggle) {\r
             view.toggleGrid(toggle);\r
index f5ada52..6bd0c35 100644 (file)
@@ -29,6 +29,9 @@ var Node = function(domNode) {
                 list.push(new Node($(this)));\r
             });\r
             return $(list);\r
+        },\r
+        is: function(wlxmlNode) {\r
+            return wlxmlNode && (wlxmlNode.id === this.id);\r
         }\r
     }\r
 \r
index cefe7b4..517f45b 100644 (file)
@@ -31,6 +31,7 @@ return function(sandbox) {
         setNode: function(node) {\r
             this.dom.empty();\r
             var nodes = this.nodes = {};\r
+            this.currentNode = node;\r
             this.nodes[node.id] = node;\r
             var parents = node.parents();\r
             parents.each(function() {\r
@@ -53,7 +54,11 @@ return function(sandbox) {
     return {\r
         start: function() { sandbox.publish('ready'); },\r
         getView: function() { return view.dom; },\r
-        setNode: function(node) { view.setNode(node); },\r
+        setNode: function(wlxmlNode) {\r
+            if(!wlxmlNode.is(view.currentNode)) {\r
+                view.setNode(wlxmlNode);\r
+            }\r
+        },\r
         highlightNode: function(id) { view.highlightNode(id); },\r
         dimNode: function(id) { view.dimNode(id); }\r
     }\r
index 3c78bd1..7415b2d 100644 (file)
@@ -31,6 +31,7 @@ return function(sandbox) {
         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
@@ -65,8 +66,9 @@ return function(sandbox) {
         start: function() {\r
             sandbox.publish('ready');\r
         },\r
-        setNode: function(node) {\r
-            view.setNode(node);\r
+        setNode: function(wlxmlNode) {\r
+            if(!wlxmlNode.is(view.currentNode))\r
+                view.setNode(wlxmlNode);\r
         },\r
         getView: function() {\r
             return view.dom;\r
index 5edc7ac..6f65c19 100644 (file)
@@ -25,6 +25,13 @@ return function(sandbox) {
                 if(!origin || moduleName != origin)\r
                     sandbox.getModule(moduleName).dimNode(wlxmlNode)\r
             });\r
+        },\r
+        selectNode: function(wlxmlNode, origin) {\r
+            sandbox.getModule('documentCanvas').selectNode(wlxmlNode);\r
+            sandbox.getModule('nodePane').setNode(wlxmlNode);\r
+            sandbox.getModule('nodeFamilyTree').setNode(wlxmlNode);\r
+            sandbox.getModule('nodeBreadCrumbs').setNode(wlxmlNode);\r
+            \r
         }\r
     }\r
     \r
@@ -101,10 +108,8 @@ return function(sandbox) {
             views.visualEditing.setView('leftColumn', sandbox.getModule('documentCanvas').getView());\r
         },\r
         \r
-        nodeSelected: function(node) {\r
-            sandbox.getModule('nodePane').setNode(node);\r
-            sandbox.getModule('nodeFamilyTree').setNode(node);\r
-            sandbox.getModule('nodeBreadCrumbs').setNode(node);\r
+        nodeSelected: function(wlxmlNode) {\r
+            commands.selectNode(wlxmlNode);\r
         },\r
         \r
         contentChanged: function() {\r
@@ -148,7 +153,7 @@ return function(sandbox) {
             commands.dimDocumentNode(wlxmlNode, 'nodeFamilyTree');\r
         },\r
         nodeSelected: function(wlxmlNode) {\r
-            sandbox.getModule('documentCanvas').selectNode(wlxmlNode);\r
+            commands.selectNode(wlxmlNode);\r
         }\r
     };\r
     \r
@@ -179,7 +184,7 @@ return function(sandbox) {
             commands.dimDocumentNode(wlxmlNode, 'nodeBreadCrumbs');\r
         },\r
         nodeSelected: function(wlxmlNode) {\r
-            sandbox.getModule('documentCanvas').selectNode(wlxmlNode);\r
+            commands.selectNode(wlxmlNode);\r
         }        \r
     }\r
     \r