X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/11461f05a370b4112d73258f56b3ab280fd1b6e5..04bf18e5d4d0d3d4a3663b8979eaf98417f44140:/modules/documentCanvas/canvas/documentElement.js diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index d90fe63..88287b8 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -1,6 +1,7 @@ define([ -'libs/jquery-1.9.1.min' -], function($) { +'libs/jquery-1.9.1.min', +'libs/underscore-min' +], function($, _) { 'use strict'; @@ -11,8 +12,9 @@ var DocumentElement = function(htmlElement, canvas) { return; this.canvas = canvas; this.$element = $(htmlElement); - this.wlxmlTag = this.$element.prop('tagName'); -}; + + this.wlxmlTag = this.$element.attr('wlxml-tag'); +} $.extend(DocumentElement.prototype, { dom: function() { @@ -47,7 +49,7 @@ $.extend(DocumentElement.prototype, { }, wrapWithNodeElement: function(wlxmlNode) { - this.$element.wrap($('<' + wlxmlNode.tag + ' class="' + wlxmlNode.klass + '"">')[0]); + this.$element.wrap($('<' + wlxmlNode.tag + ' class="' + wlxmlNode.klass.replace('.', '-') + '">')[0]); return documentElementFromHTMLElement(this.$element.parent().get(0), this.canvas); }, @@ -102,6 +104,29 @@ $.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) { + 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('wlxml-class'))) + return true; + return false; } }); @@ -110,15 +135,15 @@ DocumentNodeElement.createDOM = function(params) { if(params.text) { dom = $(document.createTextNode(params.text)); } else { - dom = $('<' + params.tag + '>'); + dom = $('