Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1372 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.dom");
13
dojo.provide("dojo.dom");
12
dojo.dom.ELEMENT_NODE = 1;
14
dojo.dom.ELEMENT_NODE = 1;
13
dojo.dom.ATTRIBUTE_NODE = 2;
15
dojo.dom.ATTRIBUTE_NODE = 2;
14
dojo.dom.TEXT_NODE = 3;
16
dojo.dom.TEXT_NODE = 3;
15
dojo.dom.CDATA_SECTION_NODE = 4;
17
dojo.dom.CDATA_SECTION_NODE = 4;
16
dojo.dom.ENTITY_REFERENCE_NODE = 5;
18
dojo.dom.ENTITY_REFERENCE_NODE = 5;
17
dojo.dom.ENTITY_NODE = 6;
19
dojo.dom.ENTITY_NODE = 6;
18
dojo.dom.PROCESSING_INSTRUCTION_NODE = 7;
20
dojo.dom.PROCESSING_INSTRUCTION_NODE = 7;
19
dojo.dom.COMMENT_NODE = 8;
21
dojo.dom.COMMENT_NODE = 8;
20
dojo.dom.DOCUMENT_NODE = 9;
22
dojo.dom.DOCUMENT_NODE = 9;
21
dojo.dom.DOCUMENT_TYPE_NODE = 10;
23
dojo.dom.DOCUMENT_TYPE_NODE = 10;
22
dojo.dom.DOCUMENT_FRAGMENT_NODE = 11;
24
dojo.dom.DOCUMENT_FRAGMENT_NODE = 11;
23
dojo.dom.NOTATION_NODE = 12;
25
dojo.dom.NOTATION_NODE = 12;
24
dojo.dom.dojoml = "http://www.dojotoolkit.org/2004/dojoml";
26
dojo.dom.dojoml = "http://www.dojotoolkit.org/2004/dojoml";
25
dojo.dom.xmlns = {svg:"http://www.w3.org/2000/svg", smil:"http://www.w3.org/2001/SMIL20/", mml:"http://www.w3.org/1998/Math/MathML", cml:"http://www.xml-cml.org", xlink:"http://www.w3.org/1999/xlink", xhtml:"http://www.w3.org/1999/xhtml", xul:"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", xbl:"http://www.mozilla.org/xbl", fo:"http://www.w3.org/1999/XSL/Format", xsl:"http://www.w3.org/1999/XSL/Transform", xslt:"http://www.w3.org/1999/XSL/Transform", xi:"http://www.w3.org/2001/XInclude", xforms:"http://www.w3.org/2002/01/xforms", saxon:"http://icl.com/saxon", xalan:"http://xml.apache.org/xslt", xsd:"http://www.w3.org/2001/XMLSchema", dt:"http://www.w3.org/2001/XMLSchema-datatypes", xsi:"http://www.w3.org/2001/XMLSchema-instance", rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#", rdfs:"http://www.w3.org/2000/01/rdf-schema#", dc:"http://purl.org/dc/elements/1.1/", dcq:"http://purl.org/dc/qualifiers/1.0", "soap-env":"http://schemas.xmlsoap.org/soap/envelope/", wsdl:"http://schemas.xmlsoap.org/wsdl/", AdobeExtensions:"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"};
27
dojo.dom.xmlns = {svg:"http://www.w3.org/2000/svg", smil:"http://www.w3.org/2001/SMIL20/", mml:"http://www.w3.org/1998/Math/MathML", cml:"http://www.xml-cml.org", xlink:"http://www.w3.org/1999/xlink", xhtml:"http://www.w3.org/1999/xhtml", xul:"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", xbl:"http://www.mozilla.org/xbl", fo:"http://www.w3.org/1999/XSL/Format", xsl:"http://www.w3.org/1999/XSL/Transform", xslt:"http://www.w3.org/1999/XSL/Transform", xi:"http://www.w3.org/2001/XInclude", xforms:"http://www.w3.org/2002/01/xforms", saxon:"http://icl.com/saxon", xalan:"http://xml.apache.org/xslt", xsd:"http://www.w3.org/2001/XMLSchema", dt:"http://www.w3.org/2001/XMLSchema-datatypes", xsi:"http://www.w3.org/2001/XMLSchema-instance", rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#", rdfs:"http://www.w3.org/2000/01/rdf-schema#", dc:"http://purl.org/dc/elements/1.1/", dcq:"http://purl.org/dc/qualifiers/1.0", "soap-env":"http://schemas.xmlsoap.org/soap/envelope/", wsdl:"http://schemas.xmlsoap.org/wsdl/", AdobeExtensions:"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"};
26
dojo.dom.isNode = function (wh) {
28
dojo.dom.isNode = function (wh) {
27
	if (typeof Element == "function") {
29
	if (typeof Element == "function") {
28
		try {
30
		try {
29
			return wh instanceof Element;
31
			return wh instanceof Element;
30
		}
32
		}
31
		catch (e) {
33
		catch (e) {
32
		}
34
		}
33
	} else {
35
	} else {
34
		return wh && !isNaN(wh.nodeType);
36
		return wh && !isNaN(wh.nodeType);
35
	}
37
	}
36
};
38
};
37
dojo.dom.getUniqueId = function () {
39
dojo.dom.getUniqueId = function () {
38
	var _document = dojo.doc();
40
	var _document = dojo.doc();
39
	do {
41
	do {
40
		var id = "dj_unique_" + (++arguments.callee._idIncrement);
42
		var id = "dj_unique_" + (++arguments.callee._idIncrement);
41
	} while (_document.getElementById(id));
43
	} while (_document.getElementById(id));
42
	return id;
44
	return id;
43
};
45
};
44
dojo.dom.getUniqueId._idIncrement = 0;
46
dojo.dom.getUniqueId._idIncrement = 0;
45
dojo.dom.firstElement = dojo.dom.getFirstChildElement = function (parentNode, tagName) {
47
dojo.dom.firstElement = dojo.dom.getFirstChildElement = function (parentNode, tagName) {
46
	var node = parentNode.firstChild;
48
	var node = parentNode.firstChild;
47
	while (node && node.nodeType != dojo.dom.ELEMENT_NODE) {
49
	while (node && node.nodeType != dojo.dom.ELEMENT_NODE) {
48
		node = node.nextSibling;
50
		node = node.nextSibling;
49
	}
51
	}
50
	if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
52
	if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
51
		node = dojo.dom.nextElement(node, tagName);
53
		node = dojo.dom.nextElement(node, tagName);
52
	}
54
	}
53
	return node;
55
	return node;
54
};
56
};
55
dojo.dom.lastElement = dojo.dom.getLastChildElement = function (parentNode, tagName) {
57
dojo.dom.lastElement = dojo.dom.getLastChildElement = function (parentNode, tagName) {
56
	var node = parentNode.lastChild;
58
	var node = parentNode.lastChild;
57
	while (node && node.nodeType != dojo.dom.ELEMENT_NODE) {
59
	while (node && node.nodeType != dojo.dom.ELEMENT_NODE) {
58
		node = node.previousSibling;
60
		node = node.previousSibling;
59
	}
61
	}
60
	if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
62
	if (tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
61
		node = dojo.dom.prevElement(node, tagName);
63
		node = dojo.dom.prevElement(node, tagName);
62
	}
64
	}
63
	return node;
65
	return node;
64
};
66
};
65
dojo.dom.nextElement = dojo.dom.getNextSiblingElement = function (node, tagName) {
67
dojo.dom.nextElement = dojo.dom.getNextSiblingElement = function (node, tagName) {
66
	if (!node) {
68
	if (!node) {
67
		return null;
69
		return null;
68
	}
70
	}
69
	do {
71
	do {
70
		node = node.nextSibling;
72
		node = node.nextSibling;
71
	} while (node && node.nodeType != dojo.dom.ELEMENT_NODE);
73
	} while (node && node.nodeType != dojo.dom.ELEMENT_NODE);
72
	if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
74
	if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
73
		return dojo.dom.nextElement(node, tagName);
75
		return dojo.dom.nextElement(node, tagName);
74
	}
76
	}
