refactorization
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 1 Aug 2013 10:43:38 +0000 (12:43 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 5 Aug 2013 10:20:07 +0000 (12:20 +0200)
modules/documentCanvas/canvas/documentElement.js

index 11c0f1f..d923787 100644 (file)
@@ -124,32 +124,25 @@ var getDisplayStyle = function(tag, klass) {
 $.extend(DocumentNodeElement, {
     createDOM: function(params) {
         var dom = $('<div document-node-element>'),
 $.extend(DocumentNodeElement, {
     createDOM: function(params) {
         var dom = $('<div document-node-element>'),
+            widgetsContainer = $('<div class="canvas-widgets" contenteditable="false">'),
             container = $('<div document-element-content>');
         
             container = $('<div document-element-content>');
         
-        container.attr('wlxml-tag', params.tag);
+        dom.append(widgetsContainer, container);
+        // Make sure widgets aren't navigable with arrow keys
+        widgetsContainer.find('*').add(widgetsContainer).attr('tabindex', -1);
+
+        var element = this.fromHTMLElement(dom[0]);
+
+        element.setWlxmlTag(params.tag);
         if(params.klass)
         if(params.klass)
-            container.attr('wlxml-class', params.klass.replace(/\./g, '-'));
+            element.setWlxmlClass(params.klass);
         if(params.meta) {
             _.keys(params.meta).forEach(function(key) {
         if(params.meta) {
             _.keys(params.meta).forEach(function(key) {
-                dom.attr('wlxml-meta-'+key, params.meta[key]);
+                element.setWlxmlMetaAttr(key, params.meta[key]);
             });
         }
             });
         }
-        dom.data('other-attrs', params.others);
-
-        /* display style */
-        var displayStyle = getDisplayStyle(params.tag, params.klass);
-        dom.css('display', displayStyle);
-        container.css('display', displayStyle);
-
-        var widgetsContainer = $('<div class="canvas-widgets" contenteditable="false">');
+        element.data('other-attrs', params.others);
         widgetsContainer.append(widgets.labelWidget(params.tag, params.klass));
         widgetsContainer.append(widgets.labelWidget(params.tag, params.klass));
-        dom.append(widgetsContainer);
-
-        // Make sure widgets aren't navigable with arrow keys
-        widgetsContainer.find('*').add(widgetsContainer).attr('tabindex', -1);
-        
-        dom.append(container);
-
         if(params.rawChildren) {
             container.append(params.rawChildren);
         }
         if(params.rawChildren) {
             container.append(params.rawChildren);
         }