editor: canvas - refactoring
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 6 Mar 2014 09:28:28 +0000 (10:28 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 28 Mar 2014 11:37:11 +0000 (12:37 +0100)
src/editor/modules/documentCanvas/canvas/documentElement.js

index 7f448ba..b7a4900 100644 (file)
@@ -142,15 +142,11 @@ var DocumentNodeElement = function(htmlElement, canvas) {
 };
 
 $.extend(DocumentNodeElement, {
 };
 
 $.extend(DocumentNodeElement, {
-    create: function(wlxmlNode, canvas) {
-        return this.fromHTMLElement(this.createDOM(wlxmlNode, canvas)[0], canvas);
-    },
-
     fromHTMLElement: function(htmlElement, canvas) {
         return new this(htmlElement, canvas);
     },
 
     fromHTMLElement: function(htmlElement, canvas) {
         return new this(htmlElement, canvas);
     },
 
-    createDOM: function(wlxmlNode, canvas) {
+    create: function(wlxmlNode, canvas) {
         var dom = $('<div>')
                 .attr('document-node-element', ''),
             widgetsContainer = $('<div>')
         var dom = $('<div>')
                 .attr('document-node-element', ''),
             widgetsContainer = $('<div>')
@@ -174,9 +170,8 @@ $.extend(DocumentNodeElement, {
             container.append(DocumentElement.create(node, canvas).dom());
         }.bind(this));
 
             container.append(DocumentElement.create(node, canvas).dom());
         }.bind(this));
 
-        return dom;
+        return element;
     }
     }
-
 });
 
 var manipulate = function(e, params, action) {
 });
 
 var manipulate = function(e, params, action) {
@@ -327,22 +322,19 @@ var DocumentTextElement = function(htmlElement, canvas) {
 };
 
 $.extend(DocumentTextElement, {
 };
 
 $.extend(DocumentTextElement, {
-    createDOM: function(wlxmlTextNode, canvas) {
+    create: function(wlxmlTextNode, canvas) {
         var dom = $('<div>')
             .attr('document-text-element', '')
             .text(wlxmlTextNode.getText() || utils.unicode.ZWS),
         element = this.fromHTMLElement(dom[0], canvas);
         element.data('wlxmlNode', wlxmlTextNode);
         var dom = $('<div>')
             .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);
     },
     },
 
     fromHTMLElement: function(htmlElement, canvas) {
         return new this(htmlElement, canvas);
     },
+
     isContentContainer: function(htmlElement) {
         return htmlElement.nodeType === Node.TEXT_NODE && $(htmlElement).parent().is('[document-text-element]');
     }
     isContentContainer: function(htmlElement) {
         return htmlElement.nodeType === Node.TEXT_NODE && $(htmlElement).parent().is('[document-text-element]');
     }