2 'libs/jquery-1.9.1.min'
7 // DocumentElement represents a node from WLXML document rendered inside Canvas
8 var DocumentElement = function(htmlElement) {
9 if(arguments.length === 0)
11 this.$element = $(htmlElement);
12 this.wlxmlTag = this.$element.prop('tagName');
15 $.extend(DocumentElement.prototype, {
16 children: function() {
18 if(this instanceof DocumentTextElement)
22 var elementContent = this.$element.contents();
23 elementContent.each(function(idx) {
24 var element = documentElementFromHTMLElement(this);
25 if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && $.trim($(this).text()) === '')
27 if(idx > 0 && element instanceof DocumentTextElement) {
28 if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '')
37 var DocumentNodeElement = function(htmlElement) {
38 DocumentElement.call(this, htmlElement);
41 var DocumentTextElement = function(htmlElement) {
42 DocumentElement.call(this, htmlElement);
45 DocumentNodeElement.prototype = new DocumentElement();
46 DocumentTextElement.prototype = new DocumentElement();
48 var documentElementFromHTMLElement = function(htmlElement) {
49 if(htmlElement.nodeType === Node.ELEMENT_NODE)
50 return new DocumentNodeElement(htmlElement);
51 if(htmlElement.nodeType === Node.TEXT_NODE)
52 return new DocumentTextElement(htmlElement);
56 wrap: function(htmlElement) {
57 return documentElementFromHTMLElement(htmlElement);
59 DocumentElement: DocumentElement,
60 DocumentNodeElement: DocumentNodeElement,
61 DocumentTextElement: DocumentTextElement