From: Aleksander Ɓukasz Date: Mon, 8 Jul 2013 09:45:29 +0000 (+0200) Subject: refactoring X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/60c827deca03f56b138fddbd22d42d0ba52dcdc5?hp=20ce93fdd697712c5b085145d85db9bb1b632f58 refactoring --- diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 3f6a208..35ffeea 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -59,21 +59,24 @@ DocumentTextElement.prototype = new DocumentElement(); $.extend(DocumentNodeElement.prototype, { append: function(params) { - var to_append = $('<' + params.tag + '>'); - if(params.klass) - to_append.attr('class', params.klass); + var to_append = DocumentNodeElement.createDOM(params.tag, params.klass) this.$element.append(to_append); return documentElementFromHTMLElement(to_append); }, after: function(params) { - var to_append = $('<' + params.tag + '>'); - if(params.klass) - to_append.attr('class', params.klass); + var to_append = DocumentNodeElement.createDOM(params.tag, params.klass) this.$element.after(to_append); return documentElementFromHTMLElement(to_append); } }) +DocumentNodeElement.createDOM = function(tag, klass) { + var dom = $('<' + tag + '>'); + if(klass) + dom.attr('class', klass); + return dom; +} + var documentElementFromHTMLElement = function(htmlElement) { if(htmlElement.nodeType === Node.ELEMENT_NODE) return new DocumentNodeElement(htmlElement);