From: Aleksander Ɓukasz Date: Tue, 16 Jul 2013 14:17:07 +0000 (+0200) Subject: Fixing class name storage/retrival X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/9db0e3facfdcb376b589ea922215bbdb1a3d1787?ds=inline Fixing class name storage/retrival Only first dot/dash was getting replaced --- diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index edc81ee..030ff19 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -118,11 +118,11 @@ describe('Canvas', function() { }); it('knows WLXML class of a WLXML tag it renders', function(){ - var c = canvas.fromXML('
'), + var c = canvas.fromXML('
'), section = c.doc(); - expect(section.getWlxmlClass()).to.equal('some.class'); - section.setWlxmlClass('some.other.class'); - expect(section.getWlxmlClass()).to.equal('some.other.class'); + expect(section.getWlxmlClass()).to.equal('some.class.A'); + section.setWlxmlClass('some.class.B'); + expect(section.getWlxmlClass()).to.equal('some.class.B'); section.setWlxmlClass(null); expect(section.getWlxmlClass()).to.be.undefined; }); diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index c881c7f..ba859fc 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -192,12 +192,12 @@ $.extend(DocumentNodeElement.prototype, { getWlxmlClass: function() { var klass = this.dom().attr('wlxml-class'); if(klass) - return klass.replace('-', '.'); + return klass.replace(/-/g, '.'); return undefined; }, setWlxmlClass: function(klass) { if(klass) - this.dom().attr('wlxml-class', klass.replace('.', '-')); + this.dom().attr('wlxml-class', klass.replace(/\./g, '-')); else this.dom().removeAttr('wlxml-class'); }, diff --git a/modules/nodePane/nodePane.js b/modules/nodePane/nodePane.js index a1c2a81..48dd77a 100644 --- a/modules/nodePane/nodePane.js +++ b/modules/nodePane/nodePane.js @@ -14,7 +14,7 @@ return function(sandbox) { view.on('change', 'select', function(e) { var target = $(e.target); var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'tag' : 'class'; - sandbox.publish('nodeElementChange', attr, target.val()); + sandbox.publish('nodeElementChange', attr, target.val().replace(/-/g, '.')); }); return { @@ -26,7 +26,7 @@ return function(sandbox) { }, setNodeElement: function(nodeElement) { view.find('.rng-module-nodePane-tagSelect').val(nodeElement.getWlxmlTag()); - view.find('.rng-module-nodePane-classSelect').val(nodeElement.getWlxmlClass()); + view.find('.rng-module-nodePane-classSelect').val((nodeElement.getWlxmlClass() || '').replace(/\./g, '-')); //var widget = metaWidget.create({attrs:canvasNode.getMetaAttrs()}); //widget.on('valueChanged', function(key, value) {