this.reloadRoot();
},
+ createElement: function(wlxmlNode) {
+ var Factory = wlxmlNode.nodeType === Node.TEXT_NODE ? documentElement.DocumentTextElement : documentElement.DocumentNodeElement;
+ return Factory.create(wlxmlNode, this);
+ },
+
reloadRoot: function() {
var canvasDOM = this.generateCanvasDOM(this.wlxmlDocument.root);
//var canvasDOM = this.wlxmlDocument.root.getData('canvasElement') ? this.wlxmlDocument.root.getData('canvasElement').dom() : this.generateCanvasDOM(this.wlxmlDocument.root);
};
-var elementTypeFromWlxmlNode = function(wlxmlNode) {
- return wlxmlNode.nodeType === Node.TEXT_NODE ? DocumentTextElement : DocumentNodeElement;
-};
-
$.extend(DocumentElement, {
- create: function(node, canvas) {
- return elementTypeFromWlxmlNode(node).create(node, canvas);
- },
-
fromHTMLElement: function(htmlElement, canvas) {
var $element = $(htmlElement);
if(htmlElement.nodeType === Node.ELEMENT_NODE && $element.attr('document-node-element') !== undefined) {
element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()});
wlxmlNode.contents().forEach(function(node) {
- container.append(DocumentElement.create(node, canvas).dom());
+ container.append(canvas.createElement(node).dom());
}.bind(this));
return element;
if(params instanceof DocumentElement) {
element = params;
} else {
- element = DocumentElement.create(params);
+ element = e.canvas.createElement(params);
}
var target = (action === 'append' || action === 'prepend') ? e._container() : e.dom();
target[action](element.dom());
if(params instanceof DocumentNodeElement) {
element = params;
} else {
- element = DocumentElement.create(params, this.canvas);
+ element = this.canvas.createElement(params);
}
this.dom().wrap('<div>');
this.dom().parent().after(element.dom());
if(params instanceof DocumentNodeElement) {
element = params;
} else {
- element = DocumentNodeElement.create(params, this.canvas);
+ element = this.canvas.createElement(params, this.canvas);
}
this.dom().wrap('<div>');
this.dom().parent().before(element.dom());