$.extend(DocumentNodeElement, {
createDOM: function(params) {
var dom = $('<div document-node-element>'),
+ widgetsContainer = $('<div class="canvas-widgets" contenteditable="false">'),
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)
- container.attr('wlxml-class', params.klass.replace(/\./g, '-'));
+ element.setWlxmlClass(params.klass);
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));
- 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);
}