2150 |
mathias |
1 |
if(!dojo._hasResource["dojo.foo"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojo.foo"] = true;
|
|
|
3 |
/*
|
|
|
4 |
* loader.js - A bootstrap module. Runs before the hostenv_*.js file. Contains
|
|
|
5 |
* all of the package loading methods.
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
(function(){
|
|
|
9 |
var d = dojo;
|
|
|
10 |
|
|
|
11 |
dojo.mixin(dojo, {
|
|
|
12 |
_loadedModules: {},
|
|
|
13 |
_inFlightCount: 0,
|
|
|
14 |
_hasResource: {},
|
|
|
15 |
|
|
|
16 |
// FIXME: it should be possible to pull module prefixes in from djConfig
|
|
|
17 |
_modulePrefixes: {
|
|
|
18 |
dojo: {name: "dojo", value: "."},
|
|
|
19 |
doh: {name: "doh", value: "../util/doh"},
|
|
|
20 |
tests: {name: "tests", value: "tests"}
|
|
|
21 |
},
|
|
|
22 |
|
|
|
23 |
_moduleHasPrefix: function(/*String*/module){
|
|
|
24 |
// summary: checks to see if module has been established
|
|
|
25 |
var mp = this._modulePrefixes;
|
|
|
26 |
return !!(mp[module] && mp[module].value); // Boolean
|
|
|
27 |
},
|
|
|
28 |
|
|
|
29 |
_getModulePrefix: function(/*String*/module){
|
|
|
30 |
// summary: gets the prefix associated with module
|
|
|
31 |
var mp = this._modulePrefixes;
|
|
|
32 |
if(this._moduleHasPrefix(module)){
|
|
|
33 |
return mp[module].value; // String
|
|
|
34 |
}
|
|
|
35 |
return module; // String
|
|
|
36 |
},
|
|
|
37 |
|
|
|
38 |
_loadedUrls: [],
|
|
|
39 |
|
|
|
40 |
//WARNING:
|
|
|
41 |
// This variable is referenced by packages outside of bootstrap:
|
|
|
42 |
// FloatingPane.js and undo/browser.js
|
|
|
43 |
_postLoad: false,
|
|
|
44 |
|
|
|
45 |
//Egad! Lots of test files push on this directly instead of using dojo.addOnLoad.
|
|
|
46 |
_loaders: [],
|
|
|
47 |
_unloaders: [],
|
|
|
48 |
_loadNotifying: false
|
|
|
49 |
});
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
//>>excludeStart("xdomainExclude", fileName.indexOf("dojo.xd.js") != -1 && kwArgs.loader == "xdomain");
|
|
|
53 |
dojo._loadPath = function(/*String*/relpath, /*String?*/module, /*Function?*/cb){
|
|
|
54 |
// summary:
|
|
|
55 |
// Load a Javascript module given a relative path
|
|
|
56 |
//
|
|
|
57 |
// description:
|
|
|
58 |
// Loads and interprets the script located at relpath, which is
|
|
|
59 |
// relative to the script root directory. If the script is found but
|
|
|
60 |
// its interpretation causes a runtime exception, that exception is
|
|
|
61 |
// not caught by us, so the caller will see it. We return a true
|
|
|
62 |
// value if and only if the script is found.
|
|
|
63 |
//
|
|
|
64 |
// relpath:
|
|
|
65 |
// A relative path to a script (no leading '/', and typically ending
|
|
|
66 |
// in '.js').
|
|
|
67 |
// module:
|
|
|
68 |
// A module whose existance to check for after loading a path. Can be
|
|
|
69 |
// used to determine success or failure of the load.
|
|
|
70 |
// cb:
|
|
|
71 |
// a callback function to pass the result of evaluating the script
|
|
|
72 |
|
|
|
73 |
var uri = (((relpath.charAt(0) == '/' || relpath.match(/^\w+:/))) ? "" : this.baseUrl) + relpath;
|
|
|
74 |
if(djConfig.cacheBust && d.isBrowser){
|
|
|
75 |
uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,"");
|
|
|
76 |
}
|
|
|
77 |
try{
|
|
|
78 |
return !module ? this._loadUri(uri, cb) : this._loadUriAndCheck(uri, module, cb); // Boolean
|
|
|
79 |
}catch(e){
|
|
|
80 |
console.debug(e);
|
|
|
81 |
return false; // Boolean
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
dojo._loadUri = function(/*String (URL)*/uri, /*Function?*/cb){
|
|
|
86 |
// summary:
|
|
|
87 |
// Loads JavaScript from a URI
|
|
|
88 |
// description:
|
|
|
89 |
// Reads the contents of the URI, and evaluates the contents. This is
|
|
|
90 |
// used to load modules as well as resource bundles. Returns true if
|
|
|
91 |
// it succeeded. Returns false if the URI reading failed. Throws if
|
|
|
92 |
// the evaluation throws.
|
|
|
93 |
// uri: a uri which points at the script to be loaded
|
|
|
94 |
// cb:
|
|
|
95 |
// a callback function to process the result of evaluating the script
|
|
|
96 |
// as an expression, typically used by the resource bundle loader to
|
|
|
97 |
// load JSON-style resources
|
|
|
98 |
|
|
|
99 |
if(this._loadedUrls[uri]){
|
|
|
100 |
return true; // Boolean
|
|
|
101 |
}
|
|
|
102 |
var contents = this._getText(uri, true);
|
|
|
103 |
if(!contents){ return false; } // Boolean
|
|
|
104 |
this._loadedUrls[uri] = true;
|
|
|
105 |
this._loadedUrls.push(uri);
|
|
|
106 |
if(cb){ contents = '('+contents+')'; }
|
|
|
107 |
var value = d["eval"](contents+"\r\n//@ sourceURL="+uri);
|
|
|
108 |
if(cb){ cb(value); }
|
|
|
109 |
return true; // Boolean
|
|
|
110 |
}
|
|
|
111 |
//>>excludeEnd("xdomainExclude");
|
|
|
112 |
|
|
|
113 |
// FIXME: probably need to add logging to this method
|
|
|
114 |
dojo._loadUriAndCheck = function(/*String (URL)*/uri, /*String*/moduleName, /*Function?*/cb){
|
|
|
115 |
// summary: calls loadUri then findModule and returns true if both succeed
|
|
|
116 |
var ok = false;
|
|
|
117 |
try{
|
|
|
118 |
ok = this._loadUri(uri, cb);
|
|
|
119 |
}catch(e){
|
|
|
120 |
console.debug("failed loading " + uri + " with error: " + e);
|
|
|
121 |
}
|
|
|
122 |
return Boolean(ok && this._loadedModules[moduleName]); // Boolean
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
dojo.loaded = function(){
|
|
|
126 |
// summary:
|
|
|
127 |
// signal fired when initial environment and package loading is
|
|
|
128 |
// complete. You may use dojo.addOnLoad() or dojo.connect() to
|
|
|
129 |
// this method in order to handle initialization tasks that
|
|
|
130 |
// require the environment to be initialized. In a browser host,
|
|
|
131 |
// declarative widgets will be constructed when this function
|
|
|
132 |
// finishes runing.
|
|
|
133 |
this._loadNotifying = true;
|
|
|
134 |
this._postLoad = true;
|
|
|
135 |
var mll = this._loaders;
|
|
|
136 |
|
|
|
137 |
//Clear listeners so new ones can be added
|
|
|
138 |
//For other xdomain package loads after the initial load.
|
|
|
139 |
this._loaders = [];
|
|
|
140 |
|
|
|
141 |
for(var x=0; x<mll.length; x++){
|
|
|
142 |
mll[x]();
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
this._loadNotifying = false;
|
|
|
146 |
|
|
|
147 |
//Make sure nothing else got added to the onload queue
|
|
|
148 |
//after this first run. If something did, and we are not waiting for any
|
|
|
149 |
//more inflight resources, run again.
|
|
|
150 |
if(d._postLoad && d._inFlightCount == 0 && this._loaders.length > 0){
|
|
|
151 |
d._callLoaded();
|
|
|
152 |
}
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
dojo.unloaded = function(){
|
|
|
156 |
// summary:
|
|
|
157 |
// signal fired by impending environment destruction. You may use
|
|
|
158 |
// dojo.addOnUnload() or dojo.connect() to this method to perform
|
|
|
159 |
// page/application cleanup methods.
|
|
|
160 |
var mll = this._unloaders;
|
|
|
161 |
while(mll.length){
|
|
|
162 |
(mll.pop())();
|
|
|
163 |
}
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName){
|
|
|
167 |
// summary:
|
|
|
168 |
// Registers a function to be triggered after the DOM has finished
|
|
|
169 |
// loading and widgets declared in markup have been instantiated.
|
|
|
170 |
// Images and CSS files may or may not have finished downloading when
|
|
|
171 |
// the specified function is called. (Note that widgets' CSS and HTML
|
|
|
172 |
// code is guaranteed to be downloaded before said widgets are
|
|
|
173 |
// instantiated.)
|
|
|
174 |
// example:
|
|
|
175 |
// | dojo.addOnLoad(functionPointer);
|
|
|
176 |
// | dojo.addOnLoad(object, "functionName");
|
|
|
177 |
if(arguments.length == 1){
|
|
|
178 |
d._loaders.push(obj);
|
|
|
179 |
}else if(arguments.length > 1){
|
|
|
180 |
d._loaders.push(function(){
|
|
|
181 |
obj[functionName]();
|
|
|
182 |
});
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
//Added for xdomain loading. dojo.addOnLoad is used to
|
|
|
186 |
//indicate callbacks after doing some dojo.require() statements.
|
|
|
187 |
//In the xdomain case, if all the requires are loaded (after initial
|
|
|
188 |
//page load), then immediately call any listeners.
|
|
|
189 |
if(d._postLoad && d._inFlightCount == 0 && !d._loadNotifying){
|
|
|
190 |
d._callLoaded();
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
|
|
|
195 |
// summary: registers a function to be triggered when the page unloads
|
|
|
196 |
// example:
|
|
|
197 |
// | dojo.addOnUnload(functionPointer)
|
|
|
198 |
// | dojo.addOnUnload(object, "functionName")
|
|
|
199 |
if(arguments.length == 1){
|
|
|
200 |
d._unloaders.push(obj);
|
|
|
201 |
}else if(arguments.length > 1){
|
|
|
202 |
d._unloaders.push(function(){
|
|
|
203 |
obj[functionName]();
|
|
|
204 |
});
|
|
|
205 |
}
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
dojo._modulesLoaded = function(){
|
|
|
209 |
if(d._postLoad){ return; }
|
|
|
210 |
if(d._inFlightCount > 0){
|
|
|
211 |
console.debug("files still in flight!");
|
|
|
212 |
return;
|
|
|
213 |
}
|
|
|
214 |
d._callLoaded();
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
dojo._callLoaded = function(){
|
|
|
218 |
//The "object" check is for IE, and the other opera check fixes an issue
|
|
|
219 |
//in Opera where it could not find the body element in some widget test cases.
|
|
|
220 |
//For 0.9, maybe route all browsers through the setTimeout (need protection
|
|
|
221 |
//still for non-browser environments though). This might also help the issue with
|
|
|
222 |
//FF 2.0 and freezing issues where we try to do sync xhr while background css images
|
|
|
223 |
//are being loaded (trac #2572)? Consider for 0.9.
|
|
|
224 |
if(typeof setTimeout == "object" || (djConfig["useXDomain"] && d.isOpera)){
|
|
|
225 |
setTimeout("dojo.loaded();", 0);
|
|
|
226 |
}else{
|
|
|
227 |
d.loaded();
|
|
|
228 |
}
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
dojo._getModuleSymbols = function(/*String*/modulename){
|
|
|
232 |
// summary:
|
|
|
233 |
// Converts a module name in dotted JS notation to an array
|
|
|
234 |
// representing the path in the source tree
|
|
|
235 |
var syms = modulename.split(".");
|
|
|
236 |
for(var i = syms.length; i>0; i--){
|
|
|
237 |
var parentModule = syms.slice(0, i).join(".");
|
|
|
238 |
if((i==1) && !this._moduleHasPrefix(parentModule)){
|
|
|
239 |
// Support default module directory (sibling of dojo) for top-level modules
|
|
|
240 |
syms[0] = "../" + syms[0];
|
|
|
241 |
}else{
|
|
|
242 |
var parentModulePath = this._getModulePrefix(parentModule);
|
|
|
243 |
if(parentModulePath != parentModule){
|
|
|
244 |
syms.splice(0, i, parentModulePath);
|
|
|
245 |
break;
|
|
|
246 |
}
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
// console.debug(syms);
|
|
|
250 |
return syms; // Array
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
dojo._global_omit_module_check = false;
|
|
|
254 |
|
|
|
255 |
dojo._loadModule = dojo.require = function(/*String*/moduleName, /*Boolean?*/omitModuleCheck){
|
|
|
256 |
// summary:
|
|
|
257 |
// loads a Javascript module from the appropriate URI
|
|
|
258 |
// moduleName: String
|
|
|
259 |
// omitModuleCheck: Boolean?
|
|
|
260 |
// description:
|
|
|
261 |
// _loadModule("A.B") first checks to see if symbol A.B is defined. If
|
|
|
262 |
// it is, it is simply returned (nothing to do).
|
|
|
263 |
//
|
|
|
264 |
// If it is not defined, it will look for "A/B.js" in the script root
|
|
|
265 |
// directory.
|
|
|
266 |
//
|
|
|
267 |
// It throws if it cannot find a file to load, or if the symbol A.B is
|
|
|
268 |
// not defined after loading.
|
|
|
269 |
//
|
|
|
270 |
// It returns the object A.B.
|
|
|
271 |
//
|
|
|
272 |
// This does nothing about importing symbols into the current package.
|
|
|
273 |
// It is presumed that the caller will take care of that. For example,
|
|
|
274 |
// to import all symbols:
|
|
|
275 |
//
|
|
|
276 |
// | with (dojo._loadModule("A.B")) {
|
|
|
277 |
// | ...
|
|
|
278 |
// | }
|
|
|
279 |
//
|
|
|
280 |
// And to import just the leaf symbol:
|
|
|
281 |
//
|
|
|
282 |
// | var B = dojo._loadModule("A.B");
|
|
|
283 |
// | ...
|
|
|
284 |
// returns: the required namespace object
|
|
|
285 |
omitModuleCheck = this._global_omit_module_check || omitModuleCheck;
|
|
|
286 |
var module = this._loadedModules[moduleName];
|
|
|
287 |
if(module){
|
|
|
288 |
return module;
|
|
|
289 |
}
|
|
|
290 |
|
|
|
291 |
// convert periods to slashes
|
|
|
292 |
var relpath = this._getModuleSymbols(moduleName).join("/") + '.js';
|
|
|
293 |
|
|
|
294 |
var modArg = (!omitModuleCheck) ? moduleName : null;
|
|
|
295 |
var ok = this._loadPath(relpath, modArg);
|
|
|
296 |
|
|
|
297 |
if((!ok)&&(!omitModuleCheck)){
|
|
|
298 |
throw new Error("Could not load '" + moduleName + "'; last tried '" + relpath + "'");
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
// check that the symbol was defined
|
|
|
302 |
// Don't bother if we're doing xdomain (asynchronous) loading.
|
|
|
303 |
if((!omitModuleCheck)&&(!this["_isXDomain"])){
|
|
|
304 |
// pass in false so we can give better error
|
|
|
305 |
module = this._loadedModules[moduleName];
|
|
|
306 |
if(!module){
|
|
|
307 |
throw new Error("symbol '" + moduleName + "' is not defined after loading '" + relpath + "'");
|
|
|
308 |
}
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
return module;
|
|
|
312 |
}
|
|
|
313 |
|
|
|
314 |
dojo.provide = function(/*String*/ resourceName){
|
|
|
315 |
// summary:
|
|
|
316 |
// Each javascript source file must have (exactly) one dojo.provide()
|
|
|
317 |
// call at the top of the file, corresponding to the file name.
|
|
|
318 |
// For example, js/dojo/foo.js must have dojo.provide("dojo.foo"); at the
|
|
|
319 |
// top of the file.
|
|
|
320 |
// description:
|
|
|
321 |
// Each javascript source file is called a resource. When a resource
|
|
|
322 |
// is loaded by the browser, dojo.provide() registers that it has been
|
|
|
323 |
// loaded.
|
|
|
324 |
//
|
|
|
325 |
// For backwards compatibility reasons, in addition to registering the
|
|
|
326 |
// resource, dojo.provide() also ensures that the javascript object
|
|
|
327 |
// for the module exists. For example,
|
|
|
328 |
// dojo.provide("dojo.io.cometd"), in addition to registering that
|
|
|
329 |
// cometd.js is a resource for the dojo.iomodule, will ensure that
|
|
|
330 |
// the dojo.io javascript object exists, so that calls like
|
|
|
331 |
// dojo.io.foo = function(){ ... } don't fail.
|
|
|
332 |
//
|
|
|
333 |
// In the case of a build (or in the future, a rollup), where multiple
|
|
|
334 |
// javascript source files are combined into one bigger file (similar
|
|
|
335 |
// to a .lib or .jar file), that file will contain multiple
|
|
|
336 |
// dojo.provide() calls, to note that it includes multiple resources.
|
|
|
337 |
|
|
|
338 |
//Make sure we have a string.
|
|
|
339 |
resourceName = resourceName + "";
|
|
|
340 |
return (d._loadedModules[resourceName] = d.getObject(resourceName, true)); // Object
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
//Start of old bootstrap2:
|
|
|
344 |
|
|
|
345 |
dojo.platformRequire = function(/*Object containing Arrays*/modMap){
|
|
|
346 |
// description:
|
|
|
347 |
// This method taks a "map" of arrays which one can use to optionally
|
|
|
348 |
// load dojo modules. The map is indexed by the possible
|
|
|
349 |
// dojo.name_ values, with two additional values: "default"
|
|
|
350 |
// and "common". The items in the "default" array will be loaded if
|
|
|
351 |
// none of the other items have been choosen based on the
|
|
|
352 |
// hostenv.name_ item. The items in the "common" array will _always_
|
|
|
353 |
// be loaded, regardless of which list is chosen. Here's how it's
|
|
|
354 |
// normally called:
|
|
|
355 |
//
|
|
|
356 |
// | dojo.platformRequire({
|
|
|
357 |
// | // an example that passes multiple args to _loadModule()
|
|
|
358 |
// | browser: [
|
|
|
359 |
// | ["foo.bar.baz", true, true],
|
|
|
360 |
// | "foo.sample",
|
|
|
361 |
// | "foo.test,
|
|
|
362 |
// | ],
|
|
|
363 |
// | default: [ "foo.sample.*" ],
|
|
|
364 |
// | common: [ "really.important.module.*" ]
|
|
|
365 |
// | });
|
|
|
366 |
|
|
|
367 |
// FIXME: dojo.name_ no longer works!!
|
|
|
368 |
|
|
|
369 |
var common = modMap["common"]||[];
|
|
|
370 |
var result = common.concat(modMap[d._name]||modMap["default"]||[]);
|
|
|
371 |
|
|
|
372 |
for(var x=0; x<result.length; x++){
|
|
|
373 |
var curr = result[x];
|
|
|
374 |
if(curr.constructor == Array){
|
|
|
375 |
d._loadModule.apply(d, curr);
|
|
|
376 |
}else{
|
|
|
377 |
d._loadModule(curr);
|
|
|
378 |
}
|
|
|
379 |
}
|
|
|
380 |
}
|
|
|
381 |
|
|
|
382 |
|
|
|
383 |
dojo.requireIf = function(/*Boolean*/ condition, /*String*/ resourceName){
|
|
|
384 |
// summary:
|
|
|
385 |
// If the condition is true then call dojo.require() for the specified
|
|
|
386 |
// resource
|
|
|
387 |
if(condition === true){
|
|
|
388 |
// FIXME: why do we support chained require()'s here? does the build system?
|
|
|
389 |
var args = [];
|
|
|
390 |
for(var i = 1; i < arguments.length; i++){
|
|
|
391 |
args.push(arguments[i]);
|
|
|
392 |
}
|
|
|
393 |
d.require.apply(d, args);
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
|
|
|
397 |
dojo.requireAfterIf = d.requireIf;
|
|
|
398 |
|
|
|
399 |
dojo.registerModulePath = function(/*String*/module, /*String*/prefix){
|
|
|
400 |
// summary:
|
|
|
401 |
// maps a module name to a path
|
|
|
402 |
// description:
|
|
|
403 |
// An unregistered module is given the default path of ../<module>,
|
|
|
404 |
// relative to Dojo root. For example, module acme is mapped to
|
|
|
405 |
// ../acme. If you want to use a different module name, use
|
|
|
406 |
// dojo.registerModulePath.
|
|
|
407 |
d._modulePrefixes[module] = { name: module, value: prefix };
|
|
|
408 |
}
|
|
|
409 |
|
|
|
410 |
dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale, /*String?*/availableFlatLocales){
|
|
|
411 |
// summary:
|
|
|
412 |
// Declares translated resources and loads them if necessary, in the
|
|
|
413 |
// same style as dojo.require. Contents of the resource bundle are
|
|
|
414 |
// typically strings, but may be any name/value pair, represented in
|
|
|
415 |
// JSON format. See also dojo.i18n.getLocalization.
|
|
|
416 |
// moduleName:
|
|
|
417 |
// name of the package containing the "nls" directory in which the
|
|
|
418 |
// bundle is found
|
|
|
419 |
// bundleName:
|
|
|
420 |
// bundle name, i.e. the filename without the '.js' suffix
|
|
|
421 |
// locale:
|
|
|
422 |
// the locale to load (optional) By default, the browser's user
|
|
|
423 |
// locale as defined by dojo.locale
|
|
|
424 |
// availableFlatLocales:
|
|
|
425 |
// A comma-separated list of the available, flattened locales for this
|
|
|
426 |
// bundle. This argument should only be set by the build process.
|
|
|
427 |
// description:
|
|
|
428 |
// Load translated resource bundles provided underneath the "nls"
|
|
|
429 |
// directory within a package. Translated resources may be located in
|
|
|
430 |
// different packages throughout the source tree. For example, a
|
|
|
431 |
// particular widget may define one or more resource bundles,
|
|
|
432 |
// structured in a program as follows, where moduleName is
|
|
|
433 |
// mycode.mywidget and bundleNames available include bundleone and
|
|
|
434 |
// bundletwo:
|
|
|
435 |
//
|
|
|
436 |
// ...
|
|
|
437 |
// mycode/
|
|
|
438 |
// mywidget/
|
|
|
439 |
// nls/
|
|
|
440 |
// bundleone.js (the fallback translation, English in this example)
|
|
|
441 |
// bundletwo.js (also a fallback translation)
|
|
|
442 |
// de/
|
|
|
443 |
// bundleone.js
|
|
|
444 |
// bundletwo.js
|
|
|
445 |
// de-at/
|
|
|
446 |
// bundleone.js
|
|
|
447 |
// en/
|
|
|
448 |
// (empty; use the fallback translation)
|
|
|
449 |
// en-us/
|
|
|
450 |
// bundleone.js
|
|
|
451 |
// en-gb/
|
|
|
452 |
// bundleone.js
|
|
|
453 |
// es/
|
|
|
454 |
// bundleone.js
|
|
|
455 |
// bundletwo.js
|
|
|
456 |
// ...etc
|
|
|
457 |
// ...
|
|
|
458 |
//
|
|
|
459 |
// Each directory is named for a locale as specified by RFC 3066,
|
|
|
460 |
// (http://www.ietf.org/rfc/rfc3066.txt), normalized in lowercase.
|
|
|
461 |
// Note that the two bundles in the example do not define all the same
|
|
|
462 |
// variants. For a given locale, bundles will be loaded for that
|
|
|
463 |
// locale and all more general locales above it, including a fallback
|
|
|
464 |
// at the root directory. For example, a declaration for the "de-at"
|
|
|
465 |
// locale will first load nls/de-at/bundleone.js, then
|
|
|
466 |
// nls/de/bundleone.js and finally nls/bundleone.js. The data will be
|
|
|
467 |
// flattened into a single Object so that lookups will follow this
|
|
|
468 |
// cascading pattern. An optional build step can preload the bundles
|
|
|
469 |
// to avoid data redundancy and the multiple network hits normally
|
|
|
470 |
// required to load these resources.
|
|
|
471 |
|
|
|
472 |
d.require("dojo.i18n");
|
|
|
473 |
d.i18n._requireLocalization.apply(d.hostenv, arguments);
|
|
|
474 |
};
|
|
|
475 |
|
|
|
476 |
|
|
|
477 |
var ore = new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$");
|
|
|
478 |
var ire = new RegExp("^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$");
|
|
|
479 |
|
|
|
480 |
dojo._Url = function(/*dojo._Url||String...*/){
|
|
|
481 |
// summary:
|
|
|
482 |
// Constructor to create an object representing a URL.
|
|
|
483 |
// It is marked as private, since we might consider removing
|
|
|
484 |
// or simplifying it.
|
|
|
485 |
// description:
|
|
|
486 |
// Each argument is evaluated in order relative to the next until
|
|
|
487 |
// a canonical uri is produced. To get an absolute Uri relative to
|
|
|
488 |
// the current document use:
|
|
|
489 |
// new dojo._Url(document.baseURI, url)
|
|
|
490 |
|
|
|
491 |
var n = null;
|
|
|
492 |
|
|
|
493 |
// TODO: support for IPv6, see RFC 2732
|
|
|
494 |
var _a = arguments;
|
|
|
495 |
var uri = _a[0];
|
|
|
496 |
// resolve uri components relative to each other
|
|
|
497 |
for(var i = 1; i<_a.length; i++){
|
|
|
498 |
if(!_a[i]){ continue; }
|
|
|
499 |
|
|
|
500 |
// Safari doesn't support this.constructor so we have to be explicit
|
|
|
501 |
// FIXME: Tracked (and fixed) in Webkit bug 3537.
|
|
|
502 |
// http://bugs.webkit.org/show_bug.cgi?id=3537
|
|
|
503 |
var relobj = new d._Url(_a[i]+"");
|
|
|
504 |
var uriobj = new d._Url(uri+"");
|
|
|
505 |
|
|
|
506 |
if(
|
|
|
507 |
(relobj.path=="") &&
|
|
|
508 |
(!relobj.scheme) &&
|
|
|
509 |
(!relobj.authority) &&
|
|
|
510 |
(!relobj.query)
|
|
|
511 |
){
|
|
|
512 |
if(relobj.fragment != n){
|
|
|
513 |
uriobj.fragment = relobj.fragment;
|
|
|
514 |
}
|
|
|
515 |
relobj = uriobj;
|
|
|
516 |
}else if(!relobj.scheme){
|
|
|
517 |
relobj.scheme = uriobj.scheme;
|
|
|
518 |
|
|
|
519 |
if(!relobj.authority){
|
|
|
520 |
relobj.authority = uriobj.authority;
|
|
|
521 |
|
|
|
522 |
if(relobj.path.charAt(0) != "/"){
|
|
|
523 |
var path = uriobj.path.substring(0,
|
|
|
524 |
uriobj.path.lastIndexOf("/") + 1) + relobj.path;
|
|
|
525 |
|
|
|
526 |
var segs = path.split("/");
|
|
|
527 |
for(var j = 0; j < segs.length; j++){
|
|
|
528 |
if(segs[j] == "."){
|
|
|
529 |
if(j == segs.length - 1){
|
|
|
530 |
segs[j] = "";
|
|
|
531 |
}else{
|
|
|
532 |
segs.splice(j, 1);
|
|
|
533 |
j--;
|
|
|
534 |
}
|
|
|
535 |
}else if(j > 0 && !(j == 1 && segs[0] == "") &&
|
|
|
536 |
segs[j] == ".." && segs[j-1] != ".."){
|
|
|
537 |
|
|
|
538 |
if(j == (segs.length - 1)){
|
|
|
539 |
segs.splice(j, 1);
|
|
|
540 |
segs[j - 1] = "";
|
|
|
541 |
}else{
|
|
|
542 |
segs.splice(j - 1, 2);
|
|
|
543 |
j -= 2;
|
|
|
544 |
}
|
|
|
545 |
}
|
|
|
546 |
}
|
|
|
547 |
relobj.path = segs.join("/");
|
|
|
548 |
}
|
|
|
549 |
}
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
uri = "";
|
|
|
553 |
if(relobj.scheme){
|
|
|
554 |
uri += relobj.scheme + ":";
|
|
|
555 |
}
|
|
|
556 |
if(relobj.authority){
|
|
|
557 |
uri += "//" + relobj.authority;
|
|
|
558 |
}
|
|
|
559 |
uri += relobj.path;
|
|
|
560 |
if(relobj.query){
|
|
|
561 |
uri += "?" + relobj.query;
|
|
|
562 |
}
|
|
|
563 |
if(relobj.fragment){
|
|
|
564 |
uri += "#" + relobj.fragment;
|
|
|
565 |
}
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
this.uri = uri.toString();
|
|
|
569 |
|
|
|
570 |
// break the uri into its main components
|
|
|
571 |
var r = this.uri.match(ore);
|
|
|
572 |
|
|
|
573 |
this.scheme = r[2] || (r[1] ? "" : n);
|
|
|
574 |
this.authority = r[4] || (r[3] ? "" : n);
|
|
|
575 |
this.path = r[5]; // can never be undefined
|
|
|
576 |
this.query = r[7] || (r[6] ? "" : n);
|
|
|
577 |
this.fragment = r[9] || (r[8] ? "" : n);
|
|
|
578 |
|
|
|
579 |
if(this.authority != n){
|
|
|
580 |
// server based naming authority
|
|
|
581 |
r = this.authority.match(ire);
|
|
|
582 |
|
|
|
583 |
this.user = r[3] || n;
|
|
|
584 |
this.password = r[4] || n;
|
|
|
585 |
this.host = r[5];
|
|
|
586 |
this.port = r[7] || n;
|
|
|
587 |
}
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
dojo._Url.prototype.toString = function(){ return this.uri; };
|
|
|
591 |
|
|
|
592 |
dojo.moduleUrl = function(/*String*/module, /*dojo._Url||String*/url){
|
|
|
593 |
// summary:
|
|
|
594 |
// Returns a Url object relative to a module
|
|
|
595 |
//
|
|
|
596 |
// example:
|
|
|
597 |
// | dojo.moduleUrl("dojo.widget","templates/template.html");
|
|
|
598 |
// example:
|
|
|
599 |
// | dojo.moduleUrl("acme","images/small.png")
|
|
|
600 |
|
|
|
601 |
var loc = dojo._getModuleSymbols(module).join('/');
|
|
|
602 |
if(!loc){ return null; }
|
|
|
603 |
if(loc.lastIndexOf("/") != loc.length-1){
|
|
|
604 |
loc += "/";
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
//If the path is an absolute path (starts with a / or is on another
|
|
|
608 |
//domain/xdomain) then don't add the baseUrl.
|
|
|
609 |
var colonIndex = loc.indexOf(":");
|
|
|
610 |
if(loc.charAt(0) != "/" && (colonIndex == -1 || colonIndex > loc.indexOf("/"))){
|
|
|
611 |
loc = d.baseUrl + loc;
|
|
|
612 |
}
|
|
|
613 |
|
|
|
614 |
return new d._Url(loc, url); // String
|
|
|
615 |
}
|
|
|
616 |
})();
|
|
|
617 |
|
|
|
618 |
}
|