X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/72006ca5628befdc32bb1cd31002f22c4a7c8bca..00d1285a2038e326246c5f5ff3bca7728f67925b:/modules/documentCanvas/canvas/documentElement.js?ds=sidebyside diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index da9b148..88287b8 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -13,9 +13,8 @@ var DocumentElement = function(htmlElement, canvas) { this.canvas = canvas; this.$element = $(htmlElement); - var tagNameProp = this.$element.prop('tagName'); - this.wlxmlTag = tagNameProp ? tagNameProp.toLowerCase() : undefined; -}; + this.wlxmlTag = this.$element.attr('wlxml-tag'); +} $.extend(DocumentElement.prototype, { dom: function() { @@ -106,11 +105,26 @@ $.extend(DocumentNodeElement.prototype, { after: function(params) { manipulate(this, params, 'after'); }, + getWlxmlTag: function() { + return this.$element.attr('wlxml-tag'); + }, + setWlxmlTag: function(tag) { + this.$element.attr('wlxml-tag', tag); + }, + getWlxmlClass: function() { + var klass = this.$element.attr('wlxml-class'); + if(klass) + return klass.replace('-', '.'); + return undefined; + }, setWlxmlClass: function(klass) { - this.$element.attr('class', klass); + if(klass) + this.$element.attr('wlxml-class', klass); + else + this.$element.removeAttr('wlxml-class'); }, is: function(what) { - if(what === 'list' && _.contains(['list-items', 'list-items-enum'], this.$element.attr('class'))) + if(what === 'list' && _.contains(['list-items', 'list-items-enum'], this.$element.attr('wlxml-class'))) return true; return false; } @@ -121,9 +135,9 @@ DocumentNodeElement.createDOM = function(params) { if(params.text) { dom = $(document.createTextNode(params.text)); } else { - dom = $('<' + params.tag + '>'); + dom = $('