bootstrap.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. /*=====
  7. // note:
  8. // 'djConfig' does not exist under 'dojo.*' so that it can be set before the
  9. // 'dojo' variable exists.
  10. // note:
  11. // Setting any of these variables *after* the library has loaded does
  12. // nothing at all.
  13. djConfig = {
  14. // summary:
  15. // Application code can set the global 'djConfig' prior to loading
  16. // the library to override certain global settings for how dojo works.
  17. //
  18. // isDebug: Boolean
  19. // Defaults to `false`. If set to `true`, ensures that Dojo provides
  20. // extended debugging feedback via Firebug. If Firebug is not available
  21. // on your platform, setting `isDebug` to `true` will force Dojo to
  22. // pull in (and display) the version of Firebug Lite which is
  23. // integrated into the Dojo distribution, thereby always providing a
  24. // debugging/logging console when `isDebug` is enabled. Note that
  25. // Firebug's `console.*` methods are ALWAYS defined by Dojo. If
  26. // `isDebug` is false and you are on a platform without Firebug, these
  27. // methods will be defined as no-ops.
  28. isDebug: false,
  29. // debugAtAllCosts: Boolean
  30. // Defaults to `false`. If set to `true`, this triggers an alternate
  31. // mode of the package system in which dependencies are detected and
  32. // only then are resources evaluated in dependency order via
  33. // `<script>` tag inclusion. This may double-request resources and
  34. // cause problems with scripts which expect `dojo.require()` to
  35. // preform synchronously. `debugAtAllCosts` can be an invaluable
  36. // debugging aid, but when using it, ensure that all code which
  37. // depends on Dojo modules is wrapped in `dojo.addOnLoad()` handlers.
  38. // Due to the somewhat unpredictable side-effects of using
  39. // `debugAtAllCosts`, it is strongly recommended that you enable this
  40. // flag as a last resort. `debugAtAllCosts` has no effect when loading
  41. // resources across domains. For usage information, see the
  42. // [Dojo Book](http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-your-dojo-code-run-faster-and-better/debugging-facilities/deb)
  43. debugAtAllCosts: false,
  44. // locale: String
  45. // The locale to assume for loading localized resources in this page,
  46. // specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt).
  47. // Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`.
  48. // See the documentation for `dojo.i18n` and `dojo.requireLocalization`
  49. // for details on loading localized resources. If no locale is specified,
  50. // Dojo assumes the locale of the user agent, according to `navigator.userLanguage`
  51. // or `navigator.language` properties.
  52. locale: undefined,
  53. // extraLocale: Array
  54. // No default value. Specifies additional locales whose
  55. // resources should also be loaded alongside the default locale when
  56. // calls to `dojo.requireLocalization()` are processed.
  57. extraLocale: undefined,
  58. // baseUrl: String
  59. // The directory in which `dojo.js` is located. Under normal
  60. // conditions, Dojo auto-detects the correct location from which it
  61. // was loaded. You may need to manually configure `baseUrl` in cases
  62. // where you have renamed `dojo.js` or in which `<base>` tags confuse
  63. // some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned
  64. // either the value of `djConfig.baseUrl` if one is provided or the
  65. // auto-detected root if not. Other modules are located relative to
  66. // this path. The path should end in a slash.
  67. baseUrl: undefined,
  68. // modulePaths: Object
  69. // A map of module names to paths relative to `dojo.baseUrl`. The
  70. // key/value pairs correspond directly to the arguments which
  71. // `dojo.registerModulePath` accepts. Specifiying
  72. // `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent
  73. // of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple
  74. // modules may be configured via `djConfig.modulePaths`.
  75. modulePaths: {},
  76. // afterOnLoad: Boolean
  77. // Indicates Dojo was added to the page after the page load. In this case
  78. // Dojo will not wait for the page DOMContentLoad/load events and fire
  79. // its dojo.addOnLoad callbacks after making sure all outstanding
  80. // dojo.required modules have loaded. Only works with a built dojo.js,
  81. // it does not work the dojo.js directly from source control.
  82. afterOnLoad: false,
  83. // addOnLoad: Function or Array
  84. // Adds a callback via dojo.addOnLoad. Useful when Dojo is added after
  85. // the page loads and djConfig.afterOnLoad is true. Supports the same
  86. // arguments as dojo.addOnLoad. When using a function reference, use
  87. // `djConfig.addOnLoad = function(){};`. For object with function name use
  88. // `djConfig.addOnLoad = [myObject, "functionName"];` and for object with
  89. // function reference use
  90. // `djConfig.addOnLoad = [myObject, function(){}];`
  91. addOnLoad: null,
  92. // require: Array
  93. // An array of module names to be loaded immediately after dojo.js has been included
  94. // in a page.
  95. require: [],
  96. // defaultDuration: Array
  97. // Default duration, in milliseconds, for wipe and fade animations within dijits.
  98. // Assigned to dijit.defaultDuration.
  99. defaultDuration: 200,
  100. // dojoBlankHtmlUrl: String
  101. // Used by some modules to configure an empty iframe. Used by dojo.io.iframe and
  102. // dojo.back, and dijit popup support in IE where an iframe is needed to make sure native
  103. // controls do not bleed through the popups. Normally this configuration variable
  104. // does not need to be set, except when using cross-domain/CDN Dojo builds.
  105. // Save dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl`
  106. // to the path on your domain your copy of blank.html.
  107. dojoBlankHtmlUrl: undefined,
  108. // ioPublish: Boolean?
  109. // Set this to true to enable publishing of topics for the different phases of
  110. // IO operations. Publishing is done via dojo.publish. See dojo.__IoPublish for a list
  111. // of topics that are published.
  112. ioPublish: false,
  113. // useCustomLogger: Anything?
  114. // If set to a value that evaluates to true such as a string or array and
  115. // isDebug is true and Firebug is not available or running, then it bypasses
  116. // the creation of Firebug Lite allowing you to define your own console object.
  117. useCustomLogger: undefined,
  118. // transparentColor: Array
  119. // Array containing the r, g, b components used as transparent color in dojo.Color;
  120. // if undefined, [255,255,255] (white) will be used.
  121. transparentColor: undefined,
  122. // skipIeDomLoaded: Boolean
  123. // For IE only, skip the DOMContentLoaded hack used. Sometimes it can cause an Operation
  124. // Aborted error if the rest of the page triggers script defers before the DOM is ready.
  125. // If this is config value is set to true, then dojo.addOnLoad callbacks will not be
  126. // triggered until the page load event, which is after images and iframes load. If you
  127. // want to trigger the callbacks sooner, you can put a script block in the bottom of
  128. // your HTML that calls dojo._loadInit();. If you are using multiversion support, change
  129. // "dojo." to the appropriate scope name for dojo.
  130. skipIeDomLoaded: false
  131. }
  132. =====*/
  133. (function(){
  134. // firebug stubs
  135. if(typeof this["loadFirebugConsole"] == "function"){
  136. // for Firebug 1.2
  137. this["loadFirebugConsole"]();
  138. }else{
  139. this.console = this.console || {};
  140. // Be careful to leave 'log' always at the end
  141. var cn = [
  142. "assert", "count", "debug", "dir", "dirxml", "error", "group",
  143. "groupEnd", "info", "profile", "profileEnd", "time", "timeEnd",
  144. "trace", "warn", "log"
  145. ];
  146. var i = 0, tn;
  147. while((tn=cn[i++])){
  148. if(!console[tn]){
  149. (function(){
  150. var tcn = tn+"";
  151. console[tcn] = ('log' in console) ? function(){
  152. var a = Array.apply({}, arguments);
  153. a.unshift(tcn+":");
  154. console["log"](a.join(" "));
  155. } : function(){}
  156. console[tcn]._fake = true;
  157. })();
  158. }
  159. }
  160. }
  161. //TODOC: HOW TO DOC THIS?
  162. // dojo is the root variable of (almost all) our public symbols -- make sure it is defined.
  163. if(typeof dojo == "undefined"){
  164. dojo = {
  165. _scopeName: "dojo",
  166. _scopePrefix: "",
  167. _scopePrefixArgs: "",
  168. _scopeSuffix: "",
  169. _scopeMap: {},
  170. _scopeMapRev: {}
  171. };
  172. }
  173. var d = dojo;
  174. //Need placeholders for dijit and dojox for scoping code.
  175. if(typeof dijit == "undefined"){
  176. dijit = {_scopeName: "dijit"};
  177. }
  178. if(typeof dojox == "undefined"){
  179. dojox = {_scopeName: "dojox"};
  180. }
  181. if(!d._scopeArgs){
  182. d._scopeArgs = [dojo, dijit, dojox];
  183. }
  184. /*=====
  185. dojo.global = {
  186. // summary:
  187. // Alias for the global scope
  188. // (e.g. the window object in a browser).
  189. // description:
  190. // Refer to 'dojo.global' rather than referring to window to ensure your
  191. // code runs correctly in contexts other than web browsers (e.g. Rhino on a server).
  192. }
  193. =====*/
  194. d.global = this;
  195. d.config =/*===== djConfig = =====*/{
  196. isDebug: false,
  197. debugAtAllCosts: false
  198. };
  199. // FIXME: 2.0, drop djConfig support. Use dojoConfig exclusively for global config.
  200. var cfg = typeof djConfig != "undefined" ? djConfig :
  201. typeof dojoConfig != "undefined" ? dojoConfig : null;
  202. if(cfg){
  203. for(var c in cfg){
  204. d.config[c] = cfg[c];
  205. }
  206. }
  207. /*=====
  208. // Override locale setting, if specified
  209. dojo.locale = {
  210. // summary: the locale as defined by Dojo (read-only)
  211. };
  212. =====*/
  213. dojo.locale = d.config.locale;
  214. var rev = "$Rev: 31ff515 $".match(/[0-9a-f]{7,}/);
  215. /*=====
  216. dojo.version = function(){
  217. // summary:
  218. // Version number of the Dojo Toolkit
  219. // major: Integer
  220. // Major version. If total version is "1.2.0beta1", will be 1
  221. // minor: Integer
  222. // Minor version. If total version is "1.2.0beta1", will be 2
  223. // patch: Integer
  224. // Patch version. If total version is "1.2.0beta1", will be 0
  225. // flag: String
  226. // Descriptor flag. If total version is "1.2.0beta1", will be "beta1"
  227. // revision: Number
  228. // The SVN rev from which dojo was pulled
  229. this.major = 0;
  230. this.minor = 0;
  231. this.patch = 0;
  232. this.flag = "";
  233. this.revision = 0;
  234. }
  235. =====*/
  236. dojo.version = {
  237. major: 1, minor: 6, patch: 3, flag: "",
  238. revision: rev ? rev[0] : NaN,
  239. toString: function(){
  240. with(d.version){
  241. return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String
  242. }
  243. }
  244. }
  245. // Register with the OpenAjax hub
  246. if(typeof OpenAjax != "undefined"){
  247. OpenAjax.hub.registerLibrary(dojo._scopeName, "http://dojotoolkit.org", d.version.toString());
  248. }
  249. var extraNames, extraLen, empty = {};
  250. for(var i in {toString: 1}){ extraNames = []; break; }
  251. dojo._extraNames = extraNames = extraNames || ["hasOwnProperty", "valueOf", "isPrototypeOf",
  252. "propertyIsEnumerable", "toLocaleString", "toString", "constructor"];
  253. extraLen = extraNames.length;
  254. dojo._mixin = function(/*Object*/ target, /*Object*/ source){
  255. // summary:
  256. // Adds all properties and methods of source to target. This addition
  257. // is "prototype extension safe", so that instances of objects
  258. // will not pass along prototype defaults.
  259. var name, s, i;
  260. for(name in source){
  261. // the "tobj" condition avoid copying properties in "source"
  262. // inherited from Object.prototype. For example, if target has a custom
  263. // toString() method, don't overwrite it with the toString() method
  264. // that source inherited from Object.prototype
  265. s = source[name];
  266. if(!(name in target) || (target[name] !== s && (!(name in empty) || empty[name] !== s))){
  267. target[name] = s;
  268. }
  269. }
  270. // IE doesn't recognize some custom functions in for..in
  271. if(extraLen && source){
  272. for(i = 0; i < extraLen; ++i){
  273. name = extraNames[i];
  274. s = source[name];
  275. if(!(name in target) || (target[name] !== s && (!(name in empty) || empty[name] !== s))){
  276. target[name] = s;
  277. }
  278. }
  279. }
  280. return target; // Object
  281. }
  282. dojo.mixin = function(/*Object*/obj, /*Object...*/props){
  283. // summary:
  284. // Adds all properties and methods of props to obj and returns the
  285. // (now modified) obj.
  286. // description:
  287. // `dojo.mixin` can mix multiple source objects into a
  288. // destination object which is then returned. Unlike regular
  289. // `for...in` iteration, `dojo.mixin` is also smart about avoiding
  290. // extensions which other toolkits may unwisely add to the root
  291. // object prototype
  292. // obj:
  293. // The object to mix properties into. Also the return value.
  294. // props:
  295. // One or more objects whose values are successively copied into
  296. // obj. If more than one of these objects contain the same value,
  297. // the one specified last in the function call will "win".
  298. // example:
  299. // make a shallow copy of an object
  300. // | var copy = dojo.mixin({}, source);
  301. // example:
  302. // many class constructors often take an object which specifies
  303. // values to be configured on the object. In this case, it is
  304. // often simplest to call `dojo.mixin` on the `this` object:
  305. // | dojo.declare("acme.Base", null, {
  306. // | constructor: function(properties){
  307. // | // property configuration:
  308. // | dojo.mixin(this, properties);
  309. // |
  310. // | console.log(this.quip);
  311. // | // ...
  312. // | },
  313. // | quip: "I wasn't born yesterday, you know - I've seen movies.",
  314. // | // ...
  315. // | });
  316. // |
  317. // | // create an instance of the class and configure it
  318. // | var b = new acme.Base({quip: "That's what it does!" });
  319. // example:
  320. // copy in properties from multiple objects
  321. // | var flattened = dojo.mixin(
  322. // | {
  323. // | name: "Frylock",
  324. // | braces: true
  325. // | },
  326. // | {
  327. // | name: "Carl Brutanananadilewski"
  328. // | }
  329. // | );
  330. // |
  331. // | // will print "Carl Brutanananadilewski"
  332. // | console.log(flattened.name);
  333. // | // will print "true"
  334. // | console.log(flattened.braces);
  335. if(!obj){ obj = {}; }
  336. for(var i=1, l=arguments.length; i<l; i++){
  337. d._mixin(obj, arguments[i]);
  338. }
  339. return obj; // Object
  340. }
  341. dojo._getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
  342. if(!context){
  343. if(parts[0] && d._scopeMap[parts[0]]) {
  344. // Voodoo code from the old days where "dojo" or "dijit" maps to some special object
  345. // rather than just window.dojo
  346. context = d._scopeMap[parts.shift()][1];
  347. }else{
  348. context = d.global;
  349. }
  350. }
  351. try{
  352. for(var i = 0; i < parts.length; i++){
  353. var p = parts[i];
  354. // Fix for prototype pollution CVE-2021-23450
  355. if (p === '__proto__' || p === 'constructor') {
  356. return;
  357. }
  358. if(!(p in context)){
  359. if(create){
  360. context[p] = {};
  361. }else{
  362. return; // return undefined
  363. }
  364. }
  365. context = context[p];
  366. }
  367. return context; // mixed
  368. }catch(e){
  369. // "p in context" throws an exception when context is a number, boolean, etc. rather than an object,
  370. // so in that corner case just return undefined (by having no return statement)
  371. }
  372. }
  373. dojo.setObject = function(/*String*/name, /*Object*/value, /*Object?*/context){
  374. // summary:
  375. // Set a property from a dot-separated string, such as "A.B.C"
  376. // description:
  377. // Useful for longer api chains where you have to test each object in
  378. // the chain, or when you have an object reference in string format.
  379. // Objects are created as needed along `path`. Returns the passed
  380. // value if setting is successful or `undefined` if not.
  381. // name:
  382. // Path to a property, in the form "A.B.C".
  383. // context:
  384. // Optional. Object to use as root of path. Defaults to
  385. // `dojo.global`.
  386. // example:
  387. // set the value of `foo.bar.baz`, regardless of whether
  388. // intermediate objects already exist:
  389. // | dojo.setObject("foo.bar.baz", value);
  390. // example:
  391. // without `dojo.setObject`, we often see code like this:
  392. // | // ensure that intermediate objects are available
  393. // | if(!obj["parent"]){ obj.parent = {}; }
  394. // | if(!obj.parent["child"]){ obj.parent.child= {}; }
  395. // | // now we can safely set the property
  396. // | obj.parent.child.prop = "some value";
  397. // wheras with `dojo.setObject`, we can shorten that to:
  398. // | dojo.setObject("parent.child.prop", "some value", obj);
  399. var parts=name.split("."), p=parts.pop(), obj=d._getProp(parts, true, context);
  400. return obj && p ? (obj[p]=value) : undefined; // Object
  401. }
  402. dojo.getObject = function(/*String*/name, /*Boolean?*/create, /*Object?*/context){
  403. // summary:
  404. // Get a property from a dot-separated string, such as "A.B.C"
  405. // description:
  406. // Useful for longer api chains where you have to test each object in
  407. // the chain, or when you have an object reference in string format.
  408. // name:
  409. // Path to an property, in the form "A.B.C".
  410. // create:
  411. // Optional. Defaults to `false`. If `true`, Objects will be
  412. // created at any point along the 'path' that is undefined.
  413. // context:
  414. // Optional. Object to use as root of path. Defaults to
  415. // 'dojo.global'. Null may be passed.
  416. return !name ? context : d._getProp(name.split("."), create, context); // Object
  417. }
  418. dojo.exists = function(/*String*/name, /*Object?*/obj){
  419. // summary:
  420. // determine if an object supports a given method
  421. // description:
  422. // useful for longer api chains where you have to test each object in
  423. // the chain. Useful for object and method detection.
  424. // name:
  425. // Path to an object, in the form "A.B.C".
  426. // obj:
  427. // Object to use as root of path. Defaults to
  428. // 'dojo.global'. Null may be passed.
  429. // example:
  430. // | // define an object
  431. // | var foo = {
  432. // | bar: { }
  433. // | };
  434. // |
  435. // | // search the global scope
  436. // | dojo.exists("foo.bar"); // true
  437. // | dojo.exists("foo.bar.baz"); // false
  438. // |
  439. // | // search from a particular scope
  440. // | dojo.exists("bar", foo); // true
  441. // | dojo.exists("bar.baz", foo); // false
  442. return d.getObject(name, false, obj) !== undefined; // Boolean
  443. }
  444. dojo["eval"] = function(/*String*/ scriptFragment){
  445. // summary:
  446. // A legacy method created for use exclusively by internal Dojo methods. Do not use
  447. // this method directly, the behavior of this eval will differ from the normal
  448. // browser eval.
  449. // description:
  450. // Placed in a separate function to minimize size of trapped
  451. // exceptions. Calling eval() directly from some other scope may
  452. // complicate tracebacks on some platforms.
  453. // returns:
  454. // The result of the evaluation. Often `undefined`
  455. return d.global.eval ? d.global.eval(scriptFragment) : eval(scriptFragment); // Object
  456. }
  457. /*=====
  458. dojo.deprecated = function(behaviour, extra, removal){
  459. // summary:
  460. // Log a debug message to indicate that a behavior has been
  461. // deprecated.
  462. // behaviour: String
  463. // The API or behavior being deprecated. Usually in the form
  464. // of "myApp.someFunction()".
  465. // extra: String?
  466. // Text to append to the message. Often provides advice on a
  467. // new function or facility to achieve the same goal during
  468. // the deprecation period.
  469. // removal: String?
  470. // Text to indicate when in the future the behavior will be
  471. // removed. Usually a version number.
  472. // example:
  473. // | dojo.deprecated("myApp.getTemp()", "use myApp.getLocaleTemp() instead", "1.0");
  474. }
  475. dojo.experimental = function(moduleName, extra){
  476. // summary: Marks code as experimental.
  477. // description:
  478. // This can be used to mark a function, file, or module as
  479. // experimental. Experimental code is not ready to be used, and the
  480. // APIs are subject to change without notice. Experimental code may be
  481. // completed deleted without going through the normal deprecation
  482. // process.
  483. // moduleName: String
  484. // The name of a module, or the name of a module file or a specific
  485. // function
  486. // extra: String?
  487. // some additional message for the user
  488. // example:
  489. // | dojo.experimental("dojo.data.Result");
  490. // example:
  491. // | dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
  492. }
  493. =====*/
  494. //Real functions declared in dojo._firebug.firebug.
  495. d.deprecated = d.experimental = function(){};
  496. })();
  497. // vim:ai:ts=4:noet