From 029c09d7b013195c31125fd7c56347e08963df6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 12 Jul 2013 16:45:16 +0200 Subject: [PATCH] Moving DocumentNodeElement methods where they belong --- .../documentCanvas/canvas/documentElement.js | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index d0adbc0..84610b8 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -18,26 +18,6 @@ $.extend(DocumentElement.prototype, { dom: function() { return this.$element; }, - children: function() { - var toret = []; - if(this instanceof DocumentTextElement) - return toret; - - - var elementContent = this.$element.contents(); - var element = this; - elementContent.each(function(idx) { - var childElement = documentElementFromHTMLElement(this, element.canvas); - if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && (childElement instanceof DocumentTextElement) && $.trim($(this).text()) === '') - return true; - if(idx > 0 && childElement instanceof DocumentTextElement) { - if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '') - return true; - } - toret.push(childElement); - }); - return toret; - }, parent: function() { return documentElementFromHTMLElement(this.$element.parent()[0], this.canvas); }, @@ -53,18 +33,6 @@ $.extend(DocumentElement.prototype, { return wrapper; }, - childIndex: function(child) { - var children = this.children(), - toret = null; - children.forEach(function(c, idx) { - if(c.sameNode(child)) { - toret = idx; - return false; - } - }); - return toret; - }, - detach: function() { this.$element.detach(); this.canvas = null; @@ -105,6 +73,37 @@ $.extend(DocumentNodeElement.prototype, { after: function(params) { manipulate(this, params, 'after'); }, + children: function() { + var toret = []; + if(this instanceof DocumentTextElement) + return toret; + + + var elementContent = this.$element.contents(); + var element = this; + elementContent.each(function(idx) { + var childElement = documentElementFromHTMLElement(this, element.canvas); + if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && (childElement instanceof DocumentTextElement) && $.trim($(this).text()) === '') + return true; + if(idx > 0 && childElement instanceof DocumentTextElement) { + if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '') + return true; + } + toret.push(childElement); + }); + return toret; + }, + childIndex: function(child) { + var children = this.children(), + toret = null; + children.forEach(function(c, idx) { + if(c.sameNode(child)) { + toret = idx; + return false; + } + }); + return toret; + }, getWlxmlTag: function() { return this.$element.attr('wlxml-tag'); }, -- 2.20.1