Visual editor: using dash instead of dot in wlxml-class attribute
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 18 Apr 2013 13:47:06 +0000 (15:47 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 18 Apr 2013 13:47:06 +0000 (15:47 +0200)
This makes it possible to target nodes via [attr|=value] CSS selector

modules/visualEditor.transformations.js

index 7374f2e..725aaea 100644 (file)
@@ -23,7 +23,7 @@ if(typeof module !== 'undefined' && module.exports) {
                     var toret = $('<div></div>').attr('wlxml-tag', tagName);
                     var currentTag = $(this);
                     if(currentTag.attr('class'))
-                        toret.attr('wlxml-class', currentTag.attr('class'));
+                        toret.attr('wlxml-class', currentTag.attr('class').replace(/\./g, '-'));
                     toret.append(currentTag.contents());
                     return toret;
                 });
@@ -35,7 +35,7 @@ if(typeof module !== 'undefined' && module.exports) {
                     var currentTag = $(this);
                     var toret = $('<span></span>').attr('wlxml-tag', tagName);
                     if(currentTag.attr('class'))
-                        toret.attr('wlxml-class', currentTag.attr('class'));
+                        toret.attr('wlxml-class', currentTag.attr('class').replace(/\./g, '-'));
                     toret.append(currentTag.contents());
                     return toret;
                 });
@@ -70,7 +70,7 @@ if(typeof module !== 'undefined' && module.exports) {
                 var tagName = div.attr('wlxml-tag');
                 var toret = $('<'+tagName+'>');
                 if(div.attr('wlxml-class'))
-                    toret.attr('class', div.attr('wlxml-class'))
+                    toret.attr('class', div.attr('wlxml-class').replace(/-/g, '.'))
                 toret.append(div.contents());
                 return toret;
             });