3 // 'djConfig' does not exist under 'dojo.*' so that it can be set before the
4 // 'dojo' variable exists.
6 // Setting any of these variables *after* the library has loaded does
11 // Application code can set the global 'djConfig' prior to loading
12 // the library to override certain global settings for how dojo works.
15 // Defaults to `false`. If set to `true`, ensures that Dojo provides
16 // extende debugging feedback via Firebug. If Firebug is not available
17 // on your platform, setting `isDebug` to `true` will force Dojo to
18 // pull in (and display) the version of Firebug Lite which is
19 // integrated into the Dojo distribution, thereby always providing a
20 // debugging/logging console when `isDebug` is enabled. Note that
21 // Firebug's `console.*` methods are ALWAYS defined by Dojo. If
22 // `isDebug` is false and you are on a platform without Firebug, these
23 // methods will be defined as no-ops.
25 // debugAtAllCosts: Boolean
26 // Defaults to `false`. If set to `true`, this triggers an alternate
27 // mode of the package system in which dependencies are detected and
28 // only then are resources evaluated in dependency order via
29 // `<script>` tag inclusion. This may double-request resources and
30 // cause problems with scripts which expect `dojo.require()` to
31 // preform synchronously. `debugAtAllCosts` can be an invaluable
32 // debugging aid, but when using it, ensure that all code which
33 // depends on Dojo modules is wrapped in `dojo.addOnLoad()` handlers.
34 // Due to the somewhat unpredictable side-effects of using
35 // `debugAtAllCosts`, it is strongly recommended that you enable this
36 // flag as a last resort. `debugAtAllCosts` has no effect when loading
37 // resources across domains. For usage information, see the
38 // [Dojo Book](http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-your-dojo-code-run-faster-and-better/debugging-facilities/deb)
39 debugAtAllCosts: false,
41 // The locale to assume for loading localized resources in this page,
42 // specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt).
43 // Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`.
44 // See the documentation for `dojo.i18n` and `dojo.requireLocalization`
45 // for details on loading localized resources. If no locale is specified,
46 // Dojo assumes the locale of the user agent, according to `navigator.userLanguage`
47 // or `navigator.language` properties.
50 // No default value. Specifies additional locales whose
51 // resources should also be loaded alongside the default locale when
52 // calls to `dojo.requireLocalization()` are processed.
53 extraLocale: undefined,
55 // The directory in which `dojo.js` is located. Under normal
56 // conditions, Dojo auto-detects the correct location from which it
57 // was loaded. You may need to manually configure `baseUrl` in cases
58 // where you have renamed `dojo.js` or in which `<base>` tags confuse
59 // some browsers (e.g., IE 6). The variable `dojo.baseUrl` is assigned
60 // either the value of `djConfig.baseUrl` if one is provided or the
61 // auto-detected root if not. Other modules are located relative to
64 // modulePaths: Object
65 // A map of module names to paths relative to `dojo.baseUrl`. The
66 // key/value pairs correspond directly to the arguments which
67 // `dojo.registerModulePath` accepts. Specifiying
68 // `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent
69 // of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple
70 // modules may be configured via `djConfig.modulePaths`.
78 // if((!this["console"])||(!console["firebug"])){
82 log: function(){} // no-op
87 "assert", "count", "debug", "dir", "dirxml", "error", "group",
88 "groupEnd", "info", "profile", "profileEnd", "time", "timeEnd",
89 "trace", "warn", "log"
96 console[tcn] = function(){
97 var a = Array.apply({}, arguments);
99 console.log(a.join(" "));
105 //TODOC: HOW TO DOC THIS?
106 // dojo is the root variable of (almost all) our public symbols -- make sure it is defined.
107 if(typeof dojo == "undefined"){
111 _scopePrefixArgs: "",
120 //Need placeholders for dijit and dojox for scoping code.
121 if(typeof dijit == "undefined"){
122 this.dijit = {_scopeName: "dijit"};
124 if(typeof dojox == "undefined"){
125 this.dojox = {_scopeName: "dojox"};
129 d._scopeArgs = [dojo, dijit, dojox];
135 // Alias for the global scope
136 // (e.g. the window object in a browser).
138 // Refer to 'dojo.global' rather than referring to window to ensure your
139 // code runs correctly in contexts other than web browsers (e.g. Rhino on a server).
144 d.config =/*===== djConfig = =====*/{
146 debugAtAllCosts: false
149 if(typeof djConfig != "undefined"){
150 for(var opt in djConfig){
151 d.config[opt] = djConfig[opt];
155 var _platforms = ["Browser", "Rhino", "Spidermonkey", "Mobile"];
157 while((t=_platforms.shift())){
162 // Override locale setting, if specified
164 // summary: the locale as defined by Dojo (read-only)
167 dojo.locale = d.config.locale;
169 var rev = "$Rev: 13707 $".match(/\d+/);
173 // version number of dojo
175 // Major version. If total version is "1.2.0beta1", will be 1
177 // Minor version. If total version is "1.2.0beta1", will be 2
179 // Patch version. If total version is "1.2.0beta1", will be 0
181 // Descriptor flag. If total version is "1.2.0beta1", will be "beta1"
183 // The SVN rev from which dojo was pulled
184 major: 1, minor: 1, patch: 1, flag: "",
185 revision: rev ? +rev[0] : 999999, //FIXME: use NaN?
186 toString: function(){
188 return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String
193 // Register with the OpenAjax hub
194 if(typeof OpenAjax != "undefined"){
195 OpenAjax.hub.registerLibrary(dojo._scopeName, "http://dojotoolkit.org", d.version.toString());
198 dojo._mixin = function(/*Object*/ obj, /*Object*/ props){
200 // Adds all properties and methods of props to obj. This addition
201 // is "prototype extension safe", so that instances of objects
202 // will not pass along prototype defaults.
205 // the "tobj" condition avoid copying properties in "props"
206 // inherited from Object.prototype. For example, if obj has a custom
207 // toString() method, don't overwrite it with the toString() method
208 // that props inherited from Object.prototype
209 if(tobj[x] === undefined || tobj[x] != props[x]){
213 // IE doesn't recognize custom toStrings in for..in
214 if(d["isIE"] && props){
215 var p = props.toString;
216 if(typeof p == "function" && p != obj.toString && p != tobj.toString &&
217 p != "\nfunction toString() {\n [native code]\n}\n"){
218 obj.toString = props.toString;
221 return obj; // Object
224 dojo.mixin = function(/*Object*/obj, /*Object...*/props){
226 // Adds all properties and methods of props to obj and returns the
227 // (now modified) obj.
229 // `dojo.mixin` can mix multiple source objects into a
230 // destionation object which is then returned. Unlike regular
231 // `for...in` iteration, `dojo.mixin` is also smart about avoiding
232 // extensions which other toolkits may unwisely add to the root
235 // The object to mix properties into. Also the return value.
237 // One or more objects whose values are successively copied into
238 // obj. If more than one of these objects contain the same value,
239 // the one specified last in the function call will "win".
241 // make a shallow copy of an object
242 // | var copy = dojo.mixin({}, source);
244 // many class constructors often take an object which specifies
245 // values to be configured on the object. In this case, it is
246 // often simplest to call `dojo.mixin` on the `this` object:
247 // | dojo.declare("acme.Base", null, {
248 // | constructor: function(properties){
249 // | // property configuration:
250 // | dojo.mixin(this, properties);
252 // | console.debug(this.quip);
255 // | quip: "I wasn't born yesterday, you know - I've seen movies.",
259 // | // create an instance of the class and configure it
260 // | var b = new acme.Base({quip: "That's what it does!" });
262 // copy in properties from multiple objects
263 // | var flattened = dojo.mixin(
265 // | name: "Frylock",
269 // | name: "Carl Brutanananadilewski"
273 // | // will print "Carl Brutanananadilewski"
274 // | console.debug(flattened.name);
275 // | // will print "true"
276 // | console.debug(flattened.braces);
277 for(var i=1, l=arguments.length; i<l; i++){
278 d._mixin(obj, arguments[i]);
280 return obj; // Object
283 dojo._getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
284 var obj=context || d.global;
285 for(var i=0, p; obj && (p=parts[i]); i++){
286 if(i == 0 && this._scopeMap[p]){
287 p = this._scopeMap[p];
289 obj = (p in obj ? obj[p] : (create ? obj[p]={} : undefined));
294 dojo.setObject = function(/*String*/name, /*Object*/value, /*Object?*/context){
296 // Set a property from a dot-separated string, such as "A.B.C"
298 // Useful for longer api chains where you have to test each object in
299 // the chain, or when you have an object reference in string format.
300 // Objects are created as needed along `path`. Returns the passed
301 // value if setting is successful or `undefined` if not.
303 // Path to a property, in the form "A.B.C".
305 // Optional. Object to use as root of path. Defaults to
308 // set the value of `foo.bar.baz`, regardless of whether
309 // intermediate objects already exist:
310 // | dojo.setObject("foo.bar.baz", value);
312 // without `dojo.setObject`, we often see code like this:
313 // | // ensure that intermediate objects are available
314 // | if(!obj["parent"]){ obj.parent = {}; }
315 // | if(!obj.parent["child"]){ obj.parent.child= {}; }
316 // | // now we can safely set the property
317 // | obj.parent.child.prop = "some value";
318 // wheras with `dojo.setObject`, we can shorten that to:
319 // | dojo.setObject("parent.child.prop", "some value", obj);
320 var parts=name.split("."), p=parts.pop(), obj=d._getProp(parts, true, context);
321 return obj && p ? (obj[p]=value) : undefined; // Object
324 dojo.getObject = function(/*String*/name, /*Boolean*/create, /*Object*/context){
326 // Get a property from a dot-separated string, such as "A.B.C"
328 // Useful for longer api chains where you have to test each object in
329 // the chain, or when you have an object reference in string format.
331 // Path to an property, in the form "A.B.C".
333 // Optional. Object to use as root of path. Defaults to
334 // 'dojo.global'. Null may be passed.
336 // Optional. Defaults to `false`. If `true`, Objects will be
337 // created at any point along the 'path' that is undefined.
338 return d._getProp(name.split("."), create, context); // Object
341 dojo.exists = function(/*String*/name, /*Object?*/obj){
343 // determine if an object supports a given method
345 // useful for longer api chains where you have to test each object in
348 // Path to an object, in the form "A.B.C".
350 // Object to use as root of path. Defaults to
351 // 'dojo.global'. Null may be passed.
353 // | // define an object
358 // | // search the global scope
359 // | dojo.exists("foo.bar"); // true
360 // | dojo.exists("foo.bar.baz"); // false
362 // | // search from a particular scope
363 // | dojo.exists("bar", foo); // true
364 // | dojo.exists("bar.baz", foo); // false
365 return !!d.getObject(name, false, obj); // Boolean
369 dojo["eval"] = function(/*String*/ scriptFragment){
371 // Perform an evaluation in the global scope. Use this rather than
372 // calling 'eval()' directly.
374 // Placed in a separate function to minimize size of trapped
375 // exceptions. Calling eval() directly from some other scope may
376 // complicate tracebacks on some platforms.
378 // The result of the evaluation. Often `undefined`
382 // - JSC eval() takes an optional second argument which can be 'unsafe'.
383 // - Mozilla/SpiderMonkey eval() takes an optional second argument which is the
384 // scope object for new symbols.
386 // FIXME: investigate Joseph Smarr's technique for IE:
387 // http://josephsmarr.com/2007/01/31/fixing-eval-to-use-global-scope-in-ie/
389 // http://trac.dojotoolkit.org/ticket/744
390 return d.global.eval ? d.global.eval(scriptFragment) : eval(scriptFragment); // Object
394 dojo.deprecated = function(behaviour, extra, removal){
396 // Log a debug message to indicate that a behavior has been
399 // The API or behavior being deprecated. Usually in the form
400 // of "myApp.someFunction()".
402 // Text to append to the message. Often provides advice on a
403 // new function or facility to achieve the same goal during
404 // the deprecation period.
406 // Text to indicate when in the future the behavior will be
407 // removed. Usually a version number.
409 // | dojo.deprecated("myApp.getTemp()", "use myApp.getLocaleTemp() instead", "1.0");
412 dojo.experimental = function(moduleName, extra){
413 // summary: Marks code as experimental.
415 // This can be used to mark a function, file, or module as
416 // experimental. Experimental code is not ready to be used, and the
417 // APIs are subject to change without notice. Experimental code may be
418 // completed deleted without going through the normal deprecation
420 // moduleName: String
421 // The name of a module, or the name of a module file or a specific
424 // some additional message for the user
426 // | dojo.experimental("dojo.data.Result");
428 // | dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
432 //Real functions declared in dojo._firebug.firebug.
433 d.deprecated = d.experimental = function(){};