X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/71b7ba4d1d17adc39165914016fa892671cc4316..5713cbab555401cab4cb69012bf1d5ec47153982:/src/editor/modules/documentCanvas/canvas/documentElement.js diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index ee340f1..cd6b3d8 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -18,22 +18,14 @@ var DocumentElement = function(htmlElement, canvas) { this._setupDOMHandler(htmlElement); } -var elementTypeFromParams = function(params) { - return params.text !== undefined ? DocumentTextElement : DocumentNodeElement; -}; - -var elementTypeFromNode = function(wlxmlNode) { +var elementTypeFromWlxmlNode = function(wlxmlNode) { return wlxmlNode.nodeType === Node.TEXT_NODE ? DocumentTextElement : DocumentNodeElement; } $.extend(DocumentElement, { - create: function(params, canvas) { - return elementTypeFromParams(params).create(params); - }, - - create2: function(node, canvas) { - return elementTypeFromNode(node).create2(node, canvas); + create: function(node, canvas) { + return elementTypeFromWlxmlNode(node).create(node, canvas); }, createDOM: function(wlxmlNode) { @@ -60,6 +52,13 @@ $.extend(DocumentElement.prototype, { dom: function() { return this.$element; }, + data: function() { + var dom = this.dom(), + args = Array.prototype.slice.call(arguments, 0); + if(args.length === 2 && args[1] === undefined) + return dom.removeData(args[0]); + return dom.data.apply(dom, arguments); + }, parent: function() { var parents = this.$element.parents('[document-node-element]'); if(parents.length) @@ -147,54 +146,15 @@ var DocumentNodeElement = function(htmlElement, canvas) { }; $.extend(DocumentNodeElement, { - createDOM: function(params, canvas) { - var dom = $('