From 60c827deca03f56b138fddbd22d42d0ba52dcdc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 8 Jul 2013 11:45:29 +0200 Subject: [PATCH 1/1] refactoring --- modules/documentCanvas/canvas/documentElement.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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); -- 2.20.1