summaryrefslogtreecommitdiff
path: root/frontend/delta/js/MochiKit/MockDOM.js
Unidiff
Diffstat (limited to 'frontend/delta/js/MochiKit/MockDOM.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/delta/js/MochiKit/MockDOM.js135
1 files changed, 135 insertions, 0 deletions
diff --git a/frontend/delta/js/MochiKit/MockDOM.js b/frontend/delta/js/MochiKit/MockDOM.js
new file mode 100644
index 0000000..6df7922
--- a/dev/null
+++ b/frontend/delta/js/MochiKit/MockDOM.js
@@ -0,0 +1,135 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24/***
25
26MochiKit.MockDOM 1.5
27
28See <http://mochikit.com/> for documentation, downloads, license, etc.
29
30(c) 2005 Bob Ippolito. All rights Reserved.
31
32***/
33
34var MochiKit = MochiKit || {};
35
36MochiKit.MockDOM = MochiKit.MockDOM || {};
37
38MochiKit.MockDOM.NAME = "MochiKit.MockDOM";
39MochiKit.MockDOM.VERSION = "1.5";
40MochiKit.MockDOM.__export__ = false;
41
42MochiKit.MockDOM.__repr__ = function () {
43 return "[" + this.NAME + " " + this.VERSION + "]";
44};
45
46/** @id MochiKit.MockDOM.toString */
47MochiKit.MockDOM.toString = function () {
48 return this.__repr__();
49};
50
51/** @id MochiKit.MockDOM.createDocument */
52MochiKit.MockDOM.createDocument = function () {
53 var doc = new MochiKit.MockDOM.MockElement("DOCUMENT");
54 doc.body = doc.createElement("BODY");
55 doc.appendChild(doc.body);
56 return doc;
57};
58
59/** @id MochiKit.MockDOM.MockElement */
60MochiKit.MockDOM.MockElement = function (name, data, ownerDocument) {
61 this.tagName = this.nodeName = name.toUpperCase();
62 this.ownerDocument = ownerDocument || null;
63 if (name == "DOCUMENT") {
64 this.nodeType = 9;
65 this.childNodes = [];
66 } else if (typeof(data) == "string") {
67 this.nodeValue = data;
68 this.nodeType = 3;
69 } else {
70 this.nodeType = 1;
71 this.childNodes = [];
72 }
73 if (name.substring(0, 1) == "<") {
74 var nameattr = name.substring(
75 name.indexOf('"') + 1, name.lastIndexOf('"'));
76 name = name.substring(1, name.indexOf(" "));
77 this.tagName = this.nodeName = name.toUpperCase();
78 this.setAttribute("name", nameattr);
79 }
80};
81
82MochiKit.MockDOM.MockElement.prototype = {
83 /** @id MochiKit.MockDOM.MockElement.prototype.createElement */
84 createElement: function (tagName) {
85 return new MochiKit.MockDOM.MockElement(tagName, null, this.nodeType == 9 ? this : this.ownerDocument);
86 },
87 /** @id MochiKit.MockDOM.MockElement.prototype.createTextNode */
88 createTextNode: function (text) {
89 return new MochiKit.MockDOM.MockElement("text", text, this.nodeType == 9 ? this : this.ownerDocument);
90 },
91 /** @id MochiKit.MockDOM.MockElement.prototype.setAttribute */
92 setAttribute: function (name, value) {
93 this[name] = value;
94 },
95 /** @id MochiKit.MockDOM.MockElement.prototype.getAttribute */
96 getAttribute: function (name) {
97 return this[name];
98 },
99 /** @id MochiKit.MockDOM.MockElement.prototype.appendChild */
100 appendChild: function (child) {
101 this.childNodes.push(child);
102 },
103 /** @id MochiKit.MockDOM.MockElement.prototype.toString */
104 toString: function () {
105 return "MockElement(" + this.tagName + ")";
106 },
107 /** @id MochiKit.MockDOM.MockElement.prototype.getElementsByTagName */
108 getElementsByTagName: function (tagName) {
109 var foundElements = [];
110 MochiKit.Base.nodeWalk(this, function(node){
111 if (tagName == '*' || tagName == node.tagName) {
112 foundElements.push(node);
113 return node.childNodes;
114 }
115 });
116 return foundElements;
117 }
118};
119
120 /** @id MochiKit.MockDOM.EXPORT_OK */
121MochiKit.MockDOM.EXPORT_OK = [
122 "mockElement",
123 "createDocument"
124];
125
126 /** @id MochiKit.MockDOM.EXPORT */
127MochiKit.MockDOM.EXPORT = [
128 "document"
129];
130
131MochiKit.MockDOM.__new__ = function () {
132 this.document = this.createDocument();
133};
134
135MochiKit.MockDOM.__new__();