Fixing event handling in documentCanvas module
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 10 Jun 2013 09:45:32 +0000 (11:45 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 10 Jun 2013 09:45:32 +0000 (11:45 +0200)
Propagation caused handling the event multiple times for each
parent of the wlxml node.

modules/documentCanvas/documentCanvas.js

index ea44955..f7d7fd0 100644 (file)
@@ -20,9 +20,16 @@ return function(sandbox) {
                 sandbox.publish('contentChanged');\r
             });\r
 \r
-            this.node.on('mouseover', '[wlxml-tag]', function(e) { sandbox.publish('nodeHovered', $(e.target)); });\r
-            this.node.on('mouseout', '[wlxml-tag]', function(e) { sandbox.publish('nodeBlured', $(e.target)); });\r
+            this.node.on('mouseover', '[wlxml-tag]', function(e) {\r
+                e.stopPropagation();\r
+                sandbox.publish('nodeHovered', $(e.target));\r
+            });\r
+            this.node.on('mouseout', '[wlxml-tag]', function(e) {\r
+                e.stopPropagation();\r
+                sandbox.publish('nodeBlured', $(e.target));\r
+            });\r
             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
             });\r