integration wip: highlight/dim/select node via family tree
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 20 Nov 2013 09:50:14 +0000 (10:50 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:53 +0000 (14:50 +0100)
src/editor/modules/documentCanvas/canvas/canvas.js
src/editor/modules/documentCanvas/documentCanvas.js
src/editor/modules/nodeFamilyTree/nodeFamilyTree.js
src/editor/modules/rng/rng.js

index 3a662e9..b0d461b 100644 (file)
@@ -110,6 +110,11 @@ $.extend(Canvas.prototype, {
         return documentElement.DocumentNodeElement.fromHTMLElement(this.d.get(0), this); //{wlxmlTag: this.d.prop('tagName')};
     },
 
+    toggleElementHighlight: function(node, toggle) {
+        var element = utils.findCanvasElement(node);
+        element.toggleHighlight(toggle);
+    },
+
     createNodeElement: function(params) {
         return documentElement.DocumentNodeElement.create(params, this);
     },
@@ -230,6 +235,10 @@ $.extend(Canvas.prototype, {
 
 
     setCurrentElement: function(element, params) {
+        if(!(element instanceof documentElement.DocumentElement)) {
+            element = utils.findCanvasElement(element);
+        }
+
         params = _.extend({caretTo: 'end'}, params);
         var findFirstDirectTextChild = function(e, nodeToLand) {
             var byBrowser = this.getCursor().getPosition().element;
index a398f26..3ca4e46 100644 (file)
@@ -53,14 +53,14 @@ return function(sandbox) {
             }
             sandbox.publish('currentNodeElementChanged', currentNodeElement);
         },
-        highlightElement: function(element) {
-            element.toggleHighlight(true);
+        highlightElement: function(node) {
+            canvas.toggleElementHighlight(node, true);
         },
-        dimElement: function(element) {
-            element.toggleHighlight(false);
+        dimElement: function(node) {
+            canvas.toggleElementHighlight(node, false);
         },
-        jumpToElement: function(element) {
-            canvas.setCurrentElement(element);
+        jumpToElement: function(node) {
+            canvas.setCurrentElement(node);
         },
         command: function(command, params) {
             commands.run(command, params, canvas);
index fde220b..610901a 100644 (file)
@@ -27,16 +27,16 @@ return function(sandbox) {
             var view = this;
             this.dom.on('click', 'a', function(e) {
                 var target = $(e.target);
-                sandbox.publish('elementClicked', target.data('element'));
+                sandbox.publish('nodeClicked', target.data('element'));
             });
             
             this.dom.on('mouseenter', 'a', function(e) {
                 var target = $(e.target);
-                sandbox.publish('elementEntered', target.data('element'));
+                sandbox.publish('nodeEntered', target.data('element'));
             });
             this.dom.on('mouseleave', 'a', function(e) {
                 var target = $(e.target);
-                sandbox.publish('elementLeft', target.data('element'));
+                sandbox.publish('nodeLeft', target.data('element'));
             });
         },
         setElement: function(element) {
index 614fc76..58f4dee 100644 (file)
@@ -191,14 +191,14 @@ return function(sandbox) {
         ready: function() {
             views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());
         },
-        elementEntered: function(element) {
-            commands.highlightDocumentElement(element, 'nodeFamilyTree');
+        nodeEntered: function(node) {
+            commands.highlightDocumentElement(node, 'nodeFamilyTree');
         },
-        elementLeft: function(element) {
-            commands.dimDocumentElement(element, 'nodeFamilyTree');
+        nodeLeft: function(node) {
+            commands.dimDocumentElement(node, 'nodeFamilyTree');
         },
-        elementClicked: function(element) {
-            commands.jumpToDocumentElement(element);
+        nodeClicked: function(node) {
+            commands.jumpToDocumentElement(node);
         }
     };