Visual editor - cross highlighting nodes between main content and edit pane
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 22 Apr 2013 09:52:47 +0000 (11:52 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 22 Apr 2013 09:52:47 +0000 (11:52 +0200)
modules/visualEditor.js

index f7ae32c..4c8af20 100644 (file)
@@ -15,8 +15,8 @@ rng.modules.visualEditor = function(sandbox) {
                 isDirty = true;\r
             });\r
 
                 isDirty = true;\r
             });\r
 
-            this.node.on('mouseover', '[wlxml-tag]', function(e) { $(e.target).addClass('rng-hover')});\r
-            this.node.on('mouseout', '[wlxml-tag]', function(e) { $(e.target).removeClass('rng-hover')});\r
+            this.node.on('mouseover', '[wlxml-tag]', function(e) { view.highlightNode($(e.target));});\r
+            this.node.on('mouseout', '[wlxml-tag]', function(e) { view.dimNode($(e.target));});\r
             this.node.on('click', '[wlxml-tag]', function(e) {\r
                 console.log('clicked node type: '+e.target.nodeType);\r
                 view._markSelected($(e.target));\r
             this.node.on('click', '[wlxml-tag]', function(e) {\r
                 console.log('clicked node type: '+e.target.nodeType);\r
                 view._markSelected($(e.target));\r
@@ -139,6 +139,24 @@ rng.modules.visualEditor = function(sandbox) {
             if(node)\r
                 this.selectNode(node);\r
         },\r
             if(node)\r
                 this.selectNode(node);\r
         },\r
+        highlightNode: function(node) {\r
+            node.addClass('rng-hover');\r
+            mediator.nodeHighlighted(node);\r
+        },\r
+        dimNode: function(node) {\r
+            node.removeClass('rng-hover');\r
+            mediator.nodeDimmed(node);\r
+        },\r
+        highlightNodeById: function(id) {\r
+            var node = this.node.find('#'+id);\r
+            if(node)\r
+                this.highlightNode(node);\r
+        },\r
+        dimNodeById: function(id) {\r
+            var node = this.node.find('#'+id);\r
+            if(node)\r
+                this.dimNode(node);\r
+        },\r
         selectFirstNode: function() {\r
             var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {\r
                 return $(this).clone().children().remove().end().text().trim() !== '';\r
         selectFirstNode: function() {\r
             var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {\r
                 return $(this).clone().children().remove().end().text().trim() !== '';\r
@@ -205,8 +223,18 @@ rng.modules.visualEditor = function(sandbox) {
             \r
             view.node.on('click', '.rng-visualEditor-editPaneSurrouding a', function(e) {\r
                 var target = $(e.target);\r
             \r
             view.node.on('click', '.rng-visualEditor-editPaneSurrouding a', function(e) {\r
                 var target = $(e.target);\r
+                mediator.nodeDimmedById(target.attr('data-id'));\r
                 mediator.nodeSelectedById(target.attr('data-id'));\r
             });\r
                 mediator.nodeSelectedById(target.attr('data-id'));\r
             });\r
+            \r
+            view.node.on('mouseenter', '.rng-visualEditor-editPaneSurrouding a', function(e) {\r
+                var target = $(e.target);\r
+                mediator.nodeHighlightedById(target.attr('data-id')); \r
+            });\r
+            view.node.on('mouseleave', '.rng-visualEditor-editPaneSurrouding a', function(e) {\r
+                var target = $(e.target);\r
+                mediator.nodeDimmedById(target.attr('data-id')); \r
+            });\r
         },\r
         selectTab: function(id) {\r
            this.node.find('.rng-visualEditor-sidebarContentItem').hide();\r
         },\r
         selectTab: function(id) {\r
            this.node.find('.rng-visualEditor-sidebarContentItem').hide();\r
@@ -230,6 +258,14 @@ rng.modules.visualEditor = function(sandbox) {
             });\r
             var naviTemplate = sandbox.getTemplate('editPaneNavigation')({parent: parent, children: children});\r
             pane.find('.rng-visualEditor-editPaneSurrouding > div').html($(naviTemplate));\r
             });\r
             var naviTemplate = sandbox.getTemplate('editPaneNavigation')({parent: parent, children: children});\r
             pane.find('.rng-visualEditor-editPaneSurrouding > div').html($(naviTemplate));\r
+        },\r
+        highlightNode: function(id) {\r
+            var pane = this.node.find('#rng-visualEditor-edit');\r
+            pane.find('a[data-id="'+id+'"]').addClass('rng-hover');\r
+        },\r
+        dimNode: function(id) {\r
+            var pane = this.node.find('#rng-visualEditor-edit');\r
+            pane.find('a[data-id="' +id+'"]').removeClass('rng-hover');\r
         }\r
     }\r
     \r
         }\r
     }\r
     \r
@@ -249,6 +285,18 @@ rng.modules.visualEditor = function(sandbox) {
         },\r
         nodeSelectedById: function(id) {\r
             view.selectNodeById(id);\r
         },\r
         nodeSelectedById: function(id) {\r
             view.selectNodeById(id);\r
+        },\r
+        nodeHighlightedById: function(id) {\r
+            view.highlightNodeById(id);\r
+        },\r
+        nodeDimmedById: function(id) {\r
+            view.dimNodeById(id);\r
+        },\r
+        nodeHighlighted: function(node) {\r
+            sideBarView.highlightNode(node.attr('id'));\r
+        },\r
+        nodeDimmed: function(node) {\r
+            sideBarView.dimNode(node.attr('id'));\r
         }\r
     }\r
     \r
         }\r
     }\r
     \r