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.widget.DomWidget");
13
dojo.provide("dojo.widget.DomWidget");
12
dojo.require("dojo.event.*");
14
dojo.require("dojo.event.*");
13
dojo.require("dojo.widget.Widget");
15
dojo.require("dojo.widget.Widget");
14
dojo.require("dojo.dom");
16
dojo.require("dojo.dom");
15
dojo.require("dojo.html.style");
17
dojo.require("dojo.html.style");
16
dojo.require("dojo.xml.Parse");
18
dojo.require("dojo.xml.Parse");
17
dojo.require("dojo.uri.*");
19
dojo.require("dojo.uri.*");
18
dojo.require("dojo.lang.func");
20
dojo.require("dojo.lang.func");
19
dojo.require("dojo.lang.extras");
21
dojo.require("dojo.lang.extras");
20
dojo.widget._cssFiles = {};
22
dojo.widget._cssFiles = {};
21
dojo.widget._cssStrings = {};
23
dojo.widget._cssStrings = {};
22
dojo.widget._templateCache = {};
24
dojo.widget._templateCache = {};
23
dojo.widget.defaultStrings = {dojoRoot:dojo.hostenv.getBaseScriptUri(), dojoWidgetModuleUri:dojo.uri.moduleUri("dojo.widget"), baseScriptUri:dojo.hostenv.getBaseScriptUri()};
25
dojo.widget.defaultStrings = {dojoRoot:dojo.hostenv.getBaseScriptUri(), dojoWidgetModuleUri:dojo.uri.moduleUri("dojo.widget"), baseScriptUri:dojo.hostenv.getBaseScriptUri()};
24
dojo.widget.fillFromTemplateCache = function (obj, templatePath, templateString, avoidCache) {
26
dojo.widget.fillFromTemplateCache = function (obj, templatePath, templateString, avoidCache) {
25
	var tpath = templatePath || obj.templatePath;
27
	var tpath = templatePath || obj.templatePath;
26
	var tmplts = dojo.widget._templateCache;
28
	var tmplts = dojo.widget._templateCache;
27
	if (!tpath && !obj["widgetType"]) {
29
	if (!tpath && !obj["widgetType"]) {
28
		do {
30
		do {
29
			var dummyName = "__dummyTemplate__" + dojo.widget._templateCache.dummyCount++;
31
			var dummyName = "__dummyTemplate__" + dojo.widget._templateCache.dummyCount++;
30
		} while (tmplts[dummyName]);
32
		} while (tmplts[dummyName]);
31
		obj.widgetType = dummyName;
33
		obj.widgetType = dummyName;
32
	}
34
	}
33
	var wt = tpath ? tpath.toString() : obj.widgetType;
35
	var wt = tpath ? tpath.toString() : obj.widgetType;
34
	var ts = tmplts[wt];
36
	var ts = tmplts[wt];
35
	if (!ts) {
37
	if (!ts) {
36
		tmplts[wt] = {"string":null, "node":null};
38
		tmplts[wt] = {"string":null, "node":null};
37
		if (avoidCache) {
39
		if (avoidCache) {
38
			ts = {};
40
			ts = {};
39
		} else {
41
		} else {
40
			ts = tmplts[wt];
42
			ts = tmplts[wt];
41
		}
43
		}
42
	}
44
	}
43
	if ((!obj.templateString) && (!avoidCache)) {
45
	if ((!obj.templateString) && (!avoidCache)) {
44
		obj.templateString = templateString || ts["string"];
46
		obj.templateString = templateString || ts["string"];
45
	}
47
	}
46
	if (obj.templateString) {
48
	if (obj.templateString) {
47
		obj.templateString = this._sanitizeTemplateString(obj.templateString);
49
		obj.templateString = this._sanitizeTemplateString(obj.templateString);
48
	}
50
	}
49
	if ((!obj.templateNode) && (!avoidCache)) {
51
	if ((!obj.templateNode) && (!avoidCache)) {
50
		obj.templateNode = ts["node"];
52
		obj.templateNode = ts["node"];
51
	}
53
	}
52
	if ((!obj.templateNode) && (!obj.templateString) && (tpath)) {
54
	if ((!obj.templateNode) && (!obj.templateString) && (tpath)) {
53
		var tstring = this._sanitizeTemplateString(dojo.hostenv.getText(tpath));
55
		var tstring = this._sanitizeTemplateString(dojo.hostenv.getText(tpath));
54
		obj.templateString = tstring;
56
		obj.templateString = tstring;
55
		if (!avoidCache) {
57
		if (!avoidCache) {
56
			tmplts[wt]["string"] = tstring;
58
			tmplts[wt]["string"] = tstring;
57
		}
59
		}
58
	}
60
	}
59
	if ((!ts["string"]) && (!avoidCache)) {
61
	if ((!ts["string"]) && (!avoidCache)) {
60
		ts.string = obj.templateString;
62
		ts.string = obj.templateString;
61
	}
63
	}
62
};
64
};
63
dojo.widget._sanitizeTemplateString = function (tString) {
65
dojo.widget._sanitizeTemplateString = function (tString) {
64
	if (tString) {
66
	if (tString) {
65
		tString = tString.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, "");
67
		tString = tString.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, "");
66
		var matches = tString.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
68
		var matches = tString.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
67
		if (matches) {
69
		if (matches) {
68
			tString = matches[1];
70
			tString = matches[1];
69
		}
71
		}
70
	} else {
72
	} else {
71
		tString = "";
73
		tString = "";
72
	}
74
	}
