Fixing class name storage/retrival
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 16 Jul 2013 14:17:07 +0000 (16:17 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 16 Jul 2013 14:17:07 +0000 (16:17 +0200)
Only first dot/dash was getting replaced

modules/documentCanvas/canvas/canvas.test3.js
modules/documentCanvas/canvas/documentElement.js
modules/nodePane/nodePane.js

index edc81ee..030ff19 100644 (file)
@@ -118,11 +118,11 @@ describe('Canvas', function() {
             });
 
             it('knows WLXML class of a WLXML tag it renders', function(){
             });
 
             it('knows WLXML class of a WLXML tag it renders', function(){
-                var c = canvas.fromXML('<section class="some.class"></section>'),
+                var c = canvas.fromXML('<section class="some.class.A"></section>'),
                     section = c.doc();
                     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;
             });
                 section.setWlxmlClass(null);
                 expect(section.getWlxmlClass()).to.be.undefined;
             });
index c881c7f..ba859fc 100644 (file)
@@ -192,12 +192,12 @@ $.extend(DocumentNodeElement.prototype, {
     getWlxmlClass: function() {
         var klass = this.dom().attr('wlxml-class');
         if(klass)
     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)
         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');
     },
         else
             this.dom().removeAttr('wlxml-class');
     },
index a1c2a81..48dd77a 100644 (file)
@@ -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';
     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 {
     });
     
     return {
@@ -26,7 +26,7 @@ return function(sandbox) {
         },
         setNodeElement: function(nodeElement) {
             view.find('.rng-module-nodePane-tagSelect').val(nodeElement.getWlxmlTag());
         },
         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) {
 
             //var widget = metaWidget.create({attrs:canvasNode.getMetaAttrs()});
             //widget.on('valueChanged', function(key, value) {