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.ContentPane");
13
dojo.provide("dojo.widget.ContentPane");
12
dojo.require("dojo.widget.*");
14
dojo.require("dojo.widget.*");
13
dojo.require("dojo.io.*");
15
dojo.require("dojo.io.*");
14
dojo.require("dojo.widget.HtmlWidget");
16
dojo.require("dojo.widget.HtmlWidget");
15
dojo.require("dojo.string");
17
dojo.require("dojo.string");
16
dojo.require("dojo.string.extras");
18
dojo.require("dojo.string.extras");
17
dojo.require("dojo.html.style");
19
dojo.require("dojo.html.style");
18
dojo.widget.defineWidget("dojo.widget.ContentPane", dojo.widget.HtmlWidget, function () {
20
dojo.widget.defineWidget("dojo.widget.ContentPane", dojo.widget.HtmlWidget, function () {
19
	this._styleNodes = [];
21
	this._styleNodes = [];
20
	this._onLoadStack = [];
22
	this._onLoadStack = [];
21
	this._onUnloadStack = [];
23
	this._onUnloadStack = [];
22
	this._callOnUnload = false;
24
	this._callOnUnload = false;
23
	this._ioBindObj;
25
	this._ioBindObj;
24
	this.scriptScope;
26
	this.scriptScope;
25
	this.bindArgs = {};
27
	this.bindArgs = {};
26
}, {isContainer:true, adjustPaths:true, href:"", extractContent:true, parseContent:true, cacheContent:true, preload:false, refreshOnShow:false, handler:"", executeScripts:false, scriptSeparation:true, loadingMessage:"Loading...", isLoaded:false, postCreate:function (args, frag, parentComp) {
28
}, {isContainer:true, adjustPaths:true, href:"", extractContent:true, parseContent:true, cacheContent:true, preload:false, refreshOnShow:false, handler:"", executeScripts:false, scriptSeparation:true, loadingMessage:"Loading...", isLoaded:false, postCreate:function (args, frag, parentComp) {
27
	if (this.handler !== "") {
29
	if (this.handler !== "") {
28
		this.setHandler(this.handler);
30
		this.setHandler(this.handler);
29
	}
31
	}
30
	if (this.isShowing() || this.preload) {
32
	if (this.isShowing() || this.preload) {
31
		this.loadContents();
33
		this.loadContents();
32
	}
34
	}
33
}, show:function () {
35
}, show:function () {
34
	if (this.refreshOnShow) {
36
	if (this.refreshOnShow) {
35
		this.refresh();
37
		this.refresh();
36
	} else {
38
	} else {
37
		this.loadContents();
39
		this.loadContents();
38
	}
40
	}
39
	dojo.widget.ContentPane.superclass.show.call(this);
41
	dojo.widget.ContentPane.superclass.show.call(this);
40
}, refresh:function () {
42
}, refresh:function () {
41
	this.isLoaded = false;
43
	this.isLoaded = false;
42
	this.loadContents();
44
	this.loadContents();
43
}, loadContents:function () {
45
}, loadContents:function () {
44
	if (this.isLoaded) {
46
	if (this.isLoaded) {
45
		return;
47
		return;
46
	}
48
	}
47
	if (dojo.lang.isFunction(this.handler)) {
49
	if (dojo.lang.isFunction(this.handler)) {
48
		this._runHandler();
50
		this._runHandler();
49
	} else {
51
	} else {
50
		if (this.href != "") {
52
		if (this.href != "") {
51
			this._downloadExternalContent(this.href, this.cacheContent && !this.refreshOnShow);
53
			this._downloadExternalContent(this.href, this.cacheContent && !this.refreshOnShow);
52
		}
54
		}
53
	}
55
	}
54
}, setUrl:function (url) {
56
}, setUrl:function (url) {
55
	this.href = url;
57
	this.href = url;
56
	this.isLoaded = false;
58
	this.isLoaded = false;
57
	if (this.preload || this.isShowing()) {
59
	if (this.preload || this.isShowing()) {
58
		this.loadContents();
60
		this.loadContents();
59
	}
61
	}
60
}, abort:function () {
62
}, abort:function () {
61
	var bind = this._ioBindObj;
63
	var bind = this._ioBindObj;
62
	if (!bind || !bind.abort) {
64
	if (!bind || !bind.abort) {
63
		return;
65
		return;
64
	}
66
	}
65
	bind.abort();
67
	bind.abort();
66
	delete this._ioBindObj;
68
	delete this._ioBindObj;
67
}, _downloadExternalContent:function (url, useCache) {
69
}, _downloadExternalContent:function (url, useCache) {
68
	this.abort();
70
	this.abort();
69
	this._handleDefaults(this.loadingMessage, "onDownloadStart");
71
	this._handleDefaults(this.loadingMessage, "onDownloadStart");
70
	var self = this;
72
	var self = this;
71
	this._ioBindObj = dojo.io.bind(this._cacheSetting({url:url, mimetype:"text/html", handler:function (type, data, xhr) {
73
	this._ioBindObj = dojo.io.bind(this._cacheSetting({url:url, mimetype:"text/html", handler:function (type, data, xhr) {
72
		delete self._ioBindObj;
74
		delete self._ioBindObj;
73
		if (type == "load") {
75
		if (type == "load") {
74
			self.onDownloadEnd.call(self, url, data);
76
			self.onDownloadEnd.call(self, url, data);
75
		} else {
77
		} else {
76
			var e = {responseText:xhr.responseText, status:xhr.status, statusText:xhr.statusText, responseHeaders:xhr.getAllResponseHeaders(), text:"Error loading '" + url + "' (" + xhr.status + " " + xhr.statusText + ")"};
78
			var e = {responseText:xhr.responseText, status:xhr.status, statusText:xhr.statusText, responseHeaders:xhr.getAllResponseHeaders(), text:"Error loading '" + url + "' (" + xhr.status + " " + xhr.statusText + ")"};
77
			self._handleDefaults.call(self, e, "onDownloadError");
79
			self._handleDefaults.call(self, e, "onDownloadError");
78
			self.onLoad();
80
			self.onLoad();
79
		}
81
		}
80
	}}, useCache));
82
	}}, useCache));
81
}, _cacheSetting:function (bindObj, useCache) {
83
}, _cacheSetting:function (bindObj, useCache) {
82
	for (var x in this.bindArgs) {
84
	for (var x in this.bindArgs) {
83
		if (dojo.lang.isUndefined(bindObj[x])) {
85
		if (dojo.lang.isUndefined(bindObj[x])) {
84
			bindObj[x] = this.bindArgs[x];
86
			bindObj[x] = this.bindArgs[x];
85
		}
87
		}
86
	}
88
	}
87
	if (dojo.lang.isUndefined(bindObj.useCache)) {
89
	if (dojo.lang.isUndefined(bindObj.useCache)) {
88
		bindObj.useCache = useCache;
90
		bindObj.useCache = useCache;
89
	}
91
	}
90
	if (dojo.lang.isUndefined(bindObj.preventCache)) {
92
	if (dojo.lang.isUndefined(bindObj.preventCache)) {
91
		bindObj.preventCache = !useCache;
93
		bindObj.preventCache = !useCache;
92
	}
94
	}
93
	if (dojo.lang.isUndefined(bindObj.mimetype)) {
95
	if (dojo.lang.isUndefined(bindObj.mimetype)) {
94
		bindObj.mimetype = "text/html";
96
		bindObj.mimetype = "text/html";
95
	}
97
	}
96
	return bindObj;
98
	return bindObj;
97
}, onLoad:function (e) {
99
}, onLoad:function (e) {
98
	this._runStack("_onLoadStack");
100
	this._runStack("_onLoadStack");
99
	this.isLoaded = true;
101
	this.isLoaded = true;
100
}, onUnLoad:function (e) {
102
}, onUnLoad:function (e) {
101
	dojo.deprecated(this.widgetType + ".onUnLoad, use .onUnload (lowercased load)", 0.5);
103
	dojo.deprecated(this.widgetType + ".onUnLoad, use .onUnload (lowercased load)", 0.5);
102
}, onUnload:function (e) {
104
}, onUnload:function (e) {
103
	this._runStack("_onUnloadStack");
105
	this._runStack("_onUnloadStack");
104
	delete this.scriptScope;
106
	delete this.scriptScope;
105
	if (this.onUnLoad !== dojo.widget.ContentPane.prototype.onUnLoad) {
107
	if (this.onUnLoad !== dojo.widget.ContentPane.prototype.onUnLoad) {
106
		this.onUnLoad.apply(this, arguments);
108
		this.onUnLoad.apply(this, arguments);
107
	}
109
	}
108
}, _runStack:function (stName) {
110
}, _runStack:function (stName) {
109
	var st = this[stName];
111
	var st = this[stName];
110
	var err = "";
112
	var err = "";
111
	var scope = this.scriptScope || window;
113
	var scope = this.scriptScope || window;
112
	for (var i = 0; i < st.length; i++) {
114
	for (var i = 0; i < st.length; i++) {
113
		try {
115
		try {
114
			st[i].call(scope);
116
			st[i].call(scope);
115
		}
117
		}
116
		catch (e) {
118
		catch (e) {
117
			err += "\n" + st[i] + " failed: " + e.description;
119
			err += "\n" + st[i] + " failed: " + e.description;
118
		}
120
		}
119
	}
121
	}
120
	this[stName] = [];
122
	this[stName] = [];
121
	if (err.length) {
123
	if (err.length) {
122
		var name = (stName == "_onLoadStack") ? "addOnLoad" : "addOnUnLoad";
124
		var name = (stName == "_onLoadStack") ? "addOnLoad" : "addOnUnLoad";
123
		this._handleDefaults(name + " failure\n " + err, "onExecError", "debug");
125
		this._handleDefaults(name + " failure\n " + err, "onExecError", "debug");
124
	}
126
	}
125
}, addOnLoad:function (obj, func) {
127
}, addOnLoad:function (obj, func) {
126
	this._pushOnStack(this._onLoadStack, obj, func);
128
	this._pushOnStack(this._onLoadStack, obj, func);
127
}, addOnUnload:function (obj, func) {
129
}, addOnUnload:function (obj, func) {
128
	this._pushOnStack(this._onUnloadStack, obj, func);
130
	this._pushOnStack(this._onUnloadStack, obj, func);
129
}, addOnUnLoad:function () {
131
}, addOnUnLoad:function () {
130
	dojo.deprecated(this.widgetType + ".addOnUnLoad, use addOnUnload instead. (lowercased Load)", 0.5);
132
	dojo.deprecated(this.widgetType + ".addOnUnLoad, use addOnUnload instead. (lowercased Load)", 0.5);
131
	this.addOnUnload.apply(this, arguments);
133
	this.addOnUnload.apply(this, arguments);
132
}, _pushOnStack:function (stack, obj, func) {
134
}, _pushOnStack:function (stack, obj, func) {
133
	if (typeof func == "undefined") {
135
	if (typeof func == "undefined") {
134
		stack.push(obj);
136
		stack.push(obj);
135
	} else {
137
	} else {
136
		stack.push(function () {
138
		stack.push(function () {
137
			obj[func]();
139
			obj[func]();
138
		});
140
		});
139
	}
141
	}
140
}, destroy:function () {
142
}, destroy:function () {
141
	this.onUnload();
143
	this.onUnload();
142
	dojo.widget.ContentPane.superclass.destroy.call(this);
144
	dojo.widget.ContentPane.superclass.destroy.call(this);
143
}, onExecError:function (e) {
145
}, onExecError:function (e) {
144
}, onContentError:function (e) {
146
}, onContentError:function (e) {
145
}, onDownloadError:function (e) {
147
}, onDownloadError:function (e) {
146
}, onDownloadStart:function (e) {
148
}, onDownloadStart:function (e) {
147
}, onDownloadEnd:function (url, data) {
149
}, onDownloadEnd:function (url, data) {
148
	data = this.splitAndFixPaths(data, url);
150
	data = this.splitAndFixPaths(data, url);
149
	this.setContent(data);
151
	this.setContent(data);
150
}, _handleDefaults:function (e, handler, messType) {
152
}, _handleDefaults:function (e, handler, messType) {
151
	if (!handler) {
153
	if (!handler) {
152
		handler = "onContentError";
154
		handler = "onContentError";
153
	}
155
	}
154
	if (dojo.lang.isString(e)) {
156
	if (dojo.lang.isString(e)) {
155
		e = {text:e};
157
		e = {text:e};
156
	}
158
	}
157
	if (!e.text) {
159
	if (!e.text) {
158
		e.text = e.toString();
160
		e.text = e.toString();
159
	}
161
	}
160
	e.toString = function () {
162
	e.toString = function () {
161
		return this.text;
163
		return this.text;
162
	};
164
	};
163
	if (typeof e.returnValue != "boolean") {
165
	if (typeof e.returnValue != "boolean") {
164
		e.returnValue = true;
166
		e.returnValue = true;
165
	}
167
	}
166
	if (typeof e.preventDefault != "function") {
168
	if (typeof e.preventDefault != "function") {
167
		e.preventDefault = function () {
169
		e.preventDefault = function () {
168
			this.returnValue = false;
170
			this.returnValue = false;
169
		};
171
		};
170
	}
172
	}
171
	this[handler](e);
173
	this[handler](e);
172
	if (e.returnValue) {
174
	if (e.returnValue) {
173
		switch (messType) {
175
		switch (messType) {
174
		  case true:
176
		  case true:
175
		  case "alert":
177
		  case "alert":
176
			alert(e.toString());
178
			alert(e.toString());
177
			break;
179
			break;
178
		  case "debug":
180
		  case "debug":
179
			dojo.debug(e.toString());
181
			dojo.debug(e.toString());
180
			break;
182
			break;
181
		  default:
183
		  default:
182
			if (this._callOnUnload) {
184
			if (this._callOnUnload) {
183
				this.onUnload();
185
				this.onUnload();
184
			}
186
			}
185
			this._callOnUnload = false;
187
			this._callOnUnload = false;
186
			if (arguments.callee._loopStop) {
188
			if (arguments.callee._loopStop) {
187
				dojo.debug(e.toString());
189
				dojo.debug(e.toString());
188
			} else {
190
			} else {
189
				arguments.callee._loopStop = true;
191
				arguments.callee._loopStop = true;
190
				this._setContent(e.toString());
192
				this._setContent(e.toString());
191
			}
193
			}
192
		}
194
		}
193
	}
195
	}
194
	arguments.callee._loopStop = false;
196
	arguments.callee._loopStop = false;
195
}, splitAndFixPaths:function (s, url) {
197
}, splitAndFixPaths:function (s, url) {
196
	var titles = [], scripts = [], tmp = [];
198
	var titles = [], scripts = [], tmp = [];
197
	var match = [], requires = [], attr = [], styles = [];
199
	var match = [], requires = [], attr = [], styles = [];
198
	var str = "", path = "", fix = "", tagFix = "", tag = "", origPath = "";
200
	var str = "", path = "", fix = "", tagFix = "", tag = "", origPath = "";
199
	if (!url) {
201
	if (!url) {
200
		url = "./";
202
		url = "./";
201
	}
203
	}
202
	if (s) {
204
	if (s) {
203
		var regex = /<title[^>]*>([\s\S]*?)<\/title>/i;
205
		var regex = /<title[^>]*>([\s\S]*?)<\/title>/i;
204
		while (match = regex.exec(s)) {
206
		while (match = regex.exec(s)) {
205
			titles.push(match[1]);
207
			titles.push(match[1]);
206
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
208
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
207
		}
209
		}
208
		if (this.adjustPaths) {
210
		if (this.adjustPaths) {
209
			var regexFindTag = /<[a-z][a-z0-9]*[^>]*\s(?:(?:src|href|style)=[^>])+[^>]*>/i;
211
			var regexFindTag = /<[a-z][a-z0-9]*[^>]*\s(?:(?:src|href|style)=[^>])+[^>]*>/i;
210
			var regexFindAttr = /\s(src|href|style)=(['"]?)([\w()\[\]\/.,\\'"-:;#=&?\s@]+?)\2/i;
212
			var regexFindAttr = /\s(src|href|style)=(['"]?)([\w()\[\]\/.,\\'"-:;#=&?\s@]+?)\2/i;
211
			var regexProtocols = /^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/;
213
			var regexProtocols = /^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/;
212
			while (tag = regexFindTag.exec(s)) {
214
			while (tag = regexFindTag.exec(s)) {
213
				str += s.substring(0, tag.index);
215
				str += s.substring(0, tag.index);
214
				s = s.substring((tag.index + tag[0].length), s.length);
216
				s = s.substring((tag.index + tag[0].length), s.length);
215
				tag = tag[0];
217
				tag = tag[0];
216
				tagFix = "";
218
				tagFix = "";
217
				while (attr = regexFindAttr.exec(tag)) {
219
				while (attr = regexFindAttr.exec(tag)) {
218
					path = "";
220
					path = "";
219
					origPath = attr[3];
221
					origPath = attr[3];
220
					switch (attr[1].toLowerCase()) {
222
					switch (attr[1].toLowerCase()) {
221
					  case "src":
223
					  case "src":
222
					  case "href":
224
					  case "href":
223
						if (regexProtocols.exec(origPath)) {
225
						if (regexProtocols.exec(origPath)) {
224
							path = origPath;
226
							path = origPath;
225
						} else {
227
						} else {
226
							path = (new dojo.uri.Uri(url, origPath).toString());
228
							path = (new dojo.uri.Uri(url, origPath).toString());
227
						}
229
						}
228
						break;
230
						break;
229
					  case "style":
231
					  case "style":
230
						path = dojo.html.fixPathsInCssText(origPath, url);
232
						path = dojo.html.fixPathsInCssText(origPath, url);
231
						break;
233
						break;
232
					  default:
234
					  default:
233
						path = origPath;
235
						path = origPath;
234
					}
236
					}
235
					fix = " " + attr[1] + "=" + attr[2] + path + attr[2];
237
					fix = " " + attr[1] + "=" + attr[2] + path + attr[2];
236
					tagFix += tag.substring(0, attr.index) + fix;
238
					tagFix += tag.substring(0, attr.index) + fix;
237
					tag = tag.substring((attr.index + attr[0].length), tag.length);
239
					tag = tag.substring((attr.index + attr[0].length), tag.length);
238
				}
240
				}
239
				str += tagFix + tag;
241
				str += tagFix + tag;
240
			}
242
			}
241
			s = str + s;
243
			s = str + s;
242
		}
244
		}
243
		regex = /(?:<(style)[^>]*>([\s\S]*?)<\/style>|<link ([^>]*rel=['"]?stylesheet['"]?[^>]*)>)/i;
245
		regex = /(?:<(style)[^>]*>([\s\S]*?)<\/style>|<link ([^>]*rel=['"]?stylesheet['"]?[^>]*)>)/i;
244
		while (match = regex.exec(s)) {
246
		while (match = regex.exec(s)) {
245
			if (match[1] && match[1].toLowerCase() == "style") {
247
			if (match[1] && match[1].toLowerCase() == "style") {
246
				styles.push(dojo.html.fixPathsInCssText(match[2], url));
248
				styles.push(dojo.html.fixPathsInCssText(match[2], url));
247
			} else {
249
			} else {
248
				if (attr = match[3].match(/href=(['"]?)([^'">]*)\1/i)) {
250
				if (attr = match[3].match(/href=(['"]?)([^'">]*)\1/i)) {
249
					styles.push({path:attr[2]});
251
					styles.push({path:attr[2]});
250
				}
252
				}
251
			}
253
			}
252
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
254
			s = s.substring(0, match.index) + s.substr(match.index + match[0].length);
253
		}
255
		}
254
		var regex = /<script([^>]*)>([\s\S]*?)<\/script>/i;
256
		var regex = /<script([^>]*)>([\s\S]*?)<\/script>/i;
255
		var regexSrc = /src=(['"]?)([^"']*)\1/i;
257
		var regexSrc = /src=(['"]?)([^"']*)\1/i;
256
		var regexDojoJs = /.*(\bdojo\b\.js(?:\.uncompressed\.js)?)$/;
258
		var regexDojoJs = /.*(\bdojo\b\.js(?:\.uncompressed\.js)?)$/;
257
		var regexInvalid = /(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g;
259
		var regexInvalid = /(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g;
258
		var regexRequires = /dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix|registerModulePath)|defineNamespace)\((['"]).*?\1\)\s*;?/;
260
		var regexRequires = /dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix|registerModulePath)|defineNamespace)\((['"]).*?\1\)\s*;?/;
259
		while (match = regex.exec(s)) {
261
		while (match = regex.exec(s)) {
260
			if (this.executeScripts && match[1]) {
262
			if (this.executeScripts && match[1]) {
261
				if (attr = regexSrc.exec(match[1])) {
263
				if (attr = regexSrc.exec(match[1])) {
262
					if (regexDojoJs.exec(attr[2])) {
264
					if (regexDojoJs.exec(attr[2])) {
263
						dojo.debug("Security note! inhibit:" + attr[2] + " from  being loaded again.");
265
						dojo.debug("Security note! inhibit:" + attr[2] + " from  being loaded again.");
264
					} else {
266
					} else {
265
						scripts.push({path:attr[2]});
267
						scripts.push({path:attr[2]});
266
					}
268
					}
267
				}
269
				}
268
			}
270
			}
269
			if (match[2]) {
271
			if (match[2]) {
270
				var sc = match[2].replace(regexInvalid, "");
272
				var sc = match[2].replace(regexInvalid, "");
271
				if (!sc) {
273
				if (!sc) {
272
					continue;
274
					continue;
273
				}
275
				}
274
				while (tmp = regexRequires.exec(sc)) {
276
				while (tmp = regexRequires.exec(sc)) {
275
					requires.push(tmp[0]);
277
					requires.push(tmp[0]);
276
					sc = sc.substring(0, tmp.index) + sc.substr(tmp.index + tmp[0].length);
278
					sc = sc.substring(0, tmp.index) + sc.substr(tmp.index + tmp[0].length);
277
				}
279
				}
278
				if (this.executeScripts) {
280
				if (this.executeScripts) {
279
					scripts.push(sc);
281
					scripts.push(sc);
280
				}
282
				}
281
			}
283
			}
282
			s = s.substr(0, match.index) + s.substr(match.index + match[0].length);
284
			s = s.substr(0, match.index) + s.substr(match.index + match[0].length);
283
		}
285
		}
284
		if (this.extractContent) {
286
		if (this.extractContent) {
285
			match = s.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
287
			match = s.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
286
			if (match) {
288
			if (match) {
287
				s = match[1];
289
				s = match[1];
288
			}
290
			}
289
		}
291
		}
290
		if (this.executeScripts && this.scriptSeparation) {
292
		if (this.executeScripts && this.scriptSeparation) {
291
			var regex = /(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*?\S=)((['"])[^>]*scriptScope[^>]*>)/;
293
			var regex = /(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*?\S=)((['"])[^>]*scriptScope[^>]*>)/;
292
			var regexAttr = /([\s'";:\(])scriptScope(.*)/;
294
			var regexAttr = /([\s'";:\(])scriptScope(.*)/;
293
			str = "";
295
			str = "";
294
			while (tag = regex.exec(s)) {
296
			while (tag = regex.exec(s)) {
295
				tmp = ((tag[3] == "'") ? "\"" : "'");
297
				tmp = ((tag[3] == "'") ? "\"" : "'");
296
				fix = "";
298
				fix = "";
297
				str += s.substring(0, tag.index) + tag[1];
299
				str += s.substring(0, tag.index) + tag[1];
298
				while (attr = regexAttr.exec(tag[2])) {
300
				while (attr = regexAttr.exec(tag[2])) {
299
					tag[2] = tag[2].substring(0, attr.index) + attr[1] + "dojo.widget.byId(" + tmp + this.widgetId + tmp + ").scriptScope" + attr[2];
301
					tag[2] = tag[2].substring(0, attr.index) + attr[1] + "dojo.widget.byId(" + tmp + this.widgetId + tmp + ").scriptScope" + attr[2];
300
				}
302
				}
301
				str += tag[2];
303
				str += tag[2];
302
				s = s.substr(tag.index + tag[0].length);
304
				s = s.substr(tag.index + tag[0].length);
303
			}
305
			}
304
			s = str + s;
306
			s = str + s;
305
		}
307
		}
306
	}
308
	}
307
	return {"xml":s, "styles":styles, "titles":titles, "requires":requires, "scripts":scripts, "url":url};
309
	return {"xml":s, "styles":styles, "titles":titles, "requires":requires, "scripts":scripts, "url":url};
308
}, _setContent:function (cont) {
310
}, _setContent:function (cont) {
309
	this.destroyChildren();
311
	this.destroyChildren();
310
	for (var i = 0; i < this._styleNodes.length; i++) {
312
	for (var i = 0; i < this._styleNodes.length; i++) {
311
		if (this._styleNodes[i] && this._styleNodes[i].parentNode) {
313
		if (this._styleNodes[i] && this._styleNodes[i].parentNode) {
312
			this._styleNodes[i].parentNode.removeChild(this._styleNodes[i]);
314
			this._styleNodes[i].parentNode.removeChild(this._styleNodes[i]);
313
		}
315
		}
314
	}
316
	}
315
	this._styleNodes = [];
317
	this._styleNodes = [];
316
	try {
318
	try {
317
		var node = this.containerNode || this.domNode;
319
		var node = this.containerNode || this.domNode;
318
		while (node.firstChild) {
320
		while (node.firstChild) {
319
			dojo.html.destroyNode(node.firstChild);
321
			dojo.html.destroyNode(node.firstChild);
320
		}
322
		}
321
		if (typeof cont != "string") {
323
		if (typeof cont != "string") {
322
			node.appendChild(cont);
324
			node.appendChild(cont);
323
		} else {
325
		} else {
324
			node.innerHTML = cont;
326
			node.innerHTML = cont;
325
		}
327
		}
326
	}
328
	}
327
	catch (e) {
329
	catch (e) {
328
		e.text = "Couldn't load content:" + e.description;
330
		e.text = "Couldn't load content:" + e.description;
329
		this._handleDefaults(e, "onContentError");
331
		this._handleDefaults(e, "onContentError");
330
	}
332
	}
331
}, setContent:function (data) {
333
}, setContent:function (data) {
332
	this.abort();
334
	this.abort();
333
	if (this._callOnUnload) {
335
	if (this._callOnUnload) {
334
		this.onUnload();
336
		this.onUnload();
335
	}
337
	}
336
	this._callOnUnload = true;
338
	this._callOnUnload = true;
337
	if (!data || dojo.html.isNode(data)) {
339
	if (!data || dojo.html.isNode(data)) {
338
		this._setContent(data);
340
		this._setContent(data);
339
		this.onResized();
341
		this.onResized();
340
		this.onLoad();
342
		this.onLoad();
341
	} else {
343
	} else {
342
		if (typeof data.xml != "string") {
344
		if (typeof data.xml != "string") {
343
			this.href = "";
345
			this.href = "";
344
			data = this.splitAndFixPaths(data);
346
			data = this.splitAndFixPaths(data);
345
		}
347
		}
346
		this._setContent(data.xml);
348
		this._setContent(data.xml);
347
		for (var i = 0; i < data.styles.length; i++) {
349
		for (var i = 0; i < data.styles.length; i++) {
348
			if (data.styles[i].path) {
350
			if (data.styles[i].path) {
349
				this._styleNodes.push(dojo.html.insertCssFile(data.styles[i].path, dojo.doc(), false, true));
351
				this._styleNodes.push(dojo.html.insertCssFile(data.styles[i].path, dojo.doc(), false, true));
350
			} else {
352
			} else {
351
				this._styleNodes.push(dojo.html.insertCssText(data.styles[i]));
353
				this._styleNodes.push(dojo.html.insertCssText(data.styles[i]));
352
			}
354
			}
353
		}
355
		}
354
		if (this.parseContent) {
356
		if (this.parseContent) {
355
			for (var i = 0; i < data.requires.length; i++) {
357
			for (var i = 0; i < data.requires.length; i++) {
356
				try {
358
				try {
357
					eval(data.requires[i]);
359
					eval(data.requires[i]);
358
				}
360
				}
359
				catch (e) {
361
				catch (e) {
360
					e.text = "ContentPane: error in package loading calls, " + (e.description || e);
362
					e.text = "ContentPane: error in package loading calls, " + (e.description || e);
361
					this._handleDefaults(e, "onContentError", "debug");
363
					this._handleDefaults(e, "onContentError", "debug");
362
				}
364
				}
363
			}
365
			}
364
		}
366
		}
365
		var _self = this;
367
		var _self = this;
366
		function asyncParse() {
368
		function asyncParse() {
367
			if (_self.executeScripts) {
369
			if (_self.executeScripts) {
368
				_self._executeScripts(data.scripts);
370
				_self._executeScripts(data.scripts);
369
			}
371
			}
370
			if (_self.parseContent) {
372
			if (_self.parseContent) {
371
				var node = _self.containerNode || _self.domNode;
373
				var node = _self.containerNode || _self.domNode;
372
				var parser = new dojo.xml.Parse();
374
				var parser = new dojo.xml.Parse();
373
				var frag = parser.parseElement(node, null, true);
375
				var frag = parser.parseElement(node, null, true);
374
				dojo.widget.getParser().createSubComponents(frag, _self);
376
				dojo.widget.getParser().createSubComponents(frag, _self);
375
			}
377
			}
376
			_self.onResized();
378
			_self.onResized();
377
			_self.onLoad();
379
			_self.onLoad();
378
		}
380
		}
379
		if (dojo.hostenv.isXDomain && data.requires.length) {
381
		if (dojo.hostenv.isXDomain && data.requires.length) {
380
			dojo.addOnLoad(asyncParse);
382
			dojo.addOnLoad(asyncParse);
381
		} else {
383
		} else {
382
			asyncParse();
384
			asyncParse();
383
		}
385
		}
384
	}
386
	}
385
}, setHandler:function (handler) {
387
}, setHandler:function (handler) {
386
	var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
388
	var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
387
	if (!dojo.lang.isFunction(fcn)) {
389
	if (!dojo.lang.isFunction(fcn)) {
388
		this._handleDefaults("Unable to set handler, '" + handler + "' not a function.", "onExecError", true);
390
		this._handleDefaults("Unable to set handler, '" + handler + "' not a function.", "onExecError", true);
389
		return;
391
		return;
390
	}
392
	}
391
	this.handler = function () {
393
	this.handler = function () {
392
		return fcn.apply(this, arguments);
394
		return fcn.apply(this, arguments);
393
	};
395
	};
394
}, _runHandler:function () {
396
}, _runHandler:function () {
395
	var ret = true;
397
	var ret = true;
396
	if (dojo.lang.isFunction(this.handler)) {
398
	if (dojo.lang.isFunction(this.handler)) {
397
		this.handler(this, this.domNode);
399
		this.handler(this, this.domNode);
398
		ret = false;
400
		ret = false;
399
	}
401
	}
400
	this.onLoad();
402
	this.onLoad();
401
	return ret;
403
	return ret;
402
}, _executeScripts:function (scripts) {
404
}, _executeScripts:function (scripts) {
403
	var self = this;
405
	var self = this;
404
	var tmp = "", code = "";
406
	var tmp = "", code = "";
405
	for (var i = 0; i < scripts.length; i++) {
407
	for (var i = 0; i < scripts.length; i++) {
406
		if (scripts[i].path) {
408
		if (scripts[i].path) {
407
			dojo.io.bind(this._cacheSetting({"url":scripts[i].path, "load":function (type, scriptStr) {
409
			dojo.io.bind(this._cacheSetting({"url":scripts[i].path, "load":function (type, scriptStr) {
408
				dojo.lang.hitch(self, tmp = ";" + scriptStr);
410
				dojo.lang.hitch(self, tmp = ";" + scriptStr);
409
			}, "error":function (type, error) {
411
			}, "error":function (type, error) {
410
				error.text = type + " downloading remote script";
412
				error.text = type + " downloading remote script";
411
				self._handleDefaults.call(self, error, "onExecError", "debug");
413
				self._handleDefaults.call(self, error, "onExecError", "debug");
412
			}, "mimetype":"text/plain", "sync":true}, this.cacheContent));
414
			}, "mimetype":"text/plain", "sync":true}, this.cacheContent));
413
			code += tmp;
415
			code += tmp;
414
		} else {
416
		} else {
415
			code += scripts[i];
417
			code += scripts[i];
416
		}
418
		}
417
	}
419
	}
418
	try {
420
	try {
419
		if (this.scriptSeparation) {
421
		if (this.scriptSeparation) {
420
			delete this.scriptScope;
422
			delete this.scriptScope;
421
			this.scriptScope = new (new Function("_container_", code + "; return this;"))(self);
423
			this.scriptScope = new (new Function("_container_", code + "; return this;"))(self);
422
		} else {
424
		} else {
423
			var djg = dojo.global();
425
			var djg = dojo.global();
424
			if (djg.execScript) {
426
			if (djg.execScript) {
425
				djg.execScript(code);
427
				djg.execScript(code);
426
			} else {
428
			} else {
427
				var djd = dojo.doc();
429
				var djd = dojo.doc();
428
				var sc = djd.createElement("script");
430
				var sc = djd.createElement("script");
429
				sc.appendChild(djd.createTextNode(code));
431
				sc.appendChild(djd.createTextNode(code));
430
				(this.containerNode || this.domNode).appendChild(sc);
432
				(this.containerNode || this.domNode).appendChild(sc);
431
			}
433
			}
432
		}
434
		}
433
	}
435
	}
434
	catch (e) {
436
	catch (e) {
435
		e.text = "Error running scripts from content:\n" + e.description;
437
		e.text = "Error running scripts from content:\n" + e.description;
436
		this._handleDefaults(e, "onExecError", "debug");
438
		this._handleDefaults(e, "onExecError", "debug");
437
	}
439
	}
438
}});
440
}});
439
 
441