Subversion Repositories Applications.papyrus

Rev

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

Rev 1318 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.hostenv.resetXd = function () {
13
dojo.hostenv.resetXd = function () {
12
	this.isXDomain = djConfig.useXDomain || false;
14
	this.isXDomain = djConfig.useXDomain || false;
13
	this.xdTimer = 0;
15
	this.xdTimer = 0;
14
	this.xdInFlight = {};
16
	this.xdInFlight = {};
15
	this.xdOrderedReqs = [];
17
	this.xdOrderedReqs = [];
16
	this.xdDepMap = {};
18
	this.xdDepMap = {};
17
	this.xdContents = [];
19
	this.xdContents = [];
18
	this.xdDefList = [];
20
	this.xdDefList = [];
19
};
21
};
20
dojo.hostenv.resetXd();
22
dojo.hostenv.resetXd();
21
dojo.hostenv.createXdPackage = function (contents, resourceName, resourcePath) {
23
dojo.hostenv.createXdPackage = function (contents, resourceName, resourcePath) {
22
	var deps = [];
24
	var deps = [];
23
	var depRegExp = /dojo.(require|requireIf|requireAll|provide|requireAfterIf|requireAfter|kwCompoundRequire|conditionalRequire|hostenv\.conditionalLoadModule|.hostenv\.loadModule|hostenv\.moduleLoaded)\(([\w\W]*?)\)/mg;
25
	var depRegExp = /dojo.(requireLocalization|require|requireIf|requireAll|provide|requireAfterIf|requireAfter|kwCompoundRequire|conditionalRequire|hostenv\.conditionalLoadModule|.hostenv\.loadModule|hostenv\.moduleLoaded)\(([\w\W]*?)\)/mg;
24
	var match;
26
	var match;
25
	while ((match = depRegExp.exec(contents)) != null) {
27
	while ((match = depRegExp.exec(contents)) != null) {
-
 
28
		if (match[1] == "requireLocalization") {
-
 
29
			eval(match[0]);
-
 
30
		} else {
26
		deps.push("\"" + match[1] + "\", " + match[2]);
31
			deps.push("\"" + match[1] + "\", " + match[2]);
-
 
32
		}
27
	}
33
	}
28
	var output = [];
34
	var output = [];
29
	output.push("dojo.hostenv.packageLoaded({\n");
35
	output.push("dojo.hostenv.packageLoaded({\n");
30
	if (deps.length > 0) {
36
	if (deps.length > 0) {
31
		output.push("depends: [");
37
		output.push("depends: [");
32
		for (var i = 0; i < deps.length; i++) {
38
		for (var i = 0; i < deps.length; i++) {
33
			if (i > 0) {
39
			if (i > 0) {
34
				output.push(",\n");
40
				output.push(",\n");
35
			}
41
			}
36
			output.push("[" + deps[i] + "]");
42
			output.push("[" + deps[i] + "]");
37
		}
43
		}
38
		output.push("],");
44
		output.push("],");
39
	}
45
	}
40
	output.push("\ndefinePackage: function(dojo){");
46
	output.push("\ndefinePackage: function(dojo){");
41
	output.push(contents);
47
	output.push(contents);
42
	output.push("\n}, resourceName: '" + resourceName + "', resourcePath: '" + resourcePath + "'});");
48
	output.push("\n}, resourceName: '" + resourceName + "', resourcePath: '" + resourcePath + "'});");
43
	return output.join("");
49
	return output.join("");
44
};
50
};
45
dojo.hostenv.loadPath = function (relpath, module, cb) {
51
dojo.hostenv.loadPath = function (relpath, module, cb) {
46
	var colonIndex = relpath.indexOf(":");
52
	var colonIndex = relpath.indexOf(":");
47
	var slashIndex = relpath.indexOf("/");
53
	var slashIndex = relpath.indexOf("/");
48
	var uri;
54
	var uri;
49
	var currentIsXDomain = false;
55
	var currentIsXDomain = false;
50
	if (colonIndex > 0 && colonIndex < slashIndex) {
56
	if (colonIndex > 0 && colonIndex < slashIndex) {
51
		uri = relpath;
57
		uri = relpath;
52
		this.isXDomain = currentIsXDomain = true;
58
		this.isXDomain = currentIsXDomain = true;
53
	} else {
59
	} else {
54
		uri = this.getBaseScriptUri() + relpath;
60
		uri = this.getBaseScriptUri() + relpath;
55
		colonIndex = uri.indexOf(":");
61
		colonIndex = uri.indexOf(":");
56
		slashIndex = uri.indexOf("/");
62
		slashIndex = uri.indexOf("/");
57
		if (colonIndex > 0 && colonIndex < slashIndex && (!location.host || uri.indexOf("http://" + location.host) != 0)) {
63
		if (colonIndex > 0 && colonIndex < slashIndex && (!location.host || uri.indexOf("http://" + location.host) != 0)) {
58
			this.isXDomain = currentIsXDomain = true;
64
			this.isXDomain = currentIsXDomain = true;
59
		}
65
		}
60
	}
66
	}
61
	if (djConfig.cacheBust && dojo.render.html.capable) {
67
	if (djConfig.cacheBust && dojo.render.html.capable) {
62
		uri += "?" + String(djConfig.cacheBust).replace(/\W+/g, "");
68
		uri += "?" + String(djConfig.cacheBust).replace(/\W+/g, "");
63
	}
69
	}
64
	try {
70
	try {
65
		return ((!module || this.isXDomain) ? this.loadUri(uri, cb, currentIsXDomain, module) : this.loadUriAndCheck(uri, module, cb));
71
		return ((!module || this.isXDomain) ? this.loadUri(uri, cb, currentIsXDomain, module) : this.loadUriAndCheck(uri, module, cb));
66
	}
72
	}
67
	catch (e) {
73
	catch (e) {
68
		dojo.debug(e);
74
		dojo.debug(e);
69
		return false;
75
		return false;
70
	}
76
	}
71
};
77
};
72
dojo.hostenv.loadUri = function (uri, cb, currentIsXDomain, module) {
78
dojo.hostenv.loadUri = function (uri, cb, currentIsXDomain, module) {
73
	if (this.loadedUris[uri]) {
79
	if (this.loadedUris[uri]) {
74
		return 1;
80
		return 1;
75
	}
81
	}
76
	if (this.isXDomain) {
82
	if (this.isXDomain && module) {
77
		if (uri.indexOf("__package__") != -1) {
83
		if (uri.indexOf("__package__") != -1) {
78
			module += ".*";
84
			module += ".*";
79
		}
85
		}
80
		this.xdOrderedReqs.push(module);
86
		this.xdOrderedReqs.push(module);
81
		if (currentIsXDomain) {
87
		if (currentIsXDomain || uri.indexOf("/nls/") == -1) {
82
			this.xdInFlight[module] = true;
88
			this.xdInFlight[module] = true;
83
			this.inFlightCount++;
89
			this.inFlightCount++;
84
		}
90
		}
85
		if (!this.xdTimer) {
91
		if (!this.xdTimer) {
86
			this.xdTimer = setInterval("dojo.hostenv.watchInFlightXDomain();", 100);
92
			this.xdTimer = setInterval("dojo.hostenv.watchInFlightXDomain();", 100);
87
		}
93
		}
88
		this.xdStartTime = (new Date()).getTime();
94
		this.xdStartTime = (new Date()).getTime();
89
	}
95
	}
90
	if (currentIsXDomain) {
96
	if (currentIsXDomain) {
91
		var lastIndex = uri.lastIndexOf(".");
97
		var lastIndex = uri.lastIndexOf(".");
92
		if (lastIndex <= 0) {
98
		if (lastIndex <= 0) {
93
			lastIndex = uri.length - 1;
99
			lastIndex = uri.length - 1;
94
		}
100
		}
95
		var xdUri = uri.substring(0, lastIndex) + ".xd";
101
		var xdUri = uri.substring(0, lastIndex) + ".xd";
96
		if (lastIndex != uri.length - 1) {
102
		if (lastIndex != uri.length - 1) {
97
			xdUri += uri.substring(lastIndex, uri.length);
103
			xdUri += uri.substring(lastIndex, uri.length);
98
		}
104
		}
99
		var element = document.createElement("script");
105
		var element = document.createElement("script");
100
		element.type = "text/javascript";
106
		element.type = "text/javascript";
101
		element.src = xdUri;
107
		element.src = xdUri;
102
		if (!this.headElement) {
108
		if (!this.headElement) {
103
			this.headElement = document.getElementsByTagName("head")[0];
109
			this.headElement = document.getElementsByTagName("head")[0];
104
			if (!this.headElement) {
110
			if (!this.headElement) {
105
				this.headElement = document.getElementsByTagName("html")[0];
111
				this.headElement = document.getElementsByTagName("html")[0];
106
			}
112
			}
107
		}
113
		}
108
		this.headElement.appendChild(element);
114
		this.headElement.appendChild(element);
109
	} else {
115
	} else {
110
		var contents = this.getText(uri, null, true);
116
		var contents = this.getText(uri, null, true);
111
		if (contents == null) {
117
		if (contents == null) {
112
			return 0;
118
			return 0;
113
		}
119
		}
114
		if (this.isXDomain && uri.indexOf("/nls/") == -1) {
120
		if (this.isXDomain && uri.indexOf("/nls/") == -1) {
115
			var pkg = this.createXdPackage(contents, module, uri);
121
			var pkg = this.createXdPackage(contents, module, uri);
116
			dj_eval(pkg);
122
			dj_eval(pkg);
117
		} else {
123
		} else {
118
			if (cb) {
124
			if (cb) {
119
				contents = "(" + contents + ")";
125
				contents = "(" + contents + ")";
120
			}
126
			}
121
			var value = dj_eval(contents);
127
			var value = dj_eval(contents);
122
			if (cb) {
128
			if (cb) {
123
				cb(value);
129
				cb(value);
124
			}
130
			}
125
		}
131
		}
126
	}
132
	}
127
	this.loadedUris[uri] = true;
133
	this.loadedUris[uri] = true;
128
	return 1;
134
	return 1;
129
};
135
};
130
dojo.hostenv.packageLoaded = function (pkg) {
136
dojo.hostenv.packageLoaded = function (pkg) {
131
	var deps = pkg.depends;
137
	var deps = pkg.depends;
132
	var requireList = null;
138
	var requireList = null;
133
	var requireAfterList = null;
139
	var requireAfterList = null;
134
	var provideList = [];
140
	var provideList = [];
135
	if (deps && deps.length > 0) {
141
	if (deps && deps.length > 0) {
136
		var dep = null;
142
		var dep = null;
137
		var insertHint = 0;
143
		var insertHint = 0;
138
		var attachedPackage = false;
144
		var attachedPackage = false;
139
		for (var i = 0; i < deps.length; i++) {
145
		for (var i = 0; i < deps.length; i++) {
140
			dep = deps[i];
146
			dep = deps[i];
141
			if (dep[0] == "provide" || dep[0] == "hostenv.moduleLoaded") {
147
			if (dep[0] == "provide" || dep[0] == "hostenv.moduleLoaded") {
142
				provideList.push(dep[1]);
148
				provideList.push(dep[1]);
143
			} else {
149
			} else {
144
				if (!requireList) {
150
				if (!requireList) {
145
					requireList = [];
151
					requireList = [];
146
				}
152
				}
147
				if (!requireAfterList) {
153
				if (!requireAfterList) {
148
					requireAfterList = [];
154
					requireAfterList = [];
149
				}
155
				}
150
				var unpackedDeps = this.unpackXdDependency(dep);
156
				var unpackedDeps = this.unpackXdDependency(dep);
151
				if (unpackedDeps.requires) {
157
				if (unpackedDeps.requires) {
152
					requireList = requireList.concat(unpackedDeps.requires);
158
					requireList = requireList.concat(unpackedDeps.requires);
153
				}
159
				}
154
				if (unpackedDeps.requiresAfter) {
160
				if (unpackedDeps.requiresAfter) {
155
					requireAfterList = requireAfterList.concat(unpackedDeps.requiresAfter);
161
					requireAfterList = requireAfterList.concat(unpackedDeps.requiresAfter);
156
				}
162
				}
157
			}
163
			}
158
			var depType = dep[0];
164
			var depType = dep[0];
159
			var objPath = depType.split(".");
165
			var objPath = depType.split(".");
160
			if (objPath.length == 2) {
166
			if (objPath.length == 2) {
161
				dojo[objPath[0]][objPath[1]].apply(dojo[objPath[0]], dep.slice(1));
167
				dojo[objPath[0]][objPath[1]].apply(dojo[objPath[0]], dep.slice(1));
162
			} else {
168
			} else {
163
				dojo[depType].apply(dojo, dep.slice(1));
169
				dojo[depType].apply(dojo, dep.slice(1));
164
			}
170
			}
165
		}
171
		}
166
		var contentIndex = this.xdContents.push({content:pkg.definePackage, resourceName:pkg["resourceName"], resourcePath:pkg["resourcePath"], isDefined:false}) - 1;
172
		var contentIndex = this.xdContents.push({content:pkg.definePackage, resourceName:pkg["resourceName"], resourcePath:pkg["resourcePath"], isDefined:false}) - 1;
167
		for (var i = 0; i < provideList.length; i++) {
173
		for (var i = 0; i < provideList.length; i++) {
168
			this.xdDepMap[provideList[i]] = {requires:requireList, requiresAfter:requireAfterList, contentIndex:contentIndex};
174
			this.xdDepMap[provideList[i]] = {requires:requireList, requiresAfter:requireAfterList, contentIndex:contentIndex};
169
		}
175
		}
170
		for (var i = 0; i < provideList.length; i++) {
176
		for (var i = 0; i < provideList.length; i++) {
171
			this.xdInFlight[provideList[i]] = false;
177
			this.xdInFlight[provideList[i]] = false;
172
		}
178
		}
173
	}
179
	}
174
};
180
};
175
dojo.hostenv.xdLoadFlattenedBundle = function (moduleName, bundleName, locale, bundleData) {
181
dojo.hostenv.xdLoadFlattenedBundle = function (moduleName, bundleName, locale, bundleData) {
176
	locale = locale || "root";
182
	locale = locale || "root";
177
	var jsLoc = dojo.hostenv.normalizeLocale(locale).replace("-", "_");
183
	var jsLoc = dojo.hostenv.normalizeLocale(locale).replace("-", "_");
178
	var bundlePackage = [moduleName, "nls", bundleName].join(".");
184
	var bundlePackage = [moduleName, "nls", bundleName].join(".");
179
	var bundle = dojo.hostenv.startPackage(bundlePackage);
185
	var bundle = dojo.hostenv.startPackage(bundlePackage);
180
	bundle[jsLoc] = bundleData;
186
	bundle[jsLoc] = bundleData;
181
	var mapName = [moduleName, jsLoc, bundleName].join(".");
187
	var mapName = [moduleName, jsLoc, bundleName].join(".");
182
	var bundleMap = dojo.hostenv.xdBundleMap[mapName];
188
	var bundleMap = dojo.hostenv.xdBundleMap[mapName];
183
	if (bundleMap) {
189
	if (bundleMap) {
184
		for (var param in bundleMap) {
190
		for (var param in bundleMap) {
185
			bundle[param] = bundleData;
191
			bundle[param] = bundleData;
186
		}
192
		}
187
	}
193
	}
188
};
194
};
189
dojo.hostenv.xdBundleMap = {};
195
dojo.hostenv.xdBundleMap = {};
190
dojo.xdRequireLocalization = function (moduleName, bundleName, locale, availableFlatLocales) {
196
dojo.xdRequireLocalization = function (moduleName, bundleName, locale, availableFlatLocales) {
191
	var locales = availableFlatLocales.split(",");
197
	var locales = availableFlatLocales.split(",");
192
	var jsLoc = dojo.hostenv.normalizeLocale(locale);
198
	var jsLoc = dojo.hostenv.normalizeLocale(locale);
193
	var bestLocale = "";
199
	var bestLocale = "";
194
	for (var i = 0; i < locales.length; i++) {
200
	for (var i = 0; i < locales.length; i++) {
195
		if (jsLoc.indexOf(locales[i]) == 0) {
201
		if (jsLoc.indexOf(locales[i]) == 0) {
196
			if (locales[i].length > bestLocale.length) {
202
			if (locales[i].length > bestLocale.length) {
197
				bestLocale = locales[i];
203
				bestLocale = locales[i];
198
			}
204
			}
199
		}
205
		}
200
	}
206
	}
201
	var fixedBestLocale = bestLocale.replace("-", "_");
207
	var fixedBestLocale = bestLocale.replace("-", "_");
202
	var bundlePackage = dojo.evalObjPath([moduleName, "nls", bundleName].join("."));
208
	var bundlePackage = dojo.evalObjPath([moduleName, "nls", bundleName].join("."));
203
	if (bundlePackage && bundlePackage[fixedBestLocale]) {
209
	if (bundlePackage && bundlePackage[fixedBestLocale]) {
204
		bundle[jsLoc.replace("-", "_")] = bundlePackage[fixedBestLocale];
210
		bundle[jsLoc.replace("-", "_")] = bundlePackage[fixedBestLocale];
205
	} else {
211
	} else {
206
		var mapName = [moduleName, (fixedBestLocale || "root"), bundleName].join(".");
212
		var mapName = [moduleName, (fixedBestLocale || "root"), bundleName].join(".");
207
		var bundleMap = dojo.hostenv.xdBundleMap[mapName];
213
		var bundleMap = dojo.hostenv.xdBundleMap[mapName];
208
		if (!bundleMap) {
214
		if (!bundleMap) {
209
			bundleMap = dojo.hostenv.xdBundleMap[mapName] = {};
215
			bundleMap = dojo.hostenv.xdBundleMap[mapName] = {};
210
		}
216
		}
211
		bundleMap[jsLoc.replace("-", "_")] = true;
217
		bundleMap[jsLoc.replace("-", "_")] = true;
212
		dojo.require(moduleName + ".nls" + (bestLocale ? "." + bestLocale : "") + "." + bundleName);
218
		dojo.require(moduleName + ".nls" + (bestLocale ? "." + bestLocale : "") + "." + bundleName);
213
	}
219
	}
214
};
220
};
215
(function () {
221
(function () {
216
	var extra = djConfig.extraLocale;
222
	var extra = djConfig.extraLocale;
217
	if (extra) {
223
	if (extra) {
218
		if (!extra instanceof Array) {
224
		if (!extra instanceof Array) {
219
			extra = [extra];
225
			extra = [extra];
220
		}
226
		}
221
		dojo._xdReqLoc = dojo.xdRequireLocalization;
227
		dojo._xdReqLoc = dojo.xdRequireLocalization;
222
		dojo.xdRequireLocalization = function (m, b, locale, fLocales) {
228
		dojo.xdRequireLocalization = function (m, b, locale, fLocales) {
223
			dojo._xdReqLoc(m, b, locale, fLocales);
229
			dojo._xdReqLoc(m, b, locale, fLocales);
224
			if (locale) {
230
			if (locale) {
225
				return;
231
				return;
226
			}
232
			}
227
			for (var i = 0; i < extra.length; i++) {
233
			for (var i = 0; i < extra.length; i++) {
228
				dojo._xdReqLoc(m, b, extra[i], fLocales);
234
				dojo._xdReqLoc(m, b, extra[i], fLocales);
229
			}
235
			}
230
		};
236
		};
231
	}
237
	}
232
})();
238
})();
233
dojo.hostenv.unpackXdDependency = function (dep) {
239
dojo.hostenv.unpackXdDependency = function (dep) {
234
	var newDeps = null;
240
	var newDeps = null;
235
	var newAfterDeps = null;
241
	var newAfterDeps = null;
236
	switch (dep[0]) {
242
	switch (dep[0]) {
237
	  case "requireIf":
243
	  case "requireIf":
238
	  case "requireAfterIf":
244
	  case "requireAfterIf":
239
	  case "conditionalRequire":
245
	  case "conditionalRequire":
240
		if ((dep[1] === true) || (dep[1] == "common") || (dep[1] && dojo.render[dep[1]].capable)) {
246
		if ((dep[1] === true) || (dep[1] == "common") || (dep[1] && dojo.render[dep[1]].capable)) {
241
			newDeps = [{name:dep[2], content:null}];
247
			newDeps = [{name:dep[2], content:null}];
242
		}
248
		}
243
		break;
249
		break;
244
	  case "requireAll":
250
	  case "requireAll":
245
		dep.shift();
251
		dep.shift();
246
		newDeps = dep;
252
		newDeps = dep;
247
		dojo.hostenv.flattenRequireArray(newDeps);
253
		dojo.hostenv.flattenRequireArray(newDeps);
248
		break;
254
		break;
249
	  case "kwCompoundRequire":
255
	  case "kwCompoundRequire":
250
	  case "hostenv.conditionalLoadModule":
256
	  case "hostenv.conditionalLoadModule":
251
		var modMap = dep[1];
257
		var modMap = dep[1];
252
		var common = modMap["common"] || [];
258
		var common = modMap["common"] || [];
253
		var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_] || []) : common.concat(modMap["default"] || []);
259
		var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_] || []) : common.concat(modMap["default"] || []);
