X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/71b7ba4d1d17adc39165914016fa892671cc4316..2fbd2cb6926b1066b38adf0698a3679d089ad80c:/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..1c0719f 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -1,11 +1,10 @@ define([ 'libs/jquery', 'libs/underscore', -'modules/documentCanvas/classAttributes', 'modules/documentCanvas/canvas/utils', 'modules/documentCanvas/canvas/widgets', 'modules/documentCanvas/canvas/wlxmlManagers' -], function($, _, classAttributes, utils, widgets, wlxmlManagers) { +], function($, _, utils, widgets, wlxmlManagers) { 'use strict'; @@ -18,22 +17,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 +51,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) @@ -81,13 +79,6 @@ $.extend(DocumentElement.prototype, { return other && (typeof other === typeof this) && other.dom()[0] === this.dom()[0]; }, - wrapWithNodeElement: function(wlxmlNode) { - var wrapper = DocumentNodeElement.create({tag: wlxmlNode.tag, klass: wlxmlNode.klass}, this); - this.dom().replaceWith(wrapper.dom()); - wrapper.append(this); - return wrapper; - }, - markAsCurrent: function() { this.canvas.markAsCurrent(this); }, @@ -147,54 +138,15 @@ var DocumentNodeElement = function(htmlElement, canvas) { }; $.extend(DocumentNodeElement, { - createDOM: function(params, canvas) { - var dom = $('