isDirty = true;\r
});\r
- this.node.on('mouseover', '.rng', function(e) { $(e.target).addClass('rng-hover')});\r
- this.node.on('mouseout', '.rng', function(e) { $(e.target).removeClass('rng-hover')});\r
- this.node.on('click', '.rng', function(e) {\r
+ this.node.on('mouseover', '[wlxml-tag]', function(e) { $(e.target).addClass('rng-hover')});\r
+ this.node.on('mouseout', '[wlxml-tag]', function(e) { $(e.target).removeClass('rng-hover')});\r
+ this.node.on('click', '[wlxml-tag]', function(e) {\r
+ console.log('clicked node type: '+e.target.nodeType);\r
view._markSelected($(e.target));\r
});\r
\r
var anchor = $(window.getSelection().anchorNode);\r
if(anchor[0].nodeType === Node.TEXT_NODE)\r
anchor = anchor.parent();\r
- if(!anchor.hasClass('rng'))\r
+ if(!anchor.is('[wlxml-tag]'))\r
return;\r
view._markSelected(anchor);\r
});
return this.node.find('#rng-visualEditor-content').html();\r
}, \r
_markSelected: function(node) {\r
- this.node.find('.rng').removeClass('rng-current');\r
+ this.node.find('.rng-current').removeClass('rng-current');\r
node.addClass('rng-current');\r
}\r
};\r
console.log('running ' + tagName);
toret.find(tagName).replaceWith(function() {
var suffix = tagName !== 'div' ? tagName : 'block';
- return $('<div></div>').addClass('rng rng-' + suffix).append($(this).contents());
+ return $('<div></div>').attr('wlxml-tag', suffix).append($(this).contents());
});
});
tagName = tagName.toLowerCase();
toret.find(tagName).replaceWith(function() {
var node = this;
- return $('<span></span>').addClass('rng rng-' + tagName).append($(this).contents());
+ return $('<span></span>').attr('wlxml-tag', tagName).append($(this).contents());
});
});
return toret.children();
toret.find('div, span').replaceWith(function() {
var div = $(this);
- var tagName = div.attr('class').split('rng-')[1];
+ var tagName = div.attr('wlxml-tag');
return $('<'+tagName+'>').append(div.contents());
});