254
		dojo.hostenv.flattenRequireArray(newDeps);
260
		dojo.hostenv.flattenRequireArray(newDeps);
255
		break;
261
		break;
256
	  case "require":
262
	  case "require":
257
	  case "requireAfter":
263
	  case "requireAfter":
258
	  case "hostenv.loadModule":
264
	  case "hostenv.loadModule":
259
		newDeps = [{name:dep[1], content:null}];
265
		newDeps = [{name:dep[1], content:null}];
260
		break;
266
		break;
261
	}
267
	}
262
	if (dep[0] == "requireAfterIf" || dep[0] == "requireIf") {
268
	if (dep[0] == "requireAfterIf" || dep[0] == "requireIf") {
263
		newAfterDeps = newDeps;
269
		newAfterDeps = newDeps;
264
		newDeps = null;
270
		newDeps = null;
265
	}
271
	}
266
	return {requires:newDeps, requiresAfter:newAfterDeps};
272
	return {requires:newDeps, requiresAfter:newAfterDeps};
267
};
273
};
268
dojo.hostenv.xdWalkReqs = function () {
274
dojo.hostenv.xdWalkReqs = function () {
269
	var reqChain = null;
275
	var reqChain = null;
270
	var req;
276
	var req;
271
	for (var i = 0; i < this.xdOrderedReqs.length; i++) {
277
	for (var i = 0; i < this.xdOrderedReqs.length; i++) {
272
		req = this.xdOrderedReqs[i];
278
		req = this.xdOrderedReqs[i];
273
		if (this.xdDepMap[req]) {
279
		if (this.xdDepMap[req]) {
274
			reqChain = [req];
280
			reqChain = [req];
275
			reqChain[req] = true;
281
			reqChain[req] = true;
276
			this.xdEvalReqs(reqChain);
282
			this.xdEvalReqs(reqChain);
277
		}
283
		}
278
	}
284
	}
279
};
285
};
280
dojo.hostenv.xdEvalReqs = function (reqChain) {
286
dojo.hostenv.xdEvalReqs = function (reqChain) {
281
	while (reqChain.length > 0) {
287
	while (reqChain.length > 0) {
282
		var req = reqChain[reqChain.length - 1];
288
		var req = reqChain[reqChain.length - 1];
283
		var pkg = this.xdDepMap[req];
289
		var pkg = this.xdDepMap[req];
284
		if (pkg) {
290
		if (pkg) {
285
			var reqs = pkg.requires;
291
			var reqs = pkg.requires;
286
			if (reqs && reqs.length > 0) {
292
			if (reqs && reqs.length > 0) {
287
				var nextReq;
293
				var nextReq;
288
				for (var i = 0; i < reqs.length; i++) {
294
				for (var i = 0; i < reqs.length; i++) {
289
					nextReq = reqs[i].name;
295
					nextReq = reqs[i].name;
290
					if (nextReq && !reqChain[nextReq]) {
296
					if (nextReq && !reqChain[nextReq]) {
291
						reqChain.push(nextReq);
297
						reqChain.push(nextReq);
292
						reqChain[nextReq] = true;
298
						reqChain[nextReq] = true;
293
						this.xdEvalReqs(reqChain);
299
						this.xdEvalReqs(reqChain);
294
					}
300
					}
295
				}
301
				}
296
			}
302
			}
297
			var contents = this.xdContents[pkg.contentIndex];
303
			var contents = this.xdContents[pkg.contentIndex];
298
			if (!contents.isDefined) {
304
			if (!contents.isDefined) {
299
				var content = contents.content;
305
				var content = contents.content;
300
				content["resourceName"] = contents["resourceName"];
306
				content["resourceName"] = contents["resourceName"];
301
				content["resourcePath"] = contents["resourcePath"];
307
				content["resourcePath"] = contents["resourcePath"];
302
				this.xdDefList.push(content);
308
				this.xdDefList.push(content);
303
				contents.isDefined = true;
309
				contents.isDefined = true;
304
			}
310
			}
305
			this.xdDepMap[req] = null;
311
			this.xdDepMap[req] = null;
306
			var reqs = pkg.requiresAfter;
312
			var reqs = pkg.requiresAfter;
307
			if (reqs && reqs.length > 0) {
313
			if (reqs && reqs.length > 0) {
308
				var nextReq;
314
				var nextReq;
309
				for (var i = 0; i < reqs.length; i++) {
315
				for (var i = 0; i < reqs.length; i++) {
310
					nextReq = reqs[i].name;
316
					nextReq = reqs[i].name;
311
					if (nextReq && !reqChain[nextReq]) {
317
					if (nextReq && !reqChain[nextReq]) {
312
						reqChain.push(nextReq);
318
						reqChain.push(nextReq);
313
						reqChain[nextReq] = true;
319
						reqChain[nextReq] = true;
314
						this.xdEvalReqs(reqChain);
320
						this.xdEvalReqs(reqChain);
315
					}
321
					}
316
				}
322
				}
317
			}
323
			}
318
		}
324
		}
319
		reqChain.pop();
325
		reqChain.pop();
320
	}
326
	}
321
};
327
};
322
dojo.hostenv.clearXdInterval = function () {
328
dojo.hostenv.clearXdInterval = function () {
323
	clearInterval(this.xdTimer);
329
	clearInterval(this.xdTimer);
324
	this.xdTimer = 0;
330
	this.xdTimer = 0;
325
};
331
};
326
dojo.hostenv.watchInFlightXDomain = function () {
332
dojo.hostenv.watchInFlightXDomain = function () {
327
	var waitInterval = (djConfig.xdWaitSeconds || 15) * 1000;
333
	var waitInterval = (djConfig.xdWaitSeconds || 15) * 1000;
328
	if (this.xdStartTime + waitInterval < (new Date()).getTime()) {
334
	if (this.xdStartTime + waitInterval < (new Date()).getTime()) {
329
		this.clearXdInterval();
335
		this.clearXdInterval();
330
		var noLoads = "";
336
		var noLoads = "";
331
		for (var param in this.xdInFlight) {
337
		for (var param in this.xdInFlight) {
332
			if (this.xdInFlight[param]) {
338
			if (this.xdInFlight[param]) {
333
				noLoads += param + " ";
339
				noLoads += param + " ";
334
			}
340
			}
335
		}
341
		}
336
		dojo.raise("Could not load cross-domain packages: " + noLoads);
342
		dojo.raise("Could not load cross-domain packages: " + noLoads);
337
	}
343
	}
338
	for (var param in this.xdInFlight) {
344
	for (var param in this.xdInFlight) {
339
		if (this.xdInFlight[param]) {
345
		if (this.xdInFlight[param]) {
340
			return;
346
			return;
341
		}
347
		}
342
	}
348
	}
343
	this.clearXdInterval();
349
	this.clearXdInterval();
344
	this.xdWalkReqs();
350
	this.xdWalkReqs();
345
	var defLength = this.xdDefList.length;
351
	var defLength = this.xdDefList.length;
346
	for (var i = 0; i < defLength; i++) {
352
	for (var i = 0; i < defLength; i++) {
347
		var content = dojo.hostenv.xdDefList[i];
353
		var content = dojo.hostenv.xdDefList[i];
348
		if (djConfig["debugAtAllCosts"] && content["resourceName"]) {
354
		if (djConfig["debugAtAllCosts"] && content["resourceName"]) {
349
			if (!this["xdDebugQueue"]) {
355
			if (!this["xdDebugQueue"]) {
350
				this.xdDebugQueue = [];
356
				this.xdDebugQueue = [];
351
			}
357
			}
352
			this.xdDebugQueue.push({resourceName:content.resourceName, resourcePath:content.resourcePath});
358
			this.xdDebugQueue.push({resourceName:content.resourceName, resourcePath:content.resourcePath});
353
		} else {
359
		} else {
354
			content(dojo);
360
			content(dojo);
355
		}
361
		}
356
	}
362
	}
357
	for (var i = 0; i < this.xdContents.length; i++) {
363
	for (var i = 0; i < this.xdContents.length; i++) {
358
		var current = this.xdContents[i];
364
		var current = this.xdContents[i];
359
		if (current.content && !current.isDefined) {
365
		if (current.content && !current.isDefined) {
360
			current.content(dojo);
366
			current.content(dojo);
361
		}
367
		}
362
	}
368
	}
363
	this.resetXd();
369
	this.resetXd();
364
	if (this["xdDebugQueue"] && this.xdDebugQueue.length > 0) {
370
	if (this["xdDebugQueue"] && this.xdDebugQueue.length > 0) {
365
		this.xdDebugFileLoaded();
371
		this.xdDebugFileLoaded();
366
	} else {
372
	} else {
367
		this.xdNotifyLoaded();
373
		this.xdNotifyLoaded();
368
	}
374
	}
369
};
375
};
370
dojo.hostenv.xdNotifyLoaded = function () {
376
dojo.hostenv.xdNotifyLoaded = function () {
371
	this.inFlightCount = 0;
377
	this.inFlightCount = 0;
-
 
378
	if (this._djInitFired && !this.loadNotifying) {
372
	this.callLoaded();
379
		this.callLoaded();
-
 
380
	}
373
};
381
};
374
dojo.hostenv.flattenRequireArray = function (target) {
382
dojo.hostenv.flattenRequireArray = function (target) {
375
	if (target) {
383
	if (target) {
376
		for (var i = 0; i < target.length; i++) {
384
		for (var i = 0; i < target.length; i++) {
377
			if (target[i] instanceof Array) {
385
			if (target[i] instanceof Array) {
378
				target[i] = {name:target[i][0], content:null};
386
				target[i] = {name:target[i][0], content:null};
379
			} else {
387
			} else {
380
				target[i] = {name:target[i], content:null};
388
				target[i] = {name:target[i], content:null};
381
			}
389
			}
382
		}
390
		}
383
	}
391
	}
384
};
392
};
385
dojo.hostenv.xdHasCalledPreload = false;
393
dojo.hostenv.xdHasCalledPreload = false;
386
dojo.hostenv.xdRealCallLoaded = dojo.hostenv.callLoaded;
394
dojo.hostenv.xdRealCallLoaded = dojo.hostenv.callLoaded;
387
dojo.hostenv.callLoaded = function () {
395
dojo.hostenv.callLoaded = function () {
388
	if (this.xdHasCalledPreload || dojo.hostenv.getModulePrefix("dojo") == "src" || !this.localesGenerated) {
396
	if (this.xdHasCalledPreload || dojo.hostenv.getModulePrefix("dojo") == "src" || !this.localesGenerated) {
389
		this.xdRealCallLoaded();
397
		this.xdRealCallLoaded();
390
		this.xdHasCalledPreload = true;
-
 
391
	} else {
398
	} else {
392
		if (this.localesGenerated) {
399
		if (this.localesGenerated) {
393
			this.registerNlsPrefix = function () {
400
			this.registerNlsPrefix = function () {
394
				dojo.registerModulePath("nls", dojo.hostenv.getModulePrefix("dojo") + "/../nls");
401
				dojo.registerModulePath("nls", dojo.hostenv.getModulePrefix("dojo") + "/../nls");
395
			};
402
			};
396
			this.preloadLocalizations();
403
			this.preloadLocalizations();
397
		}
404
		}
398
		this.xdHasCalledPreload = true;
-
 
399
	}
405
	}
-
 
406
	this.xdHasCalledPreload = true;
400
};
407
};
401
 
408