75
	return node;
77
	return node;
76
};
78
};
77
dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement = function (node, tagName) {
79
dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement = function (node, tagName) {
78
	if (!node) {
80
	if (!node) {
79
		return null;
81
		return null;
80
	}
82
	}
81
	if (tagName) {
83
	if (tagName) {
82
		tagName = tagName.toLowerCase();
84
		tagName = tagName.toLowerCase();
83
	}
85
	}
84
	do {
86
	do {
85
		node = node.previousSibling;
87
		node = node.previousSibling;
86
	} while (node && node.nodeType != dojo.dom.ELEMENT_NODE);
88
	} while (node && node.nodeType != dojo.dom.ELEMENT_NODE);
87
	if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
89
	if (node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
88
		return dojo.dom.prevElement(node, tagName);
90
		return dojo.dom.prevElement(node, tagName);
89
	}
91
	}
90
	return node;
92
	return node;
91
};
93
};
92
dojo.dom.moveChildren = function (srcNode, destNode, trim) {
94
dojo.dom.moveChildren = function (srcNode, destNode, trim) {
93
	var count = 0;
95
	var count = 0;
94
	if (trim) {
96
	if (trim) {
95
		while (srcNode.hasChildNodes() && srcNode.firstChild.nodeType == dojo.dom.TEXT_NODE) {
97
		while (srcNode.hasChildNodes() && srcNode.firstChild.nodeType == dojo.dom.TEXT_NODE) {
96
			srcNode.removeChild(srcNode.firstChild);
98
			srcNode.removeChild(srcNode.firstChild);
97
		}
99
		}
98
		while (srcNode.hasChildNodes() && srcNode.lastChild.nodeType == dojo.dom.TEXT_NODE) {
100
		while (srcNode.hasChildNodes() && srcNode.lastChild.nodeType == dojo.dom.TEXT_NODE) {
99
			srcNode.removeChild(srcNode.lastChild);
101
			srcNode.removeChild(srcNode.lastChild);
100
		}
102
		}
101
	}
103
	}
102
	while (srcNode.hasChildNodes()) {
104
	while (srcNode.hasChildNodes()) {
103
		destNode.appendChild(srcNode.firstChild);
105
		destNode.appendChild(srcNode.firstChild);
104
		count++;
106
		count++;
105
	}
107
	}
106
	return count;
108
	return count;
107
};
109
};
108
dojo.dom.copyChildren = function (srcNode, destNode, trim) {
110
dojo.dom.copyChildren = function (srcNode, destNode, trim) {
109
	var clonedNode = srcNode.cloneNode(true);
111
	var clonedNode = srcNode.cloneNode(true);
110
	return this.moveChildren(clonedNode, destNode, trim);
112
	return this.moveChildren(clonedNode, destNode, trim);
111
};
113
};
112
dojo.dom.replaceChildren = function (node, newChild) {
114
dojo.dom.replaceChildren = function (node, newChild) {
113
	var nodes = [];
115
	var nodes = [];
114
	if (dojo.render.html.ie) {
116
	if (dojo.render.html.ie) {
115
		for (var i = 0; i < node.childNodes.length; i++) {
117
		for (var i = 0; i < node.childNodes.length; i++) {
116
			nodes.push(node.childNodes[i]);
118
			nodes.push(node.childNodes[i]);
117
		}
119
		}
118
	}
120
	}
119
	dojo.dom.removeChildren(node);
121
	dojo.dom.removeChildren(node);
120
	node.appendChild(newChild);
122
	node.appendChild(newChild);
121
	for (var i = 0; i < nodes.length; i++) {
123
	for (var i = 0; i < nodes.length; i++) {
122
		dojo.dom.destroyNode(nodes[i]);
124
		dojo.dom.destroyNode(nodes[i]);
123
	}
125
	}
124
};
126
};
125
dojo.dom.removeChildren = function (node) {
127
dojo.dom.removeChildren = function (node) {
126
	var count = node.childNodes.length;
128
	var count = node.childNodes.length;
127
	while (node.hasChildNodes()) {
129
	while (node.hasChildNodes()) {
128
		dojo.dom.removeNode(node.firstChild);
130
		dojo.dom.removeNode(node.firstChild);
129
	}
131
	}
130
	return count;
132
	return count;
131
};
133
};
132
dojo.dom.replaceNode = function (node, newNode) {
134
dojo.dom.replaceNode = function (node, newNode) {
133
	return node.parentNode.replaceChild(newNode, node);
135
	return node.parentNode.replaceChild(newNode, node);
134
};
136
};
135
dojo.dom.destroyNode = function (node) {
137
dojo.dom.destroyNode = function (node) {
136
	if (node.parentNode) {
138
	if (node.parentNode) {
137
		node = dojo.dom.removeNode(node);
139
		node = dojo.dom.removeNode(node);
138
	}
140
	}
139
	if (node.nodeType != 3) {
141
	if (node.nodeType != 3) {
140
		if (dojo.evalObjPath("dojo.event.browser.clean", false)) {
142
		if (dojo.evalObjPath("dojo.event.browser.clean", false)) {
141
			dojo.event.browser.clean(node);
143
			dojo.event.browser.clean(node);
142
		}
144
		}
143
		if (dojo.render.html.ie) {
145
		if (dojo.render.html.ie) {
144
			node.outerHTML = "";
146
			node.outerHTML = "";
145
		}
147
		}
146
	}
148
	}
147
};
149
};
148
dojo.dom.removeNode = function (node) {
150
dojo.dom.removeNode = function (node) {
149
	if (node && node.parentNode) {
151
	if (node && node.parentNode) {
150
		return node.parentNode.removeChild(node);
152
		return node.parentNode.removeChild(node);
151
	}
153
	}
152
};
154
};
153
dojo.dom.getAncestors = function (node, filterFunction, returnFirstHit) {
155
dojo.dom.getAncestors = function (node, filterFunction, returnFirstHit) {
154
	var ancestors = [];
156
	var ancestors = [];
155
	var isFunction = (filterFunction && (filterFunction instanceof Function || typeof filterFunction == "function"));
157
	var isFunction = (filterFunction && (filterFunction instanceof Function || typeof filterFunction == "function"));
156
	while (node) {
158
	while (node) {
157
		if (!isFunction || filterFunction(node)) {
159
		if (!isFunction || filterFunction(node)) {
158
			ancestors.push(node);
160
			ancestors.push(node);
159
		}
161
		}
160
		if (returnFirstHit && ancestors.length > 0) {
162
		if (returnFirstHit && ancestors.length > 0) {
161
			return ancestors[0];
163
			return ancestors[0];
162
		}
164
		}
163
		node = node.parentNode;
165
		node = node.parentNode;
164
	}
166
	}
165
	if (returnFirstHit) {
167
	if (returnFirstHit) {
166
		return null;
168
		return null;
167
	}
169
	}
168
	return ancestors;
170
	return ancestors;
169
};
171
};
170
dojo.dom.getAncestorsByTag = function (node, tag, returnFirstHit) {
172
dojo.dom.getAncestorsByTag = function (node, tag, returnFirstHit) {
171
	tag = tag.toLowerCase();
173
	tag = tag.toLowerCase();
172
	return dojo.dom.getAncestors(node, function (el) {
174
	return dojo.dom.getAncestors(node, function (el) {
173
		return ((el.tagName) && (el.tagName.toLowerCase() == tag));
175
		return ((el.tagName) && (el.tagName.toLowerCase() == tag));
174
	}, returnFirstHit);
176
	}, returnFirstHit);
175
};
177
};
176
dojo.dom.getFirstAncestorByTag = function (node, tag) {
178
dojo.dom.getFirstAncestorByTag = function (node, tag) {
177
	return dojo.dom.getAncestorsByTag(node, tag, true);
179
	return dojo.dom.getAncestorsByTag(node, tag, true);
178
};
180
};
179
dojo.dom.isDescendantOf = function (node, ancestor, guaranteeDescendant) {
181
dojo.dom.isDescendantOf = function (node, ancestor, guaranteeDescendant) {
180
	if (guaranteeDescendant && node) {
182
	if (guaranteeDescendant && node) {
181
		node = node.parentNode;
183
		node = node.parentNode;
182
	}
184
	}
183
	while (node) {
185
	while (node) {
184
		if (node == ancestor) {
186
		if (node == ancestor) {
185
			return true;
187
			return true;
186
		}
188
		}
187
		node = node.parentNode;
189
		node = node.parentNode;
188
	}
190
	}
189
	return false;
191
	return false;
190
};
192
};
191
dojo.dom.innerXML = function (node) {
193
dojo.dom.innerXML = function (node) {
192
	if (node.innerXML) {
194
	if (node.innerXML) {
193
		return node.innerXML;
195
		return node.innerXML;
194
	} else {
196
	} else {
195
		if (node.xml) {
197
		if (node.xml) {
196
			return node.xml;
198
			return node.xml;
197
		} else {
199
		} else {
198
			if (typeof XMLSerializer != "undefined") {
200
			if (typeof XMLSerializer != "undefined") {
199
				return (new XMLSerializer()).serializeToString(node);
201
				return (new XMLSerializer()).serializeToString(node);
200
			}
202
			}
201
		}
203
		}
202
	}
204
	}
203
};
205
};
204
dojo.dom.createDocument = function () {
206
dojo.dom.createDocument = function () {
205
	var doc = null;
207
	var doc = null;
206
	var _document = dojo.doc();
208
	var _document = dojo.doc();
207
	if (!dj_undef("ActiveXObject")) {
209
	if (!dj_undef("ActiveXObject")) {
208
		var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
210
		var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
209
		for (var i = 0; i < prefixes.length; i++) {
211
		for (var i = 0; i < prefixes.length; i++) {
210
			try {
212
			try {
211
				doc = new ActiveXObject(prefixes[i] + ".XMLDOM");
213
				doc = new ActiveXObject(prefixes[i] + ".XMLDOM");
212
			}
214
			}
213
			catch (e) {
215
			catch (e) {
214
			}
216
			}
215
			if (doc) {
217
			if (doc) {
216
				break;
218
				break;
217
			}
219
			}
218
		}
220
		}
219
	} else {
221
	} else {
220
		if ((_document.implementation) && (_document.implementation.createDocument)) {
222
		if ((_document.implementation) && (_document.implementation.createDocument)) {
221
			doc = _document.implementation.createDocument("", "", null);
223
			doc = _document.implementation.createDocument("", "", null);
222
		}
224
		}
223
	}
225
	}
224
	return doc;
226
	return doc;
225
};
227
};
226
dojo.dom.createDocumentFromText = function (str, mimetype) {
228
dojo.dom.createDocumentFromText = function (str, mimetype) {
227
	if (!mimetype) {
229
	if (!mimetype) {
228
		mimetype = "text/xml";
230
		mimetype = "text/xml";
229
	}
231
	}
230
	if (!dj_undef("DOMParser")) {
232
	if (!dj_undef("DOMParser")) {
231
		var parser = new DOMParser();
233
		var parser = new DOMParser();
232
		return parser.parseFromString(str, mimetype);
234
		return parser.parseFromString(str, mimetype);
233
	} else {
235
	} else {
234
		if (!dj_undef("ActiveXObject")) {
236
		if (!dj_undef("ActiveXObject")) {
235
			var domDoc = dojo.dom.createDocument();
237
			var domDoc = dojo.dom.createDocument();
236
			if (domDoc) {
238
			if (domDoc) {
237
				domDoc.async = false;
239
				domDoc.async = false;
238
				domDoc.loadXML(str);
240
				domDoc.loadXML(str);
239
				return domDoc;
241
				return domDoc;
240
			} else {
242
			} else {
241
				dojo.debug("toXml didn't work?");
243
				dojo.debug("toXml didn't work?");
242
			}
244
			}
243
		} else {
245
		} else {
244
			var _document = dojo.doc();
246
			var _document = dojo.doc();
245
			if (_document.createElement) {
247
			if (_document.createElement) {
246
				var tmp = _document.createElement("xml");
248
				var tmp = _document.createElement("xml");
247
				tmp.innerHTML = str;
249
				tmp.innerHTML = str;
248
				if (_document.implementation && _document.implementation.createDocument) {
250
				if (_document.implementation && _document.implementation.createDocument) {
249
					var xmlDoc = _document.implementation.createDocument("foo", "", null);
251
					var xmlDoc = _document.implementation.createDocument("foo", "", null);
250
					for (var i = 0; i < tmp.childNodes.length; i++) {
252
					for (var i = 0; i < tmp.childNodes.length; i++) {
251
						xmlDoc.importNode(tmp.childNodes.item(i), true);
253
						xmlDoc.importNode(tmp.childNodes.item(i), true);
252
					}
254
					}
253
					return xmlDoc;
255
					return xmlDoc;
254
				}
256
				}
255
				return ((tmp.document) && (tmp.document.firstChild ? tmp.document.firstChild : tmp));
257
				return ((tmp.document) && (tmp.document.firstChild ? tmp.document.firstChild : tmp));
256
			}
258
			}
257
		}
259
		}
258
	}
260
	}
259
	return null;
261
	return null;
260
};
262
};
261
dojo.dom.prependChild = function (node, parent) {
263
dojo.dom.prependChild = function (node, parent) {
262
	if (parent.firstChild) {
264
	if (parent.firstChild) {
263
		parent.insertBefore(node, parent.firstChild);
265
		parent.insertBefore(node, parent.firstChild);
264
	} else {
266
	} else {
265
		parent.appendChild(node);
267
		parent.appendChild(node);
266
	}
268
	}
267
	return true;
269
	return true;
268
};
270
};
269
dojo.dom.insertBefore = function (node, ref, force) {
271
dojo.dom.insertBefore = function (node, ref, force) {
270
	if ((force != true) && (node === ref || node.nextSibling === ref)) {
272
	if ((force != true) && (node === ref || node.nextSibling === ref)) {
271
		return false;
273
		return false;
272
	}
274
	}
273
	var parent = ref.parentNode;
275
	var parent = ref.parentNode;
274
	parent.insertBefore(node, ref);
276
	parent.insertBefore(node, ref);
275
	return true;
277
	return true;
276
};
278
};
277
dojo.dom.insertAfter = function (node, ref, force) {
279
dojo.dom.insertAfter = function (node, ref, force) {
278
	var pn = ref.parentNode;
280
	var pn = ref.parentNode;
279
	if (ref == pn.lastChild) {
281
	if (ref == pn.lastChild) {
280
		if ((force != true) && (node === ref)) {
282
		if ((force != true) && (node === ref)) {
281
			return false;
283
			return false;
282
		}
284
		}
283
		pn.appendChild(node);
285
		pn.appendChild(node);
284
	} else {
286
	} else {
285
		return this.insertBefore(node, ref.nextSibling, force);
287
		return this.insertBefore(node, ref.nextSibling, force);
286
	}
288
	}
287
	return true;
289
	return true;
288
};
290
};
289
dojo.dom.insertAtPosition = function (node, ref, position) {
291
dojo.dom.insertAtPosition = function (node, ref, position) {
290
	if ((!node) || (!ref) || (!position)) {
292
	if ((!node) || (!ref) || (!position)) {
291
		return false;
293
		return false;
292
	}
294
	}
293
	switch (position.toLowerCase()) {
295
	switch (position.toLowerCase()) {
294
	  case "before":
296
	  case "before":
295
		return dojo.dom.insertBefore(node, ref);
297
		return dojo.dom.insertBefore(node, ref);
296
	  case "after":
298
	  case "after":
297
		return dojo.dom.insertAfter(node, ref);
299
		return dojo.dom.insertAfter(node, ref);
298
	  case "first":
300
	  case "first":
299
		if (ref.firstChild) {
301
		if (ref.firstChild) {
300
			return dojo.dom.insertBefore(node, ref.firstChild);
302
			return dojo.dom.insertBefore(node, ref.firstChild);
301
		} else {
303
		} else {
302
			ref.appendChild(node);
304
			ref.appendChild(node);
303
			return true;
305
			return true;
304
		}
306
		}
305
		break;
307
		break;
306
	  default:
308
	  default:
307
		ref.appendChild(node);
309
		ref.appendChild(node);
308
		return true;
310
		return true;
309
	}
311
	}
310
};
312
};
311
dojo.dom.insertAtIndex = function (node, containingNode, insertionIndex) {
313
dojo.dom.insertAtIndex = function (node, containingNode, insertionIndex) {
312
	var siblingNodes = containingNode.childNodes;
314
	var siblingNodes = containingNode.childNodes;
313
	if (!siblingNodes.length || siblingNodes.length == insertionIndex) {
315
	if (!siblingNodes.length || siblingNodes.length == insertionIndex) {
314
		containingNode.appendChild(node);
316
		containingNode.appendChild(node);
315
		return true;
317
		return true;
316
	}
318
	}
317
	if (insertionIndex == 0) {
319
	if (insertionIndex == 0) {
318
		return dojo.dom.prependChild(node, containingNode);
320
		return dojo.dom.prependChild(node, containingNode);
319
	}
321
	}
320
	return dojo.dom.insertAfter(node, siblingNodes[insertionIndex - 1]);
322
	return dojo.dom.insertAfter(node, siblingNodes[insertionIndex - 1]);
321
};
323
};
322
dojo.dom.textContent = function (node, text) {
324
dojo.dom.textContent = function (node, text) {
323
	if (arguments.length > 1) {
325
	if (arguments.length > 1) {
324
		var _document = dojo.doc();
326
		var _document = dojo.doc();
325
		dojo.dom.replaceChildren(node, _document.createTextNode(text));
327
		dojo.dom.replaceChildren(node, _document.createTextNode(text));
326
		return text;
328
		return text;
327
	} else {
329
	} else {
328
		if (node.textContent != undefined) {
330
		if (node.textContent != undefined) {
329
			return node.textContent;
331
			return node.textContent;
330
		}
332
		}
331
		var _result = "";
333
		var _result = "";
332
		if (node == null) {
334
		if (node == null) {
333
			return _result;
335
			return _result;
334
		}
336
		}
335
		for (var i = 0; i < node.childNodes.length; i++) {
337
		for (var i = 0; i < node.childNodes.length; i++) {
336
			switch (node.childNodes[i].nodeType) {
338
			switch (node.childNodes[i].nodeType) {
337
			  case 1:
339
			  case 1:
338
			  case 5:
340
			  case 5:
339
				_result += dojo.dom.textContent(node.childNodes[i]);
341
				_result += dojo.dom.textContent(node.childNodes[i]);
340
				break;
342
				break;
341
			  case 3:
343
			  case 3:
342
			  case 2:
344
			  case 2:
343
			  case 4:
345
			  case 4:
344
				_result += node.childNodes[i].nodeValue;
346
				_result += node.childNodes[i].nodeValue;
345
				break;
347
				break;
346
			  default:
348
			  default:
347
				break;
349
				break;
348
			}
350
			}
349
		}
351
		}
350
		return _result;
352
		return _result;
351
	}
353
	}
352
};
354
};
353
dojo.dom.hasParent = function (node) {
355
dojo.dom.hasParent = function (node) {
354
	return Boolean(node && node.parentNode && dojo.dom.isNode(node.parentNode));
356
	return Boolean(node && node.parentNode && dojo.dom.isNode(node.parentNode));
355
};
357
};
356
dojo.dom.isTag = function (node) {
358
dojo.dom.isTag = function (node) {
357
	if (node && node.tagName) {
359
	if (node && node.tagName) {
358
		for (var i = 1; i < arguments.length; i++) {
360
		for (var i = 1; i < arguments.length; i++) {
359
			if (node.tagName == String(arguments[i])) {
361
			if (node.tagName == String(arguments[i])) {
360
				return String(arguments[i]);
362
				return String(arguments[i]);
361
			}
363
			}
362
		}
364
		}
363
	}
365
	}
364
	return "";
366
	return "";
365
};
367
};
366
dojo.dom.setAttributeNS = function (elem, namespaceURI, attrName, attrValue) {
368
dojo.dom.setAttributeNS = function (elem, namespaceURI, attrName, attrValue) {
367
	if (elem == null || ((elem == undefined) && (typeof elem == "undefined"))) {
369
	if (elem == null || ((elem == undefined) && (typeof elem == "undefined"))) {
368
		dojo.raise("No element given to dojo.dom.setAttributeNS");
370
		dojo.raise("No element given to dojo.dom.setAttributeNS");
369
	}
371
	}
370
	if (!((elem.setAttributeNS == undefined) && (typeof elem.setAttributeNS == "undefined"))) {
372
	if (!((elem.setAttributeNS == undefined) && (typeof elem.setAttributeNS == "undefined"))) {
371
		elem.setAttributeNS(namespaceURI, attrName, attrValue);
373
		elem.setAttributeNS(namespaceURI, attrName, attrValue);
372
	} else {
374
	} else {
373
		var ownerDoc = elem.ownerDocument;
375
		var ownerDoc = elem.ownerDocument;
374
		var attribute = ownerDoc.createNode(2, attrName, namespaceURI);
376
		var attribute = ownerDoc.createNode(2, attrName, namespaceURI);
375
		attribute.nodeValue = attrValue;
377
		attribute.nodeValue = attrValue;
376
		elem.setAttributeNode(attribute);
378
		elem.setAttributeNode(attribute);
377
	}
379
	}
378
};
380
};
379
 
381