PageRenderTime 36ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/DotNetKicks/Incremental.Kick.Web.UI/Static/Scripts/2.0.2/Dojo/dojo.js.uncompressed.js

http://dotnetkicks.googlecode.com/
JavaScript | 7258 lines | 5302 code | 832 blank | 1124 comment | 1440 complexity | 47d5c6787181810e67b946a3968de939 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception

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

  1. /*
  2. Copyright (c) 2004-2005, The Dojo Foundation
  3. All Rights Reserved.
  4. Licensed under the Academic Free License version 2.1 or above OR the
  5. modified BSD license. For more information on Dojo licensing, see:
  6. http://dojotoolkit.org/community/licensing.shtml
  7. */
  8. /**
  9. * @file bootstrap1.js
  10. *
  11. * bootstrap file that runs before hostenv_*.js file.
  12. *
  13. * @author Copyright 2004 Mark D. Anderson (mda@discerning.com)
  14. * @author Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php
  15. *
  16. * $Id: bootstrap1.js 2555 2005-12-20 00:26:24Z alex $
  17. */
  18. /**
  19. * The global djConfig can be set prior to loading the library, to override
  20. * certain settings. It does not exist under dojo.* so that it can be set
  21. * before the dojo variable exists. Setting any of these variables *after* the
  22. * library has loaded does nothing at all. The variables that can be set are
  23. * as follows:
  24. */
  25. /**
  26. * dj_global is an alias for the top-level global object in the host
  27. * environment (the "window" object in a browser).
  28. */
  29. var dj_global = this; //typeof window == 'undefined' ? this : window;
  30. function dj_undef(name, obj){
  31. if(!obj){ obj = dj_global; }
  32. return (typeof obj[name] == "undefined");
  33. }
  34. if(dj_undef("djConfig")){
  35. var djConfig = {};
  36. }
  37. /**
  38. * dojo is the root variable of (almost all) our public symbols.
  39. */
  40. var dojo;
  41. if(dj_undef("dojo")){ dojo = {}; }
  42. dojo.version = {
  43. major: 0, minor: 2, patch: 1, flag: "",
  44. revision: Number("$Rev: 2555 $".match(/[0-9]+/)[0]),
  45. toString: function() {
  46. with (dojo.version) {
  47. return major + "." + minor + "." + patch + flag + " (" + revision + ")";
  48. }
  49. }
  50. };
  51. /*
  52. * evaluate a string like "A.B" without using eval.
  53. */
  54. dojo.evalObjPath = function(objpath, create){
  55. // fast path for no periods
  56. if(typeof objpath != "string"){ return dj_global; }
  57. if(objpath.indexOf('.') == -1){
  58. if((dj_undef(objpath, dj_global))&&(create)){
  59. dj_global[objpath] = {};
  60. }
  61. return dj_global[objpath];
  62. }
  63. var syms = objpath.split(/\./);
  64. var obj = dj_global;
  65. for(var i=0;i<syms.length;++i){
  66. if(!create){
  67. obj = obj[syms[i]];
  68. if((typeof obj == 'undefined')||(!obj)){
  69. return obj;
  70. }
  71. }else{
  72. if(dj_undef(syms[i], obj)){
  73. obj[syms[i]] = {};
  74. }
  75. obj = obj[syms[i]];
  76. }
  77. }
  78. return obj;
  79. };
  80. // ****************************************************************
  81. // global public utils
  82. // ****************************************************************
  83. /*
  84. * utility to print an Error.
  85. * TODO: overriding Error.prototype.toString won't accomplish this?
  86. * ... since natively generated Error objects do not always reflect such things?
  87. */
  88. dojo.errorToString = function(excep){
  89. return ((!dj_undef("message", excep)) ? excep.message : (dj_undef("description", excep) ? excep : excep.description ));
  90. };
  91. /**
  92. * Throws an Error object given the string err. For now, will also do a println
  93. * to the user first.
  94. */
  95. dojo.raise = function(message, excep){
  96. if(excep){
  97. message = message + ": "+dojo.errorToString(excep);
  98. }
  99. var he = dojo.hostenv;
  100. if((!dj_undef("hostenv", dojo))&&(!dj_undef("println", dojo.hostenv))){
  101. dojo.hostenv.println("FATAL: " + message);
  102. }
  103. throw Error(message);
  104. };
  105. dj_throw = dj_rethrow = function(m, e){
  106. dojo.deprecated("dj_throw and dj_rethrow deprecated, use dojo.raise instead");
  107. dojo.raise(m, e);
  108. };
  109. /**
  110. * Produce a line of debug output.
  111. * Does nothing unless djConfig.isDebug is true.
  112. * varargs, joined with ''.
  113. * Caller should not supply a trailing "\n".
  114. */
  115. dojo.debug = function(){
  116. if (!djConfig.isDebug) { return; }
  117. var args = arguments;
  118. if(dj_undef("println", dojo.hostenv)){
  119. dojo.raise("dojo.debug not available (yet?)");
  120. }
  121. var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
  122. var s = [(isJUM ? "": "DEBUG: ")];
  123. for(var i=0;i<args.length;++i){
  124. if(!false && args[i] instanceof Error){
  125. var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) +
  126. (args[i].fileName ? ", file: " + args[i].fileName : "") +
  127. (args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
  128. } else {
  129. try {
  130. var msg = String(args[i]);
  131. } catch(e) {
  132. if(dojo.render.html.ie) {
  133. var msg = "[ActiveXObject]";
  134. } else {
  135. var msg = "[unknown]";
  136. }
  137. }
  138. }
  139. s.push(msg);
  140. }
  141. if(isJUM){ // this seems to be the only way to get JUM to "play nice"
  142. jum.debug(s.join(" "));
  143. }else{
  144. dojo.hostenv.println(s.join(" "));
  145. }
  146. }
  147. /**
  148. * this is really hacky for now - just
  149. * display the properties of the object
  150. **/
  151. dojo.debugShallow = function(obj){
  152. if (!djConfig.isDebug) { return; }
  153. dojo.debug('------------------------------------------------------------');
  154. dojo.debug('Object: '+obj);
  155. for(i in obj){
  156. dojo.debug(i + ': ' + obj[i]);
  157. }
  158. dojo.debug('------------------------------------------------------------');
  159. }
  160. var dj_debug = dojo.debug;
  161. /**
  162. * We put eval() in this separate function to keep down the size of the trapped
  163. * evaluation context.
  164. *
  165. * Note that:
  166. * - JSC eval() takes an optional second argument which can be 'unsafe'.
  167. * - Mozilla/SpiderMonkey eval() takes an optional second argument which is the
  168. * scope object for new symbols.
  169. */
  170. function dj_eval(s){ return dj_global.eval ? dj_global.eval(s) : eval(s); }
  171. /**
  172. * Convenience for throwing an exception because some function is not
  173. * implemented.
  174. */
  175. dj_unimplemented = dojo.unimplemented = function(funcname, extra){
  176. // FIXME: need to move this away from dj_*
  177. var mess = "'" + funcname + "' not implemented";
  178. if((!dj_undef(extra))&&(extra)){ mess += " " + extra; }
  179. dojo.raise(mess);
  180. }
  181. /**
  182. * Convenience for informing of deprecated behaviour.
  183. */
  184. dj_deprecated = dojo.deprecated = function(behaviour, extra, removal){
  185. var mess = "DEPRECATED: " + behaviour;
  186. if(extra){ mess += " " + extra; }
  187. if(removal){ mess += " -- will be removed in version: " + removal; }
  188. dojo.debug(mess);
  189. }
  190. /**
  191. * Does inheritance
  192. */
  193. dojo.inherits = function(subclass, superclass){
  194. if(typeof superclass != 'function'){
  195. dojo.raise("superclass: "+superclass+" borken");
  196. }
  197. subclass.prototype = new superclass();
  198. subclass.prototype.constructor = subclass;
  199. subclass.superclass = superclass.prototype;
  200. // DEPRICATED: super is a reserved word, use 'superclass'
  201. subclass['super'] = superclass.prototype;
  202. }
  203. dj_inherits = function(subclass, superclass){
  204. dojo.deprecated("dj_inherits deprecated, use dojo.inherits instead");
  205. dojo.inherits(subclass, superclass);
  206. }
  207. // an object that authors use determine what host we are running under
  208. dojo.render = (function(){
  209. function vscaffold(prefs, names){
  210. var tmp = {
  211. capable: false,
  212. support: {
  213. builtin: false,
  214. plugin: false
  215. },
  216. prefixes: prefs
  217. };
  218. for(var x in names){
  219. tmp[x] = false;
  220. }
  221. return tmp;
  222. }
  223. return {
  224. name: "",
  225. ver: dojo.version,
  226. os: { win: false, linux: false, osx: false },
  227. html: vscaffold(["html"], ["ie", "opera", "khtml", "safari", "moz"]),
  228. svg: vscaffold(["svg"], ["corel", "adobe", "batik"]),
  229. vml: vscaffold(["vml"], ["ie"]),
  230. swf: vscaffold(["Swf", "Flash", "Mm"], ["mm"]),
  231. swt: vscaffold(["Swt"], ["ibm"])
  232. };
  233. })();
  234. // ****************************************************************
  235. // dojo.hostenv methods that must be defined in hostenv_*.js
  236. // ****************************************************************
  237. /**
  238. * The interface definining the interaction with the EcmaScript host environment.
  239. */
  240. /*
  241. * None of these methods should ever be called directly by library users.
  242. * Instead public methods such as loadModule should be called instead.
  243. */
  244. dojo.hostenv = (function(){
  245. // default configuration options
  246. var config = {
  247. isDebug: false,
  248. allowQueryConfig: false,
  249. baseScriptUri: "",
  250. baseRelativePath: "",
  251. libraryScriptUri: "",
  252. iePreventClobber: false,
  253. ieClobberMinimal: true,
  254. preventBackButtonFix: true,
  255. searchIds: [],
  256. parseWidgets: true
  257. };
  258. if (typeof djConfig == "undefined") { djConfig = config; }
  259. else {
  260. for (var option in config) {
  261. if (typeof djConfig[option] == "undefined") {
  262. djConfig[option] = config[option];
  263. }
  264. }
  265. }
  266. var djc = djConfig;
  267. function _def(obj, name, def){
  268. return (dj_undef(name, obj) ? def : obj[name]);
  269. }
  270. return {
  271. name_: '(unset)',
  272. version_: '(unset)',
  273. pkgFileName: "__package__",
  274. // for recursion protection
  275. loading_modules_: {},
  276. loaded_modules_: {},
  277. addedToLoadingCount: [],
  278. removedFromLoadingCount: [],
  279. inFlightCount: 0,
  280. modulePrefixes_: {
  281. dojo: {name: "dojo", value: "src"}
  282. },
  283. setModulePrefix: function(module, prefix){
  284. this.modulePrefixes_[module] = {name: module, value: prefix};
  285. },
  286. getModulePrefix: function(module){
  287. var mp = this.modulePrefixes_;
  288. if((mp[module])&&(mp[module]["name"])){
  289. return mp[module].value;
  290. }
  291. return module;
  292. },
  293. getTextStack: [],
  294. loadUriStack: [],
  295. loadedUris: [],
  296. // lookup cache for modules.
  297. // NOTE: this is partially redundant a private variable in the jsdown
  298. // implementation, but we don't want to couple the two.
  299. // modules_ : {},
  300. post_load_: false,
  301. modulesLoadedListeners: [],
  302. /**
  303. * Return the name of the hostenv.
  304. */
  305. getName: function(){ return this.name_; },
  306. /**
  307. * Return the version of the hostenv.
  308. */
  309. getVersion: function(){ return this.version_; },
  310. /**
  311. * Read the plain/text contents at the specified uri. If getText() is
  312. * not implemented, then it is necessary to override loadUri() with an
  313. * implementation that doesn't rely on it.
  314. */
  315. getText: function(uri){
  316. dojo.unimplemented('getText', "uri=" + uri);
  317. },
  318. /**
  319. * return the uri of the script that defined this function
  320. * private method that must be implemented by the hostenv.
  321. */
  322. getLibraryScriptUri: function(){
  323. // FIXME: need to implement!!!
  324. dojo.unimplemented('getLibraryScriptUri','');
  325. }
  326. };
  327. })();
  328. /**
  329. * Display a line of text to the user.
  330. * The line argument should not contain a trailing "\n"; that is added by the
  331. * implementation.
  332. */
  333. //dojo.hostenv.println = function(line) {}
  334. // ****************************************************************
  335. // dojo.hostenv methods not defined in hostenv_*.js
  336. // ****************************************************************
  337. /**
  338. * Return the base script uri that other scripts are found relative to.
  339. * It is either the empty string, or a non-empty string ending in '/'.
  340. */
  341. dojo.hostenv.getBaseScriptUri = function(){
  342. if(djConfig.baseScriptUri.length){
  343. return djConfig.baseScriptUri;
  344. }
  345. var uri = new String(djConfig.libraryScriptUri||djConfig.baseRelativePath);
  346. if (!uri) { dojo.raise("Nothing returned by getLibraryScriptUri(): " + uri); }
  347. var lastslash = uri.lastIndexOf('/');
  348. djConfig.baseScriptUri = djConfig.baseRelativePath;
  349. return djConfig.baseScriptUri;
  350. }
  351. /**
  352. * Set the base script uri.
  353. */
  354. // In JScript .NET, see interface System._AppDomain implemented by
  355. // System.AppDomain.CurrentDomain. Members include AppendPrivatePath,
  356. // RelativeSearchPath, BaseDirectory.
  357. dojo.hostenv.setBaseScriptUri = function(uri){ djConfig.baseScriptUri = uri }
  358. /**
  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. * @param relpath A relative path to a script (no leading '/', and typically
  368. * ending in '.js').
  369. * @param 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. */
  372. dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
  373. if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){
  374. dojo.raise("relpath '" + relpath + "'; must be relative");
  375. }
  376. var uri = this.getBaseScriptUri() + relpath;
  377. if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + djConfig.cacheBust.replace(/\W+/g,""); }
  378. try{
  379. return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
  380. }catch(e){
  381. dojo.debug(e);
  382. return false;
  383. }
  384. }
  385. /**
  386. * Reads the contents of the URI, and evaluates the contents.
  387. * Returns true if it succeeded. Returns false if the URI reading failed.
  388. * Throws if the evaluation throws.
  389. * The result of the eval is not available to the caller.
  390. */
  391. dojo.hostenv.loadUri = function(uri, cb){
  392. if(dojo.hostenv.loadedUris[uri]){
  393. return;
  394. }
  395. var contents = this.getText(uri, null, true);
  396. if(contents == null){ return 0; }
  397. var value = dj_eval(contents);
  398. return 1;
  399. }
  400. // FIXME: probably need to add logging to this method
  401. dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
  402. var ok = true;
  403. try{
  404. ok = this.loadUri(uri, cb);
  405. }catch(e){
  406. dojo.debug("failed loading ", uri, " with error: ", e);
  407. }
  408. return ((ok)&&(this.findModule(module, false))) ? true : false;
  409. }
  410. dojo.loaded = function(){ }
  411. dojo.hostenv.loaded = function(){
  412. this.post_load_ = true;
  413. var mll = this.modulesLoadedListeners;
  414. for(var x=0; x<mll.length; x++){
  415. mll[x]();
  416. }
  417. dojo.loaded();
  418. }
  419. /*
  420. Call styles:
  421. dojo.addOnLoad(functionPointer)
  422. dojo.addOnLoad(object, "functionName")
  423. */
  424. dojo.addOnLoad = function(obj, fcnName) {
  425. if(arguments.length == 1) {
  426. dojo.hostenv.modulesLoadedListeners.push(obj);
  427. } else if(arguments.length > 1) {
  428. dojo.hostenv.modulesLoadedListeners.push(function() {
  429. obj[fcnName]();
  430. });
  431. }
  432. };
  433. dojo.hostenv.modulesLoaded = function(){
  434. if(this.post_load_){ return; }
  435. if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
  436. if(this.inFlightCount > 0){
  437. dojo.debug("files still in flight!");
  438. return;
  439. }
  440. if(typeof setTimeout == "object"){
  441. setTimeout("dojo.hostenv.loaded();", 0);
  442. }else{
  443. dojo.hostenv.loaded();
  444. }
  445. }
  446. }
  447. dojo.hostenv.moduleLoaded = function(modulename){
  448. var modref = dojo.evalObjPath((modulename.split(".").slice(0, -1)).join('.'));
  449. this.loaded_modules_[(new String(modulename)).toLowerCase()] = modref;
  450. }
  451. /**
  452. * loadModule("A.B") first checks to see if symbol A.B is defined.
  453. * If it is, it is simply returned (nothing to do).
  454. *
  455. * If it is not defined, it will look for "A/B.js" in the script root directory,
  456. * followed by "A.js".
  457. *
  458. * It throws if it cannot find a file to load, or if the symbol A.B is not
  459. * defined after loading.
  460. *
  461. * It returns the object A.B.
  462. *
  463. * This does nothing about importing symbols into the current package.
  464. * It is presumed that the caller will take care of that. For example, to import
  465. * all symbols:
  466. *
  467. * with (dojo.hostenv.loadModule("A.B")) {
  468. * ...
  469. * }
  470. *
  471. * And to import just the leaf symbol:
  472. *
  473. * var B = dojo.hostenv.loadModule("A.B");
  474. * ...
  475. *
  476. * dj_load is an alias for dojo.hostenv.loadModule
  477. */
  478. dojo.hostenv._global_omit_module_check = false;
  479. dojo.hostenv.loadModule = function(modulename, exact_only, omit_module_check){
  480. omit_module_check = this._global_omit_module_check || omit_module_check;
  481. var module = this.findModule(modulename, false);
  482. if(module){
  483. return module;
  484. }
  485. // protect against infinite recursion from mutual dependencies
  486. if(dj_undef(modulename, this.loading_modules_)){
  487. this.addedToLoadingCount.push(modulename);
  488. }
  489. this.loading_modules_[modulename] = 1;
  490. // convert periods to slashes
  491. var relpath = modulename.replace(/\./g, '/') + '.js';
  492. var syms = modulename.split(".");
  493. var nsyms = modulename.split(".");
  494. for (var i = syms.length - 1; i > 0; i--) {
  495. var parentModule = syms.slice(0, i).join(".");
  496. var parentModulePath = this.getModulePrefix(parentModule);
  497. if (parentModulePath != parentModule) {
  498. syms.splice(0, i, parentModulePath);
  499. break;
  500. }
  501. }
  502. var last = syms[syms.length - 1];
  503. // figure out if we're looking for a full package, if so, we want to do
  504. // things slightly diffrently
  505. if(last=="*"){
  506. modulename = (nsyms.slice(0, -1)).join('.');
  507. while(syms.length){
  508. syms.pop();
  509. syms.push(this.pkgFileName);
  510. relpath = syms.join("/") + '.js';
  511. if(relpath.charAt(0)=="/"){
  512. relpath = relpath.slice(1);
  513. }
  514. ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
  515. if(ok){ break; }
  516. syms.pop();
  517. }
  518. }else{
  519. relpath = syms.join("/") + '.js';
  520. modulename = nsyms.join('.');
  521. var ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
  522. if((!ok)&&(!exact_only)){
  523. syms.pop();
  524. while(syms.length){
  525. relpath = syms.join('/') + '.js';
  526. ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
  527. if(ok){ break; }
  528. syms.pop();
  529. relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
  530. if(relpath.charAt(0)=="/"){
  531. relpath = relpath.slice(1);
  532. }
  533. ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
  534. if(ok){ break; }
  535. }
  536. }
  537. if((!ok)&&(!omit_module_check)){
  538. dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
  539. }
  540. }
  541. // check that the symbol was defined
  542. if(!omit_module_check){
  543. // pass in false so we can give better error
  544. module = this.findModule(modulename, false);
  545. if(!module){
  546. dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
  547. }
  548. }
  549. return module;
  550. }
  551. /**
  552. * startPackage("A.B") follows the path, and at each level creates a new empty
  553. * object or uses what already exists. It returns the result.
  554. */
  555. dojo.hostenv.startPackage = function(packname){
  556. var syms = packname.split(/\./);
  557. if(syms[syms.length-1]=="*"){
  558. syms.pop();
  559. }
  560. return dojo.evalObjPath(syms.join("."), true);
  561. }
  562. /**
  563. * findModule("A.B") returns the object A.B if it exists, otherwise null.
  564. * @param modulename A string like 'A.B'.
  565. * @param must_exist Optional, defualt false. throw instead of returning null
  566. * if the module does not currently exist.
  567. */
  568. dojo.hostenv.findModule = function(modulename, must_exist) {
  569. // check cache
  570. /*
  571. if(!dj_undef(modulename, this.modules_)){
  572. return this.modules_[modulename];
  573. }
  574. */
  575. if(this.loaded_modules_[(new String(modulename)).toLowerCase()]){
  576. return this.loaded_modules_[modulename];
  577. }
  578. // see if symbol is defined anyway
  579. var module = dojo.evalObjPath(modulename);
  580. if((typeof module !== 'undefined')&&(module)){
  581. return module;
  582. // return this.modules_[modulename] = module;
  583. }
  584. if(must_exist){
  585. dojo.raise("no loaded module named '" + modulename + "'");
  586. }
  587. return null;
  588. }
  589. /**
  590. * @file hostenv_browser.js
  591. *
  592. * Implements the hostenv interface for a browser environment.
  593. *
  594. * Perhaps it could be called a "dom" or "useragent" environment.
  595. *
  596. * @author Copyright 2004 Mark D. Anderson (mda@discerning.com)
  597. * @author Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php
  598. */
  599. // make jsc shut up (so we can use jsc to sanity check the code even if it will never run it).
  600. /*@cc_on
  601. @if (@_jscript_version >= 7)
  602. var window; var XMLHttpRequest;
  603. @end
  604. @*/
  605. if(typeof window == 'undefined'){
  606. dojo.raise("no window object");
  607. }
  608. // attempt to figure out the path to dojo if it isn't set in the config
  609. (function() {
  610. // before we get any further with the config options, try to pick them out
  611. // of the URL. Most of this code is from NW
  612. if(djConfig.allowQueryConfig){
  613. var baseUrl = document.location.toString(); // FIXME: use location.query instead?
  614. var params = baseUrl.split("?", 2);
  615. if(params.length > 1){
  616. var paramStr = params[1];
  617. var pairs = paramStr.split("&");
  618. for(var x in pairs){
  619. var sp = pairs[x].split("=");
  620. // FIXME: is this eval dangerous?
  621. if((sp[0].length > 9)&&(sp[0].substr(0, 9) == "djConfig.")){
  622. var opt = sp[0].substr(9);
  623. try{
  624. djConfig[opt]=eval(sp[1]);
  625. }catch(e){
  626. djConfig[opt]=sp[1];
  627. }
  628. }
  629. }
  630. }
  631. }
  632. if(((djConfig["baseScriptUri"] == "")||(djConfig["baseRelativePath"] == "")) &&(document && document.getElementsByTagName)){
  633. var scripts = document.getElementsByTagName("script");
  634. var rePkg = /(__package__|dojo)\.js(\?|$)/i;
  635. for(var i = 0; i < scripts.length; i++) {
  636. var src = scripts[i].getAttribute("src");
  637. if(!src) { continue; }
  638. var m = src.match(rePkg);
  639. if(m) {
  640. root = src.substring(0, m.index);
  641. if(!this["djConfig"]) { djConfig = {}; }
  642. if(djConfig["baseScriptUri"] == "") { djConfig["baseScriptUri"] = root; }
  643. if(djConfig["baseRelativePath"] == "") { djConfig["baseRelativePath"] = root; }
  644. break;
  645. }
  646. }
  647. }
  648. var dr = dojo.render;
  649. var drh = dojo.render.html;
  650. var dua = drh.UA = navigator.userAgent;
  651. var dav = drh.AV = navigator.appVersion;
  652. var t = true;
  653. var f = false;
  654. drh.capable = t;
  655. drh.support.builtin = t;
  656. dr.ver = parseFloat(drh.AV);
  657. dr.os.mac = dav.indexOf("Macintosh") >= 0;
  658. dr.os.win = dav.indexOf("Windows") >= 0;
  659. // could also be Solaris or something, but it's the same browser
  660. dr.os.linux = dav.indexOf("X11") >= 0;
  661. drh.opera = dua.indexOf("Opera") >= 0;
  662. drh.khtml = (dav.indexOf("Konqueror") >= 0)||(dav.indexOf("Safari") >= 0);
  663. drh.safari = dav.indexOf("Safari") >= 0;
  664. var geckoPos = dua.indexOf("Gecko");
  665. drh.mozilla = drh.moz = (geckoPos >= 0)&&(!drh.khtml);
  666. if (drh.mozilla) {
  667. // gecko version is YYYYMMDD
  668. drh.geckoVersion = dua.substring(geckoPos + 6, geckoPos + 14);
  669. }
  670. drh.ie = (document.all)&&(!drh.opera);
  671. drh.ie50 = drh.ie && dav.indexOf("MSIE 5.0")>=0;
  672. drh.ie55 = drh.ie && dav.indexOf("MSIE 5.5")>=0;
  673. drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0")>=0;
  674. dr.vml.capable=drh.ie;
  675. dr.svg.capable = f;
  676. dr.svg.support.plugin = f;
  677. dr.svg.support.builtin = f;
  678. dr.svg.adobe = f;
  679. if (document.implementation
  680. && document.implementation.hasFeature
  681. && document.implementation.hasFeature("org.w3c.dom.svg", "1.0")
  682. ){
  683. dr.svg.capable = t;
  684. dr.svg.support.builtin = t;
  685. dr.svg.support.plugin = f;
  686. dr.svg.adobe = f;
  687. }else{
  688. // check for ASVG
  689. if(navigator.mimeTypes && navigator.mimeTypes.length > 0){
  690. var result = navigator.mimeTypes["image/svg+xml"] ||
  691. navigator.mimeTypes["image/svg"] ||
  692. navigator.mimeTypes["image/svg-xml"];
  693. if (result){
  694. dr.svg.adobe = result && result.enabledPlugin &&
  695. result.enabledPlugin.description &&
  696. (result.enabledPlugin.description.indexOf("Adobe") > -1);
  697. if(dr.svg.adobe) {
  698. dr.svg.capable = t;
  699. dr.svg.support.plugin = t;
  700. }
  701. }
  702. }else if(drh.ie && dr.os.win){
  703. var result = f;
  704. try {
  705. var test = new ActiveXObject("Adobe.SVGCtl");
  706. result = t;
  707. } catch(e){}
  708. if (result){
  709. dr.svg.capable = t;
  710. dr.svg.support.plugin = t;
  711. dr.svg.adobe = t;
  712. }
  713. }else{
  714. dr.svg.capable = f;
  715. dr.svg.support.plugin = f;
  716. dr.svg.adobe = f;
  717. }
  718. }
  719. })();
  720. dojo.hostenv.startPackage("dojo.hostenv");
  721. dojo.hostenv.name_ = 'browser';
  722. dojo.hostenv.searchIds = [];
  723. // These are in order of decreasing likelihood; this will change in time.
  724. var DJ_XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
  725. dojo.hostenv.getXmlhttpObject = function(){
  726. var http = null;
  727. var last_e = null;
  728. try{ http = new XMLHttpRequest(); }catch(e){}
  729. if(!http){
  730. for(var i=0; i<3; ++i){
  731. var progid = DJ_XMLHTTP_PROGIDS[i];
  732. try{
  733. http = new ActiveXObject(progid);
  734. }catch(e){
  735. last_e = e;
  736. }
  737. if(http){
  738. DJ_XMLHTTP_PROGIDS = [progid]; // so faster next time
  739. break;
  740. }
  741. }
  742. /*if(http && !http.toString) {
  743. http.toString = function() { "[object XMLHttpRequest]"; }
  744. }*/
  745. }
  746. if(!http){
  747. return dojo.raise("XMLHTTP not available", last_e);
  748. }
  749. return http;
  750. }
  751. /**
  752. * Read the contents of the specified uri and return those contents.
  753. *
  754. * @param uri A relative or absolute uri. If absolute, it still must be in the
  755. * same "domain" as we are.
  756. *
  757. * @param async_cb If not specified, load synchronously. If specified, load
  758. * asynchronously, and use async_cb as the progress handler which takes the
  759. * xmlhttp object as its argument. If async_cb, this function returns null.
  760. *
  761. * @param fail_ok Default false. If fail_ok and !async_cb and loading fails,
  762. * return null instead of throwing.
  763. */
  764. dojo.hostenv.getText = function(uri, async_cb, fail_ok){
  765. var http = this.getXmlhttpObject();
  766. if(async_cb){
  767. http.onreadystatechange = function(){
  768. if((4==http.readyState)&&(http["status"])){
  769. if(http.status==200){
  770. dojo.debug("LOADED URI: "+uri);
  771. async_cb(http.responseText);
  772. }
  773. }
  774. }
  775. }
  776. http.open('GET', uri, async_cb ? true : false);
  777. http.send(null);
  778. if(async_cb){
  779. return null;
  780. }
  781. return http.responseText;
  782. }
  783. /*
  784. * It turns out that if we check *right now*, as this script file is being loaded,
  785. * then the last script element in the window DOM is ourselves.
  786. * That is because any subsequent script elements haven't shown up in the document
  787. * object yet.
  788. */
  789. /*
  790. function dj_last_script_src() {
  791. var scripts = window.document.getElementsByTagName('script');
  792. if(scripts.length < 1){
  793. dojo.raise("No script elements in window.document, so can't figure out my script src");
  794. }
  795. var script = scripts[scripts.length - 1];
  796. var src = script.src;
  797. if(!src){
  798. dojo.raise("Last script element (out of " + scripts.length + ") has no src");
  799. }
  800. return src;
  801. }
  802. if(!dojo.hostenv["library_script_uri_"]){
  803. dojo.hostenv.library_script_uri_ = dj_last_script_src();
  804. }
  805. */
  806. dojo.hostenv.defaultDebugContainerId = 'dojoDebug';
  807. dojo.hostenv._println_buffer = [];
  808. dojo.hostenv._println_safe = false;
  809. dojo.hostenv.println = function (line){
  810. if(!dojo.hostenv._println_safe){
  811. dojo.hostenv._println_buffer.push(line);
  812. }else{
  813. try {
  814. var console = document.getElementById(djConfig.debugContainerId ?
  815. djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId);
  816. if(!console) { console = document.getElementsByTagName("body")[0] || document.body; }
  817. var div = document.createElement("div");
  818. div.appendChild(document.createTextNode(line));
  819. console.appendChild(div);
  820. } catch (e) {
  821. try{
  822. // safari needs the output wrapped in an element for some reason
  823. document.write("<div>" + line + "</div>");
  824. }catch(e2){
  825. window.status = line;
  826. }
  827. }
  828. }
  829. }
  830. dojo.addOnLoad(function(){
  831. dojo.hostenv._println_safe = true;
  832. while(dojo.hostenv._println_buffer.length > 0){
  833. dojo.hostenv.println(dojo.hostenv._println_buffer.shift());
  834. }
  835. });
  836. function dj_addNodeEvtHdlr (node, evtName, fp, capture){
  837. var oldHandler = node["on"+evtName] || function(){};
  838. node["on"+evtName] = function(){
  839. fp.apply(node, arguments);
  840. oldHandler.apply(node, arguments);
  841. }
  842. return true;
  843. }
  844. dj_addNodeEvtHdlr(window, "load", function(){
  845. if(dojo.render.html.ie){
  846. dojo.hostenv.makeWidgets();
  847. }
  848. dojo.hostenv.modulesLoaded();
  849. });
  850. dojo.hostenv.makeWidgets = function(){
  851. // you can put searchIds in djConfig and dojo.hostenv at the moment
  852. // we should probably eventually move to one or the other
  853. var sids = [];
  854. if(djConfig.searchIds && djConfig.searchIds.length > 0) {
  855. sids = sids.concat(djConfig.searchIds);
  856. }
  857. if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) {
  858. sids = sids.concat(dojo.hostenv.searchIds);
  859. }
  860. if((djConfig.parseWidgets)||(sids.length > 0)){
  861. if(dojo.evalObjPath("dojo.widget.Parse")){
  862. // we must do this on a delay to avoid:
  863. // http://www.shaftek.org/blog/archives/000212.html
  864. // IE is such a tremendous peice of shit.
  865. try{
  866. var parser = new dojo.xml.Parse();
  867. if(sids.length > 0){
  868. for(var x=0; x<sids.length; x++){
  869. var tmpNode = document.getElementById(sids[x]);
  870. if(!tmpNode){ continue; }
  871. var frag = parser.parseElement(tmpNode, null, true);
  872. dojo.widget.getParser().createComponents(frag);
  873. }
  874. }else if(djConfig.parseWidgets){
  875. var frag = parser.parseElement(document.getElementsByTagName("body")[0] || document.body, null, true);
  876. dojo.widget.getParser().createComponents(frag);
  877. }
  878. }catch(e){
  879. dojo.debug("auto-build-widgets error:", e);
  880. }
  881. }
  882. }
  883. }
  884. dojo.hostenv.modulesLoadedListeners.push(function(){
  885. if(!dojo.render.html.ie) {
  886. dojo.hostenv.makeWidgets();
  887. }
  888. });
  889. // we assume that we haven't hit onload yet. Lord help us.
  890. try {
  891. if (!window["djConfig"] || !window.djConfig["preventBackButtonFix"]){
  892. document.write("<iframe style='border: 0px; width: 1px; height: 1px; position: absolute; bottom: 0px; right: 0px; visibility: visible;' name='djhistory' id='djhistory' src='"+(dojo.hostenv.getBaseScriptUri()+'iframe_history.html')+"'></iframe>");
  893. }
  894. if (dojo.render.html.ie) {
  895. document.write('<style>v\:*{ behavior:url(#default#VML); }</style>');
  896. document.write('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>');
  897. }
  898. } catch (e) { }
  899. // stub, over-ridden by debugging code. This will at least keep us from
  900. // breaking when it's not included
  901. dojo.hostenv.writeIncludes = function(){}
  902. dojo.hostenv.byId = dojo.byId = function(id, doc){
  903. if(typeof id == "string" || id instanceof String){
  904. if(!doc){ doc = document; }
  905. return doc.getElementById(id);
  906. }
  907. return id; // assume it's a node
  908. }
  909. dojo.hostenv.byIdArray = dojo.byIdArray = function(){
  910. var ids = [];
  911. for(var i = 0; i < arguments.length; i++){
  912. if((arguments[i] instanceof Array)||(typeof arguments[i] == "array")){
  913. for(var j = 0; j < arguments[i].length; j++){
  914. ids = ids.concat(dojo.hostenv.byIdArray(arguments[i][j]));
  915. }
  916. }else{
  917. ids.push(dojo.hostenv.byId(arguments[i]));
  918. }
  919. }
  920. return ids;
  921. }
  922. /*
  923. * bootstrap2.js - runs after the hostenv_*.js file.
  924. */
  925. /*
  926. * This method taks a "map" of arrays which one can use to optionally load dojo
  927. * modules. The map is indexed by the possible dojo.hostenv.name_ values, with
  928. * two additional values: "default" and "common". The items in the "default"
  929. * array will be loaded if none of the other items have been choosen based on
  930. * the hostenv.name_ item. The items in the "common" array will _always_ be
  931. * loaded, regardless of which list is chosen. Here's how it's normally
  932. * called:
  933. *
  934. * dojo.hostenv.conditionalLoadModule({
  935. * browser: [
  936. * ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule()
  937. * "foo.sample.*",
  938. * "foo.test,
  939. * ],
  940. * default: [ "foo.sample.*" ],
  941. * common: [ "really.important.module.*" ]
  942. * });
  943. */
  944. dojo.hostenv.conditionalLoadModule = function(modMap){
  945. var common = modMap["common"]||[];
  946. var result = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
  947. for(var x=0; x<result.length; x++){
  948. var curr = result[x];
  949. if(curr.constructor == Array){
  950. dojo.hostenv.loadModule.apply(dojo.hostenv, curr);
  951. }else{
  952. dojo.hostenv.loadModule(curr);
  953. }
  954. }
  955. }
  956. dojo.hostenv.require = dojo.hostenv.loadModule;
  957. dojo.require = function(){
  958. dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
  959. }
  960. dojo.requireAfter = dojo.require;
  961. dojo.requireIf = function(){
  962. if((arguments[0] === true)||(arguments[0]=="common")||(dojo.render[arguments[0]].capable)){
  963. var args = [];
  964. for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
  965. dojo.require.apply(dojo, args);
  966. }
  967. }
  968. dojo.requireAfterIf = dojo.requireIf;
  969. dojo.conditionalRequire = dojo.requireIf;
  970. dojo.kwCompoundRequire = function(){
  971. dojo.hostenv.conditionalLoadModule.apply(dojo.hostenv, arguments);
  972. }
  973. dojo.hostenv.provide = dojo.hostenv.startPackage;
  974. dojo.provide = function(){
  975. return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
  976. }
  977. dojo.setModulePrefix = function(module, prefix){
  978. return dojo.hostenv.setModulePrefix(module, prefix);
  979. }
  980. // stub
  981. dojo.profile = { start: function(){}, end: function(){}, dump: function(){} };
  982. // determine if an object supports a given method
  983. // useful for longer api chains where you have to test each object in the chain
  984. dojo.exists = function(obj, name){
  985. var p = name.split(".");
  986. for(var i = 0; i < p.length; i++){
  987. if(!(obj[p[i]])) return false;
  988. obj = obj[p[i]];
  989. }
  990. return true;
  991. }
  992. dojo.provide("dojo.lang");
  993. dojo.provide("dojo.AdapterRegistry");
  994. dojo.provide("dojo.lang.Lang");
  995. dojo.lang.mixin = function(obj, props, tobj){
  996. if(typeof tobj != "object") {
  997. tobj = {};
  998. }
  999. for(var x in props){
  1000. if(typeof tobj[x] == "undefined" || tobj[x] != props[x]) {
  1001. obj[x] = props[x];
  1002. }
  1003. }
  1004. return obj;
  1005. }
  1006. dojo.lang.extend = function(ctor, props){
  1007. this.mixin(ctor.prototype, props);
  1008. }
  1009. dojo.lang.extendPrototype = function(obj, props){
  1010. this.extend(obj.constructor, props);
  1011. }
  1012. dojo.lang.anonCtr = 0;
  1013. dojo.lang.anon = {};
  1014. dojo.lang.nameAnonFunc = function(anonFuncPtr, namespaceObj){
  1015. var nso = (namespaceObj || dojo.lang.anon);
  1016. if((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)){
  1017. for(var x in nso){
  1018. if(nso[x] === anonFuncPtr){
  1019. return x;
  1020. }
  1021. }
  1022. }
  1023. var ret = "__"+dojo.lang.anonCtr++;
  1024. while(typeof nso[ret] != "undefined"){
  1025. ret = "__"+dojo.lang.anonCtr++;
  1026. }
  1027. nso[ret] = anonFuncPtr;
  1028. return ret;
  1029. }
  1030. /**
  1031. * Runs a function in a given scope (thisObject), can
  1032. * also be used to preserve scope.
  1033. *
  1034. * hitch(foo, "bar"); // runs foo.bar() in the scope of foo
  1035. * hitch(foo, myFunction); // runs myFunction in the scope of foo
  1036. */
  1037. dojo.lang.hitch = function(thisObject, method) {
  1038. if(dojo.lang.isString(method)) {
  1039. var fcn = thisObject[method];
  1040. } else {
  1041. var fcn = method;
  1042. }
  1043. return function() {
  1044. return fcn.apply(thisObject, arguments);
  1045. }
  1046. }
  1047. /**
  1048. * Sets a timeout in milliseconds to execute a function in a given context
  1049. * with optional arguments.
  1050. *
  1051. * setTimeout (Object context, function func, number delay[, arg1[, ...]]);
  1052. * setTimeout (function func, number delay[, arg1[, ...]]);
  1053. */
  1054. dojo.lang.setTimeout = function(func, delay){
  1055. var context = window, argsStart = 2;
  1056. if(!dojo.lang.isFunction(func)){
  1057. context = func;
  1058. func = delay;
  1059. delay = arguments[2];
  1060. argsStart++;
  1061. }
  1062. if(dojo.lang.isString(func)){
  1063. func = context[func];
  1064. }
  1065. var args = [];
  1066. for (var i = argsStart; i < arguments.length; i++) {
  1067. args.push(arguments[i]);
  1068. }
  1069. return setTimeout(function () { func.apply(context, args); }, delay);
  1070. }
  1071. /**
  1072. * Partial implmentation of is* functions from
  1073. * http://www.crockford.com/javascript/recommend.html
  1074. * NOTE: some of these may not be the best thing to use in all situations
  1075. * as they aren't part of core JS and therefore can't work in every case.
  1076. * See WARNING messages inline for tips.
  1077. *
  1078. * The following is* functions are fairly "safe"
  1079. */
  1080. dojo.lang.isObject = function(wh) {
  1081. return typeof wh == "object" || dojo.lang.isArray(wh) || dojo.lang.isFunction(wh);
  1082. }
  1083. dojo.lang.isArray = function(wh) {
  1084. return (wh instanceof Array || typeof wh == "array");
  1085. }
  1086. dojo.lang.isArrayLike = function(wh) {
  1087. if(dojo.lang.isString(wh)){ return false; }
  1088. if(dojo.lang.isArray(wh)){ return true; }
  1089. if(dojo.lang.isNumber(wh.length) && isFinite(wh)){ return true; }
  1090. return false;
  1091. }
  1092. dojo.lang.isFunction = function(wh) {
  1093. return (wh instanceof Function || typeof wh == "function");
  1094. }
  1095. dojo.lang.isString = function(wh) {
  1096. return (wh instanceof String || typeof wh == "string");
  1097. }
  1098. dojo.lang.isAlien = function(wh) {
  1099. return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(wh));
  1100. }
  1101. dojo.lang.isBoolean = function(wh) {
  1102. return (wh instanceof Boolean || typeof wh == "boolean");
  1103. }
  1104. /**
  1105. * The following is***() functions are somewhat "unsafe". Fortunately,
  1106. * there are workarounds the the language provides and are mentioned
  1107. * in the WARNING messages.
  1108. *
  1109. * WARNING: In most cases, isNaN(wh) is sufficient to determine whether or not
  1110. * something is a number or can be used as such. For example, a number or string
  1111. * can be used interchangably when accessing array items (arr["1"] is the same as
  1112. * arr[1]) and isNaN will return false for both values ("1" and 1). Should you
  1113. * use isNumber("1"), that will return false, which is generally not too useful.
  1114. * Also, isNumber(NaN) returns true, again, this isn't generally useful, but there
  1115. * are corner cases (like when you want to make sure that two things are really
  1116. * the same type of thing). That is really where isNumber "shines".
  1117. *
  1118. * RECOMMENDATION: Use isNaN(wh) when possible
  1119. */
  1120. dojo.lang.isNumber = function(wh) {
  1121. return (wh instanceof Number || typeof wh == "number");
  1122. }
  1123. /**
  1124. * WARNING: In some cases, isUndefined will not behave as you
  1125. * might expect. If you do isUndefined(foo) and there is no earlier
  1126. * reference to foo, an error will be thrown before isUndefined is
  1127. * called. It behaves correctly if you scope yor object first, i.e.
  1128. * isUndefined(foo.bar) where foo is an object and bar isn't a
  1129. * property of the object.
  1130. *
  1131. * RECOMMENDATION: Use `typeof foo == "undefined"` when possible
  1132. *
  1133. * FIXME: Should isUndefined go away since it is error prone?
  1134. */
  1135. dojo.lang.isUndefined = function(wh) {
  1136. return ((wh == undefined)&&(typeof wh == "undefined"));
  1137. }
  1138. // end Crockford functions
  1139. dojo.lang.whatAmI = function(wh) {
  1140. try {
  1141. if(dojo.lang.isArray(wh)) { return "array"; }
  1142. if(dojo.lang.isFunction(wh)) { return "function"; }
  1143. if(dojo.lang.isString(wh)) { return "string"; }
  1144. if(dojo.lang.isNumber(wh)) { return "number"; }
  1145. if(dojo.lang.isBoolean(wh)) { return "boolean"; }
  1146. if(dojo.lang.isAlien(wh)) { return "alien"; }
  1147. if(dojo.lang.isUndefined(wh)) { return "undefined"; }
  1148. // FIXME: should this go first?
  1149. for(var name in dojo.lang.whatAmI.custom) {
  1150. if(dojo.lang.whatAmI.custom[name](wh)) {
  1151. return name;
  1152. }
  1153. }
  1154. if(dojo.lang.isObject(wh)) { return "object"; }
  1155. } catch(E) {}
  1156. return "unknown";
  1157. }
  1158. /*
  1159. * dojo.lang.whatAmI.custom[typeName] = someFunction
  1160. * will return typeName is someFunction(wh) returns true
  1161. */
  1162. dojo.lang.whatAmI.custom = {};
  1163. dojo.lang.find = function(arr, val, identity){
  1164. // support both (arr, val) and (val, arr)
  1165. if(!dojo.lang.isArray(arr) && dojo.lang.isArray(val)) {
  1166. var a = arr;
  1167. arr = val;
  1168. val = a;
  1169. }
  1170. var isString = dojo.lang.isString(arr);
  1171. if(isString) { arr = arr.split(""); }
  1172. if(identity){
  1173. for(var i=0;i<arr.length;++i){
  1174. if(arr[i] === val){ return i; }
  1175. }
  1176. }else{
  1177. for(var i=0;i<arr.length;++i){
  1178. if(arr[i] == val){ return i; }
  1179. }
  1180. }
  1181. return -1;
  1182. }
  1183. dojo.lang.indexOf = dojo.lang.find;
  1184. dojo.lang.findLast = function(arr, val, identity) {
  1185. // support both (arr, val) and (val, arr)
  1186. if(!dojo.lang.isArray(arr) && dojo.lang.isArray(val)) {
  1187. var a = arr;
  1188. arr = val;
  1189. val = a;
  1190. }
  1191. var isString = dojo.lang.isString(arr);
  1192. if(isString) { arr = arr.split(""); }
  1193. if(identity){
  1194. for(var i = arr.length-1; i >= 0; i--) {
  1195. if(arr[i] === val){ return i; }
  1196. }
  1197. }else{
  1198. for(var i = arr.length-1; i >= 0; i--) {
  1199. if(arr[i] == val){ return i; }
  1200. }
  1201. }
  1202. return -1;
  1203. }
  1204. dojo.lang.lastIndexOf = dojo.lang.findLast;
  1205. dojo.lang.inArray = function(arr, val){
  1206. return dojo.lang.find(arr, val) > -1;
  1207. }
  1208. dojo.lang.getNameInObj = function(ns, item){
  1209. if(!ns){ ns = dj_global; }
  1210. for(var x in ns){
  1211. if(ns[x] === item){
  1212. return new String(x);
  1213. }
  1214. }
  1215. return null;
  1216. }
  1217. // FIXME: Is this worthless since you can do: if(name in obj)
  1218. // is this the right place for this?
  1219. dojo.lang.has = function(obj, name){
  1220. return (typeof obj[name] !== 'undefined');
  1221. }
  1222. dojo.lang.isEmpty = function(obj) {
  1223. if(dojo.lang.isObject(obj)) {
  1224. var tmp = {};
  1225. var count = 0;
  1226. for(var x in obj){
  1227. if(obj[x] && (!tmp[x])){
  1228. count++;
  1229. break;
  1230. }
  1231. }
  1232. return (count == 0);
  1233. } else if(dojo.lang.isArray(obj) || dojo.lang.isString(obj)) {
  1234. return obj.length == 0;
  1235. }
  1236. }
  1237. dojo.lang.forEach = function(arr, unary_func, fix_length){
  1238. var isString = dojo.lang.isString(arr);
  1239. if(isString) { arr = arr.split(""); }
  1240. var il = arr.length;
  1241. for(var i=0; i< ((fix_length) ? il : arr.length); i++){
  1242. if(unary_func(arr[i], i, arr) == "break"){
  1243. break;
  1244. }
  1245. }
  1246. }
  1247. dojo.lang.map = function(arr, obj, unary_func){
  1248. var isString = dojo.lang.isString(arr);
  1249. if(isString){
  1250. arr = arr.split("");
  1251. }
  1252. if(dojo.lang.isFunction(obj)&&(!unary_func)){
  1253. unary_func = obj;
  1254. obj = dj_global;
  1255. }else if(dojo.lang.isFunction(obj) && unary_func){
  1256. // ff 1.5 compat
  1257. var tmpObj = obj;
  1258. obj = unary_func;
  1259. unary_func = tmpObj;
  1260. }
  1261. if(Array.map){
  1262. var outArr = Array.map(arr, unary_func, obj);
  1263. }else{
  1264. var outArr = [];
  1265. for(var i=0;i<arr.length;++i){
  1266. outArr.push(unary_func.call(obj, arr[i]));
  1267. }
  1268. }
  1269. if(isString) {
  1270. return outArr.join("");
  1271. } else {
  1272. return outArr;
  1273. }
  1274. }
  1275. dojo.lang.tryThese = function(){
  1276. for(var x=0; x<arguments.length; x++){
  1277. try{
  1278. if(typeof arguments[x] == "function"){
  1279. var ret = (arguments[x]());
  1280. if(ret){
  1281. return ret;
  1282. }
  1283. }
  1284. }catch(e){
  1285. dojo.debug(e);
  1286. }
  1287. }
  1288. }
  1289. dojo.lang.delayThese = function(farr, cb, delay, onend){
  1290. /**
  1291. * alternate: (array funcArray, function callback, function onend)
  1292. * alternate: (array funcArray, function callback)
  1293. * alternate: (array funcArray)
  1294. */
  1295. if(!farr.length){
  1296. if(typeof onend == "function"){
  1297. onend();
  1298. }
  1299. return;
  1300. }
  1301. if((typeof delay == "undefined")&&(typeof cb == "number")){
  1302. delay = cb;
  1303. cb = function(){};
  1304. }else if(!cb){
  1305. cb = function(){};
  1306. if(!delay){ delay = 0; }
  1307. }
  1308. setTimeout(function(){
  1309. (farr.shift())();
  1310. cb();
  1311. dojo.lang.delayThese(farr, cb, delay, onend);
  1312. }, delay);
  1313. }
  1314. dojo.lang.shallowCopy = function(obj) {
  1315. var ret = {}, key;
  1316. for(key in obj) {
  1317. if(dojo.lang.isUndefined(ret[key])) {
  1318. ret[key] = obj[key];
  1319. }
  1320. }
  1321. return ret;
  1322. }
  1323. dojo.lang.every = function(arr, callback, thisObject) {
  1324. var isString = dojo.lang.isString(arr);
  1325. if(isString) { arr = arr.split(""); }
  1326. if(Array.every) {
  1327. return Array.every(arr, callback, thisObject);
  1328. } else {
  1329. if(!thisObject) {
  1330. if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
  1331. thisObject = dj_global;
  1332. }
  1333. for(var i = 0; i < arr.length; i++) {
  1334. if(!callback.call(thisObject, arr[i], i, arr)) {
  1335. return false;
  1336. }
  1337. }
  1338. return true;
  1339. }
  1340. }
  1341. dojo.lang.some = function(arr, callback, thisObject) {
  1342. var isString = dojo.lang.isString(arr);
  1343. if(isString) { arr = arr.split(""); }
  1344. if(Array.some) {
  1345. return Array.some(arr, callback, thisObject);
  1346. } else {
  1347. if(!thisObject) {
  1348. if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
  1349. thisObject = dj_global;
  1350. }
  1351. for(var i = 0; i < arr.length; i++) {
  1352. if(callback.call(thisObject, arr[i], i, arr)) {
  1353. return true;
  1354. }
  1355. }
  1356. return false;
  1357. }
  1358. }
  1359. dojo.lang.filter = function(arr, callback, thisObject) {
  1360. var isString = dojo.lang.isString(arr);
  1361. if(isString) { arr = arr.split(""); }
  1362. if(Array.filter) {
  1363. var outArr = Array.filter(arr, callback, thisObject);
  1364. } else {
  1365. if(!thisObject) {
  1366. if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
  1367. thisObject = dj_global;
  1368. }
  1369. var outArr = [];
  1370. for(var i = 0; i < arr.length; i++) {
  1371. if(callback.call(thisObject, arr[i], i, arr)) {
  1372. outArr.push(arr[i]);
  1373. }
  1374. }
  1375. }
  1376. if(isString) {
  1377. return outArr.join("");
  1378. } else {
  1379. return outArr;
  1380. }
  1381. }
  1382. dojo.AdapterRegistry = function(){
  1383. /***
  1384. A registry to facilitate adaptation.
  1385. Pairs is an array of [name, check, wrap] triples
  1386. All check/wrap functions in this registry should be of the same arity.
  1387. ***/
  1388. this.pairs = [];
  1389. }
  1390. dojo.lang.extend(dojo.AdapterRegistry, {
  1391. register: function (name, check, wrap, /* optional */ override){
  1392. /***
  1393. The check function should return true if the given arguments are
  1394. appropriate for the wrap function.
  1395. If override is given and true, the check function will be given
  1396. highest priority. Otherwise, it will be the lowest priority
  1397. adapter.
  1398. ***/
  1399. if (override) {
  1400. this.pairs.unshift([name, check, wrap]);
  1401. } else {
  1402. this.pairs.push([name, check, wrap]);
  1403. }
  1404. },
  1405. match: function (/* ... */) {
  1406. /***
  1407. Find an adapter for the given arguments.
  1408. If no suitable adapter is found, throws NotFound.
  1409. ***/
  1410. for(var i = 0; i < this.pairs.length; i++){
  1411. var pair = this.pairs[i];
  1412. if(pair[1].apply(this, arguments)){
  1413. return pair[2].apply(this, arguments);
  1414. }
  1415. }
  1416. dojo.raise("No match found");
  1417. },
  1418. unregister: function (name) {
  1419. /***
  1420. Remove a named adapter from the registry
  1421. ***/
  1422. for(var i = 0; i < this.pairs.length; i++){
  1423. var pair = this.pairs[i];
  1424. if(pair[0] == name){
  1425. this.pairs.splice(i, 1);
  1426. return true;
  1427. }
  1428. }
  1429. return false;
  1430. }
  1431. });
  1432. dojo.lang.reprRegistry = new dojo.AdapterRegistry();
  1433. dojo.lang.registerRepr = function(name, check, wrap, /*optional*/ override){
  1434. /***
  1435. Register a repr function. repr functions should take
  1436. one argument and return a string representation of it
  1437. suitable for developers, primarily used when debugging.
  1438. If override is given, it is used as the highest priority
  1439. repr, otherwise it will be used as the lowest.
  1440. ***/
  1441. dojo.lang.reprRegistry.register(name, check, wrap, override);
  1442. };
  1443. dojo.lang.repr = function(obj){
  1444. /***
  1445. Return a "programmer representation" for an object
  1446. ***/
  1447. if(typeof(obj) == "undefined"){
  1448. return "undefined";
  1449. }else if(obj === null){
  1450. return "null";
  1451. }
  1452. try{
  1453. if(typeof(obj["__repr__"]) == 'function'){
  1454. return obj["__repr__"]();
  1455. }else if((typeof(obj["repr"]) == 'function')&&(obj.repr != arguments.callee)){
  1456. return obj["repr"]();
  1457. }
  1458. return dojo.lang.reprRegistry.match(obj);
  1459. }catch(e){
  1460. if(typeof(obj.NAME) == 'string' && (
  1461. obj.toString == Function.prototype.toString ||
  1462. obj.toString == Object.prototype.toString
  1463. )){
  1464. return o.NAME;
  1465. }
  1466. }
  1467. if(typeof(obj) == "function"){
  1468. obj = (obj + "").replace(/^\s+/, "");
  1469. var idx = obj.indexOf("{");
  1470. if(idx != -1){
  1471. obj = obj.substr(0, idx) + "{...}";
  1472. }
  1473. }
  1474. return obj + "";
  1475. }
  1476. dojo.lang.reprArrayLike = function(arr){
  1477. try{
  1478. var na = dojo.lang.map(arr, dojo.lang.repr);
  1479. return "[" + na.join(", ") + "]";
  1480. }catch(e){ }
  1481. };
  1482. dojo.lang.reprString = function(str){
  1483. return ('"' + str.replace(/(["\\])/g, '\\$1') + '"'
  1484. ).replace(/[\f]/g, "\\f"
  1485. ).replace(/[\b]/g, "\\b"
  1486. ).replace(/[\n]/g, "\\n"
  1487. ).replace(/[\t]/g, "\\t"
  1488. ).replace(/[\r]/g, "\\r");
  1489. };
  1490. dojo.lang.reprNumber = function(num){
  1491. return num + "";
  1492. };
  1493. (function(){
  1494. var m = dojo.lang;
  1495. m.registerRepr("arrayLike", m.isArrayLike, m.reprArrayLike);
  1496. m.registerRepr("string", m.isString, m.reprString);
  1497. m.registerRepr("numbers", m.isNumber, m.reprNumber);
  1498. m.registerRepr("boolean", m.isBoolean, m.reprNumber);
  1499. // m.registerRepr("numbers", m.typeMatcher("number", "boolean"), m.reprNumber);
  1500. })();
  1501. /**
  1502. * Creates a 1-D array out of all the arguments passed,
  1503. * unravelling any array-like objects in the process
  1504. *
  1505. * Ex:
  1506. * unnest(1, 2, 3) ==> [1, 2, 3]
  1507. * unnest(1, [2, [3], [[[4]]]]) ==> [1, 2, 3, 4]
  1508. */
  1509. dojo.lang.unnest = function(/* ... */) {
  1510. var out = [];
  1511. for(var i = 0; i < arguments.length; i++) {
  1512. if(dojo.lang.isArrayLike(arguments[i])) {
  1513. var add = dojo.lang.unnest.apply(this, arguments[i]);
  1514. out = out.concat(add);
  1515. } else {
  1516. out.push(arguments[i]);
  1517. }
  1518. }
  1519. return out;
  1520. }
  1521. dojo.provide("dojo.string");
  1522. dojo.require("dojo.lang");
  1523. /**
  1524. * Trim whitespace from 'str'. If 'wh' > 0,
  1525. * only trim from start, if 'wh' < 0, only trim
  1526. * from end, otherwise trim both ends
  1527. */
  1528. dojo.string.trim = function(str, wh){
  1529. if(!dojo.lang.isString(str)){ return str; }
  1530. if(!str.length){ return str; }
  1531. if(wh > 0) {
  1532. return str.replace(/^\s+/, "");
  1533. } else if(wh < 0) {
  1534. return str.replace(/\s+$/, "");
  1535. } else {
  1536. return str.replace(/^\s+|\s+$/g, "");
  1537. }
  1538. }
  1539. /**
  1540. * Trim whitespace at the beginning of 'str'
  1541. */
  1542. dojo.string.trimStart = function(str) {
  1543. return dojo.string.trim(str, 1);
  1544. }
  1545. /**
  1546. * Trim whitespace at the end of 'str'
  1547. */
  1548. dojo.string.trimEnd = function(str) {
  1549. return dojo.string.trim(str, -1);
  1550. }
  1551. /**
  1552. * Parameterized string function
  1553. * str - formatted string with %{values} to be replaces
  1554. * pairs - object of name: "value" value pairs
  1555. * killExtra - remove all remaining %{values} after pairs are inserted
  1556. */
  1557. dojo.string.paramString = function(str, pairs, killExtra) {
  1558. for(var name in pairs) {
  1559. var re = new RegExp("\\%\\{" + name + "\\}", "g");
  1560. str = str.replace(re, pairs[name]);
  1561. }
  1562. if(killExtra) { str = str.replace(/%\{([^\}\s]+)\}/g, ""); }
  1563. return str;
  1564. }
  1565. /** Uppercases the first letter of each word */
  1566. dojo.string.capitalize = function (str) {
  1567. if (!dojo.lang.isString(str)) { return ""; }
  1568. if (arguments.length == 0) { str = this; }
  1569. var words = str.split(' ');
  1570. var retval = "";
  1571. var len = words.length;
  1572. for (var i=0; i<len; i++) {
  1573. var word = words[i];
  1574. word = word.charAt(0).toUpperCase() + word.substring(1, word.length);
  1575. retval += word;
  1576. if (i < len-1)
  1577. retval += " ";
  1578. }
  1579. return new String(retval);
  1580. }
  1581. /**
  1582. * Return true if the entire string is whitespace characters
  1583. */
  1584. dojo.string.isBlank = function (str) {
  1585. if(!dojo.lang.isString(str)) { return true; }
  1586. return (dojo.string.trim(str).length == 0);
  1587. }
  1588. dojo.string.encodeAscii = function(str) {
  1589. if(!dojo.lang.isString(str)) { return str; }
  1590. var ret = "";
  1591. var value = escape(str);
  1592. var match, re = /%u([0-9A-F]{4})/i;
  1593. while((match = value.match(re))) {
  1594. var num = Number("0x"+match[1]);
  1595. var newVal = escape("&#" + num + ";");
  1596. ret += value.substring(0, match.index) + newVal;
  1597. value = value.substring(match.index+match[0].length);
  1598. }
  1599. ret += value.replace(/\+/g, "%2B");
  1600. return ret;
  1601. }
  1602. // TODO: make an HTML version
  1603. dojo.string.summary = function(str, len) {
  1604. if(!len || str.length <= len) {
  1605. return str;
  1606. } else {
  1607. return str.substring(0, len).replace(/\.+$/, "") + "...";
  1608. }
  1609. }
  1610. dojo.string.escape = function(type, str) {
  1611. switch(type.toLowerCase()) {
  1612. case "xml":
  1613. case "html":
  1614. case "xhtml":
  1615. return dojo.string.escapeXml(str);
  1616. case "sql":
  1617. return dojo.string.escapeSql(str);
  1618. case "regexp":
  1619. case "regex":
  1620. return dojo.string.escapeRegExp(str);
  1621. case "javascript":
  1622. case "jscript":
  1623. case "js":
  1624. return dojo.string.escapeJavaScript(str);
  1625. case "ascii":
  1626. // so it's encode, but it seems useful
  1627. return dojo.string.encodeAscii(str);
  1628. default:
  1629. return str;
  1630. }
  1631. }
  1632. dojo.string.escapeXml = function(str) {
  1633. return str.replace(/&/gm, "&amp;").replace(/</gm, "&lt;")
  1634. .replace(/>/gm, "&gt;").replace(/"/gm, "&quot;").replace(/'/gm, "&#39;");
  1635. }
  1636. dojo.string.escapeSql = function(str) {
  1637. return str.replace(/'/gm, "''");
  1638. }
  1639. dojo.string.escapeRegExp = function(str) {
  1640. return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n

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