documentCanvas fix: node now dims correctly
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 11 Jun 2013 08:43:43 +0000 (10:43 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 11 Jun 2013 08:43:43 +0000 (10:43 +0200)
modules/documentCanvas/documentCanvas.js

index e666f0d..55c8d7e 100644 (file)
@@ -32,7 +32,7 @@ return function(sandbox) {
             this.node.on('click', '[wlxml-tag]', function(e) {\r
                 e.stopPropagation();\r
                 console.log('clicked node type: '+e.target.nodeType);\r
-                view._markSelected($(e.target));\r
+                view._markSelected(new wlxmlNode.Node($(e.target)));\r
             });\r
 \r
             this.node.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
@@ -41,7 +41,7 @@ return function(sandbox) {
                     anchor = anchor.parent();\r
                 if(!anchor.is('[wlxml-tag]'))\r
                     return;\r
-                view._markSelected(anchor);\r
+                view._markSelected(new wlxmlNode.Node(anchor));\r
             });\r
             \r
             this.node.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
@@ -165,19 +165,19 @@ return function(sandbox) {
         _markSelected: function(node) {\r
             this.dimNode(node);\r
             \r
+            \r
             this.node.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');\r
             \r
-            node.addClass('rng-module-documentCanvas-currentNode');\r
+            this.getNodeElement(node).addClass('rng-module-documentCanvas-currentNode');\r
 \r
             this.currentNode = node;\r
-            sandbox.publish('nodeSelected', new wlxmlNode.Node(node));\r
+            sandbox.publish('nodeSelected', node);\r
             \r
         },\r
         selectNode: function(node) {\r
-            node = this.getNodeElement(node);\r
             view._markSelected(node);\r
             var range = document.createRange();\r
-            range.selectNodeContents(node[0]);\r
+            range.selectNodeContents(this.getNodeElement(node)[0]);\r
             range.collapse(false);\r
 \r
             var selection = document.getSelection();\r