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.html.loader");
13
dojo.provide("dojo.widget.html.loader");
12
dojo.require("dojo.widget.HtmlWidget");
14
dojo.require("dojo.widget.HtmlWidget");
13
dojo.require("dojo.io.*");
15
dojo.require("dojo.io.*");
14
dojo.require("dojo.lang.common");
16
dojo.require("dojo.lang.common");
15
dojo.require("dojo.lang.extras");
17
dojo.require("dojo.lang.extras");
16
dojo.require("dojo.experimental");
18
dojo.require("dojo.experimental");
17
dojo.experimental("dojo.widget.html.loader");
19
dojo.experimental("dojo.widget.html.loader");
18
dojo.widget.html.loader = new (function () {
20
dojo.widget.html.loader = new (function () {
19
	this.toString = function () {
21
	this.toString = function () {
20
		return "dojo.widget.html.loader";
22
		return "dojo.widget.html.loader";
21
	};
23
	};
22
	var _loader = this;
24
	var _loader = this;
23
	dojo.addOnLoad(function () {
25
	dojo.addOnLoad(function () {
24
		dojo.experimental(_loader.toString());
26
		dojo.experimental(_loader.toString());
25
		var undo = dojo.evalObjPath("dojo.undo.browser");
27
		var undo = dojo.evalObjPath("dojo.undo.browser");
26
		if (djConfig["preventBackButtonFix"] && undo && !undo.initialState) {
28
		if (djConfig["preventBackButtonFix"] && undo && !undo.initialState) {
27
			undo.setInitialState(new trackerObj);
29
			undo.setInitialState(new trackerObj);
28
		}
30
		}
29
	});
31
	});
30
	var logger = {};
32
	var logger = {};
31
	var trackerObj = function (id, data) {
33
	var trackerObj = function (id, data) {
32
		this.id = id;
34
		this.id = id;
33
		this.data = data;
35
		this.data = data;
34
	};
36
	};
35
	trackerObj.prototype.handle = function (type) {
37
	trackerObj.prototype.handle = function (type) {
36
		if (typeof dojo == "undefined") {
38
		if (typeof dojo == "undefined") {
37
			return;
39
			return;
38
		}
40
		}
39
		var wg = dojo.widget.byId(this.id);
41
		var wg = dojo.widget.byId(this.id);
40
		if (wg) {
42
		if (wg) {
41
			wg.setContent(this.data, true);
43
			wg.setContent(this.data, true);
42
		}
44
		}
43
	};
45
	};
44
	this._log = function (widget, data) {
46
	this._log = function (widget, data) {
45
		if (widget.trackHistory) {
47
		if (widget.trackHistory) {
46
			if (!logger[widget.widgetId]) {
48
			if (!logger[widget.widgetId]) {
47
				logger[widget.widgetId] = {childrenIds:[], stack:[data]};
49
				logger[widget.widgetId] = {childrenIds:[], stack:[data]};
48
			}
50
			}
49
			var children = logger[widget.widgetId].childrenIds;
51
			var children = logger[widget.widgetId].childrenIds;
50
			while (children && children.length) {
52
			while (children && children.length) {
51
				delete logger[children.pop()];
53
				delete logger[children.pop()];
52
			}
54
			}
53
			for (var child in widget.children) {
55
			for (var child in widget.children) {
54
				logger[widget.widgetId].childrenIds = child.widgetId;
56
				logger[widget.widgetId].childrenIds = child.widgetId;
55
			}
57
			}
56
			dojo.undo.browser.addToHistory(new trackerObj(widget.widgetId, dojo.lang.shallowCopy(data, true)));
58
			dojo.undo.browser.addToHistory(new trackerObj(widget.widgetId, dojo.lang.shallowCopy(data, true)));
57
		}
59
		}
58
	};
60
	};
59
	var undef = dojo.lang.isUndefined;
61
	var undef = dojo.lang.isUndefined;
60
	var isFunc = dojo.lang.isFunction;
62
	var isFunc = dojo.lang.isFunction;
61
	function handleDefaults(e, handler, useAlert) {
63
	function handleDefaults(e, handler, useAlert) {
62
		if (!handler) {
64
		if (!handler) {
63
			handler = "onContentError";
65
			handler = "onContentError";
64
		}
66
		}
65
		if (dojo.lang.isString(e)) {
67
		if (dojo.lang.isString(e)) {
66
			e = {_text:e};
68
			e = {_text:e};
67
		}
69
		}
68
		if (!e._text) {
70
		if (!e._text) {
69
			e._text = e.toString();
71
			e._text = e.toString();
70
		}
72
		}
71
		e.toString = function () {
73
		e.toString = function () {
72
			return this._text;
74
			return this._text;
73
		};
75
		};
74
		if (typeof e.returnValue != "boolean") {
76
		if (typeof e.returnValue != "boolean") {
75
			e.returnValue = true;
77
			e.returnValue = true;
76
		}
78
		}
77
		if (typeof e.preventDefault != "function") {
79
		if (typeof e.preventDefault != "function") {
78
			e.preventDefault = function () {
80
			e.preventDefault = function () {
79
				this.returnValue = false;
81
				this.returnValue = false;
80
			};
82
			};
81
		}
83
		}
82
		this[handler](e);
84
		this[handler](e);
83
		if (e.returnValue) {
85
		if (e.returnValue) {
84
			if (useAlert) {
86
			if (useAlert) {
85
				alert(e.toString());
87
				alert(e.toString());
86
			} else {
88
			} else {
87
				this.loader.callOnUnLoad.call(this, false);
89
				this.loader.callOnUnLoad.call(this, false);
88
				this.onSetContent(e.toString());
90
				this.onSetContent(e.toString());
89
			}
91
			}
90
		}
92
		}
91
	}
93
	}
92
	function downloader(bindArgs) {
94
	function downloader(bindArgs) {
93
		for (var x in this.bindArgs) {
95
		for (var x in this.bindArgs) {
94
			bindArgs[x] = (undef(bindArgs[x]) ? this.bindArgs[x] : undefined);
96
			bindArgs[x] = (undef(bindArgs[x]) ? this.bindArgs[x] : undefined);
95
		}
97
		}
96
		var cache = this.cacheContent;
98
		var cache = this.cacheContent;
97
		if (undef(bindArgs.useCache)) {
99
		if (undef(bindArgs.useCache)) {
98
			bindArgs.useCache = cache;
100
			bindArgs.useCache = cache;
99
		}
101
		}
100
		if (undef(bindArgs.preventCache)) {
102
		if (undef(bindArgs.preventCache)) {
101
			bindArgs.preventCache = !cache;
103
			bindArgs.preventCache = !cache;
102
		}
104
		}
103
		if (undef(bindArgs.mimetype)) {
105
		if (undef(bindArgs.mimetype)) {
104
			bindArgs.mimetype = "text/html";
106
			bindArgs.mimetype = "text/html";
105
		}
107
		}
106
		this.loader.bindObj = dojo.io.bind(bindArgs);
108
		this.loader.bindObj = dojo.io.bind(bindArgs);
107
	}
109
	}
108
	function stackRunner(st) {
110
	function stackRunner(st) {
109
		var err = "", func = null;
111
		var err = "", func = null;
110
		var scope = this.scriptScope || dojo.global();
112
		var scope = this.scriptScope || dojo.global();
111
		while (st.length) {
113
		while (st.length) {
112
			func = st.shift();
114
			func = st.shift();
113
			try {
115
			try {
114
				func.call(scope);
116
				func.call(scope);
115
			}
117
			}
116
			catch (e) {
118
			catch (e) {
117
				err += "\n" + func + " failed: " + e;
119
				err += "\n" + func + " failed: " + e;
118
			}
120
			}
119
		}
121
		}
120
		if (err.length) {
122
		if (err.length) {
121
			var name = (st == this.loader.addOnLoads) ? "addOnLoad" : "addOnUnLoad";
123
			var name = (st == this.loader.addOnLoads) ? "addOnLoad" : "addOnUnLoad";
122
			handleDefaults.call(this, name + " failure\n " + err, "onExecError", true);
124
			handleDefaults.call(this, name + " failure\n " + err, "onExecError", true);
123
		}
125
		}
124
	}
126
	}
125
	function stackPusher(st, obj, func) {
127
	function stackPusher(st, obj, func) {
126
		if (typeof func == "undefined") {
128
		if (typeof func == "undefined") {
127
			st.push(obj);
129
			st.push(obj);
128
		} else {
130
		} else {
129
			st.push(function () {
131
			st.push(function () {
130
				obj[func]();
132
				obj[func]();
131
			});
133
			});
132
		}
134
		}
133
	}
135
	}
134
	function refreshed() {
136
	function refreshed() {
135
		this.onResized();
137
		this.onResized();
136
		this.onLoad();
138
		this.onLoad();
137
		this.isLoaded = true;
139
		this.isLoaded = true;
138
	}
140
	}
139
	function asyncParse(data) {
141
	function asyncParse(data) {
140
		if (this.executeScripts) {
142
		if (this.executeScripts) {
141
			this.onExecScript.call(this, data.scripts);
143
			this.onExecScript.call(this, data.scripts);
142
		}
144
		}
143
		if (this.parseContent) {
145
		if (this.parseContent) {
144
			this.onContentParse.call(this);
146
			this.onContentParse.call(this);
145
		}
147
		}
146
		refreshed.call(this);
148
		refreshed.call(this);
147
	}
149
	}
148
	function runHandler() {
150
	function runHandler() {
149
		if (dojo.lang.isFunction(this.handler)) {
151
		if (dojo.lang.isFunction(this.handler)) {
150
			this.handler(this, this.containerNode || this.domNode);
152
			this.handler(this, this.containerNode || this.domNode);
151
			refreshed.call(this);
153
			refreshed.call(this);
152
			return false;
154
			return false;
153
		}
155
		}
154
		return true;
156
		return true;
155
	}
157
	}
156
	this.htmlContentBasicFix = function (s, url) {
158
	this.htmlContentBasicFix = function (s, url) {
157
		var titles = [], styles = [];
159
		var titles = [], styles = [];
158
		var regex = /<title[^>]*>([\s\S]*?)<\/title>/i;
160
		var regex = /<title[^>]*>([\s\S]*?)<\/title>/i;
159
		var match, attr;
161
		var match, attr;
160
		while (match = regex.exec(s)) {
162
		while (match = regex.exec(s)) {
161
			titles.push(match[1]);
163
			titles.push(match[1]);
162
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
164
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
163
		}
165
		}
164
		regex = /(?:<(style)[^>]*>([\s\S]*?)<\/style>|<link ([^>]*rel=['"]?stylesheet['"]?[^>]*)>)/i;
166
		regex = /(?:<(style)[^>]*>([\s\S]*?)<\/style>|<link ([^>]*rel=['"]?stylesheet['"]?[^>]*)>)/i;
165
		while (match = regex.exec(s)) {
167
		while (match = regex.exec(s)) {
166
			if (match[1] && match[1].toLowerCase() == "style") {
168
			if (match[1] && match[1].toLowerCase() == "style") {
167
				styles.push(dojo.html.fixPathsInCssText(match[2], url));
169
				styles.push(dojo.html.fixPathsInCssText(match[2], url));
168
			} else {
170
			} else {
169
				if (attr = match[3].match(/href=(['"]?)([^'">]*)\1/i)) {
171
				if (attr = match[3].match(/href=(['"]?)([^'">]*)\1/i)) {
170
					styles.push({path:attr[2]});
172
					styles.push({path:attr[2]});
171
				}
173
				}
172
			}
174
			}
173
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
175
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
174
		}
176
		}
175
		return {"s":s, "titles":titles, "styles":styles};
177
		return {"s":s, "titles":titles, "styles":styles};
176
	};
178
	};
177
	this.htmlContentAdjustPaths = function (s, url) {
179
	this.htmlContentAdjustPaths = function (s, url) {
178
		var tag = "", str = "", tagFix = "", path = "";
180
		var tag = "", str = "", tagFix = "", path = "";
179
		var attr = [], origPath = "", fix = "";
181
		var attr = [], origPath = "", fix = "";
180
		var regexFindTag = /<[a-z][a-z0-9]*[^>]*\s(?:(?:src|href|style)=[^>])+[^>]*>/i;
182
		var regexFindTag = /<[a-z][a-z0-9]*[^>]*\s(?:(?:src|href|style)=[^>])+[^>]*>/i;
181
		var regexFindAttr = /\s(src|href|style)=(['"]?)([\w()\[\]\/.,\\'"-:;#=&?\s@]+?)\2/i;
183
		var regexFindAttr = /\s(src|href|style)=(['"]?)([\w()\[\]\/.,\\'"-:;#=&?\s@]+?)\2/i;
182
		var regexProtocols = /^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/;
184
		var regexProtocols = /^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/;
183
		while (tag = regexFindTag.exec(s)) {
185
		while (tag = regexFindTag.exec(s)) {
184
			str += s.substring(0, tag.index);
186
			str += s.substring(0, tag.index);
185
			s = s.substring((tag.index + tag[0].length), s.length);
187
			s = s.substring((tag.index + tag[0].length), s.length);
186
			tag = tag[0];
188
			tag = tag[0];
187
			tagFix = "";
189
			tagFix = "";
188
			while (attr = regexFindAttr.exec(tag)) {
190
			while (attr = regexFindAttr.exec(tag)) {
189
				path = "";
191
				path = "";
190
				origPath = attr[3];
192
				origPath = attr[3];
191
				switch (attr[1].toLowerCase()) {
193
				switch (attr[1].toLowerCase()) {
192
				  case "src":
194
				  case "src":
193
				  case "href":
195
				  case "href":
194
					if (regexProtocols.exec(origPath)) {
196
					if (regexProtocols.exec(origPath)) {
195
						path = origPath;
197
						path = origPath;
196
					} else {
198
					} else {
197
						path = (new dojo.uri.Uri(url, origPath).toString());
199
						path = (new dojo.uri.Uri(url, origPath).toString());
198
					}
200
					}
199
					break;
201
					break;
200
				  case "style":
202
				  case "style":
201
					path = dojo.html.fixPathsInCssText(origPath, url);
203
					path = dojo.html.fixPathsInCssText(origPath, url);
202
					break;
204
					break;
203
				  default:
205
				  default:
204
					path = origPath;
206
					path = origPath;
205
				}
207
				}
206
				fix = " " + attr[1] + "=" + attr[2] + path + attr[2];
208
				fix = " " + attr[1] + "=" + attr[2] + path + attr[2];
207
				tagFix += tag.substring(0, attr.index) + fix;
209
				tagFix += tag.substring(0, attr.index) + fix;
208
				tag = tag.substring((attr.index + attr[0].length), tag.length);
210
				tag = tag.substring((attr.index + attr[0].length), tag.length);
209
			}
211
			}
210
			str += tagFix + tag;
212
			str += tagFix + tag;
211
		}
213
		}
212
		return str + s;
214
		return str + s;
213
	};
215
	};
214
	this.htmlContentScripts = function (s, collectScripts) {
216
	this.htmlContentScripts = function (s, collectScripts) {
215
		var scripts = [], requires = [], match = [];
217
		var scripts = [], requires = [], match = [];
216
		var attr = "", tmp = null, tag = "", sc = "", str = "";
218
		var attr = "", tmp = null, tag = "", sc = "", str = "";
217
		var regex = /<script([^>]*)>([\s\S]*?)<\/script>/i;
219
		var regex = /<script([^>]*)>([\s\S]*?)<\/script>/i;
218
		var regexSrc = /src=(['"]?)([^"']*)\1/i;
220
		var regexSrc = /src=(['"]?)([^"']*)\1/i;
219
		var regexDojoJs = /.*(\bdojo\b\.js(?:\.uncompressed\.js)?)$/;
221
		var regexDojoJs = /.*(\bdojo\b\.js(?:\.uncompressed\.js)?)$/;
220
		var regexInvalid = /(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g;
222
		var regexInvalid = /(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g;
221
		var regexRequires = /dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix)|defineNamespace)\((['"]).*?\1\)\s*;?/;
223
		var regexRequires = /dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix)|defineNamespace)\((['"]).*?\1\)\s*;?/;
222
		while (match = regex.exec(s)) {
224
		while (match = regex.exec(s)) {
223
			if (this.executeScripts && match[1]) {
225
			if (this.executeScripts && match[1]) {
224
				if (attr = regexSrc.exec(match[1])) {
226
				if (attr = regexSrc.exec(match[1])) {
225
					if (regexDojoJs.exec(attr[2])) {
227
					if (regexDojoJs.exec(attr[2])) {
226
						dojo.debug("Security note! inhibit:" + attr[2] + " from  beeing loaded again.");
228
						dojo.debug("Security note! inhibit:" + attr[2] + " from  beeing loaded again.");
227
					} else {
229
					} else {
228
						scripts.push({path:attr[2]});
230
						scripts.push({path:attr[2]});
229
					}
231
					}
230
				}
232
				}
231
			}
233
			}
232
			if (match[2]) {
234
			if (match[2]) {
233
				sc = match[2].replace(regexInvalid, "");
235
				sc = match[2].replace(regexInvalid, "");
234
				if (!sc) {
236
				if (!sc) {
235
					continue;
237
					continue;
236
				}
238
				}
237
				while (tmp = regexRequires.exec(sc)) {
239
				while (tmp = regexRequires.exec(sc)) {
238
					requires.push(tmp[0]);
240
					requires.push(tmp[0]);
239
					sc = sc.substring(0, tmp.index) + sc.substr(tmp.index + tmp[0].length);
241
					sc = sc.substring(0, tmp.index) + sc.substr(tmp.index + tmp[0].length);
240
				}
242
				}
241
				if (collectScripts) {
243
				if (collectScripts) {
242
					scripts.push(sc);
244
					scripts.push(sc);
243
				}
245
				}
244
			}
246
			}
245
			s = s.substr(0, match.index) + s.substr(match.index + match[0].length);
247
			s = s.substr(0, match.index) + s.substr(match.index + match[0].length);
246
		}
248
		}
247
		if (collectScripts) {
249
		if (collectScripts) {
248
			var regex = /(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*\S=(['"])[^>]*[^\.\]])scriptScope([^>]*>)/;
250
			var regex = /(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*\S=(['"])[^>]*[^\.\]])scriptScope([^>]*>)/;
249
			str = "";
251
			str = "";
250
			while (tag = regex.exec(s)) {
252
			while (tag = regex.exec(s)) {
251
				tmp = ((tag[2] == "'") ? "\"" : "'");
253
				tmp = ((tag[2] == "'") ? "\"" : "'");
252
				str += s.substring(0, tag.index);
254
				str += s.substring(0, tag.index);
253
				s = s.substr(tag.index).replace(regex, "$1dojo.widget.byId(" + tmp + this.widgetId + tmp + ").scriptScope$3");
255
				s = s.substr(tag.index).replace(regex, "$1dojo.widget.byId(" + tmp + this.widgetId + tmp + ").scriptScope$3");
254
			}
256
			}
255
			s = str + s;
257
			s = str + s;
256
		}
258
		}
257
		return {"s":s, "requires":requires, "scripts":scripts};
259
		return {"s":s, "requires":requires, "scripts":scripts};
258
	};
260
	};
259
	this.splitAndFixPaths = function (args) {
261
	this.splitAndFixPaths = function (args) {
260
		if (!args.url) {
262
		if (!args.url) {
261
			args.url = "./";
263
			args.url = "./";
262
		}
264
		}
263
		url = new dojo.uri.Uri(location, args.url).toString();
265
		url = new dojo.uri.Uri(location, args.url).toString();
264
		var ret = {"xml":"", "styles":[], "titles":[], "requires":[], "scripts":[], "url":url};
266
		var ret = {"xml":"", "styles":[], "titles":[], "requires":[], "scripts":[], "url":url};
265
		if (args.content) {
267
		if (args.content) {
266
			var tmp = null, content = args.content;
268
			var tmp = null, content = args.content;
267
			if (args.adjustPaths) {
269
			if (args.adjustPaths) {
268
				content = _loader.htmlContentAdjustPaths.call(this, content, url);
270
				content = _loader.htmlContentAdjustPaths.call(this, content, url);
269
			}
271
			}
270
			tmp = _loader.htmlContentBasicFix.call(this, content, url);
272
			tmp = _loader.htmlContentBasicFix.call(this, content, url);
271
			content = tmp.s;
273
			content = tmp.s;
272
			ret.styles = tmp.styles;
274
			ret.styles = tmp.styles;
273
			ret.titles = tmp.titles;
275
			ret.titles = tmp.titles;
274
			if (args.collectRequires || args.collectScripts) {
276
			if (args.collectRequires || args.collectScripts) {
275
				tmp = _loader.htmlContentScripts.call(this, content, args.collectScripts);
277
				tmp = _loader.htmlContentScripts.call(this, content, args.collectScripts);
276
				content = tmp.s;
278
				content = tmp.s;
277
				ret.requires = tmp.requires;
279
				ret.requires = tmp.requires;
278
				ret.scripts = tmp.scripts;
280
				ret.scripts = tmp.scripts;
279
			}
281
			}
280
			var match = [];
282
			var match = [];
281
			if (args.bodyExtract) {
283
			if (args.bodyExtract) {
282
				match = content.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
284
				match = content.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
283
				if (match) {
285
				if (match) {
284
					content = match[1];
286
					content = match[1];
285
				}
287
				}
286
			}
288
			}
287
			ret.xml = content;
289
			ret.xml = content;
288
		}
290
		}
289
		return ret;
291
		return ret;
290
	};
292
	};
291
	this.hookUp = function (args) {
293
	this.hookUp = function (args) {
292
		var widget = args.widget;
294
		var widget = args.widget;
293
		if (dojo.lang.isString(widget)) {
295
		if (dojo.lang.isString(widget)) {
294
			if (args.mixin) {
296
			if (args.mixin) {
295
				dojo.raise(this.toString() + ", cant use mixin when widget is a string");
297
				dojo.raise(this.toString() + ", cant use mixin when widget is a string");
296
			}
298
			}
297
			widget = dojo.evalObjPath(widget);
299
			widget = dojo.evalObjPath(widget);
298
		}
300
		}
299
		if (!widget || !(widget instanceof dojo.widget.HtmlWidget)) {
301
		if (!widget || !(widget instanceof dojo.widget.HtmlWidget)) {
300
			dojo.raise(this.toString() + " Widget isn't defined or isn't a HtmlWidget instance");
302
			dojo.raise(this.toString() + " Widget isn't defined or isn't a HtmlWidget instance");
301
		}
303
		}
302
		if (widget.loader && widget.setUrl) {
304
		if (widget.loader && widget.setUrl) {
303
			return;
305
			return;
304
		}
306
		}
305
		var widgetProto = (args.mixin) ? widget : widget.constructor.prototype;
307
		var widgetProto = (args.mixin) ? widget : widget.constructor.prototype;
306
		widget.loader = {isLoaded:false, styleNodes:[], addOnLoads:[], addOnUnLoads:[], callOnUnLoad:(function (canCall) {
308
		widget.loader = {isLoaded:false, styleNodes:[], addOnLoads:[], addOnUnLoads:[], callOnUnLoad:(function (canCall) {
307
			return function (after) {
309
			return function (after) {
308
				this.abort();
310
				this.abort();
309
				if (canCall) {
311
				if (canCall) {
310
					this.onUnLoad();
312
					this.onUnLoad();
311
				}
313
				}
312
				canCall = after;
314
				canCall = after;
313
			};
315
			};
314
		})(false), bindObj:null, unHook:(function (w, wg) {
316
		})(false), bindObj:null, unHook:(function (w, wg) {
315
			var oldProps = {isContainer:w.isContainer, adjustPats:w.adjustPaths, href:w.href, extractContent:w.extractContent, parseContent:w.parseContent, cacheContent:w.cacheContent, bindArgs:w.bindArgs, preload:w.preload, refreshOnShow:w.refreshOnShow, handler:w.handler, trackHistory:w.trackHistory, executeScripts:w.executeScripts, scriptScope:w.scriptScope, postCreate:w.postCreate, show:w.show, refresh:w.refresh, loadContents:w.loadContents, abort:w.abort, destroy:w.destroy, onLoad:w.onLoad, onUnLoad:w.onUnLoad, addOnLoad:w.addOnLoad, addOnUnLoad:w.addOnUnLoad, onDownloadStart:w.onDownloadStart, onDownloadEnd:w.onDownloadEnd, onDownloadError:w.onDownloadError, onContentError:w.onContentError, onExecError:w.onExecError, onSetContent:w.onSetContent, setUrl:w.setUrl, setContent:w.setContent, onContentParse:w.onContentParse, onExecScript:w.onExecScript, setHandler:w.setHandler};
317
			var oldProps = {isContainer:w.isContainer, adjustPats:w.adjustPaths, href:w.href, extractContent:w.extractContent, parseContent:w.parseContent, cacheContent:w.cacheContent, bindArgs:w.bindArgs, preload:w.preload, refreshOnShow:w.refreshOnShow, handler:w.handler, trackHistory:w.trackHistory, executeScripts:w.executeScripts, scriptScope:w.scriptScope, postCreate:w.postCreate, show:w.show, refresh:w.refresh, loadContents:w.loadContents, abort:w.abort, destroy:w.destroy, onLoad:w.onLoad, onUnLoad:w.onUnLoad, addOnLoad:w.addOnLoad, addOnUnLoad:w.addOnUnLoad, onDownloadStart:w.onDownloadStart, onDownloadEnd:w.onDownloadEnd, onDownloadError:w.onDownloadError, onContentError:w.onContentError, onExecError:w.onExecError, onSetContent:w.onSetContent, setUrl:w.setUrl, setContent:w.setContent, onContentParse:w.onContentParse, onExecScript:w.onExecScript, setHandler:w.setHandler};
316
			return function () {
318
			return function () {
317
				if (wg.abort) {
319
				if (wg.abort) {
318
					wg.abort();
320
					wg.abort();
319
				}
321
				}
320
				if ((w != wg) && (dojo.widget.byType(wg.widgetType).length > 1)) {
322
				if ((w != wg) && (dojo.widget.byType(wg.widgetType).length > 1)) {
321
					return;
323
					return;
322
				}
324
				}
323
				for (var x in oldProps) {
325
				for (var x in oldProps) {
324
					if (oldProps[x] === undefined) {
326
					if (oldProps[x] === undefined) {
325
						delete w[x];
327
						delete w[x];
326
						continue;
328
						continue;
327
					}
329
					}
328
					w[x] = oldProps[x];
330
					w[x] = oldProps[x];
329
				}
331
				}
330
				delete wg._loader_defined;
332
				delete wg._loader_defined;
331
				delete wg.loader;
333
				delete wg.loader;
332
			};
334
			};
333
		})(widgetProto, widget)};
335
		})(widgetProto, widget)};
334
		if (widgetProto._loader_defined || widget._loader_defined) {
336
		if (widgetProto._loader_defined || widget._loader_defined) {
335
			return;
337
			return;
336
		}
338
		}
337
		dojo.mixin(widgetProto, {isContainer:true, adjustPaths:undef(widgetProto.adjustPaths) ? true : widgetProto.adjustPaths, href:undef(widgetProto.href) ? "" : widgetProto.href, extractContent:undef(widgetProto.extractContent) ? true : widgetProto.extractContent, parseContent:undef(widgetProto.parseContent) ? true : widgetProto.parseContent, cacheContent:undef(widgetProto.cacheContent) ? true : widgetProto.cacheContent, bindArgs:undef(widgetProto.bindArgs) ? {} : widgetProto.bindArgs, preload:undef(widgetProto.preload) ? false : widgetProto.preload, refreshOnShow:undef(widgetProto.refreshOnShow) ? false : widgetProto.refreshOnShow, handler:undef(widgetProto.handler) ? "" : widgetProto.handler, executeScripts:undef(widgetProto.executeScripts) ? false : widgetProto.executeScripts, trackHistory:undef(widgetProto.tracHistory) ? false : widgetProto.trackHistory, scriptScope:null});
339
		dojo.mixin(widgetProto, {isContainer:true, adjustPaths:undef(widgetProto.adjustPaths) ? true : widgetProto.adjustPaths, href:undef(widgetProto.href) ? "" : widgetProto.href, extractContent:undef(widgetProto.extractContent) ? true : widgetProto.extractContent, parseContent:undef(widgetProto.parseContent) ? true : widgetProto.parseContent, cacheContent:undef(widgetProto.cacheContent) ? true : widgetProto.cacheContent, bindArgs:undef(widgetProto.bindArgs) ? {} : widgetProto.bindArgs, preload:undef(widgetProto.preload) ? false : widgetProto.preload, refreshOnShow:undef(widgetProto.refreshOnShow) ? false : widgetProto.refreshOnShow, handler:undef(widgetProto.handler) ? "" : widgetProto.handler, executeScripts:undef(widgetProto.executeScripts) ? false : widgetProto.executeScripts, trackHistory:undef(widgetProto.tracHistory) ? false : widgetProto.trackHistory, scriptScope:null});
338
		widgetProto.postCreate = (function (postCreate) {
340
		widgetProto.postCreate = (function (postCreate) {
339
			return function () {
341
			return function () {
340
				if (widgetProto.constructor.superclass.postCreate != postCreate) {
342
				if (widgetProto.constructor.superclass.postCreate != postCreate) {
341
					postCreate.apply(this, arguments);
343
					postCreate.apply(this, arguments);
342
				} else {
344
				} else {
343
					widgetProto.constructor.superclass.postCreate.apply(this, arguments);
345
					widgetProto.constructor.superclass.postCreate.apply(this, arguments);
344
				}
346
				}
345
				if (this.handler !== "") {
347
				if (this.handler !== "") {
346
					this.setHandler(this.handler);
348
					this.setHandler(this.handler);
347
				}
349
				}
348
				if (this.isShowing() || this.preload) {
350
				if (this.isShowing() || this.preload) {
349
					this.loadContents();
351
					this.loadContents();
350
					if (!this.href) {
352
					if (!this.href) {
351
						_loader._log(this, (this.domNode || this.containerNode).innerHTML);
353
						_loader._log(this, (this.domNode || this.containerNode).innerHTML);
352
					}
354
					}
353
				}
355
				}
354
			};
356
			};
355
		})(widgetProto.postCreate);
357
		})(widgetProto.postCreate);
356
		widgetProto.show = (function (show) {
358
		widgetProto.show = (function (show) {
357
			return function () {
359
			return function () {
358
				if (this.refreshOnShow) {
360
				if (this.refreshOnShow) {
359
					this.refresh();
361
					this.refresh();
360
				} else {
362
				} else {
361
					this.loadContents();
363
					this.loadContents();
362
				}
364
				}
363
				if ((widgetProto.constructor.superclass.show == show) || !isFunc(show)) {
365
				if ((widgetProto.constructor.superclass.show == show) || !isFunc(show)) {
364
					widgetProto.constructor.superclass.show.apply(this, arguments);
366
					widgetProto.constructor.superclass.show.apply(this, arguments);
365
				} else {
367
				} else {
366
					show.apply(this, arguments);
368
					show.apply(this, arguments);
367
				}
369
				}
368
			};
370
			};
369
		})(widgetProto.show);
371
		})(widgetProto.show);
370
		widgetProto.destroy = (function (destroy) {
372
		widgetProto.destroy = (function (destroy) {
371
			return function (destroy) {
373
			return function (destroy) {
372
				this.onUnLoad();
374
				this.onUnLoad();
373
				this.abort();
375
				this.abort();
374
				this.loader.unHook();
376
				this.loader.unHook();
375
				if ((widgetProto.constructor.superclass.destroy != destroy) && isFunc(destroy)) {
377
				if ((widgetProto.constructor.superclass.destroy != destroy) && isFunc(destroy)) {
376
					destroy.apply(this, arguments);
378
					destroy.apply(this, arguments);
377
				} else {
379
				} else {
378
					widgetProto.constructor.superclass.destroy.apply(this, arguments);
380
					widgetProto.constructor.superclass.destroy.apply(this, arguments);
379
				}
381
				}
380
			};
382
			};
381
		})(widgetProto.destroy);
383
		})(widgetProto.destroy);
382
		if (!widgetProto.refresh) {
384
		if (!widgetProto.refresh) {
383
			widgetProto.refresh = function () {
385
			widgetProto.refresh = function () {
384
				this.loader.isLoaded = false;
386
				this.loader.isLoaded = false;
385
				this.loadContents();
387
				this.loadContents();
386
			};
388
			};
387
		}
389
		}
388
		if (!widgetProto.loadContents) {
390
		if (!widgetProto.loadContents) {
389
			widgetProto.loadContents = function () {
391
			widgetProto.loadContents = function () {
390
				if (this.loader.isLoaded) {
392
				if (this.loader.isLoaded) {
391
					return;
393
					return;
392
				}
394
				}
393
				if (isFunc(this.handler)) {
395
				if (isFunc(this.handler)) {
394
					runHandler.call(this);
396
					runHandler.call(this);
395
				} else {
397
				} else {
396
					if (this.href !== "") {
398
					if (this.href !== "") {
397
						handleDefaults.call(this, "Loading...", "onDownloadStart");
399
						handleDefaults.call(this, "Loading...", "onDownloadStart");
398
						var self = this, url = this.href;
400
						var self = this, url = this.href;
399
						downloader.call(this, {url:url, load:function (type, data, xhr) {
401
						downloader.call(this, {url:url, load:function (type, data, xhr) {
400
							self.onDownloadEnd.call(self, url, data);
402
							self.onDownloadEnd.call(self, url, data);
401
						}, error:function (type, err, xhr) {
403
						}, error:function (type, err, xhr) {
402
							var e = {responseText:xhr.responseText, status:xhr.status, statusText:xhr.statusText, responseHeaders:(xhr.getAllResponseHeaders) ? xhr.getAllResponseHeaders() : [], _text:"Error loading '" + url + "' (" + xhr.status + " " + xhr.statusText + ")"};
404
							var e = {responseText:xhr.responseText, status:xhr.status, statusText:xhr.statusText, responseHeaders:(xhr.getAllResponseHeaders) ? xhr.getAllResponseHeaders() : [], _text:"Error loading '" + url + "' (" + xhr.status + " " + xhr.statusText + ")"};
403
							handleDefaults.call(self, e, "onDownloadError");
405
							handleDefaults.call(self, e, "onDownloadError");
404
							self.onLoad();
406
							self.onLoad();
405
						}});
407
						}});
406
					}
408
					}
407
				}
409
				}
408
			};
410
			};
409
		}
411
		}
410
		if (!widgetProto.abort) {
412
		if (!widgetProto.abort) {
411
			widgetProto.abort = function () {
413
			widgetProto.abort = function () {
412
				if (!this.loader || !this.loader.bindObj || !this.loader.bindObj.abort) {
414
				if (!this.loader || !this.loader.bindObj || !this.loader.bindObj.abort) {
413
					return;
415
					return;
414
				}
416
				}
415
				this.loader.bindObj.abort();
417
				this.loader.bindObj.abort();
416
				this.loader.bindObj = null;
418
				this.loader.bindObj = null;
417
			};
419
			};
418
		}
420
		}
419
		if (!widgetProto.onLoad) {
421
		if (!widgetProto.onLoad) {
420
			widgetProto.onLoad = function () {
422
			widgetProto.onLoad = function () {
421
				stackRunner.call(this, this.loader.addOnLoads);
423
				stackRunner.call(this, this.loader.addOnLoads);
422
				this.loader.isLoaded = true;
424
				this.loader.isLoaded = true;
423
			};
425
			};
424
		}
426
		}
425
		if (!widgetProto.onUnLoad) {
427
		if (!widgetProto.onUnLoad) {
426
			widgetProto.onUnLoad = function () {
428
			widgetProto.onUnLoad = function () {
427
				stackRunner.call(this, this.loader.addOnUnLoads);
429
				stackRunner.call(this, this.loader.addOnUnLoads);
428
				delete this.scriptScope;
430
				delete this.scriptScope;
429
			};
431
			};
430
		}
432
		}
431
		if (!widgetProto.addOnLoad) {
433
		if (!widgetProto.addOnLoad) {
432
			widgetProto.addOnLoad = function (obj, func) {
434
			widgetProto.addOnLoad = function (obj, func) {
433
				stackPusher.call(this, this.loader.addOnLoads, obj, func);
435
				stackPusher.call(this, this.loader.addOnLoads, obj, func);
434
			};
436
			};
435
		}
437
		}
436
		if (!widgetProto.addOnUnLoad) {
438
		if (!widgetProto.addOnUnLoad) {
437
			widgetProto.addOnUnLoad = function (obj, func) {
439
			widgetProto.addOnUnLoad = function (obj, func) {
438
				stackPusher.call(this, this.loader.addOnUnLoads, obj, func);
440
				stackPusher.call(this, this.loader.addOnUnLoads, obj, func);
439
			};
441
			};
440
		}
442
		}
441
		if (!widgetProto.onExecError) {
443
		if (!widgetProto.onExecError) {
442
			widgetProto.onExecError = function () {
444
			widgetProto.onExecError = function () {
443
			};
445
			};
444
		}
446
		}
445
		if (!widgetProto.onContentError) {
447
		if (!widgetProto.onContentError) {
446
			widgetProto.onContentError = function () {
448
			widgetProto.onContentError = function () {
447
			};
449
			};
448
		}
450
		}
449
		if (!widgetProto.onDownloadError) {
451
		if (!widgetProto.onDownloadError) {
450
			widgetProto.onDownloadError = function () {
452
			widgetProto.onDownloadError = function () {
451
			};
453
			};
452
		}
454
		}
453
		if (!widgetProto.onDownloadStart) {
455
		if (!widgetProto.onDownloadStart) {
454
			widgetProto.onDownloadStart = function (onDownloadStart) {
456
			widgetProto.onDownloadStart = function (onDownloadStart) {
455
			};
457
			};
456
		}
458
		}
457
		if (!widgetProto.onDownloadEnd) {
459
		if (!widgetProto.onDownloadEnd) {
458
			widgetProto.onDownloadEnd = function (url, data) {
460
			widgetProto.onDownloadEnd = function (url, data) {
459
				var args = {content:data, url:url, adjustPaths:this.adjustPaths, collectScripts:this.executeScripts, collectRequires:this.parseContent, bodyExtract:this.extractContent};
461
				var args = {content:data, url:url, adjustPaths:this.adjustPaths, collectScripts:this.executeScripts, collectRequires:this.parseContent, bodyExtract:this.extractContent};
460
				data = _loader.splitAndFixPaths.call(this, args);
462
				data = _loader.splitAndFixPaths.call(this, args);
461
				this.setContent(data);
463
				this.setContent(data);
462
			};
464
			};
463
		}
465
		}
464
		if (!widgetProto.onSetContent) {
466
		if (!widgetProto.onSetContent) {
465
			widgetProto.onSetContent = function (cont) {
467
			widgetProto.onSetContent = function (cont) {
466
				this.destroyChildren();
468
				this.destroyChildren();
467
				var styleNodes = this.loader.styleNodes;
469
				var styleNodes = this.loader.styleNodes;
468
				while (styleNodes.length) {
470
				while (styleNodes.length) {
469
					var st = styleNodes.pop();
471
					var st = styleNodes.pop();
470
					if (st && st.parentNode) {
472
					if (st && st.parentNode) {
471
						st.parentNode.removeChild(st);
473
						st.parentNode.removeChild(st);
472
					}
474
					}
473
				}
475
				}
474
				var node = this.containerNode || this.domNode;
476
				var node = this.containerNode || this.domNode;
475
				while (node.firstChild) {
477
				while (node.firstChild) {
476
					try {
478
					try {
477
						dojo.event.browser.clean(node.firstChild);
479
						dojo.event.browser.clean(node.firstChild);
478
					}
480
					}
479
					catch (e) {
481
					catch (e) {
480
					}
482
					}
481
					node.removeChild(node.firstChild);
483
					node.removeChild(node.firstChild);
482
				}
484
				}
483
				try {
485
				try {
484
					if (typeof cont != "string") {
486
					if (typeof cont != "string") {
485
						node.appendChild(cont);
487
						node.appendChild(cont);
486
					} else {
488
					} else {
487
						try {
489
						try {
488
							node.innerHTML = cont;
490
							node.innerHTML = cont;
489
						}
491
						}
490
						catch (e) {
492
						catch (e) {
491
							var tmp;
493
							var tmp;
492
							(tmp = dojo.doc().createElement("div")).innerHTML = cont;
494
							(tmp = dojo.doc().createElement("div")).innerHTML = cont;
493
							while (tmp.firstChild) {
495
							while (tmp.firstChild) {
494
								node.appendChild(tmp.removeChild(tmp.firstChild));
496
								node.appendChild(tmp.removeChild(tmp.firstChild));
495
							}
497
							}
496
						}
498
						}
497
					}
499
					}
498
				}
500
				}
499
				catch (e) {
501
				catch (e) {
500
					e._text = "Could'nt load content: " + e;
502
					e._text = "Could'nt load content: " + e;
501
					var useAlert = (this.loader._onSetContent_err == e._text);
503
					var useAlert = (this.loader._onSetContent_err == e._text);
502
					this.loader._onSetContent_err = e._text;
504
					this.loader._onSetContent_err = e._text;
503
					handleDefaults.call(this, e, "onContentError", useAlert);
505
					handleDefaults.call(this, e, "onContentError", useAlert);
504
				}
506
				}
505
			};
507
			};
506
		}
508
		}
507
		if (!widgetProto.setUrl) {
509
		if (!widgetProto.setUrl) {
508
			widgetProto.setUrl = function (url) {
510
			widgetProto.setUrl = function (url) {
509
				this.href = url;
511
				this.href = url;
510
				this.loader.isLoaded = false;
512
				this.loader.isLoaded = false;
511
				if (this.preload || this.isShowing()) {
513
				if (this.preload || this.isShowing()) {
512
					this.loadContents();
514
					this.loadContents();
513
				}
515
				}
514
			};
516
			};
515
		}
517
		}
516
		if (!widgetProto.setContent) {
518
		if (!widgetProto.setContent) {
517
			widgetProto.setContent = function (data, dontLog) {
519
			widgetProto.setContent = function (data, dontLog) {
518
				this.loader.callOnUnLoad.call(this, true);
520
				this.loader.callOnUnLoad.call(this, true);
519
				if (!data || dojo.html.isNode(data)) {
521
				if (!data || dojo.html.isNode(data)) {
520
					this.onSetContent(data);
522
					this.onSetContent(data);
521
					refreshed.call(this);
523
					refreshed.call(this);
522
				} else {
524
				} else {
523
					if (typeof data.xml != "string") {
525
					if (typeof data.xml != "string") {
524
						this.href = "";
526
						this.href = "";
525
						var args = {content:data, url:this.href, adjustPaths:this.adjustPaths, collectScripts:this.executeScripts, collectRequires:this.parseContent, bodyExtract:this.extractContent};
527
						var args = {content:data, url:this.href, adjustPaths:this.adjustPaths, collectScripts:this.executeScripts, collectRequires:this.parseContent, bodyExtract:this.extractContent};
526
						data = _loader.splitAndFixPaths.call(this, args);
528
						data = _loader.splitAndFixPaths.call(this, args);
527
					} else {
529
					} else {
528
						if (data.url != "./") {
530
						if (data.url != "./") {
529
							this.url = data.url;
531
							this.url = data.url;
530
						}
532
						}
531
					}
533
					}
532
					this.onSetContent(data.xml);
534
					this.onSetContent(data.xml);
533
					for (var i = 0, styles = data.styles; i < styles.length; i++) {
535
					for (var i = 0, styles = data.styles; i < styles.length; i++) {
534
						if (styles[i].path) {
536
						if (styles[i].path) {
535
							this.loader.styleNodes.push(dojo.html.insertCssFile(styles[i].path));
537
							this.loader.styleNodes.push(dojo.html.insertCssFile(styles[i].path));
536
						} else {
538
						} else {
537
							this.loader.styleNodes.push(dojo.html.insertCssText(styles[i]));
539
							this.loader.styleNodes.push(dojo.html.insertCssText(styles[i]));
538
						}
540
						}
539
					}
541
					}
540
					if (this.parseContent) {
542
					if (this.parseContent) {
541
						for (var i = 0, requires = data.requires; i < requires.length; i++) {
543
						for (var i = 0, requires = data.requires; i < requires.length; i++) {
542
							try {
544
							try {
543
								eval(requires[i]);
545
								eval(requires[i]);
544
							}
546
							}
545
							catch (e) {
547
							catch (e) {
546
								e._text = "dojo.widget.html.loader.hookUp: error in package loading calls, " + (e.description || e);
548
								e._text = "dojo.widget.html.loader.hookUp: error in package loading calls, " + (e.description || e);
547
								handleDefaults.call(this, e, "onContentError", true);
549
								handleDefaults.call(this, e, "onContentError", true);
548
							}
550
							}
549
						}
551
						}
550
					}
552
					}
551
					if (dojo.hostenv.isXDomain && data.requires.length) {
553
					if (dojo.hostenv.isXDomain && data.requires.length) {
552
						dojo.addOnLoad(function () {
554
						dojo.addOnLoad(function () {
553
							asyncParse.call(this, data);
555
							asyncParse.call(this, data);
554
							if (!dontLog) {
556
							if (!dontLog) {
555
								_loader._log(this, data);
557
								_loader._log(this, data);
556
							}
558
							}
557
						});
559
						});
558
						dontLog = true;
560
						dontLog = true;
559
					} else {
561
					} else {
560
						asyncParse.call(this, data);
562
						asyncParse.call(this, data);
561
					}
563
					}
562
				}
564
				}
563
				if (!dontLog) {
565
				if (!dontLog) {
564
				}
566
				}
565
			};
567
			};
566
		}
568
		}
567
		if (!widgetProto.onContentParse) {
569
		if (!widgetProto.onContentParse) {
568
			widgetProto.onContentParse = function () {
570
			widgetProto.onContentParse = function () {
569
				var node = this.containerNode || this.domNode;
571
				var node = this.containerNode || this.domNode;
570
				var parser = new dojo.xml.Parse();
572
				var parser = new dojo.xml.Parse();
571
				var frag = parser.parseElement(node, null, true);
573
				var frag = parser.parseElement(node, null, true);
572
				dojo.widget.getParser().createSubComponents(frag, this);
574
				dojo.widget.getParser().createSubComponents(frag, this);
573
			};
575
			};
574
		}
576
		}
575
		if (!widgetProto.onExecScript) {
577
		if (!widgetProto.onExecScript) {
576
			widgetProto.onExecScript = function (scripts) {
578
			widgetProto.onExecScript = function (scripts) {
577
				var self = this, tmp = "", code = "";
579
				var self = this, tmp = "", code = "";
578
				for (var i = 0; i < scripts.length; i++) {
580
				for (var i = 0; i < scripts.length; i++) {
579
					if (scripts[i].path) {
581
					if (scripts[i].path) {
580
						var url = scripts[i].path;
582
						var url = scripts[i].path;
581
						downloader.call(this, {"url":url, "load":function (type, scriptStr) {
583
						downloader.call(this, {"url":url, "load":function (type, scriptStr) {
582
							(function () {
584
							(function () {
583
								tmp = scriptStr;
585
								tmp = scriptStr;
584
								scripts[i] = scriptStr;
586
								scripts[i] = scriptStr;
585
							}).call(self);
587
							}).call(self);
586
						}, "error":function (type, error) {
588
						}, "error":function (type, error) {
587
							error._text = type + " downloading remote script";
589
							error._text = type + " downloading remote script";
588
							handleDefaults.call(self, error, "onExecError", true);
590
							handleDefaults.call(self, error, "onExecError", true);
589
						}, "mimetype":"text/plain", "sync":true});
591
						}, "mimetype":"text/plain", "sync":true});
590
						code += tmp;
592
						code += tmp;
591
					} else {
593
					} else {
592
						code += scripts[i];
594
						code += scripts[i];
593
					}
595
					}
594
				}
596
				}
595
				try {
597
				try {
596
					delete this.scriptScope;
598
					delete this.scriptScope;
597
					this.scriptScope = new (new Function("_container_", code + "; return this;"))(self);
599
					this.scriptScope = new (new Function("_container_", code + "; return this;"))(self);
598
				}
600
				}
599
				catch (e) {
601
				catch (e) {
600
					e._text = "Error running scripts from content:\n" + (e.description || e.toString());
602
					e._text = "Error running scripts from content:\n" + (e.description || e.toString());
601
					handleDefaults.call(this, e, "onExecError", true);
603
					handleDefaults.call(this, e, "onExecError", true);
602
				}
604
				}
603
			};
605
			};
604
		}
606
		}
605
		if (!widgetProto.setHandler) {
607
		if (!widgetProto.setHandler) {
606
			widgetProto.setHandler = function (handler) {
608
			widgetProto.setHandler = function (handler) {
607
				var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
609
				var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
608
				if (!isFunc(fcn)) {
610
				if (!isFunc(fcn)) {
609
					handleDefaults.call(this, "Unable to set handler, '" + handler + "' not a function.", "onExecError", true);
611
					handleDefaults.call(this, "Unable to set handler, '" + handler + "' not a function.", "onExecError", true);
610
					return;
612
					return;
611
				}
613
				}
612
				this.handler = function () {
614
				this.handler = function () {
613
					return fcn.apply(this, arguments);
615
					return fcn.apply(this, arguments);
614
				};
616
				};
615
			};
617
			};
616
		}
618
		}
617
		widgetProto._loader_defined = true;
619
		widgetProto._loader_defined = true;
618
	};
620
	};
619
})();
621
})();
620
 
622