From: Aleksander Ɓukasz Date: Thu, 1 Aug 2013 10:43:38 +0000 (+0200) Subject: refactorization X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/ab1a529433f11e19769abf9bb1aa2c8c3194abeb refactorization --- diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 11c0f1f..d923787 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -124,32 +124,25 @@ var getDisplayStyle = function(tag, klass) { $.extend(DocumentNodeElement, { createDOM: function(params) { var dom = $('
'), + widgetsContainer = $('
'), container = $('
'); - 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 = $('
'); + 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); }