config.js 8.0 KB

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