From: Aleksander Ɓukasz Date: Thu, 6 Mar 2014 09:28:28 +0000 (+0100) Subject: editor: canvas - refactoring X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/d3d80ba74ca2e2afbd262edfe4be39010c86ebde editor: canvas - refactoring --- 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]'); }