From: Aleksander Ɓukasz Date: Wed, 2 Jul 2014 10:00:33 +0000 (+0200) Subject: editor: cleanup - removing unnecessary wlxml class handling code in canvas generic... X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/8c838a1e2df218ea7da65a8a449da1188e091f51 editor: cleanup - removing unnecessary wlxml class handling code in canvas generic element - generic element doesn't actually handle onNodeAttrChange for a 'class' attribute - that kind of change leads to creating new canvas element instance since e0aad96df245c7148966887cbcc77417a4b7675b - for the same reason support for changing class information on a generic element during its life time is not necessary --- diff --git a/src/editor/modules/documentCanvas/canvas/genericElement.js b/src/editor/modules/documentCanvas/canvas/genericElement.js index 4dfbe59..a703b0c 100644 --- a/src/editor/modules/documentCanvas/canvas/genericElement.js +++ b/src/editor/modules/documentCanvas/canvas/genericElement.js @@ -24,8 +24,9 @@ $.extend(generic, { init: function() { DocumentNodeElement.prototype.init.call(this); this._container() - .attr('wlxml-tag', this.wlxmlNode.getTagName()); - this.setWlxmlClass(this.wlxmlNode.getClass()); + .attr('wlxml-tag', this.wlxmlNode.getTagName()) + .attr('wlxml-class', this.wlxmlNode.getClass().replace(/\./g, '-')); + this.wlxmlNode.contents().forEach(function(node) { var el = this.canvas.createElement(node); if(el.dom) { @@ -101,11 +102,6 @@ $.extend(generic, { return toret; }, - onNodeAttrChange: function(event) { - if(event.meta.attr === 'class') { - this.setWlxmlClass(event.meta.newVal); // - } - }, onNodeAdded: function(event) { if(event.meta.node.isRoot()) { this.canvas.reloadRoot(); @@ -233,26 +229,6 @@ $.extend(generic, { } }); return toret; - }, - - getWlxmlClass: function() { - var klass = this._container().attr('wlxml-class'); - if(klass) { - return klass.replace(/-/g, '.'); - } - return undefined; - }, - setWlxmlClass: function(klass) { - if(klass === this.getWlxmlClass()) { - return; - } - if(klass) { - this._container().attr('wlxml-class', klass.replace(/\./g, '-')); - } - else { - this._container().removeAttr('wlxml-class'); - } - this.refreshPath(); } }); diff --git a/src/editor/modules/documentCanvas/canvas/keyboard.js b/src/editor/modules/documentCanvas/canvas/keyboard.js index 71a50b0..646c68a 100644 --- a/src/editor/modules/documentCanvas/canvas/keyboard.js +++ b/src/editor/modules/documentCanvas/canvas/keyboard.js @@ -52,7 +52,7 @@ handlers.push({key: KEYS.ENTER, canvas.wlxmlDocument.transaction(function() { var added = currentElement.wlxmlNode.after({ tagName: currentElement.wlxmlNode.getTagName() || 'div', - attrs: {'class': currentElement.getWlxmlClass() || 'p'} + attrs: {'class': currentElement.wlxmlNode.getClass() || 'p'} }); added.append({text:''}); return added; @@ -77,7 +77,7 @@ handlers.push({key: KEYS.ENTER, canvas.wlxmlDocument.transaction(function() { var added = element.wlxmlNode.after( - {tagName: element.wlxmlNode.getTagName() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}} + {tagName: element.wlxmlNode.getTagName() || 'div', attrs: {'class': element.wlxmlNode.getClass() || 'p'}} ); added.append({text: ''}); return added;