[483] | 1 | define(["../has", "require"], function(has, require){ |
---|
| 2 | // module: |
---|
| 3 | // dojo/_base/config |
---|
| 4 | |
---|
| 5 | /*===== |
---|
| 6 | return { |
---|
| 7 | // summary: |
---|
| 8 | // This module defines the user configuration during bootstrap. |
---|
| 9 | // description: |
---|
| 10 | // By defining user configuration as a module value, an entire configuration can be specified in a build, |
---|
| 11 | // thereby eliminating the need for sniffing and or explicitly setting in the global variable dojoConfig. |
---|
| 12 | // Also, when multiple instances of dojo exist in a single application, each will necessarily be located |
---|
| 13 | // at an unique absolute module identifier as given by the package configuration. Implementing configuration |
---|
| 14 | // as a module allows for specifying unique, per-instance configurations. |
---|
| 15 | // example: |
---|
| 16 | // Create a second instance of dojo with a different, instance-unique configuration (assume the loader and |
---|
| 17 | // dojo.js are already loaded). |
---|
| 18 | // | // specify a configuration that creates a new instance of dojo at the absolute module identifier "myDojo" |
---|
| 19 | // | require({ |
---|
| 20 | // | packages:[{ |
---|
| 21 | // | name:"myDojo", |
---|
| 22 | // | location:".", //assume baseUrl points to dojo.js |
---|
| 23 | // | }] |
---|
| 24 | // | }); |
---|
| 25 | // | |
---|
| 26 | // | // specify a configuration for the myDojo instance |
---|
| 27 | // | define("myDojo/config", { |
---|
| 28 | // | // normal configuration variables go here, e.g., |
---|
| 29 | // | locale:"fr-ca" |
---|
| 30 | // | }); |
---|
| 31 | // | |
---|
| 32 | // | // load and use the new instance of dojo |
---|
| 33 | // | require(["myDojo"], function(dojo){ |
---|
| 34 | // | // dojo is the new instance of dojo |
---|
| 35 | // | // use as required |
---|
| 36 | // | }); |
---|
| 37 | |
---|
| 38 | // isDebug: Boolean |
---|
| 39 | // Defaults to `false`. If set to `true`, ensures that Dojo provides |
---|
| 40 | // extended debugging feedback via Firebug. If Firebug is not available |
---|
| 41 | // on your platform, setting `isDebug` to `true` will force Dojo to |
---|
| 42 | // pull in (and display) the version of Firebug Lite which is |
---|
| 43 | // integrated into the Dojo distribution, thereby always providing a |
---|
| 44 | // debugging/logging console when `isDebug` is enabled. Note that |
---|
| 45 | // Firebug's `console.*` methods are ALWAYS defined by Dojo. If |
---|
| 46 | // `isDebug` is false and you are on a platform without Firebug, these |
---|
| 47 | // methods will be defined as no-ops. |
---|
| 48 | isDebug: false, |
---|
| 49 | |
---|
| 50 | // locale: String |
---|
| 51 | // The locale to assume for loading localized resources in this page, |
---|
| 52 | // specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt). |
---|
| 53 | // Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`. |
---|
| 54 | // See the documentation for `dojo.i18n` and `dojo.requireLocalization` |
---|
| 55 | // for details on loading localized resources. If no locale is specified, |
---|
| 56 | // Dojo assumes the locale of the user agent, according to `navigator.userLanguage` |
---|
| 57 | // or `navigator.language` properties. |
---|
| 58 | locale: undefined, |
---|
| 59 | |
---|
| 60 | // extraLocale: Array |
---|
| 61 | // No default value. Specifies additional locales whose |
---|
| 62 | // resources should also be loaded alongside the default locale when |
---|
| 63 | // calls to `dojo.requireLocalization()` are processed. |
---|
| 64 | extraLocale: undefined, |
---|
| 65 | |
---|
| 66 | // baseUrl: String |
---|
| 67 | // The directory in which `dojo.js` is located. Under normal |
---|
| 68 | // conditions, Dojo auto-detects the correct location from which it |
---|
| 69 | // was loaded. You may need to manually configure `baseUrl` in cases |
---|
| 70 | // where you have renamed `dojo.js` or in which `<base>` tags confuse |
---|
| 71 | // some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned |
---|
| 72 | // either the value of `djConfig.baseUrl` if one is provided or the |
---|
| 73 | // auto-detected root if not. Other modules are located relative to |
---|
| 74 | // this path. The path should end in a slash. |
---|
| 75 | baseUrl: undefined, |
---|
| 76 | |
---|
| 77 | // modulePaths: [deprecated] Object |
---|
| 78 | // A map of module names to paths relative to `dojo.baseUrl`. The |
---|
| 79 | // key/value pairs correspond directly to the arguments which |
---|
| 80 | // `dojo.registerModulePath` accepts. Specifying |
---|
| 81 | // `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent |
---|
| 82 | // of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple |
---|
| 83 | // modules may be configured via `djConfig.modulePaths`. |
---|
| 84 | modulePaths: {}, |
---|
| 85 | |
---|
| 86 | // addOnLoad: Function|Array |
---|
| 87 | // Adds a callback via dojo/ready. Useful when Dojo is added after |
---|
| 88 | // the page loads and djConfig.afterOnLoad is true. Supports the same |
---|
| 89 | // arguments as dojo/ready. When using a function reference, use |
---|
| 90 | // `djConfig.addOnLoad = function(){};`. For object with function name use |
---|
| 91 | // `djConfig.addOnLoad = [myObject, "functionName"];` and for object with |
---|
| 92 | // function reference use |
---|
| 93 | // `djConfig.addOnLoad = [myObject, function(){}];` |
---|
| 94 | addOnLoad: null, |
---|
| 95 | |
---|
| 96 | // parseOnLoad: Boolean |
---|
| 97 | // Run the parser after the page is loaded |
---|
| 98 | parseOnLoad: false, |
---|
| 99 | |
---|
| 100 | // require: String[] |
---|
| 101 | // An array of module names to be loaded immediately after dojo.js has been included |
---|
| 102 | // in a page. |
---|
| 103 | require: [], |
---|
| 104 | |
---|
| 105 | // defaultDuration: Number |
---|
| 106 | // Default duration, in milliseconds, for wipe and fade animations within dijits. |
---|
| 107 | // Assigned to dijit.defaultDuration. |
---|
| 108 | defaultDuration: 200, |
---|
| 109 | |
---|
| 110 | // dojoBlankHtmlUrl: String |
---|
| 111 | // Used by some modules to configure an empty iframe. Used by dojo/io/iframe and |
---|
| 112 | // dojo/back, and dijit/popup support in IE where an iframe is needed to make sure native |
---|
| 113 | // controls do not bleed through the popups. Normally this configuration variable |
---|
| 114 | // does not need to be set, except when using cross-domain/CDN Dojo builds. |
---|
| 115 | // Save dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl` |
---|
| 116 | // to the path on your domain your copy of blank.html. |
---|
| 117 | dojoBlankHtmlUrl: undefined, |
---|
| 118 | |
---|
| 119 | // ioPublish: Boolean? |
---|
| 120 | // Set this to true to enable publishing of topics for the different phases of |
---|
| 121 | // IO operations. Publishing is done via dojo/topic.publish(). See dojo/main.__IoPublish for a list |
---|
| 122 | // of topics that are published. |
---|
| 123 | ioPublish: false, |
---|
| 124 | |
---|
| 125 | // useCustomLogger: Anything? |
---|
| 126 | // If set to a value that evaluates to true such as a string or array and |
---|
| 127 | // isDebug is true and Firebug is not available or running, then it bypasses |
---|
| 128 | // the creation of Firebug Lite allowing you to define your own console object. |
---|
| 129 | useCustomLogger: undefined, |
---|
| 130 | |
---|
| 131 | // transparentColor: Array |
---|
| 132 | // Array containing the r, g, b components used as transparent color in dojo.Color; |
---|
| 133 | // if undefined, [255,255,255] (white) will be used. |
---|
| 134 | transparentColor: undefined, |
---|
| 135 | |
---|
| 136 | // deps: Function|Array |
---|
| 137 | // Defines dependencies to be used before the loader has been loaded. |
---|
| 138 | // When provided, they cause the loader to execute require(deps, callback) |
---|
| 139 | // once it has finished loading. Should be used with callback. |
---|
| 140 | deps: undefined, |
---|
| 141 | |
---|
| 142 | // callback: Function|Array |
---|
| 143 | // Defines a callback to be used when dependencies are defined before |
---|
| 144 | // the loader has been loaded. When provided, they cause the loader to |
---|
| 145 | // execute require(deps, callback) once it has finished loading. |
---|
| 146 | // Should be used with deps. |
---|
| 147 | callback: undefined, |
---|
| 148 | |
---|
| 149 | // deferredInstrumentation: Boolean |
---|
| 150 | // Whether deferred instrumentation should be loaded or included |
---|
| 151 | // in builds. |
---|
| 152 | deferredInstrumentation: true, |
---|
| 153 | |
---|
| 154 | // useDeferredInstrumentation: Boolean|String |
---|
| 155 | // Whether the deferred instrumentation should be used. |
---|
| 156 | // |
---|
| 157 | // * `"report-rejections"`: report each rejection as it occurs. |
---|
| 158 | // * `true` or `1` or `"report-unhandled-rejections"`: wait 1 second |
---|
| 159 | // in an attempt to detect unhandled rejections. |
---|
| 160 | useDeferredInstrumentation: "report-unhandled-rejections" |
---|
| 161 | }; |
---|
| 162 | =====*/ |
---|
| 163 | |
---|
| 164 | var result = {}; |
---|
| 165 | if(has("dojo-config-api")){ |
---|
| 166 | // must be the dojo loader; take a shallow copy of require.rawConfig |
---|
| 167 | var src = require.rawConfig, p; |
---|
| 168 | for(p in src){ |
---|
| 169 | result[p] = src[p]; |
---|
| 170 | } |
---|
| 171 | }else{ |
---|
| 172 | var adviseHas = function(featureSet, prefix, booting){ |
---|
| 173 | for(p in featureSet){ |
---|
| 174 | p!="has" && has.add(prefix + p, featureSet[p], 0, booting); |
---|
| 175 | } |
---|
| 176 | }; |
---|
| 177 | result = has("dojo-loader") ? |
---|
| 178 | // must be a built version of the dojo loader; all config stuffed in require.rawConfig |
---|
| 179 | require.rawConfig : |
---|
| 180 | // a foreign loader |
---|
| 181 | this.dojoConfig || this.djConfig || {}; |
---|
| 182 | adviseHas(result, "config", 1); |
---|
| 183 | adviseHas(result.has, "", 1); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | if(!result.locale && typeof navigator != "undefined"){ |
---|
| 187 | // Default locale for browsers. |
---|
| 188 | result.locale = (navigator.language || navigator.userLanguage).toLowerCase(); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | return result; |
---|
| 192 | }); |
---|
| 193 | |
---|