From d1363cb9ab794cf33c7d30cf15830857c8a9636c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 1 Aug 2013 10:13:03 +0200 Subject: [PATCH 1/1] Refactoring --- modules/documentCanvas/canvas/canvas.js | 10 ---------- modules/documentCanvas/canvas/documentElement.js | 8 ++++++++ modules/documentCanvas/documentCanvas.js | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 6179b83..bd45273 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -321,16 +321,6 @@ $.extend(Canvas.prototype, { list: {}, - - - highlightElement: function(element) { - this.wrapper.find('.highlighted-element').removeClass('highlighted-element'); - element.dom().addClass('highlighted-element'); - }, - - dimElement: function(element) { - element.dom().removeClass('highlighted-element'); - }, getCurrentNodeElement: function() { return this.getDocumentElement(this.wrapper.find('.current-node-element')[0]); diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index d58d8c1..3601732 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -360,6 +360,10 @@ $.extend(DocumentNodeElement.prototype, { var displayCss = toggle ? 'inline-block' : 'none'; var label = this.dom().children('.canvas-widgets').find('.canvas-widget-label'); label.css('display', displayCss); + this.toggleHighlight(toggle); + }, + + toggleHighlight: function(toogle) { this.dom().toggleClass('highlighted-element'); } }); @@ -530,6 +534,10 @@ $.extend(DocumentTextElement.prototype, { this.after(newElement); newElement.after(rhsTextElement); return newElement; + }, + + toggleHighlight: function() { + // do nothing for now } }); diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index decda83..2f8dae5 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -55,10 +55,10 @@ return function(sandbox) { sandbox.publish('currentNodeElementChanged', currentNodeElement); }, highlightElement: function(element) { - canvas.highlightElement(element); + element.toggleHighlight(true); }, dimElement: function(element) { - canvas.dimElement(element); + element.toggleHighlight(false); }, jumpToElement: function(element) { canvas.setCurrentElement(element); -- 2.20.1