PageRenderTime 68ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 3ms

/selenium/src/web/tests/html/dojo-0.4.0-mini/dojo.js.uncompressed.js

https://github.com/shs96c/webdriver
JavaScript | 9197 lines | 6112 code | 892 blank | 2193 comment | 1546 complexity | 2461e504a85094e92540c368759942c7 MD5 | raw file
Possible License(s): BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. if(typeof dojo == "undefined"){
  2. /**
  3. * @file bootstrap1.js
  4. *
  5. * summary: First file that is loaded that 'bootstraps' the entire dojo library suite.
  6. * note: Must run before hostenv_*.js file.
  7. *
  8. * @author Copyright 2004 Mark D. Anderson (mda@discerning.com)
  9. * TODOC: should the copyright be changed to Dojo Foundation?
  10. * @license Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php
  11. *
  12. * $Id: bootstrap1.js 6258 2006-10-20 03:12:36Z jburke $
  13. */
  14. // TODOC: HOW TO DOC THE BELOW?
  15. // @global: djConfig
  16. // summary:
  17. // Application code can set the global 'djConfig' prior to loading
  18. // the library to override certain global settings for how dojo works.
  19. // description: The variables that can be set are as follows:
  20. // - isDebug: false
  21. // - allowQueryConfig: false
  22. // - baseScriptUri: ""
  23. // - baseRelativePath: ""
  24. // - libraryScriptUri: ""
  25. // - iePreventClobber: false
  26. // - ieClobberMinimal: true
  27. // - locale: undefined
  28. // - extraLocale: undefined
  29. // - preventBackButtonFix: true
  30. // - searchIds: []
  31. // - parseWidgets: true
  32. // TODOC: HOW TO DOC THESE VARIABLES?
  33. // TODOC: IS THIS A COMPLETE LIST?
  34. // note:
  35. // 'djConfig' does not exist under 'dojo.*' so that it can be set before the
  36. // 'dojo' variable exists.
  37. // note:
  38. // Setting any of these variables *after* the library has loaded does nothing at all.
  39. // TODOC: is this still true? Release notes for 0.3 indicated they could be set after load.
  40. //
  41. //TODOC: HOW TO DOC THIS?
  42. // @global: dj_global
  43. // summary:
  44. // an alias for the top-level global object in the host environment
  45. // (e.g., the window object in a browser).
  46. // description:
  47. // Refer to 'dj_global' rather than referring to window to ensure your
  48. // code runs correctly in contexts other than web browsers (eg: Rhino on a server).
  49. var dj_global = this;
  50. //TODOC: HOW TO DOC THIS?
  51. // @global: dj_currentContext
  52. // summary:
  53. // Private global context object. Where 'dj_global' always refers to the boot-time
  54. // global context, 'dj_currentContext' can be modified for temporary context shifting.
  55. // dojo.global() returns dj_currentContext.
  56. // description:
  57. // Refer to dojo.global() rather than referring to dj_global to ensure your
  58. // code runs correctly in managed contexts.
  59. var dj_currentContext = this;
  60. // ****************************************************************
  61. // global public utils
  62. // TODOC: DO WE WANT TO NOTE THAT THESE ARE GLOBAL PUBLIC UTILS?
  63. // ****************************************************************
  64. function dj_undef(/*String*/ name, /*Object?*/ object){
  65. //summary: Returns true if 'name' is defined on 'object' (or globally if 'object' is null).
  66. //description: Note that 'defined' and 'exists' are not the same concept.
  67. return (typeof (object || dj_currentContext)[name] == "undefined"); // Boolean
  68. }
  69. // make sure djConfig is defined
  70. if(dj_undef("djConfig", this)){
  71. var djConfig = {};
  72. }
  73. //TODOC: HOW TO DOC THIS?
  74. // dojo is the root variable of (almost all) our public symbols -- make sure it is defined.
  75. if(dj_undef("dojo", this)){
  76. var dojo = {};
  77. }
  78. dojo.global = function(){
  79. // summary:
  80. // return the current global context object
  81. // (e.g., the window object in a browser).
  82. // description:
  83. // Refer to 'dojo.global()' rather than referring to window to ensure your
  84. // code runs correctly in contexts other than web browsers (eg: Rhino on a server).
  85. return dj_currentContext;
  86. }
  87. // Override locale setting, if specified
  88. dojo.locale = djConfig.locale;
  89. //TODOC: HOW TO DOC THIS?
  90. dojo.version = {
  91. // summary: version number of this instance of dojo.
  92. major: 0, minor: 4, patch: 0, flag: "",
  93. revision: Number("$Rev: 6258 $".match(/[0-9]+/)[0]),
  94. toString: function(){
  95. with(dojo.version){
  96. return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String
  97. }
  98. }
  99. }
  100. dojo.evalProp = function(/*String*/ name, /*Object*/ object, /*Boolean?*/ create){
  101. // summary: Returns 'object[name]'. If not defined and 'create' is true, will return a new Object.
  102. // description:
  103. // Returns null if 'object[name]' is not defined and 'create' is not true.
  104. // Note: 'defined' and 'exists' are not the same concept.
  105. if((!object)||(!name)) return undefined; // undefined
  106. if(!dj_undef(name, object)) return object[name]; // mixed
  107. return (create ? (object[name]={}) : undefined); // mixed
  108. }
  109. dojo.parseObjPath = function(/*String*/ path, /*Object?*/ context, /*Boolean?*/ create){
  110. // summary: Parse string path to an object, and return corresponding object reference and property name.
  111. // description:
  112. // Returns an object with two properties, 'obj' and 'prop'.
  113. // 'obj[prop]' is the reference indicated by 'path'.
  114. // path: Path to an object, in the form "A.B.C".
  115. // context: Object to use as root of path. Defaults to 'dojo.global()'.
  116. // create: If true, Objects will be created at any point along the 'path' that is undefined.
  117. var object = (context || dojo.global());
  118. var names = path.split('.');
  119. var prop = names.pop();
  120. for (var i=0,l=names.length;i<l && object;i++){
  121. object = dojo.evalProp(names[i], object, create);
  122. }
  123. return {obj: object, prop: prop}; // Object: {obj: Object, prop: String}
  124. }
  125. dojo.evalObjPath = function(/*String*/ path, /*Boolean?*/ create){
  126. // summary: Return the value of object at 'path' in the global scope, without using 'eval()'.
  127. // path: Path to an object, in the form "A.B.C".
  128. // create: If true, Objects will be created at any point along the 'path' that is undefined.
  129. if(typeof path != "string"){
  130. return dojo.global();
  131. }
  132. // fast path for no periods
  133. if(path.indexOf('.') == -1){
  134. return dojo.evalProp(path, dojo.global(), create); // mixed
  135. }
  136. //MOW: old 'with' syntax was confusing and would throw an error if parseObjPath returned null.
  137. var ref = dojo.parseObjPath(path, dojo.global(), create);
  138. if(ref){
  139. return dojo.evalProp(ref.prop, ref.obj, create); // mixed
  140. }
  141. return null;
  142. }
  143. dojo.errorToString = function(/*Error*/ exception){
  144. // summary: Return an exception's 'message', 'description' or text.
  145. // TODO: overriding Error.prototype.toString won't accomplish this?
  146. // ... since natively generated Error objects do not always reflect such things?
  147. if(!dj_undef("message", exception)){
  148. return exception.message; // String
  149. }else if(!dj_undef("description", exception)){
  150. return exception.description; // String
  151. }else{
  152. return exception; // Error
  153. }
  154. }
  155. dojo.raise = function(/*String*/ message, /*Error?*/ exception){
  156. // summary: Common point for raising exceptions in Dojo to enable logging.
  157. // Throws an error message with text of 'exception' if provided, or
  158. // rethrows exception object.
  159. if(exception){
  160. message = message + ": "+dojo.errorToString(exception);
  161. }
  162. // print the message to the user if hostenv.println is defined
  163. try { if(djConfig.isDebug){ dojo.hostenv.println("FATAL exception raised: "+message); } } catch (e) {}
  164. throw exception || Error(message);
  165. }
  166. //Stub functions so things don't break.
  167. //TODOC: HOW TO DOC THESE?
  168. dojo.debug = function(){};
  169. dojo.debugShallow = function(obj){};
  170. dojo.profile = { start: function(){}, end: function(){}, stop: function(){}, dump: function(){} };
  171. function dj_eval(/*String*/ scriptFragment){
  172. // summary: Perform an evaluation in the global scope. Use this rather than calling 'eval()' directly.
  173. // description: Placed in a separate function to minimize size of trapped evaluation context.
  174. // note:
  175. // - JSC eval() takes an optional second argument which can be 'unsafe'.
  176. // - Mozilla/SpiderMonkey eval() takes an optional second argument which is the
  177. // scope object for new symbols.
  178. return dj_global.eval ? dj_global.eval(scriptFragment) : eval(scriptFragment); // mixed
  179. }
  180. dojo.unimplemented = function(/*String*/ funcname, /*String?*/ extra){
  181. // summary: Throw an exception because some function is not implemented.
  182. // extra: Text to append to the exception message.
  183. var message = "'" + funcname + "' not implemented";
  184. if (extra != null) { message += " " + extra; }
  185. dojo.raise(message);
  186. }
  187. dojo.deprecated = function(/*String*/ behaviour, /*String?*/ extra, /*String?*/ removal){
  188. // summary: Log a debug message to indicate that a behavior has been deprecated.
  189. // extra: Text to append to the message.
  190. // removal: Text to indicate when in the future the behavior will be removed.
  191. var message = "DEPRECATED: " + behaviour;
  192. if(extra){ message += " " + extra; }
  193. if(removal){ message += " -- will be removed in version: " + removal; }
  194. dojo.debug(message);
  195. }
  196. dojo.render = (function(){
  197. //TODOC: HOW TO DOC THIS?
  198. // summary: Details rendering support, OS and browser of the current environment.
  199. // TODOC: is this something many folks will interact with? If so, we should doc the structure created...
  200. function vscaffold(prefs, names){
  201. var tmp = {
  202. capable: false,
  203. support: {
  204. builtin: false,
  205. plugin: false
  206. },
  207. prefixes: prefs
  208. };
  209. for(var i=0; i<names.length; i++){
  210. tmp[names[i]] = false;
  211. }
  212. return tmp;
  213. }
  214. return {
  215. name: "",
  216. ver: dojo.version,
  217. os: { win: false, linux: false, osx: false },
  218. html: vscaffold(["html"], ["ie", "opera", "khtml", "safari", "moz"]),
  219. svg: vscaffold(["svg"], ["corel", "adobe", "batik"]),
  220. vml: vscaffold(["vml"], ["ie"]),
  221. swf: vscaffold(["Swf", "Flash", "Mm"], ["mm"]),
  222. swt: vscaffold(["Swt"], ["ibm"])
  223. };
  224. })();
  225. // ****************************************************************
  226. // dojo.hostenv methods that must be defined in hostenv_*.js
  227. // ****************************************************************
  228. /**
  229. * The interface definining the interaction with the EcmaScript host environment.
  230. */
  231. /*
  232. * None of these methods should ever be called directly by library users.
  233. * Instead public methods such as loadModule should be called instead.
  234. */
  235. dojo.hostenv = (function(){
  236. // TODOC: HOW TO DOC THIS?
  237. // summary: Provides encapsulation of behavior that changes across different 'host environments'
  238. // (different browsers, server via Rhino, etc).
  239. // description: None of these methods should ever be called directly by library users.
  240. // Use public methods such as 'loadModule' instead.
  241. // default configuration options
  242. var config = {
  243. isDebug: false,
  244. allowQueryConfig: false,
  245. baseScriptUri: "",
  246. baseRelativePath: "",
  247. libraryScriptUri: "",
  248. iePreventClobber: false,
  249. ieClobberMinimal: true,
  250. preventBackButtonFix: true,
  251. delayMozLoadingFix: false,
  252. searchIds: [],
  253. parseWidgets: true
  254. };
  255. if (typeof djConfig == "undefined") { djConfig = config; }
  256. else {
  257. for (var option in config) {
  258. if (typeof djConfig[option] == "undefined") {
  259. djConfig[option] = config[option];
  260. }
  261. }
  262. }
  263. return {
  264. name_: '(unset)',
  265. version_: '(unset)',
  266. getName: function(){
  267. // sumary: Return the name of the host environment.
  268. return this.name_; // String
  269. },
  270. getVersion: function(){
  271. // summary: Return the version of the hostenv.
  272. return this.version_; // String
  273. },
  274. getText: function(/*String*/ uri){
  275. // summary: Read the plain/text contents at the specified 'uri'.
  276. // description:
  277. // If 'getText()' is not implemented, then it is necessary to override
  278. // 'loadUri()' with an implementation that doesn't rely on it.
  279. dojo.unimplemented('getText', "uri=" + uri);
  280. }
  281. };
  282. })();
  283. dojo.hostenv.getBaseScriptUri = function(){
  284. // summary: Return the base script uri that other scripts are found relative to.
  285. // TODOC: HUH? This comment means nothing to me. What other scripts? Is this the path to other dojo libraries?
  286. // MAYBE: Return the base uri to scripts in the dojo library. ???
  287. // return: Empty string or a path ending in '/'.
  288. if(djConfig.baseScriptUri.length){
  289. return djConfig.baseScriptUri;
  290. }
  291. // MOW: Why not:
  292. // uri = djConfig.libraryScriptUri || djConfig.baseRelativePath
  293. // ??? Why 'new String(...)'
  294. var uri = new String(djConfig.libraryScriptUri||djConfig.baseRelativePath);
  295. if (!uri) { dojo.raise("Nothing returned by getLibraryScriptUri(): " + uri); }
  296. // MOW: uri seems to not be actually used. Seems to be hard-coding to djConfig.baseRelativePath... ???
  297. var lastslash = uri.lastIndexOf('/'); // MOW ???
  298. djConfig.baseScriptUri = djConfig.baseRelativePath;
  299. return djConfig.baseScriptUri; // String
  300. }
  301. /*
  302. * loader.js - A bootstrap module. Runs before the hostenv_*.js file. Contains all of the package loading methods.
  303. */
  304. //A semi-colon is at the start of the line because after doing a build, this function definition
  305. //get compressed onto the same line as the last line in bootstrap1.js. That list line is just a
  306. //curly bracket, and the browser complains about that syntax. The semicolon fixes it. Putting it
  307. //here instead of at the end of bootstrap1.js, since it is more of an issue for this file, (using
  308. //the closure), and bootstrap1.js could change in the future.
  309. ;(function(){
  310. //Additional properties for dojo.hostenv
  311. var _addHostEnv = {
  312. pkgFileName: "__package__",
  313. // for recursion protection
  314. loading_modules_: {},
  315. loaded_modules_: {},
  316. addedToLoadingCount: [],
  317. removedFromLoadingCount: [],
  318. inFlightCount: 0,
  319. // FIXME: it should be possible to pull module prefixes in from djConfig
  320. modulePrefixes_: {
  321. dojo: {name: "dojo", value: "src"}
  322. },
  323. setModulePrefix: function(/*String*/module, /*String*/prefix){
  324. // summary: establishes module/prefix pair
  325. this.modulePrefixes_[module] = {name: module, value: prefix};
  326. },
  327. moduleHasPrefix: function(/*String*/module){
  328. // summary: checks to see if module has been established
  329. var mp = this.modulePrefixes_;
  330. return Boolean(mp[module] && mp[module].value); // Boolean
  331. },
  332. getModulePrefix: function(/*String*/module){
  333. // summary: gets the prefix associated with module
  334. if(this.moduleHasPrefix(module)){
  335. return this.modulePrefixes_[module].value; // String
  336. }
  337. return module; // String
  338. },
  339. getTextStack: [],
  340. loadUriStack: [],
  341. loadedUris: [],
  342. //WARNING: This variable is referenced by packages outside of bootstrap: FloatingPane.js and undo/browser.js
  343. post_load_: false,
  344. //Egad! Lots of test files push on this directly instead of using dojo.addOnLoad.
  345. modulesLoadedListeners: [],
  346. unloadListeners: [],
  347. loadNotifying: false
  348. };
  349. //Add all of these properties to dojo.hostenv
  350. for(var param in _addHostEnv){
  351. dojo.hostenv[param] = _addHostEnv[param];
  352. }
  353. })();
  354. dojo.hostenv.loadPath = function(/*String*/relpath, /*String?*/module, /*Function?*/cb){
  355. // summary:
  356. // Load a Javascript module given a relative path
  357. //
  358. // description:
  359. // Loads and interprets the script located at relpath, which is relative to the
  360. // script root directory. If the script is found but its interpretation causes
  361. // a runtime exception, that exception is not caught by us, so the caller will
  362. // see it. We return a true value if and only if the script is found.
  363. //
  364. // For now, we do not have an implementation of a true search path. We
  365. // consider only the single base script uri, as returned by getBaseScriptUri().
  366. //
  367. // relpath: A relative path to a script (no leading '/', and typically
  368. // ending in '.js').
  369. // module: A module whose existance to check for after loading a path.
  370. // Can be used to determine success or failure of the load.
  371. // cb: a callback function to pass the result of evaluating the script
  372. var uri;
  373. if(relpath.charAt(0) == '/' || relpath.match(/^\w+:/)){
  374. // dojo.raise("relpath '" + relpath + "'; must be relative");
  375. uri = relpath;
  376. }else{
  377. uri = this.getBaseScriptUri() + relpath;
  378. }
  379. if(djConfig.cacheBust && dojo.render.html.capable){
  380. uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,"");
  381. }
  382. try{
  383. return !module ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb); // Boolean
  384. }catch(e){
  385. dojo.debug(e);
  386. return false; // Boolean
  387. }
  388. }
  389. dojo.hostenv.loadUri = function(/*String (URL)*/uri, /*Function?*/cb){
  390. // summary:
  391. // Loads JavaScript from a URI
  392. //
  393. // description:
  394. // Reads the contents of the URI, and evaluates the contents. This is used to load modules as well
  395. // as resource bundles. Returns true if it succeeded. Returns false if the URI reading failed.
  396. // Throws if the evaluation throws.
  397. //
  398. // uri: a uri which points at the script to be loaded
  399. // cb: a callback function to process the result of evaluating the script as an expression, typically
  400. // used by the resource bundle loader to load JSON-style resources
  401. if(this.loadedUris[uri]){
  402. return true; // Boolean
  403. }
  404. var contents = this.getText(uri, null, true);
  405. if(!contents){ return false; } // Boolean
  406. this.loadedUris[uri] = true;
  407. if(cb){ contents = '('+contents+')'; }
  408. var value = dj_eval(contents);
  409. if(cb){ cb(value); }
  410. return true; // Boolean
  411. }
  412. // FIXME: probably need to add logging to this method
  413. dojo.hostenv.loadUriAndCheck = function(/*String (URL)*/uri, /*String*/moduleName, /*Function?*/cb){
  414. // summary: calls loadUri then findModule and returns true if both succeed
  415. var ok = true;
  416. try{
  417. ok = this.loadUri(uri, cb);
  418. }catch(e){
  419. dojo.debug("failed loading ", uri, " with error: ", e);
  420. }
  421. return Boolean(ok && this.findModule(moduleName, false)); // Boolean
  422. }
  423. dojo.loaded = function(){ }
  424. dojo.unloaded = function(){ }
  425. dojo.hostenv.loaded = function(){
  426. this.loadNotifying = true;
  427. this.post_load_ = true;
  428. var mll = this.modulesLoadedListeners;
  429. for(var x=0; x<mll.length; x++){
  430. mll[x]();
  431. }
  432. //Clear listeners so new ones can be added
  433. //For other xdomain package loads after the initial load.
  434. this.modulesLoadedListeners = [];
  435. this.loadNotifying = false;
  436. dojo.loaded();
  437. }
  438. dojo.hostenv.unloaded = function(){
  439. var mll = this.unloadListeners;
  440. while(mll.length){
  441. (mll.pop())();
  442. }
  443. dojo.unloaded();
  444. }
  445. dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName) {
  446. // summary:
  447. // Registers a function to be triggered after the DOM has finished loading
  448. // and widgets declared in markup have been instantiated. Images and CSS files
  449. // may or may not have finished downloading when the specified function is called.
  450. // (Note that widgets' CSS and HTML code is guaranteed to be downloaded before said
  451. // widgets are instantiated.)
  452. //
  453. // usage:
  454. // dojo.addOnLoad(functionPointer)
  455. // dojo.addOnLoad(object, "functionName")
  456. var dh = dojo.hostenv;
  457. if(arguments.length == 1) {
  458. dh.modulesLoadedListeners.push(obj);
  459. } else if(arguments.length > 1) {
  460. dh.modulesLoadedListeners.push(function() {
  461. obj[functionName]();
  462. });
  463. }
  464. //Added for xdomain loading. dojo.addOnLoad is used to
  465. //indicate callbacks after doing some dojo.require() statements.
  466. //In the xdomain case, if all the requires are loaded (after initial
  467. //page load), then immediately call any listeners.
  468. if(dh.post_load_ && dh.inFlightCount == 0 && !dh.loadNotifying){
  469. dh.callLoaded();
  470. }
  471. }
  472. dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
  473. // summary: registers a function to be triggered when the page unloads
  474. //
  475. // usage:
  476. // dojo.addOnLoad(functionPointer)
  477. // dojo.addOnLoad(object, "functionName")
  478. var dh = dojo.hostenv;
  479. if(arguments.length == 1){
  480. dh.unloadListeners.push(obj);
  481. } else if(arguments.length > 1) {
  482. dh.unloadListeners.push(function() {
  483. obj[functionName]();
  484. });
  485. }
  486. }
  487. dojo.hostenv.modulesLoaded = function(){
  488. if(this.post_load_){ return; }
  489. if(this.loadUriStack.length==0 && this.getTextStack.length==0){
  490. if(this.inFlightCount > 0){
  491. dojo.debug("files still in flight!");
  492. return;
  493. }
  494. dojo.hostenv.callLoaded();
  495. }
  496. }
  497. dojo.hostenv.callLoaded = function(){
  498. if(typeof setTimeout == "object"){
  499. setTimeout("dojo.hostenv.loaded();", 0);
  500. }else{
  501. dojo.hostenv.loaded();
  502. }
  503. }
  504. dojo.hostenv.getModuleSymbols = function(/*String*/modulename){
  505. // summary:
  506. // Converts a module name in dotted JS notation to an array representing the path in the source tree
  507. var syms = modulename.split(".");
  508. for(var i = syms.length; i>0; i--){
  509. var parentModule = syms.slice(0, i).join(".");
  510. if ((i==1) && !this.moduleHasPrefix(parentModule)){
  511. //Support default module directory (sibling of dojo)
  512. syms[0] = "../" + syms[0];
  513. }else{
  514. var parentModulePath = this.getModulePrefix(parentModule);
  515. if(parentModulePath != parentModule){
  516. syms.splice(0, i, parentModulePath);
  517. break;
  518. }
  519. }
  520. }
  521. return syms; // Array
  522. }
  523. dojo.hostenv._global_omit_module_check = false;
  524. dojo.hostenv.loadModule = function(/*String*/moduleName, /*Boolean?*/exactOnly, /*Boolean?*/omitModuleCheck){
  525. // summary:
  526. // loads a Javascript module from the appropriate URI
  527. //
  528. // description:
  529. // loadModule("A.B") first checks to see if symbol A.B is defined.
  530. // If it is, it is simply returned (nothing to do).
  531. //
  532. // If it is not defined, it will look for "A/B.js" in the script root directory,
  533. // followed by "A.js".
  534. //
  535. // It throws if it cannot find a file to load, or if the symbol A.B is not
  536. // defined after loading.
  537. //
  538. // It returns the object A.B.
  539. //
  540. // This does nothing about importing symbols into the current package.
  541. // It is presumed that the caller will take care of that. For example, to import
  542. // all symbols:
  543. //
  544. // with (dojo.hostenv.loadModule("A.B")) {
  545. // ...
  546. // }
  547. //
  548. // And to import just the leaf symbol:
  549. //
  550. // var B = dojo.hostenv.loadModule("A.B");
  551. // ...
  552. //
  553. // dj_load is an alias for dojo.hostenv.loadModule
  554. if(!moduleName){ return; }
  555. omitModuleCheck = this._global_omit_module_check || omitModuleCheck;
  556. var module = this.findModule(moduleName, false);
  557. if(module){
  558. return module;
  559. }
  560. // protect against infinite recursion from mutual dependencies
  561. if(dj_undef(moduleName, this.loading_modules_)){
  562. this.addedToLoadingCount.push(moduleName);
  563. }
  564. this.loading_modules_[moduleName] = 1;
  565. // convert periods to slashes
  566. var relpath = moduleName.replace(/\./g, '/') + '.js';
  567. var nsyms = moduleName.split(".");
  568. // this line allowed loading of a module manifest as if it were a namespace
  569. // it's an interesting idea, but shouldn't be combined with 'namespaces' proper
  570. // and leads to unwanted dependencies
  571. // the effect can be achieved in other (albeit less-flexible) ways now, so I am
  572. // removing this pending further design work
  573. // perhaps we can explicitly define this idea of a 'module manifest', and subclass
  574. // 'namespace manifest' from that
  575. //dojo.getNamespace(nsyms[0]);
  576. var syms = this.getModuleSymbols(moduleName);
  577. var startedRelative = ((syms[0].charAt(0) != '/') && !syms[0].match(/^\w+:/));
  578. var last = syms[syms.length - 1];
  579. var ok;
  580. // figure out if we're looking for a full package, if so, we want to do
  581. // things slightly diffrently
  582. if(last=="*"){
  583. moduleName = nsyms.slice(0, -1).join('.');
  584. while(syms.length){
  585. syms.pop();
  586. syms.push(this.pkgFileName);
  587. relpath = syms.join("/") + '.js';
  588. if(startedRelative && relpath.charAt(0)=="/"){
  589. relpath = relpath.slice(1);
  590. }
  591. ok = this.loadPath(relpath, !omitModuleCheck ? moduleName : null);
  592. if(ok){ break; }
  593. syms.pop();
  594. }
  595. }else{
  596. relpath = syms.join("/") + '.js';
  597. moduleName = nsyms.join('.');
  598. var modArg = !omitModuleCheck ? moduleName : null;
  599. ok = this.loadPath(relpath, modArg);
  600. if(!ok && !exactOnly){
  601. syms.pop();
  602. while(syms.length){
  603. relpath = syms.join('/') + '.js';
  604. ok = this.loadPath(relpath, modArg);
  605. if(ok){ break; }
  606. syms.pop();
  607. relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
  608. if(startedRelative && relpath.charAt(0)=="/"){
  609. relpath = relpath.slice(1);
  610. }
  611. ok = this.loadPath(relpath, modArg);
  612. if(ok){ break; }
  613. }
  614. }
  615. if(!ok && !omitModuleCheck){
  616. dojo.raise("Could not load '" + moduleName + "'; last tried '" + relpath + "'");
  617. }
  618. }
  619. // check that the symbol was defined
  620. //Don't bother if we're doing xdomain (asynchronous) loading.
  621. if(!omitModuleCheck && !this["isXDomain"]){
  622. // pass in false so we can give better error
  623. module = this.findModule(moduleName, false);
  624. if(!module){
  625. dojo.raise("symbol '" + moduleName + "' is not defined after loading '" + relpath + "'");
  626. }
  627. }
  628. return module;
  629. }
  630. dojo.hostenv.startPackage = function(/*String*/packageName){
  631. // summary:
  632. // Creates a JavaScript package
  633. //
  634. // description:
  635. // startPackage("A.B") follows the path, and at each level creates a new empty
  636. // object or uses what already exists. It returns the result.
  637. //
  638. // packageName: the package to be created as a String in dot notation
  639. //Make sure we have a string.
  640. var fullPkgName = String(packageName);
  641. var strippedPkgName = fullPkgName;
  642. var syms = packageName.split(/\./);
  643. if(syms[syms.length-1]=="*"){
  644. syms.pop();
  645. strippedPkgName = syms.join(".");
  646. }
  647. var evaledPkg = dojo.evalObjPath(strippedPkgName, true);
  648. this.loaded_modules_[fullPkgName] = evaledPkg;
  649. this.loaded_modules_[strippedPkgName] = evaledPkg;
  650. return evaledPkg; // Object
  651. }
  652. dojo.hostenv.findModule = function(/*String*/moduleName, /*Boolean?*/mustExist){
  653. // summary:
  654. // Returns the Object representing the module, if it exists, otherwise null.
  655. //
  656. // moduleName A fully qualified module including package name, like 'A.B'.
  657. // mustExist Optional, default false. throw instead of returning null
  658. // if the module does not currently exist.
  659. var lmn = String(moduleName);
  660. if(this.loaded_modules_[lmn]){
  661. return this.loaded_modules_[lmn]; // Object
  662. }
  663. if(mustExist){
  664. dojo.raise("no loaded module named '" + moduleName + "'");
  665. }
  666. return null; // null
  667. }
  668. //Start of old bootstrap2:
  669. dojo.kwCompoundRequire = function(/*Object containing Arrays*/modMap){
  670. // description:
  671. // This method taks a "map" of arrays which one can use to optionally load dojo
  672. // modules. The map is indexed by the possible dojo.hostenv.name_ values, with
  673. // two additional values: "default" and "common". The items in the "default"
  674. // array will be loaded if none of the other items have been choosen based on
  675. // the hostenv.name_ item. The items in the "common" array will _always_ be
  676. // loaded, regardless of which list is chosen. Here's how it's normally
  677. // called:
  678. //
  679. // dojo.kwCompoundRequire({
  680. // browser: [
  681. // ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule()
  682. // "foo.sample.*",
  683. // "foo.test,
  684. // ],
  685. // default: [ "foo.sample.*" ],
  686. // common: [ "really.important.module.*" ]
  687. // });
  688. var common = modMap["common"]||[];
  689. var result = modMap[dojo.hostenv.name_] ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
  690. for(var x=0; x<result.length; x++){
  691. var curr = result[x];
  692. if(curr.constructor == Array){
  693. dojo.hostenv.loadModule.apply(dojo.hostenv, curr);
  694. }else{
  695. dojo.hostenv.loadModule(curr);
  696. }
  697. }
  698. }
  699. dojo.require = function(/*String*/ resourceName){
  700. // summary
  701. // Ensure that the given resource (ie, javascript
  702. // source file) has been loaded.
  703. // description
  704. // dojo.require() is similar to C's #include command or java's "import" command.
  705. // You call dojo.require() to pull in the resources (ie, javascript source files)
  706. // that define the functions you are using.
  707. //
  708. // Note that in the case of a build, many resources have already been included
  709. // into dojo.js (ie, many of the javascript source files have been compressed and
  710. // concatened into dojo.js), so many dojo.require() calls will simply return
  711. // without downloading anything.
  712. dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
  713. }
  714. dojo.requireIf = function(/*Boolean*/ condition, /*String*/ resourceName){
  715. // summary
  716. // If the condition is true then call dojo.require() for the specified resource
  717. var arg0 = arguments[0];
  718. if((arg0 === true)||(arg0=="common")||(arg0 && dojo.render[arg0].capable)){
  719. var args = [];
  720. for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
  721. dojo.require.apply(dojo, args);
  722. }
  723. }
  724. dojo.requireAfterIf = dojo.requireIf;
  725. dojo.provide = function(/*String*/ resourceName){
  726. // summary
  727. // Each javascript source file must have (exactly) one dojo.provide()
  728. // call at the top of the file, corresponding to the file name.
  729. // For example, dojo/src/foo.js must have dojo.provide("dojo.foo"); at the top of the file.
  730. //
  731. // description
  732. // Each javascript source file is called a resource. When a resource
  733. // is loaded by the browser, dojo.provide() registers that it has
  734. // been loaded.
  735. //
  736. // For backwards compatibility reasons, in addition to registering the resource,
  737. // dojo.provide() also ensures that the javascript object for the module exists. For
  738. // example, dojo.provide("dojo.html.common"), in addition to registering that common.js
  739. // is a resource for the dojo.html module, will ensure that the dojo.html javascript object
  740. // exists, so that calls like dojo.html.foo = function(){ ... } don't fail.
  741. //
  742. // In the case of a build (or in the future, a rollup), where multiple javascript source
  743. // files are combined into one bigger file (similar to a .lib or .jar file), that file
  744. // will contain multiple dojo.provide() calls, to note that it includes
  745. // multiple resources.
  746. return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
  747. }
  748. dojo.registerModulePath = function(/*String*/module, /*String*/prefix){
  749. // summary: maps a module name to a path
  750. // description: An unregistered module is given the default path of ../<module>,
  751. // relative to Dojo root. For example, module acme is mapped to ../acme.
  752. // If you want to use a different module name, use dojo.registerModulePath.
  753. return dojo.hostenv.setModulePrefix(module, prefix);
  754. }
  755. dojo.setModulePrefix = function(/*String*/module, /*String*/prefix){
  756. // summary: maps a module name to a path
  757. dojo.deprecated('dojo.setModulePrefix("' + module + '", "' + prefix + '")', "replaced by dojo.registerModulePath", "0.5");
  758. return dojo.registerModulePath(module, prefix);
  759. }
  760. dojo.exists = function(/*Object*/obj, /*String*/name){
  761. // summary: determine if an object supports a given method
  762. // description: useful for longer api chains where you have to test each object in the chain
  763. var p = name.split(".");
  764. for(var i = 0; i < p.length; i++){
  765. if(!obj[p[i]]){ return false; } // Boolean
  766. obj = obj[p[i]];
  767. }
  768. return true; // Boolean
  769. }
  770. // Localization routines
  771. dojo.hostenv.normalizeLocale = function(/*String?*/locale){
  772. // summary:
  773. // Returns canonical form of locale, as used by Dojo. All variants are case-insensitive and are separated by '-'
  774. // as specified in RFC 3066. If no locale is specified, the user agent's default is returned.
  775. return locale ? locale.toLowerCase() : dojo.locale; // String
  776. };
  777. dojo.hostenv.searchLocalePath = function(/*String*/locale, /*Boolean*/down, /*Function*/searchFunc){
  778. // summary:
  779. // A helper method to assist in searching for locale-based resources. Will iterate through
  780. // the variants of a particular locale, either up or down, executing a callback function.
  781. // For example, "en-us" and true will try "en-us" followed by "en" and finally "ROOT".
  782. locale = dojo.hostenv.normalizeLocale(locale);
  783. var elements = locale.split('-');
  784. var searchlist = [];
  785. for(var i = elements.length; i > 0; i--){
  786. searchlist.push(elements.slice(0, i).join('-'));
  787. }
  788. searchlist.push(false);
  789. if(down){searchlist.reverse();}
  790. for(var j = searchlist.length - 1; j >= 0; j--){
  791. var loc = searchlist[j] || "ROOT";
  792. var stop = searchFunc(loc);
  793. if(stop){ break; }
  794. }
  795. }
  796. //These two functions are placed outside of preloadLocalizations
  797. //So that the xd loading can use/override them.
  798. dojo.hostenv.localesGenerated /***BUILD:localesGenerated***/; // value will be inserted here at build time, if necessary
  799. dojo.hostenv.registerNlsPrefix = function(){
  800. // summary:
  801. // Register module "nls" to point where Dojo can find pre-built localization files
  802. dojo.registerModulePath("nls","nls");
  803. }
  804. dojo.hostenv.preloadLocalizations = function(){
  805. // summary:
  806. // Load built, flattened resource bundles, if available for all locales used in the page.
  807. // Execute only once. Note that this is a no-op unless there is a build.
  808. if(dojo.hostenv.localesGenerated){
  809. dojo.hostenv.registerNlsPrefix();
  810. function preload(locale){
  811. locale = dojo.hostenv.normalizeLocale(locale);
  812. dojo.hostenv.searchLocalePath(locale, true, function(loc){
  813. for(var i=0; i<dojo.hostenv.localesGenerated.length;i++){
  814. if(dojo.hostenv.localesGenerated[i] == loc){
  815. dojo["require"]("nls.dojo_"+loc);
  816. return true; // Boolean
  817. }
  818. }
  819. return false; // Boolean
  820. });
  821. }
  822. preload();
  823. var extra = djConfig.extraLocale||[];
  824. for(var i=0; i<extra.length; i++){
  825. preload(extra[i]);
  826. }
  827. }
  828. dojo.hostenv.preloadLocalizations = function(){};
  829. }
  830. dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale){
  831. // summary:
  832. // Declares translated resources and loads them if necessary, in the same style as dojo.require.
  833. // Contents of the resource bundle are typically strings, but may be any name/value pair,
  834. // represented in JSON format. See also dojo.i18n.getLocalization.
  835. //
  836. // moduleName: name of the package containing the "nls" directory in which the bundle is found
  837. // bundleName: bundle name, i.e. the filename without the '.js' suffix
  838. // locale: the locale to load (optional) By default, the browser's user locale as defined by dojo.locale
  839. //
  840. // description:
  841. // Load translated resource bundles provided underneath the "nls" directory within a package.
  842. // Translated resources may be located in different packages throughout the source tree. For example,
  843. // a particular widget may define one or more resource bundles, structured in a program as follows,
  844. // where moduleName is mycode.mywidget and bundleNames available include bundleone and bundletwo:
  845. // ...
  846. // mycode/
  847. // mywidget/
  848. // nls/
  849. // bundleone.js (the fallback translation, English in this example)
  850. // bundletwo.js (also a fallback translation)
  851. // de/
  852. // bundleone.js
  853. // bundletwo.js
  854. // de-at/
  855. // bundleone.js
  856. // en/
  857. // (empty; use the fallback translation)
  858. // en-us/
  859. // bundleone.js
  860. // en-gb/
  861. // bundleone.js
  862. // es/
  863. // bundleone.js
  864. // bundletwo.js
  865. // ...etc
  866. // ...
  867. // Each directory is named for a locale as specified by RFC 3066, (http://www.ietf.org/rfc/rfc3066.txt),
  868. // normalized in lowercase. Note that the two bundles in the example do not define all the same variants.
  869. // For a given locale, bundles will be loaded for that locale and all more general locales above it, including
  870. // a fallback at the root directory. For example, a declaration for the "de-at" locale will first
  871. // load nls/de-at/bundleone.js, then nls/de/bundleone.js and finally nls/bundleone.js. The data will
  872. // be flattened into a single Object so that lookups will follow this cascading pattern. An optional build
  873. // step can preload the bundles to avoid data redundancy and the multiple network hits normally required to
  874. // load these resources.
  875. dojo.hostenv.preloadLocalizations();
  876. var bundlePackage = [moduleName, "nls", bundleName].join(".");
  877. //NOTE: When loading these resources, the packaging does not match what is on disk. This is an
  878. // implementation detail, as this is just a private data structure to hold the loaded resources.
  879. // e.g. tests/hello/nls/en-us/salutations.js is loaded as the object tests.hello.nls.salutations.en_us={...}
  880. // The structure on disk is intended to be most convenient for developers and translators, but in memory
  881. // it is more logical and efficient to store in a different order. Locales cannot use dashes, since the
  882. // resulting path will not evaluate as valid JS, so we translate them to underscores.
  883. var bundle = dojo.hostenv.findModule(bundlePackage);
  884. if(bundle){
  885. if(djConfig.localizationComplete && bundle._built){return;}
  886. var jsLoc = dojo.hostenv.normalizeLocale(locale).replace('-', '_');
  887. var translationPackage = bundlePackage+"."+jsLoc;
  888. if(dojo.hostenv.findModule(translationPackage)){return;}
  889. }
  890. bundle = dojo.hostenv.startPackage(bundlePackage);
  891. var syms = dojo.hostenv.getModuleSymbols(moduleName);
  892. var modpath = syms.concat("nls").join("/");
  893. var parent;
  894. dojo.hostenv.searchLocalePath(locale, false, function(loc){
  895. var jsLoc = loc.replace('-', '_');
  896. var translationPackage = bundlePackage + "." + jsLoc;
  897. var loaded = false;
  898. if(!dojo.hostenv.findModule(translationPackage)){
  899. // Mark loaded whether it's found or not, so that further load attempts will not be made
  900. dojo.hostenv.startPackage(translationPackage);
  901. var module = [modpath];
  902. if(loc != "ROOT"){module.push(loc);}
  903. module.push(bundleName);
  904. var filespec = module.join("/") + '.js';
  905. loaded = dojo.hostenv.loadPath(filespec, null, function(hash){
  906. // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath
  907. var clazz = function(){};
  908. clazz.prototype = parent;
  909. bundle[jsLoc] = new clazz();
  910. for(var j in hash){ bundle[jsLoc][j] = hash[j]; }
  911. });
  912. }else{
  913. loaded = true;
  914. }
  915. if(loaded && bundle[jsLoc]){
  916. parent = bundle[jsLoc];
  917. }else{
  918. bundle[jsLoc] = parent;
  919. }
  920. });
  921. };
  922. (function(){
  923. // If other locales are used, dojo.requireLocalization should load them as well, by default.
  924. // Override dojo.requireLocalization to do load the default bundle, then iterate through the
  925. // extraLocale list and load those translations as well, unless a particular locale was requested.
  926. var extra = djConfig.extraLocale;
  927. if(extra){
  928. if(!extra instanceof Array){
  929. extra = [extra];
  930. }
  931. var req = dojo.requireLocalization;
  932. dojo.requireLocalization = function(m, b, locale){
  933. req(m,b,locale);
  934. if(locale){return;}
  935. for(var i=0; i<extra.length; i++){
  936. req(m,b,extra[i]);
  937. }
  938. };
  939. }
  940. })();
  941. };
  942. if (typeof window != 'undefined') {
  943. // attempt to figure out the path to dojo if it isn't set in the config
  944. (function() {
  945. // before we get any further with the config options, try to pick them out
  946. // of the URL. Most of this code is from NW
  947. if(djConfig.allowQueryConfig){
  948. var baseUrl = document.location.toString(); // FIXME: use location.query instead?
  949. var params = baseUrl.split("?", 2);
  950. if(params.length > 1){
  951. var paramStr = params[1];
  952. var pairs = paramStr.split("&");
  953. for(var x in pairs){
  954. var sp = pairs[x].split("=");
  955. // FIXME: is this eval dangerous?
  956. if((sp[0].length > 9)&&(sp[0].substr(0, 9) == "djConfig.")){
  957. var opt = sp[0].substr(9);
  958. try{
  959. djConfig[opt]=eval(sp[1]);
  960. }catch(e){
  961. djConfig[opt]=sp[1];
  962. }
  963. }
  964. }
  965. }
  966. }
  967. if(((djConfig["baseScriptUri"] == "")||(djConfig["baseRelativePath"] == "")) &&(document && document.getElementsByTagName)){
  968. var scripts = document.getElementsByTagName("script");
  969. var rePkg = /(__package__|dojo|bootstrap1)\.js([\?\.]|$)/i;
  970. for(var i = 0; i < scripts.length; i++) {
  971. var src = scripts[i].getAttribute("src");
  972. if(!src) { continue; }
  973. var m = src.match(rePkg);
  974. if(m) {
  975. var root = src.substring(0, m.index);
  976. if(src.indexOf("bootstrap1") > -1) { root += "../"; }
  977. if(!this["djConfig"]) { djConfig = {}; }
  978. if(djConfig["baseScriptUri"] == "") { djConfig["baseScriptUri"] = root; }
  979. if(djConfig["baseRelativePath"] == "") { djConfig["baseRelativePath"] = root; }
  980. break;
  981. }
  982. }
  983. }
  984. // fill in the rendering support information in dojo.render.*
  985. var dr = dojo.render;
  986. var drh = dojo.render.html;
  987. var drs = dojo.render.svg;
  988. var dua = (drh.UA = navigator.userAgent);
  989. var dav = (drh.AV = navigator.appVersion);
  990. var t = true;
  991. var f = false;
  992. drh.capable = t;
  993. drh.support.builtin = t;
  994. dr.ver = parseFloat(drh.AV);
  995. dr.os.mac = dav.indexOf("Macintosh") >= 0;
  996. dr.os.win = dav.indexOf("Windows") >= 0;
  997. // could also be Solaris or something, but it's the same browser
  998. dr.os.linux = dav.indexOf("X11") >= 0;
  999. drh.opera = dua.indexOf("Opera") >= 0;
  1000. drh.khtml = (dav.indexOf("Konqueror") >= 0)||(dav.indexOf("Safari") >= 0);
  1001. drh.safari = dav.indexOf("Safari") >= 0;
  1002. var geckoPos = dua.indexOf("Gecko");
  1003. drh.mozilla = drh.moz = (geckoPos >= 0)&&(!drh.khtml);
  1004. if (drh.mozilla) {
  1005. // gecko version is YYYYMMDD
  1006. drh.geckoVersion = dua.substring(geckoPos + 6, geckoPos + 14);
  1007. }
  1008. drh.ie = (document.all)&&(!drh.opera);
  1009. drh.ie50 = drh.ie && dav.indexOf("MSIE 5.0")>=0;
  1010. drh.ie55 = drh.ie && dav.indexOf("MSIE 5.5")>=0;
  1011. drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0")>=0;
  1012. drh.ie70 = drh.ie && dav.indexOf("MSIE 7.0")>=0;
  1013. var cm = document["compatMode"];
  1014. drh.quirks = (cm == "BackCompat")||(cm == "QuirksMode")||drh.ie55||drh.ie50;
  1015. // TODO: is the HTML LANG attribute relevant?
  1016. dojo.locale = dojo.locale || (drh.ie ? navigator.userLanguage : navigator.language).toLowerCase();
  1017. dr.vml.capable=drh.ie;
  1018. drs.capable = f;
  1019. drs.support.plugin = f;
  1020. drs.support.builtin = f;
  1021. var tdoc = window["document"];
  1022. var tdi = tdoc["implementation"];
  1023. if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg", "1.0"))){
  1024. drs.capable = t;
  1025. drs.support.builtin = t;
  1026. drs.support.plugin = f;
  1027. }
  1028. // webkits after 420 support SVG natively. The test string is "AppleWebKit/420+"
  1029. if(drh.safari){
  1030. var tmp = dua.split("AppleWebKit/")[1];
  1031. var ver = parseFloat(tmp.split(" ")[0]);
  1032. if(ver >= 420){
  1033. drs.capable = t;
  1034. drs.support.builtin = t;
  1035. drs.support.plugin = f;
  1036. }
  1037. }
  1038. })();
  1039. dojo.hostenv.startPackage("dojo.hostenv");
  1040. dojo.render.name = dojo.hostenv.name_ = 'browser';
  1041. dojo.hostenv.searchIds = [];
  1042. // These are in order of decreasing likelihood; this will change in time.
  1043. dojo.hostenv._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
  1044. dojo.hostenv.getXmlhttpObject = function(){
  1045. var http = null;
  1046. var last_e = null;
  1047. try{ http = new XMLHttpRequest(); }catch(e){}
  1048. if(!http){
  1049. for(var i=0; i<3; ++i){
  1050. var progid = dojo.hostenv._XMLHTTP_PROGIDS[i];
  1051. try{
  1052. http = new ActiveXObject(progid);
  1053. }catch(e){
  1054. last_e = e;
  1055. }
  1056. if(http){
  1057. dojo.hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time
  1058. break;
  1059. }
  1060. }
  1061. /*if(http && !http.toString) {
  1062. http.toString = function() { "[object XMLHttpRequest]"; }
  1063. }*/
  1064. }
  1065. if(!http){
  1066. return dojo.raise("XMLHTTP not available", last_e);
  1067. }
  1068. return http;
  1069. }
  1070. /**
  1071. * Read the contents of the specified uri and return those contents.
  1072. *
  1073. * @param uri A relative or absolute uri. If absolute, it still must be in the
  1074. * same "domain" as we are.
  1075. *
  1076. * @param async_cb If not specified, load synchronously. If specified, load
  1077. * asynchronously, and use async_cb as the progress handler which takes the
  1078. * xmlhttp object as its argument. If async_cb, this function returns null.
  1079. *
  1080. * @param fail_ok Default false. If fail_ok and !async_cb and loading fails,
  1081. * return null instead of throwing.
  1082. */
  1083. dojo.hostenv._blockAsync = false;
  1084. dojo.hostenv.getText = function(uri, async_cb, fail_ok){
  1085. // need to block async callbacks from snatching this thread as the result
  1086. // of an async callback might call another sync XHR, this hangs khtml forever
  1087. // hostenv._blockAsync must also be checked in BrowserIO's watchInFlight()
  1088. // NOTE: must be declared before scope switches ie. this.getXmlhttpObject()
  1089. if(!async_cb){ this._blockAsync = true; }
  1090. var http = this.getXmlhttpObject();
  1091. function isDocumentOk(http){
  1092. var stat = http["status"];
  1093. // allow a 304 use cache, needed in konq (is this compliant with the http spec?)
  1094. return Boolean((!stat)||((200 <= stat)&&(300 > stat))||(stat==304));
  1095. }
  1096. if(async_cb){
  1097. var _this = this, timer = null, gbl = dojo.global();
  1098. var xhr = dojo.evalObjPath("dojo.io.XMLHTTPTransport");
  1099. http.onreadystatechange = function(){
  1100. if(timer){ gbl.clearTimeout(timer); timer = null; }
  1101. if(_this._blockAsync || (xhr && xhr._blockAsync)){
  1102. timer = gbl.setTimeout(function () { http.onreadystatechange.apply(this); }, 10);
  1103. }else{
  1104. if(4==http.readyState){
  1105. if(isDocumentOk(http)){
  1106. // dojo.debug("LOADED URI: "+uri);
  1107. async_cb(http.responseText);
  1108. }
  1109. }
  1110. }
  1111. }
  1112. }
  1113. http.open('GET', uri, async_cb ? true : false);
  1114. try{
  1115. http.send(null);
  1116. if(async_cb){
  1117. return null;
  1118. }
  1119. if(!isDocumentOk(http)){
  1120. var err = Error("Unable to load "+uri+" status:"+ http.status);
  1121. err.status = http.status;
  1122. err.responseText = http.responseText;
  1123. throw err;
  1124. }
  1125. }catch(e){
  1126. this._blockAsync = false;
  1127. if((fail_ok)&&(!async_cb)){
  1128. return null;
  1129. }else{
  1130. throw e;
  1131. }
  1132. }
  1133. this._blockAsync = false;
  1134. return http.responseText;
  1135. }
  1136. /*
  1137. * It turns out that if we check *right now*, as this script file is being loaded,
  1138. * then the last script element in the window DOM is ourselves.
  1139. * That is because any subsequent script elements haven't shown up in the document
  1140. * object yet.
  1141. */
  1142. /*
  1143. function dj_last_script_src() {
  1144. var scripts = window.document.getElementsByTagName('script');
  1145. if(scripts.length < 1){
  1146. dojo.raise("No script elements in window.document, so can't figure out my script src");
  1147. }
  1148. var script = scripts[scripts.length - 1];
  1149. var src = script.src;
  1150. if(!src){
  1151. dojo.raise("Last script element (out of " + scripts.length + ") has no src");
  1152. }
  1153. return src;
  1154. }
  1155. if(!dojo.hostenv["library_script_uri_"]){
  1156. dojo.hostenv.library_script_uri_ = dj_last_script_src();
  1157. }
  1158. */
  1159. dojo.hostenv.defaultDebugContainerId = 'dojoDebug';
  1160. dojo.hostenv._println_buffer = [];
  1161. dojo.hostenv._println_safe = false;
  1162. dojo.hostenv.println = function (line){
  1163. if(!dojo.hostenv._println_safe){
  1164. dojo.hostenv._println_buffer.push(line);
  1165. }else{
  1166. try {
  1167. var console = document.getElementById(djConfig.debugContainerId ?
  1168. djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId);
  1169. if(!console) { console = dojo.body(); }
  1170. var div = document.createElement("div");
  1171. div.appendChild(document.createTextNode(line));
  1172. console.appendChild(div);
  1173. } catch (e) {
  1174. try{
  1175. // safari needs the output wrapped in an element for some reason
  1176. document.write("<div>" + line + "</div>");
  1177. }catch(e2){
  1178. window.status = line;
  1179. }
  1180. }
  1181. }
  1182. }
  1183. dojo.addOnLoad(function(){
  1184. dojo.hostenv._println_safe = true;
  1185. while(dojo.hostenv._println_buffer.length > 0){
  1186. dojo.hostenv.println(dojo.hostenv._println_buffer.shift());
  1187. }
  1188. });
  1189. function dj_addNodeEvtHdlr(node, evtName, fp, capture){
  1190. var oldHandler = node["on"+evtName] || function(){};
  1191. node["on"+evtName] = function(){
  1192. fp.apply(node, arguments);
  1193. oldHandler.apply(node, arguments);
  1194. }
  1195. return true;
  1196. }
  1197. // BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/)
  1198. function dj_load_init(e){
  1199. // allow multiple calls, only first one will take effect
  1200. // A bug in khtml calls events callbacks for document for event which isnt supported
  1201. // for example a created contextmenu event calls DOMContentLoaded, workaround
  1202. var type = (e && e.type) ? e.type.toLowerCase() : "load";
  1203. if(arguments.callee.initialized || (type!="domcontentloaded" && type!="load")){ return; }
  1204. arguments.callee.initialized = true;
  1205. if(typeof(_timer) != 'undefined'){
  1206. clearInterval(_timer);
  1207. delete _timer;
  1208. }
  1209. var initFunc = function(){
  1210. //perform initialization
  1211. if(dojo.render.html.ie){
  1212. dojo.hostenv.makeWidgets();
  1213. }
  1214. };
  1215. if(dojo.hostenv.inFlightCount == 0){
  1216. initFunc();
  1217. dojo.hostenv.modulesLoaded();
  1218. }else{
  1219. dojo.addOnLoad(initFunc);
  1220. }
  1221. }
  1222. // START DOMContentLoaded
  1223. // Mozilla and Opera 9 expose the event we could use
  1224. if(document.addEventListener){
  1225. if(dojo.render.html.opera || (dojo.render.html.moz && !djConfig.delayMozLoadingFix)){
  1226. document.addEventListener("DOMContentLoaded", dj_load_init, null);
  1227. }
  1228. // mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already.
  1229. // also used for Mozilla because of trac #1640
  1230. window.addEventListener("load", dj_load_init, null);
  1231. }
  1232. // for Internet Explorer. readyState will not be achieved on init call, but dojo doesn't need it
  1233. // however, we'll include it because we don't know if there are other functions added that might.
  1234. // Note that this has changed because the build process strips all comments--including conditional
  1235. // ones.
  1236. if(dojo.render.html.ie && dojo.render.os.win){
  1237. document.attachEvent("onreadystatechange", function(e){
  1238. if(document.readyState == "complete"){
  1239. dj_load_init();
  1240. }
  1241. });
  1242. }
  1243. if (/(WebKit|khtml)/i.test(navigator.userAgent)) { // sniff
  1244. var _timer = setInterval(function() {
  1245. if (/loaded|complete/.test(document.readyState)) {
  1246. dj_load_init(); // call the onload handler
  1247. }
  1248. }, 10);
  1249. }
  1250. // END DOMContentLoaded
  1251. // IE WebControl hosted in an application can fire "beforeunload" and "unload"
  1252. // events when control visibility changes, causing Dojo to unload too soon. The
  1253. // following code fixes the problem
  1254. // Reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;199155
  1255. if(dojo.render.html.ie){
  1256. dj_addNodeEvtHdlr(window, "beforeunload", function(){
  1257. dojo.hostenv._unloading = true;
  1258. window.setTimeout(function() {
  1259. dojo.hostenv._unloading = false;
  1260. }, 0);
  1261. });
  1262. }
  1263. dj_addNodeEvtHdlr(window, "unload", function(){
  1264. dojo.hostenv.unloaded();
  1265. if((!dojo.render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){
  1266. dojo.hostenv.unloaded();
  1267. }
  1268. });
  1269. dojo.hostenv.makeWidgets = function(){
  1270. // you can put searchIds in djConfig and dojo.hostenv at the moment
  1271. // we should probably eventually move to one or the other
  1272. var sids = [];
  1273. if(djConfig.searchIds && djConfig.searchIds.length > 0) {
  1274. sids = sids.concat(djConfig.searchIds);
  1275. }
  1276. if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) {
  1277. sids = sids.concat(dojo.hostenv.searchIds);
  1278. }
  1279. if((djConfig.parseWidgets)||(sids.length > 0)){
  1280. if(dojo.evalObjPath("dojo.widget.Parse")){
  1281. // we must do this on a delay to avoid:
  1282. // http://www.shaftek.org/blog/archives/000212.html
  1283. // (IE bug)
  1284. var parser = new dojo.xml.Parse();
  1285. if(sids.length > 0){
  1286. for(var x=0; x<sids.length; x++){
  1287. var tmpNode = document.getElementById(sids[x]);
  1288. if(!tmpNode){ continue; }
  1289. var frag = parser.parseElement(tmpNode, null, true);
  1290. dojo.widget.getParser().createComponents(frag);
  1291. }
  1292. }else if(djConfig.parseWidgets){
  1293. var frag = parser.parseElement(dojo.body(), null, true);
  1294. dojo.widget.getParser().createComponents(frag);
  1295. }
  1296. }
  1297. }
  1298. }
  1299. dojo.addOnLoad(function(){
  1300. if(!dojo.render.html.ie) {
  1301. dojo.hostenv.makeWidgets();
  1302. }
  1303. });
  1304. try {
  1305. if (dojo.render.html.ie) {
  1306. document.namespaces.add("v","urn:schemas-microsoft-com:vml");
  1307. document.createStyleShe

Large files files are truncated, but you can click here to view the full file