73
	return tString;
75
	return tString;
74
};
76
};
75
dojo.widget._templateCache.dummyCount = 0;
77
dojo.widget._templateCache.dummyCount = 0;
76
dojo.widget.attachProperties = ["dojoAttachPoint", "id"];
78
dojo.widget.attachProperties = ["dojoAttachPoint", "id"];
77
dojo.widget.eventAttachProperty = "dojoAttachEvent";
79
dojo.widget.eventAttachProperty = "dojoAttachEvent";
78
dojo.widget.onBuildProperty = "dojoOnBuild";
80
dojo.widget.onBuildProperty = "dojoOnBuild";
79
dojo.widget.waiNames = ["waiRole", "waiState"];
81
dojo.widget.waiNames = ["waiRole", "waiState"];
80
dojo.widget.wai = {waiRole:{name:"waiRole", "namespace":"http://www.w3.org/TR/xhtml2", alias:"x2", prefix:"wairole:"}, waiState:{name:"waiState", "namespace":"http://www.w3.org/2005/07/aaa", alias:"aaa", prefix:""}, setAttr:function (node, ns, attr, value) {
82
dojo.widget.wai = {waiRole:{name:"waiRole", "namespace":"http://www.w3.org/TR/xhtml2", alias:"x2", prefix:"wairole:"}, waiState:{name:"waiState", "namespace":"http://www.w3.org/2005/07/aaa", alias:"aaa", prefix:""}, setAttr:function (node, ns, attr, value) {
81
	if (dojo.render.html.ie) {
83
	if (dojo.render.html.ie) {
82
		node.setAttribute(this[ns].alias + ":" + attr, this[ns].prefix + value);
84
		node.setAttribute(this[ns].alias + ":" + attr, this[ns].prefix + value);
83
	} else {
85
	} else {
84
		node.setAttributeNS(this[ns]["namespace"], attr, this[ns].prefix + value);
86
		node.setAttributeNS(this[ns]["namespace"], attr, this[ns].prefix + value);
85
	}
87
	}
86
}, getAttr:function (node, ns, attr) {
88
}, getAttr:function (node, ns, attr) {
87
	if (dojo.render.html.ie) {
89
	if (dojo.render.html.ie) {
88
		return node.getAttribute(this[ns].alias + ":" + attr);
90
		return node.getAttribute(this[ns].alias + ":" + attr);
89
	} else {
91
	} else {
90
		return node.getAttributeNS(this[ns]["namespace"], attr);
92
		return node.getAttributeNS(this[ns]["namespace"], attr);
91
	}
93
	}
92
}, removeAttr:function (node, ns, attr) {
94
}, removeAttr:function (node, ns, attr) {
93
	var success = true;
95
	var success = true;
94
	if (dojo.render.html.ie) {
96
	if (dojo.render.html.ie) {
95
		success = node.removeAttribute(this[ns].alias + ":" + attr);
97
		success = node.removeAttribute(this[ns].alias + ":" + attr);
96
	} else {
98
	} else {
97
		node.removeAttributeNS(this[ns]["namespace"], attr);
99
		node.removeAttributeNS(this[ns]["namespace"], attr);
98
	}
100
	}
99
	return success;
101
	return success;
100
}};
102
}};
101
dojo.widget.attachTemplateNodes = function (rootNode, targetObj, events) {
103
dojo.widget.attachTemplateNodes = function (rootNode, targetObj, events) {
102
	var elementNodeType = dojo.dom.ELEMENT_NODE;
104
	var elementNodeType = dojo.dom.ELEMENT_NODE;
103
	function trim(str) {
105
	function trim(str) {
104
		return str.replace(/^\s+|\s+$/g, "");
106
		return str.replace(/^\s+|\s+$/g, "");
105
	}
107
	}
106
	if (!rootNode) {
108
	if (!rootNode) {
107
		rootNode = targetObj.domNode;
109
		rootNode = targetObj.domNode;
108
	}
110
	}
109
	if (rootNode.nodeType != elementNodeType) {
111
	if (rootNode.nodeType != elementNodeType) {
110
		return;
112
		return;
111
	}
113
	}
112
	var nodes = rootNode.all || rootNode.getElementsByTagName("*");
114
	var nodes = rootNode.all || rootNode.getElementsByTagName("*");
113
	var _this = targetObj;
115
	var _this = targetObj;
114
	for (var x = -1; x < nodes.length; x++) {
116
	for (var x = -1; x < nodes.length; x++) {
115
		var baseNode = (x == -1) ? rootNode : nodes[x];
117
		var baseNode = (x == -1) ? rootNode : nodes[x];
116
		var attachPoint = [];
118
		var attachPoint = [];
117
		if (!targetObj.widgetsInTemplate || !baseNode.getAttribute("dojoType")) {
119
		if (!targetObj.widgetsInTemplate || !baseNode.getAttribute("dojoType")) {
118
			for (var y = 0; y < this.attachProperties.length; y++) {
120
			for (var y = 0; y < this.attachProperties.length; y++) {
119
				var tmpAttachPoint = baseNode.getAttribute(this.attachProperties[y]);
121
				var tmpAttachPoint = baseNode.getAttribute(this.attachProperties[y]);
120
				if (tmpAttachPoint) {
122
				if (tmpAttachPoint) {
121
					attachPoint = tmpAttachPoint.split(";");
123
					attachPoint = tmpAttachPoint.split(";");
122
					for (var z = 0; z < attachPoint.length; z++) {
124
					for (var z = 0; z < attachPoint.length; z++) {
123
						if (dojo.lang.isArray(targetObj[attachPoint[z]])) {
125
						if (dojo.lang.isArray(targetObj[attachPoint[z]])) {
124
							targetObj[attachPoint[z]].push(baseNode);
126
							targetObj[attachPoint[z]].push(baseNode);
125
						} else {
127
						} else {
126
							targetObj[attachPoint[z]] = baseNode;
128
							targetObj[attachPoint[z]] = baseNode;
127
						}
129
						}
128
					}
130
					}
129
					break;
131
					break;
130
				}
132
				}
131
			}
133
			}
132
			var attachEvent = baseNode.getAttribute(this.eventAttachProperty);
134
			var attachEvent = baseNode.getAttribute(this.eventAttachProperty);
133
			if (attachEvent) {
135
			if (attachEvent) {
134
				var evts = attachEvent.split(";");
136
				var evts = attachEvent.split(";");
135
				for (var y = 0; y < evts.length; y++) {
137
				for (var y = 0; y < evts.length; y++) {
136
					if ((!evts[y]) || (!evts[y].length)) {
138
					if ((!evts[y]) || (!evts[y].length)) {
137
						continue;
139
						continue;
138
					}
140
					}
139
					var thisFunc = null;
141
					var thisFunc = null;
140
					var tevt = trim(evts[y]);
142
					var tevt = trim(evts[y]);
141
					if (evts[y].indexOf(":") >= 0) {
143
					if (evts[y].indexOf(":") >= 0) {
142
						var funcNameArr = tevt.split(":");
144
						var funcNameArr = tevt.split(":");
143
						tevt = trim(funcNameArr[0]);
145
						tevt = trim(funcNameArr[0]);
144
						thisFunc = trim(funcNameArr[1]);
146
						thisFunc = trim(funcNameArr[1]);
145
					}
147
					}
146
					if (!thisFunc) {
148
					if (!thisFunc) {
147
						thisFunc = tevt;
149
						thisFunc = tevt;
148
					}
150
					}
149
					var tf = function () {
151
					var tf = function () {
150
						var ntf = new String(thisFunc);
152
						var ntf = new String(thisFunc);
151
						return function (evt) {
153
						return function (evt) {
152
							if (_this[ntf]) {
154
							if (_this[ntf]) {
153
								_this[ntf](dojo.event.browser.fixEvent(evt, this));
155
								_this[ntf](dojo.event.browser.fixEvent(evt, this));
154
							}
156
							}
155
						};
157
						};
156
					}();
158
					}();
157
					dojo.event.browser.addListener(baseNode, tevt, tf, false, true);
159
					dojo.event.browser.addListener(baseNode, tevt, tf, false, true);
158
				}
160
				}
159
			}
161
			}
160
			for (var y = 0; y < events.length; y++) {
162
			for (var y = 0; y < events.length; y++) {
161
				var evtVal = baseNode.getAttribute(events[y]);
163
				var evtVal = baseNode.getAttribute(events[y]);
162
				if ((evtVal) && (evtVal.length)) {
164
				if ((evtVal) && (evtVal.length)) {
163
					var thisFunc = null;
165
					var thisFunc = null;
164
					var domEvt = events[y].substr(4);
166
					var domEvt = events[y].substr(4);
165
					thisFunc = trim(evtVal);
167
					thisFunc = trim(evtVal);
166
					var funcs = [thisFunc];
168
					var funcs = [thisFunc];
167
					if (thisFunc.indexOf(";") >= 0) {
169
					if (thisFunc.indexOf(";") >= 0) {
168
						funcs = dojo.lang.map(thisFunc.split(";"), trim);
170
						funcs = dojo.lang.map(thisFunc.split(";"), trim);
169
					}
171
					}
170
					for (var z = 0; z < funcs.length; z++) {
172
					for (var z = 0; z < funcs.length; z++) {
171
						if (!funcs[z].length) {
173
						if (!funcs[z].length) {
172
							continue;
174
							continue;
173
						}
175
						}
174
						var tf = function () {
176
						var tf = function () {
175
							var ntf = new String(funcs[z]);
177
							var ntf = new String(funcs[z]);
176
							return function (evt) {
178
							return function (evt) {
177
								if (_this[ntf]) {
179
								if (_this[ntf]) {
178
									_this[ntf](dojo.event.browser.fixEvent(evt, this));
180
									_this[ntf](dojo.event.browser.fixEvent(evt, this));
179
								}
181
								}
180
							};
182
							};
181
						}();
183
						}();
182
						dojo.event.browser.addListener(baseNode, domEvt, tf, false, true);
184
						dojo.event.browser.addListener(baseNode, domEvt, tf, false, true);
183
					}
185
					}
184
				}
186
				}
185
			}
187
			}
186
		}
188
		}
187
		var tmpltPoint = baseNode.getAttribute(this.templateProperty);
189
		var tmpltPoint = baseNode.getAttribute(this.templateProperty);
188
		if (tmpltPoint) {
190
		if (tmpltPoint) {
189
			targetObj[tmpltPoint] = baseNode;
191
			targetObj[tmpltPoint] = baseNode;
190
		}
192
		}
191
		dojo.lang.forEach(dojo.widget.waiNames, function (name) {
193
		dojo.lang.forEach(dojo.widget.waiNames, function (name) {
192
			var wai = dojo.widget.wai[name];
194
			var wai = dojo.widget.wai[name];
193
			var val = baseNode.getAttribute(wai.name);
195
			var val = baseNode.getAttribute(wai.name);
194
			if (val) {
196
			if (val) {
195
				if (val.indexOf("-") == -1) {
197
				if (val.indexOf("-") == -1) {
196
					dojo.widget.wai.setAttr(baseNode, wai.name, "role", val);
198
					dojo.widget.wai.setAttr(baseNode, wai.name, "role", val);
197
				} else {
199
				} else {
198
					var statePair = val.split("-");
200
					var statePair = val.split("-");
199
					dojo.widget.wai.setAttr(baseNode, wai.name, statePair[0], statePair[1]);
201
					dojo.widget.wai.setAttr(baseNode, wai.name, statePair[0], statePair[1]);
200
				}
202
				}
201
			}
203
			}
202
		}, this);
204
		}, this);
203
		var onBuild = baseNode.getAttribute(this.onBuildProperty);
205
		var onBuild = baseNode.getAttribute(this.onBuildProperty);
204
		if (onBuild) {
206
		if (onBuild) {
205
			eval("var node = baseNode; var widget = targetObj; " + onBuild);
207
			eval("var node = baseNode; var widget = targetObj; " + onBuild);
206
		}
208
		}
207
	}
209
	}
208
};
210
};
209
dojo.widget.getDojoEventsFromStr = function (str) {
211
dojo.widget.getDojoEventsFromStr = function (str) {
210
	var re = /(dojoOn([a-z]+)(\s?))=/gi;
212
	var re = /(dojoOn([a-z]+)(\s?))=/gi;
211
	var evts = str ? str.match(re) || [] : [];
213
	var evts = str ? str.match(re) || [] : [];
212
	var ret = [];
214
	var ret = [];
213
	var lem = {};
215
	var lem = {};
214
	for (var x = 0; x < evts.length; x++) {
216
	for (var x = 0; x < evts.length; x++) {
215
		if (evts[x].length < 1) {
217
		if (evts[x].length < 1) {
216
			continue;
218
			continue;
217
		}
219
		}
218
		var cm = evts[x].replace(/\s/, "");
220
		var cm = evts[x].replace(/\s/, "");
219
		cm = (cm.slice(0, cm.length - 1));
221
		cm = (cm.slice(0, cm.length - 1));
220
		if (!lem[cm]) {
222
		if (!lem[cm]) {
221
			lem[cm] = true;
223
			lem[cm] = true;
222
			ret.push(cm);
224
			ret.push(cm);
223
		}
225
		}
224
	}
226
	}
225
	return ret;
227
	return ret;
226
};
228
};
227
dojo.declare("dojo.widget.DomWidget", dojo.widget.Widget, function () {
229
dojo.declare("dojo.widget.DomWidget", dojo.widget.Widget, function () {
228
	if ((arguments.length > 0) && (typeof arguments[0] == "object")) {
230
	if ((arguments.length > 0) && (typeof arguments[0] == "object")) {
229
		this.create(arguments[0]);
231
		this.create(arguments[0]);
230
	}
232
	}
231
}, {templateNode:null, templateString:null, templateCssString:null, preventClobber:false, domNode:null, containerNode:null, widgetsInTemplate:false, addChild:function (widget, overrideContainerNode, pos, ref, insertIndex) {
233
}, {templateNode:null, templateString:null, templateCssString:null, preventClobber:false, domNode:null, containerNode:null, widgetsInTemplate:false, addChild:function (widget, overrideContainerNode, pos, ref, insertIndex) {
232
	if (!this.isContainer) {
234
	if (!this.isContainer) {
233
		dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget");
235
		dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget");
234
		return null;
236
		return null;
235
	} else {
237
	} else {
236
		if (insertIndex == undefined) {
238
		if (insertIndex == undefined) {
237
			insertIndex = this.children.length;
239
			insertIndex = this.children.length;
238
		}
240
		}
239
		this.addWidgetAsDirectChild(widget, overrideContainerNode, pos, ref, insertIndex);
241
		this.addWidgetAsDirectChild(widget, overrideContainerNode, pos, ref, insertIndex);
240
		this.registerChild(widget, insertIndex);
242
		this.registerChild(widget, insertIndex);
241
	}
243
	}
242
	return widget;
244
	return widget;
243
}, addWidgetAsDirectChild:function (widget, overrideContainerNode, pos, ref, insertIndex) {
245
}, addWidgetAsDirectChild:function (widget, overrideContainerNode, pos, ref, insertIndex) {
244
	if ((!this.containerNode) && (!overrideContainerNode)) {
246
	if ((!this.containerNode) && (!overrideContainerNode)) {
245
		this.containerNode = this.domNode;
247
		this.containerNode = this.domNode;
246
	}
248
	}
247
	var cn = (overrideContainerNode) ? overrideContainerNode : this.containerNode;
249
	var cn = (overrideContainerNode) ? overrideContainerNode : this.containerNode;
248
	if (!pos) {
250
	if (!pos) {
249
		pos = "after";
251
		pos = "after";
250
	}
252
	}
251
	if (!ref) {
253
	if (!ref) {
252
		if (!cn) {
254
		if (!cn) {
253
			cn = dojo.body();
255
			cn = dojo.body();
254
		}
256
		}
255
		ref = cn.lastChild;
257
		ref = cn.lastChild;
256
	}
258
	}
257
	if (!insertIndex) {
259
	if (!insertIndex) {
258
		insertIndex = 0;
260
		insertIndex = 0;
259
	}
261
	}
260
	widget.domNode.setAttribute("dojoinsertionindex", insertIndex);
262
	widget.domNode.setAttribute("dojoinsertionindex", insertIndex);
261
	if (!ref) {
263
	if (!ref) {
262
		cn.appendChild(widget.domNode);
264
		cn.appendChild(widget.domNode);
263
	} else {
265
	} else {
264
		if (pos == "insertAtIndex") {
266
		if (pos == "insertAtIndex") {
265
			dojo.dom.insertAtIndex(widget.domNode, ref.parentNode, insertIndex);
267
			dojo.dom.insertAtIndex(widget.domNode, ref.parentNode, insertIndex);
266
		} else {
268
		} else {
267
			if ((pos == "after") && (ref === cn.lastChild)) {
269
			if ((pos == "after") && (ref === cn.lastChild)) {
268
				cn.appendChild(widget.domNode);
270
				cn.appendChild(widget.domNode);
269
			} else {
271
			} else {
270
				dojo.dom.insertAtPosition(widget.domNode, cn, pos);
272
				dojo.dom.insertAtPosition(widget.domNode, cn, pos);
271
			}
273
			}
272
		}
274
		}
273
	}
275
	}
274
}, registerChild:function (widget, insertionIndex) {
276
}, registerChild:function (widget, insertionIndex) {
275
	widget.dojoInsertionIndex = insertionIndex;
277
	widget.dojoInsertionIndex = insertionIndex;
276
	var idx = -1;
278
	var idx = -1;
277
	for (var i = 0; i < this.children.length; i++) {
279
	for (var i = 0; i < this.children.length; i++) {
278
		if (this.children[i].dojoInsertionIndex <= insertionIndex) {
280
		if (this.children[i].dojoInsertionIndex <= insertionIndex) {
279
			idx = i;
281
			idx = i;
280
		}
282
		}
281
	}
283
	}
282
	this.children.splice(idx + 1, 0, widget);
284
	this.children.splice(idx + 1, 0, widget);
283
	widget.parent = this;
285
	widget.parent = this;
284
	widget.addedTo(this, idx + 1);
286
	widget.addedTo(this, idx + 1);
285
	delete dojo.widget.manager.topWidgets[widget.widgetId];
287
	delete dojo.widget.manager.topWidgets[widget.widgetId];
286
}, removeChild:function (widget) {
288
}, removeChild:function (widget) {
287
	dojo.dom.removeNode(widget.domNode);
289
	dojo.dom.removeNode(widget.domNode);
288
	return dojo.widget.DomWidget.superclass.removeChild.call(this, widget);
290
	return dojo.widget.DomWidget.superclass.removeChild.call(this, widget);
289
}, getFragNodeRef:function (frag) {
291
}, getFragNodeRef:function (frag) {
290
	if (!frag) {
292
	if (!frag) {
291
		return null;
293
		return null;
292
	}
294
	}
293
	if (!frag[this.getNamespacedType()]) {
295
	if (!frag[this.getNamespacedType()]) {
294
		dojo.raise("Error: no frag for widget type " + this.getNamespacedType() + ", id " + this.widgetId + " (maybe a widget has set it's type incorrectly)");
296
		dojo.raise("Error: no frag for widget type " + this.getNamespacedType() + ", id " + this.widgetId + " (maybe a widget has set it's type incorrectly)");
295
	}
297
	}
296
	return frag[this.getNamespacedType()]["nodeRef"];
298
	return frag[this.getNamespacedType()]["nodeRef"];
297
}, postInitialize:function (args, frag, parentComp) {
299
}, postInitialize:function (args, frag, parentComp) {
298
	var sourceNodeRef = this.getFragNodeRef(frag);
300
	var sourceNodeRef = this.getFragNodeRef(frag);
299
	if (parentComp && (parentComp.snarfChildDomOutput || !sourceNodeRef)) {
301
	if (parentComp && (parentComp.snarfChildDomOutput || !sourceNodeRef)) {
300
		parentComp.addWidgetAsDirectChild(this, "", "insertAtIndex", "", args["dojoinsertionindex"], sourceNodeRef);
302
		parentComp.addWidgetAsDirectChild(this, "", "insertAtIndex", "", args["dojoinsertionindex"], sourceNodeRef);
301
	} else {
303
	} else {
302
		if (sourceNodeRef) {
304
		if (sourceNodeRef) {
303
			if (this.domNode && (this.domNode !== sourceNodeRef)) {
305
			if (this.domNode && (this.domNode !== sourceNodeRef)) {
304
				this._sourceNodeRef = dojo.dom.replaceNode(sourceNodeRef, this.domNode);
306
				this._sourceNodeRef = dojo.dom.replaceNode(sourceNodeRef, this.domNode);
305
			}
307
			}
306
		}
308
		}
307
	}
309
	}
308
	if (parentComp) {
310
	if (parentComp) {
309
		parentComp.registerChild(this, args.dojoinsertionindex);
311
		parentComp.registerChild(this, args.dojoinsertionindex);
310
	} else {
312
	} else {
311
		dojo.widget.manager.topWidgets[this.widgetId] = this;
313
		dojo.widget.manager.topWidgets[this.widgetId] = this;
312
	}
314
	}
313
	if (this.widgetsInTemplate) {
315
	if (this.widgetsInTemplate) {
314
		var parser = new dojo.xml.Parse();
316
		var parser = new dojo.xml.Parse();
315
		var subContainerNode;
317
		var subContainerNode;
316
		var subnodes = this.domNode.getElementsByTagName("*");
318
		var subnodes = this.domNode.getElementsByTagName("*");
317
		for (var i = 0; i < subnodes.length; i++) {
319
		for (var i = 0; i < subnodes.length; i++) {
318
			if (subnodes[i].getAttribute("dojoAttachPoint") == "subContainerWidget") {
320
			if (subnodes[i].getAttribute("dojoAttachPoint") == "subContainerWidget") {
319
				subContainerNode = subnodes[i];
321
				subContainerNode = subnodes[i];
320
			}
322
			}
321
			if (subnodes[i].getAttribute("dojoType")) {
323
			if (subnodes[i].getAttribute("dojoType")) {
322
				subnodes[i].setAttribute("isSubWidget", true);
324
				subnodes[i].setAttribute("isSubWidget", true);
323
			}
325
			}
324
		}
326
		}
325
		if (this.isContainer && !this.containerNode) {
327
		if (this.isContainer && !this.containerNode) {
326
			if (subContainerNode) {
328
			if (subContainerNode) {
327
				var src = this.getFragNodeRef(frag);
329
				var src = this.getFragNodeRef(frag);
328
				if (src) {
330
				if (src) {
329
					dojo.dom.moveChildren(src, subContainerNode);
331
					dojo.dom.moveChildren(src, subContainerNode);
330
					frag["dojoDontFollow"] = true;
332
					frag["dojoDontFollow"] = true;
331
				}
333
				}
332
			} else {
334
			} else {
333
				dojo.debug("No subContainerWidget node can be found in template file for widget " + this);
335
				dojo.debug("No subContainerWidget node can be found in template file for widget " + this);
334
			}
336
			}
335
		}
337
		}
336
		var templatefrag = parser.parseElement(this.domNode, null, true);
338
		var templatefrag = parser.parseElement(this.domNode, null, true);
337
		dojo.widget.getParser().createSubComponents(templatefrag, this);
339
		dojo.widget.getParser().createSubComponents(templatefrag, this);
338
		var subwidgets = [];
340
		var subwidgets = [];
339
		var stack = [this];
341
		var stack = [this];
340
		var w;
342
		var w;
341
		while ((w = stack.pop())) {
343
		while ((w = stack.pop())) {
342
			for (var i = 0; i < w.children.length; i++) {
344
			for (var i = 0; i < w.children.length; i++) {
343
				var cwidget = w.children[i];
345
				var cwidget = w.children[i];
344
				if (cwidget._processedSubWidgets || !cwidget.extraArgs["issubwidget"]) {
346
				if (cwidget._processedSubWidgets || !cwidget.extraArgs["issubwidget"]) {
345
					continue;
347
					continue;
346
				}
348
				}
347
				subwidgets.push(cwidget);
349
				subwidgets.push(cwidget);
348
				if (cwidget.isContainer) {
350
				if (cwidget.isContainer) {
349
					stack.push(cwidget);
351
					stack.push(cwidget);
350
				}
352
				}
351
			}
353
			}
352
		}
354
		}
353
		for (var i = 0; i < subwidgets.length; i++) {
355
		for (var i = 0; i < subwidgets.length; i++) {
354
			var widget = subwidgets[i];
356
			var widget = subwidgets[i];
355
			if (widget._processedSubWidgets) {
357
			if (widget._processedSubWidgets) {
356
				dojo.debug("This should not happen: widget._processedSubWidgets is already true!");
358
				dojo.debug("This should not happen: widget._processedSubWidgets is already true!");
357
				return;
359
				return;
358
			}
360
			}
359
			widget._processedSubWidgets = true;
361
			widget._processedSubWidgets = true;
360
			if (widget.extraArgs["dojoattachevent"]) {
362
			if (widget.extraArgs["dojoattachevent"]) {
361
				var evts = widget.extraArgs["dojoattachevent"].split(";");
363
				var evts = widget.extraArgs["dojoattachevent"].split(";");
362
				for (var j = 0; j < evts.length; j++) {
364
				for (var j = 0; j < evts.length; j++) {
363
					var thisFunc = null;
365
					var thisFunc = null;
364
					var tevt = dojo.string.trim(evts[j]);
366
					var tevt = dojo.string.trim(evts[j]);
365
					if (tevt.indexOf(":") >= 0) {
367
					if (tevt.indexOf(":") >= 0) {
366
						var funcNameArr = tevt.split(":");
368
						var funcNameArr = tevt.split(":");
367
						tevt = dojo.string.trim(funcNameArr[0]);
369
						tevt = dojo.string.trim(funcNameArr[0]);
368
						thisFunc = dojo.string.trim(funcNameArr[1]);
370
						thisFunc = dojo.string.trim(funcNameArr[1]);
369
					}
371
					}
370
					if (!thisFunc) {
372
					if (!thisFunc) {
371
						thisFunc = tevt;
373
						thisFunc = tevt;
372
					}
374
					}
373
					if (dojo.lang.isFunction(widget[tevt])) {
375
					if (dojo.lang.isFunction(widget[tevt])) {
374
						dojo.event.kwConnect({srcObj:widget, srcFunc:tevt, targetObj:this, targetFunc:thisFunc});
376
						dojo.event.kwConnect({srcObj:widget, srcFunc:tevt, targetObj:this, targetFunc:thisFunc});
375
					} else {
377
					} else {
376
						alert(tevt + " is not a function in widget " + widget);
378
						alert(tevt + " is not a function in widget " + widget);
377
					}
379
					}
378
				}
380
				}
379
			}
381
			}
380
			if (widget.extraArgs["dojoattachpoint"]) {
382
			if (widget.extraArgs["dojoattachpoint"]) {
381
				this[widget.extraArgs["dojoattachpoint"]] = widget;
383
				this[widget.extraArgs["dojoattachpoint"]] = widget;
382
			}
384
			}
383
		}
385
		}
384
	}
386
	}
385
	if (this.isContainer && !frag["dojoDontFollow"]) {
387
	if (this.isContainer && !frag["dojoDontFollow"]) {
386
		dojo.widget.getParser().createSubComponents(frag, this);
388
		dojo.widget.getParser().createSubComponents(frag, this);
387
	}
389
	}
388
}, buildRendering:function (args, frag) {
390
}, buildRendering:function (args, frag) {
389
	var ts = dojo.widget._templateCache[this.widgetType];
391
	var ts = dojo.widget._templateCache[this.widgetType];
390
	if (args["templatecsspath"]) {
392
	if (args["templatecsspath"]) {
391
		args["templateCssPath"] = args["templatecsspath"];
393
		args["templateCssPath"] = args["templatecsspath"];
392
	}
394
	}
393
	var cpath = args["templateCssPath"] || this.templateCssPath;
395
	var cpath = args["templateCssPath"] || this.templateCssPath;
394
	if (cpath && !dojo.widget._cssFiles[cpath.toString()]) {
396
	if (cpath && !dojo.widget._cssFiles[cpath.toString()]) {
395
		if ((!this.templateCssString) && (cpath)) {
397
		if ((!this.templateCssString) && (cpath)) {
396
			this.templateCssString = dojo.hostenv.getText(cpath);
398
			this.templateCssString = dojo.hostenv.getText(cpath);
397
			this.templateCssPath = null;
399
			this.templateCssPath = null;
398
		}
400
		}
399
		dojo.widget._cssFiles[cpath.toString()] = true;
401
		dojo.widget._cssFiles[cpath.toString()] = true;
400
	}
402
	}
401
	if ((this["templateCssString"]) && (!dojo.widget._cssStrings[this.templateCssString])) {
403
	if ((this["templateCssString"]) && (!dojo.widget._cssStrings[this.templateCssString])) {
402
		dojo.html.insertCssText(this.templateCssString, null, cpath);
404
		dojo.html.insertCssText(this.templateCssString, null, cpath);
403
		dojo.widget._cssStrings[this.templateCssString] = true;
405
		dojo.widget._cssStrings[this.templateCssString] = true;
404
	}
406
	}
405
	if ((!this.preventClobber) && ((this.templatePath) || (this.templateNode) || ((this["templateString"]) && (this.templateString.length)) || ((typeof ts != "undefined") && ((ts["string"]) || (ts["node"]))))) {
407
	if ((!this.preventClobber) && ((this.templatePath) || (this.templateNode) || ((this["templateString"]) && (this.templateString.length)) || ((typeof ts != "undefined") && ((ts["string"]) || (ts["node"]))))) {
406
		this.buildFromTemplate(args, frag);
408
		this.buildFromTemplate(args, frag);
407
	} else {
409
	} else {
408
		this.domNode = this.getFragNodeRef(frag);
410
		this.domNode = this.getFragNodeRef(frag);
409
	}
411
	}
410
	this.fillInTemplate(args, frag);
412
	this.fillInTemplate(args, frag);
411
}, buildFromTemplate:function (args, frag) {
413
}, buildFromTemplate:function (args, frag) {
412
	var avoidCache = false;
414
	var avoidCache = false;
413
	if (args["templatepath"]) {
415
	if (args["templatepath"]) {
414
		args["templatePath"] = args["templatepath"];
416
		args["templatePath"] = args["templatepath"];
415
	}
417
	}
416
	dojo.widget.fillFromTemplateCache(this, args["templatePath"], null, avoidCache);
418
	dojo.widget.fillFromTemplateCache(this, args["templatePath"], null, avoidCache);
417
	var ts = dojo.widget._templateCache[this.templatePath ? this.templatePath.toString() : this.widgetType];
419
	var ts = dojo.widget._templateCache[this.templatePath ? this.templatePath.toString() : this.widgetType];
418
	if ((ts) && (!avoidCache)) {
420
	if ((ts) && (!avoidCache)) {
419
		if (!this.templateString.length) {
421
		if (!this.templateString.length) {
420
			this.templateString = ts["string"];
422
			this.templateString = ts["string"];
421
		}
423
		}
422
		if (!this.templateNode) {
424
		if (!this.templateNode) {
423
			this.templateNode = ts["node"];
425
			this.templateNode = ts["node"];
424
		}
426
		}
425
	}
427
	}
426
	var matches = false;
428
	var matches = false;
427
	var node = null;
429
	var node = null;
428
	var tstr = this.templateString;
430
	var tstr = this.templateString;
429
	if ((!this.templateNode) && (this.templateString)) {
431
	if ((!this.templateNode) && (this.templateString)) {
430
		matches = this.templateString.match(/\$\{([^\}]+)\}/g);
432
		matches = this.templateString.match(/\$\{([^\}]+)\}/g);
431
		if (matches) {
433
		if (matches) {
432
			var hash = this.strings || {};
434
			var hash = this.strings || {};
433
			for (var key in dojo.widget.defaultStrings) {
435
			for (var key in dojo.widget.defaultStrings) {
434
				if (dojo.lang.isUndefined(hash[key])) {
436
				if (dojo.lang.isUndefined(hash[key])) {
435
					hash[key] = dojo.widget.defaultStrings[key];
437
					hash[key] = dojo.widget.defaultStrings[key];
436
				}
438
				}
437
			}
439
			}
438
			for (var i = 0; i < matches.length; i++) {
440
			for (var i = 0; i < matches.length; i++) {
439
				var key = matches[i];
441
				var key = matches[i];
440
				key = key.substring(2, key.length - 1);
442
				key = key.substring(2, key.length - 1);
441
				var kval = (key.substring(0, 5) == "this.") ? dojo.lang.getObjPathValue(key.substring(5), this) : hash[key];
443
				var kval = (key.substring(0, 5) == "this.") ? dojo.lang.getObjPathValue(key.substring(5), this) : hash[key];
442
				var value;
444
				var value;
443
				if ((kval) || (dojo.lang.isString(kval))) {
445
				if ((kval) || (dojo.lang.isString(kval))) {
444
					value = new String((dojo.lang.isFunction(kval)) ? kval.call(this, key, this.templateString) : kval);
446
					value = new String((dojo.lang.isFunction(kval)) ? kval.call(this, key, this.templateString) : kval);
445
					while (value.indexOf("\"") > -1) {
447
					while (value.indexOf("\"") > -1) {
446
						value = value.replace("\"", "&quot;");
448
						value = value.replace("\"", "&quot;");
447
					}
449
					}
448
					tstr = tstr.replace(matches[i], value);
450
					tstr = tstr.replace(matches[i], value);
449
				}
451
				}
450
			}
452
			}
451
		} else {
453
		} else {
452
			this.templateNode = this.createNodesFromText(this.templateString, true)[0];
454
			this.templateNode = this.createNodesFromText(this.templateString, true)[0];
453
			if (!avoidCache) {
455
			if (!avoidCache) {
454
				ts.node = this.templateNode;
456
				ts.node = this.templateNode;
455
			}
457
			}
456
		}
458
		}
457
	}
459
	}
458
	if ((!this.templateNode) && (!matches)) {
460
	if ((!this.templateNode) && (!matches)) {
459
		dojo.debug("DomWidget.buildFromTemplate: could not create template");
461
		dojo.debug("DomWidget.buildFromTemplate: could not create template");
460
		return false;
462
		return false;
461
	} else {
463
	} else {
462
		if (!matches) {
464
		if (!matches) {
463
			node = this.templateNode.cloneNode(true);
465
			node = this.templateNode.cloneNode(true);
464
			if (!node) {
466
			if (!node) {
465
				return false;
467
				return false;
466
			}
468
			}
467
		} else {
469
		} else {
468
			node = this.createNodesFromText(tstr, true)[0];
470
			node = this.createNodesFromText(tstr, true)[0];
469
		}
471
		}
470
	}
472
	}
471
	this.domNode = node;
473
	this.domNode = node;
472
	this.attachTemplateNodes();
474
	this.attachTemplateNodes();
473
	if (this.isContainer && this.containerNode) {
475
	if (this.isContainer && this.containerNode) {
474
		var src = this.getFragNodeRef(frag);
476
		var src = this.getFragNodeRef(frag);
475
		if (src) {
477
		if (src) {
476
			dojo.dom.moveChildren(src, this.containerNode);
478
			dojo.dom.moveChildren(src, this.containerNode);
477
		}
479
		}
478
	}
480
	}
479
}, attachTemplateNodes:function (baseNode, targetObj) {
481
}, attachTemplateNodes:function (baseNode, targetObj) {
480
	if (!baseNode) {
482
	if (!baseNode) {
481
		baseNode = this.domNode;
483
		baseNode = this.domNode;
482
	}
484
	}
483
	if (!targetObj) {
485
	if (!targetObj) {
484
		targetObj = this;
486
		targetObj = this;
485
	}
487
	}
486
	return dojo.widget.attachTemplateNodes(baseNode, targetObj, dojo.widget.getDojoEventsFromStr(this.templateString));
488
	return dojo.widget.attachTemplateNodes(baseNode, targetObj, dojo.widget.getDojoEventsFromStr(this.templateString));
487
}, fillInTemplate:function () {
489
}, fillInTemplate:function () {
488
}, destroyRendering:function () {
490
}, destroyRendering:function () {
489
	try {
491
	try {
490
		dojo.dom.destroyNode(this.domNode);
492
		dojo.dom.destroyNode(this.domNode);
491
		delete this.domNode;
493
		delete this.domNode;
492
	}
494
	}
493
	catch (e) {
495
	catch (e) {
494
	}
496
	}
495
	if (this._sourceNodeRef) {
497
	if (this._sourceNodeRef) {
496
		try {
498
		try {
497
			dojo.dom.destroyNode(this._sourceNodeRef);
499
			dojo.dom.destroyNode(this._sourceNodeRef);
498
		}
500
		}
499
		catch (e) {
501
		catch (e) {
500
		}
502
		}
501
	}
503
	}
502
}, createNodesFromText:function () {
504
}, createNodesFromText:function () {
503
	dojo.unimplemented("dojo.widget.DomWidget.createNodesFromText");
505
	dojo.unimplemented("dojo.widget.DomWidget.createNodesFromText");
504
}});
506
}});
505
 
507