From d3d80ba74ca2e2afbd262edfe4be39010c86ebde Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 6 Mar 2014 10:28:28 +0100 Subject: [PATCH] editor: canvas - refactoring --- .../documentCanvas/canvas/documentElement.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index 7f448ba..b7a4900 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -142,15 +142,11 @@ var DocumentNodeElement = function(htmlElement, canvas) { }; $.extend(DocumentNodeElement, { - create: function(wlxmlNode, canvas) { - return this.fromHTMLElement(this.createDOM(wlxmlNode, canvas)[0], canvas); - }, - fromHTMLElement: function(htmlElement, canvas) { return new this(htmlElement, canvas); }, - createDOM: function(wlxmlNode, canvas) { + create: function(wlxmlNode, canvas) { var dom = $('
') .attr('document-node-element', ''), widgetsContainer = $('
') @@ -174,9 +170,8 @@ $.extend(DocumentNodeElement, { container.append(DocumentElement.create(node, canvas).dom()); }.bind(this)); - return dom; + return element; } - }); var manipulate = function(e, params, action) { @@ -327,22 +322,19 @@ var DocumentTextElement = function(htmlElement, canvas) { }; $.extend(DocumentTextElement, { - createDOM: function(wlxmlTextNode, canvas) { + create: function(wlxmlTextNode, canvas) { var dom = $('
') .attr('document-text-element', '') .text(wlxmlTextNode.getText() || utils.unicode.ZWS), element = this.fromHTMLElement(dom[0], canvas); element.data('wlxmlNode', wlxmlTextNode); - return dom; - }, - - create: function(wlxmlTextNode, canvas) { - return this.fromHTMLElement(this.createDOM(wlxmlTextNode, canvas)[0], canvas); + return element; }, fromHTMLElement: function(htmlElement, canvas) { return new this(htmlElement, canvas); }, + isContentContainer: function(htmlElement) { return htmlElement.nodeType === Node.TEXT_NODE && $(htmlElement).parent().is('[document-text-element]'); } -- 2.20.1