From: Aleksander Ɓukasz Date: Wed, 20 Nov 2013 09:50:14 +0000 (+0100) Subject: integration wip: highlight/dim/select node via family tree X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/cd02846fc9db03e6d9a2add20150b8808a66d850?ds=sidebyside;hp=1726f584bb8ff2770506aae2e77fe27fbfd5ab98 integration wip: highlight/dim/select node via family tree --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 3a662e9..b0d461b 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -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; diff --git a/src/editor/modules/documentCanvas/documentCanvas.js b/src/editor/modules/documentCanvas/documentCanvas.js index a398f26..3ca4e46 100644 --- a/src/editor/modules/documentCanvas/documentCanvas.js +++ b/src/editor/modules/documentCanvas/documentCanvas.js @@ -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); diff --git a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js index fde220b..610901a 100644 --- a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js +++ b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js @@ -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) { diff --git a/src/editor/modules/rng/rng.js b/src/editor/modules/rng/rng.js index 614fc76..58f4dee 100644 --- a/src/editor/modules/rng/rng.js +++ b/src/editor/modules/rng/rng.js @@ -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); } };