X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6435513192b5be363719dcb1559c93b52944800d..efe36f4f1b5df351eeb4d40a54c3900cf9a7079b:/modules/documentCanvas/canvas/documentElement.js diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js deleted file mode 100644 index 50e680d..0000000 --- a/modules/documentCanvas/canvas/documentElement.js +++ /dev/null @@ -1,65 +0,0 @@ -define([ -'libs/jquery-1.9.1.min' -], function($) { - -'use strict'; - -// DocumentElement represents a node from WLXML document rendered inside Canvas -var DocumentElement = function(htmlElement) { - if(arguments.length === 0) - return; - this.$element = $(htmlElement); - this.wlxmlTag = this.$element.prop('tagName'); -}; - -$.extend(DocumentElement.prototype, { - children: function() { - var toret = []; - if(this instanceof DocumentTextElement) - return toret; - - - var elementContent = this.$element.contents(); - elementContent.each(function(idx) { - var element = documentElementFromHTMLElement(this); - if( - (toret.length === 0 && (element instanceof DocumentNodeElement)) || - (toret.length > 0 && (toret[toret.length -1] instanceof DocumentNodeElement) && (element instanceof DocumentNodeElement)) - ) - toret.push(documentElementFromHTMLElement(document.createTextNode())); - toret.push(element); - if((idx === elementContent.length - 1) && (element instanceof DocumentNodeElement)) - toret.push(documentElementFromHTMLElement(document.createTextNode())); - }); - return toret; - } -}); - -var DocumentNodeElement = function(htmlElement) { - DocumentElement.call(this, htmlElement); -}; - -var DocumentTextElement = function(htmlElement) { - DocumentElement.call(this, htmlElement); -}; - -DocumentNodeElement.prototype = new DocumentElement(); -DocumentTextElement.prototype = new DocumentElement(); - -var documentElementFromHTMLElement = function(htmlElement) { - if(htmlElement.nodeType === Node.ELEMENT_NODE) - return new DocumentNodeElement(htmlElement); - if(htmlElement.nodeType === Node.TEXT_NODE) - return new DocumentTextElement(htmlElement); -} - -return { - wrap: function(htmlElement) { - return documentElementFromHTMLElement(htmlElement); - }, - DocumentElement: DocumentElement, - DocumentNodeElement: DocumentNodeElement, - DocumentTextElement: DocumentTextElement -}; - -}); \ No newline at end of file