Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
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:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
if (typeof window != "undefined") {
14
	(function () {
15
		if (djConfig.allowQueryConfig) {
16
			var baseUrl = document.location.toString();
17
			var params = baseUrl.split("?", 2);
18
			if (params.length > 1) {
19
				var paramStr = params[1];
20
				var pairs = paramStr.split("&");
21
				for (var x in pairs) {
22
					var sp = pairs[x].split("=");
23
					if ((sp[0].length > 9) && (sp[0].substr(0, 9) == "djConfig.")) {
24
						var opt = sp[0].substr(9);
25
						try {
26
							djConfig[opt] = eval(sp[1]);
27
						}
28
						catch (e) {
29
							djConfig[opt] = sp[1];
30
						}
31
					}
32
				}
33
			}
34
		}
35
		if (((djConfig["baseScriptUri"] == "") || (djConfig["baseRelativePath"] == "")) && (document && document.getElementsByTagName)) {
36
			var scripts = document.getElementsByTagName("script");
37
			var rePkg = /(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i;
38
			for (var i = 0; i < scripts.length; i++) {
39
				var src = scripts[i].getAttribute("src");
40
				if (!src) {
41
					continue;
42
				}
43
				var m = src.match(rePkg);
44
				if (m) {
45
					var root = src.substring(0, m.index);
46
					if (src.indexOf("bootstrap1") > -1) {
47
						root += "../";
48
					}
49
					if (!this["djConfig"]) {
50
						djConfig = {};
51
					}
52
					if (djConfig["baseScriptUri"] == "") {
53
						djConfig["baseScriptUri"] = root;
54
					}
55
					if (djConfig["baseRelativePath"] == "") {
56
						djConfig["baseRelativePath"] = root;
57
					}
58
					break;
59
				}
60
			}
61
		}
62
		var dr = dojo.render;
63
		var drh = dojo.render.html;
64
		var drs = dojo.render.svg;
65
		var dua = (drh.UA = navigator.userAgent);
66
		var dav = (drh.AV = navigator.appVersion);
67
		var t = true;
68
		var f = false;
69
		drh.capable = t;
70
		drh.support.builtin = t;
71
		dr.ver = parseFloat(drh.AV);
72
		dr.os.mac = dav.indexOf("Macintosh") >= 0;
73
		dr.os.win = dav.indexOf("Windows") >= 0;
74
		dr.os.linux = dav.indexOf("X11") >= 0;
75
		drh.opera = dua.indexOf("Opera") >= 0;
76
		drh.khtml = (dav.indexOf("Konqueror") >= 0) || (dav.indexOf("Safari") >= 0);
77
		drh.safari = dav.indexOf("Safari") >= 0;
78
		var geckoPos = dua.indexOf("Gecko");
79
		drh.mozilla = drh.moz = (geckoPos >= 0) && (!drh.khtml);
80
		if (drh.mozilla) {
81
			drh.geckoVersion = dua.substring(geckoPos + 6, geckoPos + 14);
82
		}
83
		drh.ie = (document.all) && (!drh.opera);
84
		drh.ie50 = drh.ie && dav.indexOf("MSIE 5.0") >= 0;
85
		drh.ie55 = drh.ie && dav.indexOf("MSIE 5.5") >= 0;
86
		drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0") >= 0;
87
		drh.ie70 = drh.ie && dav.indexOf("MSIE 7.0") >= 0;
88
		var cm = document["compatMode"];
89
		drh.quirks = (cm == "BackCompat") || (cm == "QuirksMode") || drh.ie55 || drh.ie50;
90
		dojo.locale = dojo.locale || (drh.ie ? navigator.userLanguage : navigator.language).toLowerCase();
91
		dr.vml.capable = drh.ie;
92
		drs.capable = f;
93
		drs.support.plugin = f;
94
		drs.support.builtin = f;
95
		var tdoc = window["document"];
96
		var tdi = tdoc["implementation"];
97
		if ((tdi) && (tdi["hasFeature"]) && (tdi.hasFeature("org.w3c.dom.svg", "1.0"))) {
98
			drs.capable = t;
99
			drs.support.builtin = t;
100
			drs.support.plugin = f;
101
		}
102
		if (drh.safari) {
103
			var tmp = dua.split("AppleWebKit/")[1];
104
			var ver = parseFloat(tmp.split(" ")[0]);
105
			if (ver >= 420) {
106
				drs.capable = t;
107
				drs.support.builtin = t;
108
				drs.support.plugin = f;
109
			}
110
		} else {
111
		}
112
	})();
113
	dojo.hostenv.startPackage("dojo.hostenv");
114
	dojo.render.name = dojo.hostenv.name_ = "browser";
115
	dojo.hostenv.searchIds = [];
116
	dojo.hostenv._XMLHTTP_PROGIDS = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"];
117
	dojo.hostenv.getXmlhttpObject = function () {
118
		var http = null;
119
		var last_e = null;
120
		try {
121
			http = new XMLHttpRequest();
122
		}
123
		catch (e) {
124
		}
125
		if (!http) {
126
			for (var i = 0; i < 3; ++i) {
127
				var progid = dojo.hostenv._XMLHTTP_PROGIDS[i];
128
				try {
129
					http = new ActiveXObject(progid);
130
				}
131
				catch (e) {
132
					last_e = e;
133
				}
134
				if (http) {
135
					dojo.hostenv._XMLHTTP_PROGIDS = [progid];
136
					break;
137
				}
138
			}
139
		}
140
		if (!http) {
141
			return dojo.raise("XMLHTTP not available", last_e);
142
		}
143
		return http;
144
	};
145
	dojo.hostenv._blockAsync = false;
146
	dojo.hostenv.getText = function (uri, async_cb, fail_ok) {
147
		if (!async_cb) {
148
			this._blockAsync = true;
149
		}
150
		var http = this.getXmlhttpObject();
151
		function isDocumentOk(http) {
152
			var stat = http["status"];
153
			return Boolean((!stat) || ((200 <= stat) && (300 > stat)) || (stat == 304));
154
		}
155
		if (async_cb) {
156
			var _this = this, timer = null, gbl = dojo.global();
157
			var xhr = dojo.evalObjPath("dojo.io.XMLHTTPTransport");
158
			http.onreadystatechange = function () {
159
				if (timer) {
160
					gbl.clearTimeout(timer);
161
					timer = null;
162
				}
163
				if (_this._blockAsync || (xhr && xhr._blockAsync)) {
164
					timer = gbl.setTimeout(function () {
165
						http.onreadystatechange.apply(this);
166
					}, 10);
167
				} else {
168
					if (4 == http.readyState) {
169
						if (isDocumentOk(http)) {
170
							async_cb(http.responseText);
171
						}
172
					}
173
				}
174
			};
175
		}
176
		http.open("GET", uri, async_cb ? true : false);
177
		try {
178
			http.send(null);
179
			if (async_cb) {
180
				return null;
181
			}
182
			if (!isDocumentOk(http)) {
183
				var err = Error("Unable to load " + uri + " status:" + http.status);
184
				err.status = http.status;
185
				err.responseText = http.responseText;
186
				throw err;
187
			}
188
		}
189
		catch (e) {
190
			this._blockAsync = false;
191
			if ((fail_ok) && (!async_cb)) {
192
				return null;
193
			} else {
194
				throw e;
195
			}
196
		}
197
		this._blockAsync = false;
198
		return http.responseText;
199
	};
200
	dojo.hostenv.defaultDebugContainerId = "dojoDebug";
201
	dojo.hostenv._println_buffer = [];
202
	dojo.hostenv._println_safe = false;
203
	dojo.hostenv.println = function (line) {
204
		if (!dojo.hostenv._println_safe) {
205
			dojo.hostenv._println_buffer.push(line);
206
		} else {
207
			try {
208
				var console = document.getElementById(djConfig.debugContainerId ? djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId);
209
				if (!console) {
210
					console = dojo.body();
211
				}
212
				var div = document.createElement("div");
213
				div.appendChild(document.createTextNode(line));
214
				console.appendChild(div);
215
			}
216
			catch (e) {
217
				try {
218
					document.write("<div>" + line + "</div>");
219
				}
220
				catch (e2) {
221
					window.status = line;
222
				}
223
			}
224
		}
225
	};
226
	dojo.addOnLoad(function () {
227
		dojo.hostenv._println_safe = true;
228
		while (dojo.hostenv._println_buffer.length > 0) {
229
			dojo.hostenv.println(dojo.hostenv._println_buffer.shift());
230
		}
231
	});
232
	function dj_addNodeEvtHdlr(node, evtName, fp) {
233
		var oldHandler = node["on" + evtName] || function () {
234
		};
235
		node["on" + evtName] = function () {
236
			fp.apply(node, arguments);
237
			oldHandler.apply(node, arguments);
238
		};
239
		return true;
240
	}
1422 alexandre_ 241
	dojo.hostenv._djInitFired = false;
1318 alexandre_ 242
	function dj_load_init(e) {
1422 alexandre_ 243
		dojo.hostenv._djInitFired = true;
1318 alexandre_ 244
		var type = (e && e.type) ? e.type.toLowerCase() : "load";
245
		if (arguments.callee.initialized || (type != "domcontentloaded" && type != "load")) {
246
			return;
247
		}
248
		arguments.callee.initialized = true;
249
		if (typeof (_timer) != "undefined") {
250
			clearInterval(_timer);
251
			delete _timer;
252
		}
253
		var initFunc = function () {
254
			if (dojo.render.html.ie) {
255
				dojo.hostenv.makeWidgets();
256
			}
257
		};
258
		if (dojo.hostenv.inFlightCount == 0) {
259
			initFunc();
260
			dojo.hostenv.modulesLoaded();
261
		} else {
262
			dojo.hostenv.modulesLoadedListeners.unshift(initFunc);
263
		}
264
	}
265
	if (document.addEventListener) {
266
		if (dojo.render.html.opera || (dojo.render.html.moz && (djConfig["enableMozDomContentLoaded"] === true))) {
267
			document.addEventListener("DOMContentLoaded", dj_load_init, null);
268
		}
269
		window.addEventListener("load", dj_load_init, null);
270
	}
271
	if (dojo.render.html.ie && dojo.render.os.win) {
272
		document.attachEvent("onreadystatechange", function (e) {
273
			if (document.readyState == "complete") {
274
				dj_load_init();
275
			}
276
		});
277
	}
278
	if (/(WebKit|khtml)/i.test(navigator.userAgent)) {
279
		var _timer = setInterval(function () {
280
			if (/loaded|complete/.test(document.readyState)) {
281
				dj_load_init();
282
			}
283
		}, 10);
284
	}
285
	if (dojo.render.html.ie) {
286
		dj_addNodeEvtHdlr(window, "beforeunload", function () {
287
			dojo.hostenv._unloading = true;
288
			window.setTimeout(function () {
289
				dojo.hostenv._unloading = false;
290
			}, 0);
291
		});
292
	}
293
	dj_addNodeEvtHdlr(window, "unload", function () {
294
		dojo.hostenv.unloaded();
295
		if ((!dojo.render.html.ie) || (dojo.render.html.ie && dojo.hostenv._unloading)) {
296
			dojo.hostenv.unloaded();
297
		}
298
	});
299
	dojo.hostenv.makeWidgets = function () {
300
		var sids = [];
301
		if (djConfig.searchIds && djConfig.searchIds.length > 0) {
302
			sids = sids.concat(djConfig.searchIds);
303
		}
304
		if (dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) {
305
			sids = sids.concat(dojo.hostenv.searchIds);
306
		}
307
		if ((djConfig.parseWidgets) || (sids.length > 0)) {
308
			if (dojo.evalObjPath("dojo.widget.Parse")) {
309
				var parser = new dojo.xml.Parse();
310
				if (sids.length > 0) {
311
					for (var x = 0; x < sids.length; x++) {
312
						var tmpNode = document.getElementById(sids[x]);
313
						if (!tmpNode) {
314
							continue;
315
						}
316
						var frag = parser.parseElement(tmpNode, null, true);
317
						dojo.widget.getParser().createComponents(frag);
318
					}
319
				} else {
320
					if (djConfig.parseWidgets) {
321
						var frag = parser.parseElement(dojo.body(), null, true);
322
						dojo.widget.getParser().createComponents(frag);
323
					}
324
				}
325
			}
326
		}
327
	};
328
	dojo.addOnLoad(function () {
329
		if (!dojo.render.html.ie) {
330
			dojo.hostenv.makeWidgets();
331
		}
332
	});
333
	try {
334
		if (dojo.render.html.ie) {
335
			document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
336
			document.createStyleSheet().addRule("v\\:*", "behavior:url(#default#VML)");
337
		}
338
	}
339
	catch (e) {
340
	}
341
	dojo.hostenv.writeIncludes = function () {
342
	};
343
	if (!dj_undef("document", this)) {
344
		dj_currentDocument = this.document;
345
	}
346
	dojo.doc = function () {
347
		return dj_currentDocument;
348
	};
349
	dojo.body = function () {
350
		return dojo.doc().body || dojo.doc().getElementsByTagName("body")[0];
351
	};
352
	dojo.byId = function (id, doc) {
353
		if ((id) && ((typeof id == "string") || (id instanceof String))) {
354
			if (!doc) {
355
				doc = dj_currentDocument;
356
			}
357
			var ele = doc.getElementById(id);
358
			if (ele && (ele.id != id) && doc.all) {
359
				ele = null;
360
				eles = doc.all[id];
361
				if (eles) {
362
					if (eles.length) {
363
						for (var i = 0; i < eles.length; i++) {
364
							if (eles[i].id == id) {
365
								ele = eles[i];
366
								break;
367
							}
368
						}
369
					} else {
370
						ele = eles;
371
					}
372
				}
373
			}
374
			return ele;
375
		}
376
		return id;
377
	};
378
	dojo.setContext = function (globalObject, globalDocument) {
379
		dj_currentContext = globalObject;
380
		dj_currentDocument = globalDocument;
381
	};
382
	dojo._fireCallback = function (callback, context, cbArguments) {
383
		if ((context) && ((typeof callback == "string") || (callback instanceof String))) {
384
			callback = context[callback];
385
		}
386
		return (context ? callback.apply(context, cbArguments || []) : callback());
387
	};
388
	dojo.withGlobal = function (globalObject, callback, thisObject, cbArguments) {
389
		var rval;
390
		var oldGlob = dj_currentContext;
391
		var oldDoc = dj_currentDocument;
392
		try {
393
			dojo.setContext(globalObject, globalObject.document);
394
			rval = dojo._fireCallback(callback, thisObject, cbArguments);
395
		}
396
		finally {
397
			dojo.setContext(oldGlob, oldDoc);
398
		}
399
		return rval;
400
	};
401
	dojo.withDoc = function (documentObject, callback, thisObject, cbArguments) {
402
		var rval;
403
		var oldDoc = dj_currentDocument;
404
		try {
405
			dj_currentDocument = documentObject;
406
			rval = dojo._fireCallback(callback, thisObject, cbArguments);
407
		}
408
		finally {
409
			dj_currentDocument = oldDoc;
410
		}
411
		return rval;
412
	};
413
}
414
dojo.requireIf((djConfig["isDebug"] || djConfig["debugAtAllCosts"]), "dojo.debug");
415
dojo.requireIf(djConfig["debugAtAllCosts"] && !window.widget && !djConfig["useXDomain"], "dojo.browser_debug");
416
dojo.requireIf(djConfig["debugAtAllCosts"] && !window.widget && djConfig["useXDomain"], "dojo.browser_debug_xd");
417