/DotNetKicks/Incremental.Kick.Web.UI/Static/Scripts/2.0.2/Dojo/dojo.js.uncompressed.js
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
- /*
- Copyright (c) 2004-2005, The Dojo Foundation
- All Rights Reserved.
- Licensed under the Academic Free License version 2.1 or above OR the
- modified BSD license. For more information on Dojo licensing, see:
- http://dojotoolkit.org/community/licensing.shtml
- */
- /**
- * @file bootstrap1.js
- *
- * bootstrap file that runs before hostenv_*.js file.
- *
- * @author Copyright 2004 Mark D. Anderson (mda@discerning.com)
- * @author Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php
- *
- * $Id: bootstrap1.js 2555 2005-12-20 00:26:24Z alex $
- */
- /**
- * The global djConfig can be set prior to loading the library, to override
- * certain settings. It does not exist under dojo.* so that it can be set
- * before the dojo variable exists. Setting any of these variables *after* the
- * library has loaded does nothing at all. The variables that can be set are
- * as follows:
- */
- /**
- * dj_global is an alias for the top-level global object in the host
- * environment (the "window" object in a browser).
- */
- var dj_global = this; //typeof window == 'undefined' ? this : window;
- function dj_undef(name, obj){
- if(!obj){ obj = dj_global; }
- return (typeof obj[name] == "undefined");
- }
- if(dj_undef("djConfig")){
- var djConfig = {};
- }
- /**
- * dojo is the root variable of (almost all) our public symbols.
- */
- var dojo;
- if(dj_undef("dojo")){ dojo = {}; }
- dojo.version = {
- major: 0, minor: 2, patch: 1, flag: "",
- revision: Number("$Rev: 2555 $".match(/[0-9]+/)[0]),
- toString: function() {
- with (dojo.version) {
- return major + "." + minor + "." + patch + flag + " (" + revision + ")";
- }
- }
- };
- /*
- * evaluate a string like "A.B" without using eval.
- */
- dojo.evalObjPath = function(objpath, create){
- // fast path for no periods
- if(typeof objpath != "string"){ return dj_global; }
- if(objpath.indexOf('.') == -1){
- if((dj_undef(objpath, dj_global))&&(create)){
- dj_global[objpath] = {};
- }
- return dj_global[objpath];
- }
- var syms = objpath.split(/\./);
- var obj = dj_global;
- for(var i=0;i<syms.length;++i){
- if(!create){
- obj = obj[syms[i]];
- if((typeof obj == 'undefined')||(!obj)){
- return obj;
- }
- }else{
- if(dj_undef(syms[i], obj)){
- obj[syms[i]] = {};
- }
- obj = obj[syms[i]];
- }
- }
- return obj;
- };
- // ****************************************************************
- // global public utils
- // ****************************************************************
- /*
- * utility to print an Error.
- * TODO: overriding Error.prototype.toString won't accomplish this?
- * ... since natively generated Error objects do not always reflect such things?
- */
- dojo.errorToString = function(excep){
- return ((!dj_undef("message", excep)) ? excep.message : (dj_undef("description", excep) ? excep : excep.description ));
- };
- /**
- * Throws an Error object given the string err. For now, will also do a println
- * to the user first.
- */
- dojo.raise = function(message, excep){
- if(excep){
- message = message + ": "+dojo.errorToString(excep);
- }
- var he = dojo.hostenv;
- if((!dj_undef("hostenv", dojo))&&(!dj_undef("println", dojo.hostenv))){
- dojo.hostenv.println("FATAL: " + message);
- }
- throw Error(message);
- };
- dj_throw = dj_rethrow = function(m, e){
- dojo.deprecated("dj_throw and dj_rethrow deprecated, use dojo.raise instead");
- dojo.raise(m, e);
- };
- /**
- * Produce a line of debug output.
- * Does nothing unless djConfig.isDebug is true.
- * varargs, joined with ''.
- * Caller should not supply a trailing "\n".
- */
- dojo.debug = function(){
- if (!djConfig.isDebug) { return; }
- var args = arguments;
- if(dj_undef("println", dojo.hostenv)){
- dojo.raise("dojo.debug not available (yet?)");
- }
- var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
- var s = [(isJUM ? "": "DEBUG: ")];
- for(var i=0;i<args.length;++i){
- if(!false && args[i] instanceof Error){
- var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) +
- (args[i].fileName ? ", file: " + args[i].fileName : "") +
- (args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
- } else {
- try {
- var msg = String(args[i]);
- } catch(e) {
- if(dojo.render.html.ie) {
- var msg = "[ActiveXObject]";
- } else {
- var msg = "[unknown]";
- }
- }
- }
- s.push(msg);
- }
- if(isJUM){ // this seems to be the only way to get JUM to "play nice"
- jum.debug(s.join(" "));
- }else{
- dojo.hostenv.println(s.join(" "));
- }
- }
- /**
- * this is really hacky for now - just
- * display the properties of the object
- **/
- dojo.debugShallow = function(obj){
- if (!djConfig.isDebug) { return; }
- dojo.debug('------------------------------------------------------------');
- dojo.debug('Object: '+obj);
- for(i in obj){
- dojo.debug(i + ': ' + obj[i]);
- }
- dojo.debug('------------------------------------------------------------');
- }
- var dj_debug = dojo.debug;
- /**
- * We put eval() in this separate function to keep down the size of the trapped
- * evaluation context.
- *
- * Note that:
- * - JSC eval() takes an optional second argument which can be 'unsafe'.
- * - Mozilla/SpiderMonkey eval() takes an optional second argument which is the
- * scope object for new symbols.
- */
- function dj_eval(s){ return dj_global.eval ? dj_global.eval(s) : eval(s); }
- /**
- * Convenience for throwing an exception because some function is not
- * implemented.
- */
- dj_unimplemented = dojo.unimplemented = function(funcname, extra){
- // FIXME: need to move this away from dj_*
- var mess = "'" + funcname + "' not implemented";
- if((!dj_undef(extra))&&(extra)){ mess += " " + extra; }
- dojo.raise(mess);
- }
- /**
- * Convenience for informing of deprecated behaviour.
- */
- dj_deprecated = dojo.deprecated = function(behaviour, extra, removal){
- var mess = "DEPRECATED: " + behaviour;
- if(extra){ mess += " " + extra; }
- if(removal){ mess += " -- will be removed in version: " + removal; }
- dojo.debug(mess);
- }
- /**
- * Does inheritance
- */
- dojo.inherits = function(subclass, superclass){
- if(typeof superclass != 'function'){
- dojo.raise("superclass: "+superclass+" borken");
- }
- subclass.prototype = new superclass();
- subclass.prototype.constructor = subclass;
- subclass.superclass = superclass.prototype;
- // DEPRICATED: super is a reserved word, use 'superclass'
- subclass['super'] = superclass.prototype;
- }
- dj_inherits = function(subclass, superclass){
- dojo.deprecated("dj_inherits deprecated, use dojo.inherits instead");
- dojo.inherits(subclass, superclass);
- }
- // an object that authors use determine what host we are running under
- dojo.render = (function(){
- function vscaffold(prefs, names){
- var tmp = {
- capable: false,
- support: {
- builtin: false,
- plugin: false
- },
- prefixes: prefs
- };
- for(var x in names){
- tmp[x] = false;
- }
- return tmp;
- }
- return {
- name: "",
- ver: dojo.version,
- os: { win: false, linux: false, osx: false },
- html: vscaffold(["html"], ["ie", "opera", "khtml", "safari", "moz"]),
- svg: vscaffold(["svg"], ["corel", "adobe", "batik"]),
- vml: vscaffold(["vml"], ["ie"]),
- swf: vscaffold(["Swf", "Flash", "Mm"], ["mm"]),
- swt: vscaffold(["Swt"], ["ibm"])
- };
- })();
- // ****************************************************************
- // dojo.hostenv methods that must be defined in hostenv_*.js
- // ****************************************************************
- /**
- * The interface definining the interaction with the EcmaScript host environment.
- */
- /*
- * None of these methods should ever be called directly by library users.
- * Instead public methods such as loadModule should be called instead.
- */
- dojo.hostenv = (function(){
- // default configuration options
- var config = {
- isDebug: false,
- allowQueryConfig: false,
- baseScriptUri: "",
- baseRelativePath: "",
- libraryScriptUri: "",
- iePreventClobber: false,
- ieClobberMinimal: true,
- preventBackButtonFix: true,
- searchIds: [],
- parseWidgets: true
- };
- if (typeof djConfig == "undefined") { djConfig = config; }
- else {
- for (var option in config) {
- if (typeof djConfig[option] == "undefined") {
- djConfig[option] = config[option];
- }
- }
- }
- var djc = djConfig;
- function _def(obj, name, def){
- return (dj_undef(name, obj) ? def : obj[name]);
- }
- return {
- name_: '(unset)',
- version_: '(unset)',
- pkgFileName: "__package__",
- // for recursion protection
- loading_modules_: {},
- loaded_modules_: {},
- addedToLoadingCount: [],
- removedFromLoadingCount: [],
- inFlightCount: 0,
- modulePrefixes_: {
- dojo: {name: "dojo", value: "src"}
- },
- setModulePrefix: function(module, prefix){
- this.modulePrefixes_[module] = {name: module, value: prefix};
- },
- getModulePrefix: function(module){
- var mp = this.modulePrefixes_;
- if((mp[module])&&(mp[module]["name"])){
- return mp[module].value;
- }
- return module;
- },
- getTextStack: [],
- loadUriStack: [],
- loadedUris: [],
- // lookup cache for modules.
- // NOTE: this is partially redundant a private variable in the jsdown
- // implementation, but we don't want to couple the two.
- // modules_ : {},
- post_load_: false,
- modulesLoadedListeners: [],
- /**
- * Return the name of the hostenv.
- */
- getName: function(){ return this.name_; },
- /**
- * Return the version of the hostenv.
- */
- getVersion: function(){ return this.version_; },
- /**
- * Read the plain/text contents at the specified uri. If getText() is
- * not implemented, then it is necessary to override loadUri() with an
- * implementation that doesn't rely on it.
- */
- getText: function(uri){
- dojo.unimplemented('getText', "uri=" + uri);
- },
- /**
- * return the uri of the script that defined this function
- * private method that must be implemented by the hostenv.
- */
- getLibraryScriptUri: function(){
- // FIXME: need to implement!!!
- dojo.unimplemented('getLibraryScriptUri','');
- }
- };
- })();
- /**
- * Display a line of text to the user.
- * The line argument should not contain a trailing "\n"; that is added by the
- * implementation.
- */
- //dojo.hostenv.println = function(line) {}
- // ****************************************************************
- // dojo.hostenv methods not defined in hostenv_*.js
- // ****************************************************************
- /**
- * Return the base script uri that other scripts are found relative to.
- * It is either the empty string, or a non-empty string ending in '/'.
- */
- dojo.hostenv.getBaseScriptUri = function(){
- if(djConfig.baseScriptUri.length){
- return djConfig.baseScriptUri;
- }
- var uri = new String(djConfig.libraryScriptUri||djConfig.baseRelativePath);
- if (!uri) { dojo.raise("Nothing returned by getLibraryScriptUri(): " + uri); }
- var lastslash = uri.lastIndexOf('/');
- djConfig.baseScriptUri = djConfig.baseRelativePath;
- return djConfig.baseScriptUri;
- }
- /**
- * Set the base script uri.
- */
- // In JScript .NET, see interface System._AppDomain implemented by
- // System.AppDomain.CurrentDomain. Members include AppendPrivatePath,
- // RelativeSearchPath, BaseDirectory.
- dojo.hostenv.setBaseScriptUri = function(uri){ djConfig.baseScriptUri = uri }
- /**
- * Loads and interprets the script located at relpath, which is relative to the
- * script root directory. If the script is found but its interpretation causes
- * a runtime exception, that exception is not caught by us, so the caller will
- * see it. We return a true value if and only if the script is found.
- *
- * For now, we do not have an implementation of a true search path. We
- * consider only the single base script uri, as returned by getBaseScriptUri().
- *
- * @param relpath A relative path to a script (no leading '/', and typically
- * ending in '.js').
- * @param module A module whose existance to check for after loading a path.
- * Can be used to determine success or failure of the load.
- */
- dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
- if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){
- dojo.raise("relpath '" + relpath + "'; must be relative");
- }
- var uri = this.getBaseScriptUri() + relpath;
- if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + djConfig.cacheBust.replace(/\W+/g,""); }
- try{
- return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
- }catch(e){
- dojo.debug(e);
- return false;
- }
- }
- /**
- * Reads the contents of the URI, and evaluates the contents.
- * Returns true if it succeeded. Returns false if the URI reading failed.
- * Throws if the evaluation throws.
- * The result of the eval is not available to the caller.
- */
- dojo.hostenv.loadUri = function(uri, cb){
- if(dojo.hostenv.loadedUris[uri]){
- return;
- }
- var contents = this.getText(uri, null, true);
- if(contents == null){ return 0; }
- var value = dj_eval(contents);
- return 1;
- }
- // FIXME: probably need to add logging to this method
- dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
- var ok = true;
- try{
- ok = this.loadUri(uri, cb);
- }catch(e){
- dojo.debug("failed loading ", uri, " with error: ", e);
- }
- return ((ok)&&(this.findModule(module, false))) ? true : false;
- }
- dojo.loaded = function(){ }
- dojo.hostenv.loaded = function(){
- this.post_load_ = true;
- var mll = this.modulesLoadedListeners;
- for(var x=0; x<mll.length; x++){
- mll[x]();
- }
- dojo.loaded();
- }
- /*
- Call styles:
- dojo.addOnLoad(functionPointer)
- dojo.addOnLoad(object, "functionName")
- */
- dojo.addOnLoad = function(obj, fcnName) {
- if(arguments.length == 1) {
- dojo.hostenv.modulesLoadedListeners.push(obj);
- } else if(arguments.length > 1) {
- dojo.hostenv.modulesLoadedListeners.push(function() {
- obj[fcnName]();
- });
- }
- };
- dojo.hostenv.modulesLoaded = function(){
- if(this.post_load_){ return; }
- if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
- if(this.inFlightCount > 0){
- dojo.debug("files still in flight!");
- return;
- }
- if(typeof setTimeout == "object"){
- setTimeout("dojo.hostenv.loaded();", 0);
- }else{
- dojo.hostenv.loaded();
- }
- }
- }
- dojo.hostenv.moduleLoaded = function(modulename){
- var modref = dojo.evalObjPath((modulename.split(".").slice(0, -1)).join('.'));
- this.loaded_modules_[(new String(modulename)).toLowerCase()] = modref;
- }
- /**
- * loadModule("A.B") first checks to see if symbol A.B is defined.
- * If it is, it is simply returned (nothing to do).
- *
- * If it is not defined, it will look for "A/B.js" in the script root directory,
- * followed by "A.js".
- *
- * It throws if it cannot find a file to load, or if the symbol A.B is not
- * defined after loading.
- *
- * It returns the object A.B.
- *
- * This does nothing about importing symbols into the current package.
- * It is presumed that the caller will take care of that. For example, to import
- * all symbols:
- *
- * with (dojo.hostenv.loadModule("A.B")) {
- * ...
- * }
- *
- * And to import just the leaf symbol:
- *
- * var B = dojo.hostenv.loadModule("A.B");
- * ...
- *
- * dj_load is an alias for dojo.hostenv.loadModule
- */
- dojo.hostenv._global_omit_module_check = false;
- dojo.hostenv.loadModule = function(modulename, exact_only, omit_module_check){
- omit_module_check = this._global_omit_module_check || omit_module_check;
- var module = this.findModule(modulename, false);
- if(module){
- return module;
- }
- // protect against infinite recursion from mutual dependencies
- if(dj_undef(modulename, this.loading_modules_)){
- this.addedToLoadingCount.push(modulename);
- }
- this.loading_modules_[modulename] = 1;
- // convert periods to slashes
- var relpath = modulename.replace(/\./g, '/') + '.js';
- var syms = modulename.split(".");
- var nsyms = modulename.split(".");
- for (var i = syms.length - 1; i > 0; i--) {
- var parentModule = syms.slice(0, i).join(".");
- var parentModulePath = this.getModulePrefix(parentModule);
- if (parentModulePath != parentModule) {
- syms.splice(0, i, parentModulePath);
- break;
- }
- }
- var last = syms[syms.length - 1];
- // figure out if we're looking for a full package, if so, we want to do
- // things slightly diffrently
- if(last=="*"){
- modulename = (nsyms.slice(0, -1)).join('.');
- while(syms.length){
- syms.pop();
- syms.push(this.pkgFileName);
- relpath = syms.join("/") + '.js';
- if(relpath.charAt(0)=="/"){
- relpath = relpath.slice(1);
- }
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
- if(ok){ break; }
- syms.pop();
- }
- }else{
- relpath = syms.join("/") + '.js';
- modulename = nsyms.join('.');
- var ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
- if((!ok)&&(!exact_only)){
- syms.pop();
- while(syms.length){
- relpath = syms.join('/') + '.js';
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
- if(ok){ break; }
- syms.pop();
- relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
- if(relpath.charAt(0)=="/"){
- relpath = relpath.slice(1);
- }
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
- if(ok){ break; }
- }
- }
- if((!ok)&&(!omit_module_check)){
- dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
- }
- }
- // check that the symbol was defined
- if(!omit_module_check){
- // pass in false so we can give better error
- module = this.findModule(modulename, false);
- if(!module){
- dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
- }
- }
- return module;
- }
- /**
- * startPackage("A.B") follows the path, and at each level creates a new empty
- * object or uses what already exists. It returns the result.
- */
- dojo.hostenv.startPackage = function(packname){
- var syms = packname.split(/\./);
- if(syms[syms.length-1]=="*"){
- syms.pop();
- }
- return dojo.evalObjPath(syms.join("."), true);
- }
- /**
- * findModule("A.B") returns the object A.B if it exists, otherwise null.
- * @param modulename A string like 'A.B'.
- * @param must_exist Optional, defualt false. throw instead of returning null
- * if the module does not currently exist.
- */
- dojo.hostenv.findModule = function(modulename, must_exist) {
- // check cache
- /*
- if(!dj_undef(modulename, this.modules_)){
- return this.modules_[modulename];
- }
- */
- if(this.loaded_modules_[(new String(modulename)).toLowerCase()]){
- return this.loaded_modules_[modulename];
- }
- // see if symbol is defined anyway
- var module = dojo.evalObjPath(modulename);
- if((typeof module !== 'undefined')&&(module)){
- return module;
- // return this.modules_[modulename] = module;
- }
- if(must_exist){
- dojo.raise("no loaded module named '" + modulename + "'");
- }
- return null;
- }
-
- /**
- * @file hostenv_browser.js
- *
- * Implements the hostenv interface for a browser environment.
- *
- * Perhaps it could be called a "dom" or "useragent" environment.
- *
- * @author Copyright 2004 Mark D. Anderson (mda@discerning.com)
- * @author Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php
- */
- // make jsc shut up (so we can use jsc to sanity check the code even if it will never run it).
- /*@cc_on
- @if (@_jscript_version >= 7)
- var window; var XMLHttpRequest;
- @end
- @*/
- if(typeof window == 'undefined'){
- dojo.raise("no window object");
- }
- // attempt to figure out the path to dojo if it isn't set in the config
- (function() {
- // before we get any further with the config options, try to pick them out
- // of the URL. Most of this code is from NW
- if(djConfig.allowQueryConfig){
- var baseUrl = document.location.toString(); // FIXME: use location.query instead?
- var params = baseUrl.split("?", 2);
- if(params.length > 1){
- var paramStr = params[1];
- var pairs = paramStr.split("&");
- for(var x in pairs){
- var sp = pairs[x].split("=");
- // FIXME: is this eval dangerous?
- if((sp[0].length > 9)&&(sp[0].substr(0, 9) == "djConfig.")){
- var opt = sp[0].substr(9);
- try{
- djConfig[opt]=eval(sp[1]);
- }catch(e){
- djConfig[opt]=sp[1];
- }
- }
- }
- }
- }
- if(((djConfig["baseScriptUri"] == "")||(djConfig["baseRelativePath"] == "")) &&(document && document.getElementsByTagName)){
- var scripts = document.getElementsByTagName("script");
- var rePkg = /(__package__|dojo)\.js(\?|$)/i;
- for(var i = 0; i < scripts.length; i++) {
- var src = scripts[i].getAttribute("src");
- if(!src) { continue; }
- var m = src.match(rePkg);
- if(m) {
- root = src.substring(0, m.index);
- if(!this["djConfig"]) { djConfig = {}; }
- if(djConfig["baseScriptUri"] == "") { djConfig["baseScriptUri"] = root; }
- if(djConfig["baseRelativePath"] == "") { djConfig["baseRelativePath"] = root; }
- break;
- }
- }
- }
- var dr = dojo.render;
- var drh = dojo.render.html;
- var dua = drh.UA = navigator.userAgent;
- var dav = drh.AV = navigator.appVersion;
- var t = true;
- var f = false;
- drh.capable = t;
- drh.support.builtin = t;
- dr.ver = parseFloat(drh.AV);
- dr.os.mac = dav.indexOf("Macintosh") >= 0;
- dr.os.win = dav.indexOf("Windows") >= 0;
- // could also be Solaris or something, but it's the same browser
- dr.os.linux = dav.indexOf("X11") >= 0;
- drh.opera = dua.indexOf("Opera") >= 0;
- drh.khtml = (dav.indexOf("Konqueror") >= 0)||(dav.indexOf("Safari") >= 0);
- drh.safari = dav.indexOf("Safari") >= 0;
- var geckoPos = dua.indexOf("Gecko");
- drh.mozilla = drh.moz = (geckoPos >= 0)&&(!drh.khtml);
- if (drh.mozilla) {
- // gecko version is YYYYMMDD
- drh.geckoVersion = dua.substring(geckoPos + 6, geckoPos + 14);
- }
- drh.ie = (document.all)&&(!drh.opera);
- drh.ie50 = drh.ie && dav.indexOf("MSIE 5.0")>=0;
- drh.ie55 = drh.ie && dav.indexOf("MSIE 5.5")>=0;
- drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0")>=0;
- dr.vml.capable=drh.ie;
- dr.svg.capable = f;
- dr.svg.support.plugin = f;
- dr.svg.support.builtin = f;
- dr.svg.adobe = f;
- if (document.implementation
- && document.implementation.hasFeature
- && document.implementation.hasFeature("org.w3c.dom.svg", "1.0")
- ){
- dr.svg.capable = t;
- dr.svg.support.builtin = t;
- dr.svg.support.plugin = f;
- dr.svg.adobe = f;
- }else{
- // check for ASVG
- if(navigator.mimeTypes && navigator.mimeTypes.length > 0){
- var result = navigator.mimeTypes["image/svg+xml"] ||
- navigator.mimeTypes["image/svg"] ||
- navigator.mimeTypes["image/svg-xml"];
- if (result){
- dr.svg.adobe = result && result.enabledPlugin &&
- result.enabledPlugin.description &&
- (result.enabledPlugin.description.indexOf("Adobe") > -1);
- if(dr.svg.adobe) {
- dr.svg.capable = t;
- dr.svg.support.plugin = t;
- }
- }
- }else if(drh.ie && dr.os.win){
- var result = f;
- try {
- var test = new ActiveXObject("Adobe.SVGCtl");
- result = t;
- } catch(e){}
- if (result){
- dr.svg.capable = t;
- dr.svg.support.plugin = t;
- dr.svg.adobe = t;
- }
- }else{
- dr.svg.capable = f;
- dr.svg.support.plugin = f;
- dr.svg.adobe = f;
- }
- }
- })();
- dojo.hostenv.startPackage("dojo.hostenv");
- dojo.hostenv.name_ = 'browser';
- dojo.hostenv.searchIds = [];
- // These are in order of decreasing likelihood; this will change in time.
- var DJ_XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
- dojo.hostenv.getXmlhttpObject = function(){
- var http = null;
- var last_e = null;
- try{ http = new XMLHttpRequest(); }catch(e){}
- if(!http){
- for(var i=0; i<3; ++i){
- var progid = DJ_XMLHTTP_PROGIDS[i];
- try{
- http = new ActiveXObject(progid);
- }catch(e){
- last_e = e;
- }
- if(http){
- DJ_XMLHTTP_PROGIDS = [progid]; // so faster next time
- break;
- }
- }
- /*if(http && !http.toString) {
- http.toString = function() { "[object XMLHttpRequest]"; }
- }*/
- }
- if(!http){
- return dojo.raise("XMLHTTP not available", last_e);
- }
- return http;
- }
- /**
- * Read the contents of the specified uri and return those contents.
- *
- * @param uri A relative or absolute uri. If absolute, it still must be in the
- * same "domain" as we are.
- *
- * @param async_cb If not specified, load synchronously. If specified, load
- * asynchronously, and use async_cb as the progress handler which takes the
- * xmlhttp object as its argument. If async_cb, this function returns null.
- *
- * @param fail_ok Default false. If fail_ok and !async_cb and loading fails,
- * return null instead of throwing.
- */
- dojo.hostenv.getText = function(uri, async_cb, fail_ok){
-
- var http = this.getXmlhttpObject();
- if(async_cb){
- http.onreadystatechange = function(){
- if((4==http.readyState)&&(http["status"])){
- if(http.status==200){
- dojo.debug("LOADED URI: "+uri);
- async_cb(http.responseText);
- }
- }
- }
- }
- http.open('GET', uri, async_cb ? true : false);
- http.send(null);
- if(async_cb){
- return null;
- }
-
- return http.responseText;
- }
- /*
- * It turns out that if we check *right now*, as this script file is being loaded,
- * then the last script element in the window DOM is ourselves.
- * That is because any subsequent script elements haven't shown up in the document
- * object yet.
- */
- /*
- function dj_last_script_src() {
- var scripts = window.document.getElementsByTagName('script');
- if(scripts.length < 1){
- dojo.raise("No script elements in window.document, so can't figure out my script src");
- }
- var script = scripts[scripts.length - 1];
- var src = script.src;
- if(!src){
- dojo.raise("Last script element (out of " + scripts.length + ") has no src");
- }
- return src;
- }
- if(!dojo.hostenv["library_script_uri_"]){
- dojo.hostenv.library_script_uri_ = dj_last_script_src();
- }
- */
- dojo.hostenv.defaultDebugContainerId = 'dojoDebug';
- dojo.hostenv._println_buffer = [];
- dojo.hostenv._println_safe = false;
- dojo.hostenv.println = function (line){
- if(!dojo.hostenv._println_safe){
- dojo.hostenv._println_buffer.push(line);
- }else{
- try {
- var console = document.getElementById(djConfig.debugContainerId ?
- djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId);
- if(!console) { console = document.getElementsByTagName("body")[0] || document.body; }
- var div = document.createElement("div");
- div.appendChild(document.createTextNode(line));
- console.appendChild(div);
- } catch (e) {
- try{
- // safari needs the output wrapped in an element for some reason
- document.write("<div>" + line + "</div>");
- }catch(e2){
- window.status = line;
- }
- }
- }
- }
- dojo.addOnLoad(function(){
- dojo.hostenv._println_safe = true;
- while(dojo.hostenv._println_buffer.length > 0){
- dojo.hostenv.println(dojo.hostenv._println_buffer.shift());
- }
- });
- function dj_addNodeEvtHdlr (node, evtName, fp, capture){
- var oldHandler = node["on"+evtName] || function(){};
- node["on"+evtName] = function(){
- fp.apply(node, arguments);
- oldHandler.apply(node, arguments);
- }
- return true;
- }
- dj_addNodeEvtHdlr(window, "load", function(){
- if(dojo.render.html.ie){
- dojo.hostenv.makeWidgets();
- }
- dojo.hostenv.modulesLoaded();
- });
- dojo.hostenv.makeWidgets = function(){
- // you can put searchIds in djConfig and dojo.hostenv at the moment
- // we should probably eventually move to one or the other
- var sids = [];
- if(djConfig.searchIds && djConfig.searchIds.length > 0) {
- sids = sids.concat(djConfig.searchIds);
- }
- if(dojo.hostenv.searchIds && dojo.hostenv.searchIds.length > 0) {
- sids = sids.concat(dojo.hostenv.searchIds);
- }
- if((djConfig.parseWidgets)||(sids.length > 0)){
- if(dojo.evalObjPath("dojo.widget.Parse")){
- // we must do this on a delay to avoid:
- // http://www.shaftek.org/blog/archives/000212.html
- // IE is such a tremendous peice of shit.
- try{
- var parser = new dojo.xml.Parse();
- if(sids.length > 0){
- for(var x=0; x<sids.length; x++){
- var tmpNode = document.getElementById(sids[x]);
- if(!tmpNode){ continue; }
- var frag = parser.parseElement(tmpNode, null, true);
- dojo.widget.getParser().createComponents(frag);
- }
- }else if(djConfig.parseWidgets){
- var frag = parser.parseElement(document.getElementsByTagName("body")[0] || document.body, null, true);
- dojo.widget.getParser().createComponents(frag);
- }
- }catch(e){
- dojo.debug("auto-build-widgets error:", e);
- }
- }
- }
- }
- dojo.hostenv.modulesLoadedListeners.push(function(){
- if(!dojo.render.html.ie) {
- dojo.hostenv.makeWidgets();
- }
- });
- // we assume that we haven't hit onload yet. Lord help us.
- try {
- if (!window["djConfig"] || !window.djConfig["preventBackButtonFix"]){
- 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>");
- }
- if (dojo.render.html.ie) {
- document.write('<style>v\:*{ behavior:url(#default#VML); }</style>');
- document.write('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>');
- }
- } catch (e) { }
- // stub, over-ridden by debugging code. This will at least keep us from
- // breaking when it's not included
- dojo.hostenv.writeIncludes = function(){}
- dojo.hostenv.byId = dojo.byId = function(id, doc){
- if(typeof id == "string" || id instanceof String){
- if(!doc){ doc = document; }
- return doc.getElementById(id);
- }
- return id; // assume it's a node
- }
- dojo.hostenv.byIdArray = dojo.byIdArray = function(){
- var ids = [];
- for(var i = 0; i < arguments.length; i++){
- if((arguments[i] instanceof Array)||(typeof arguments[i] == "array")){
- for(var j = 0; j < arguments[i].length; j++){
- ids = ids.concat(dojo.hostenv.byIdArray(arguments[i][j]));
- }
- }else{
- ids.push(dojo.hostenv.byId(arguments[i]));
- }
- }
- return ids;
- }
-
- /*
- * bootstrap2.js - runs after the hostenv_*.js file.
- */
- /*
- * This method taks a "map" of arrays which one can use to optionally load dojo
- * modules. The map is indexed by the possible dojo.hostenv.name_ values, with
- * two additional values: "default" and "common". The items in the "default"
- * array will be loaded if none of the other items have been choosen based on
- * the hostenv.name_ item. The items in the "common" array will _always_ be
- * loaded, regardless of which list is chosen. Here's how it's normally
- * called:
- *
- * dojo.hostenv.conditionalLoadModule({
- * browser: [
- * ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule()
- * "foo.sample.*",
- * "foo.test,
- * ],
- * default: [ "foo.sample.*" ],
- * common: [ "really.important.module.*" ]
- * });
- */
- dojo.hostenv.conditionalLoadModule = function(modMap){
- var common = modMap["common"]||[];
- var result = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
- for(var x=0; x<result.length; x++){
- var curr = result[x];
- if(curr.constructor == Array){
- dojo.hostenv.loadModule.apply(dojo.hostenv, curr);
- }else{
- dojo.hostenv.loadModule(curr);
- }
- }
- }
- dojo.hostenv.require = dojo.hostenv.loadModule;
- dojo.require = function(){
- dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
- }
- dojo.requireAfter = dojo.require;
- dojo.requireIf = function(){
- if((arguments[0] === true)||(arguments[0]=="common")||(dojo.render[arguments[0]].capable)){
- var args = [];
- for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
- dojo.require.apply(dojo, args);
- }
- }
- dojo.requireAfterIf = dojo.requireIf;
- dojo.conditionalRequire = dojo.requireIf;
- dojo.kwCompoundRequire = function(){
- dojo.hostenv.conditionalLoadModule.apply(dojo.hostenv, arguments);
- }
- dojo.hostenv.provide = dojo.hostenv.startPackage;
- dojo.provide = function(){
- return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
- }
- dojo.setModulePrefix = function(module, prefix){
- return dojo.hostenv.setModulePrefix(module, prefix);
- }
- // stub
- dojo.profile = { start: function(){}, end: function(){}, dump: function(){} };
- // determine if an object supports a given method
- // useful for longer api chains where you have to test each object in the chain
- dojo.exists = function(obj, name){
- var p = name.split(".");
- for(var i = 0; i < p.length; i++){
- if(!(obj[p[i]])) return false;
- obj = obj[p[i]];
- }
- return true;
- }
-
- dojo.provide("dojo.lang");
- dojo.provide("dojo.AdapterRegistry");
- dojo.provide("dojo.lang.Lang");
- dojo.lang.mixin = function(obj, props, tobj){
- if(typeof tobj != "object") {
- tobj = {};
- }
- for(var x in props){
- if(typeof tobj[x] == "undefined" || tobj[x] != props[x]) {
- obj[x] = props[x];
- }
- }
- return obj;
- }
- dojo.lang.extend = function(ctor, props){
- this.mixin(ctor.prototype, props);
- }
- dojo.lang.extendPrototype = function(obj, props){
- this.extend(obj.constructor, props);
- }
- dojo.lang.anonCtr = 0;
- dojo.lang.anon = {};
- dojo.lang.nameAnonFunc = function(anonFuncPtr, namespaceObj){
- var nso = (namespaceObj || dojo.lang.anon);
- if((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)){
- for(var x in nso){
- if(nso[x] === anonFuncPtr){
- return x;
- }
- }
- }
- var ret = "__"+dojo.lang.anonCtr++;
- while(typeof nso[ret] != "undefined"){
- ret = "__"+dojo.lang.anonCtr++;
- }
- nso[ret] = anonFuncPtr;
- return ret;
- }
- /**
- * Runs a function in a given scope (thisObject), can
- * also be used to preserve scope.
- *
- * hitch(foo, "bar"); // runs foo.bar() in the scope of foo
- * hitch(foo, myFunction); // runs myFunction in the scope of foo
- */
- dojo.lang.hitch = function(thisObject, method) {
- if(dojo.lang.isString(method)) {
- var fcn = thisObject[method];
- } else {
- var fcn = method;
- }
- return function() {
- return fcn.apply(thisObject, arguments);
- }
- }
- /**
- * Sets a timeout in milliseconds to execute a function in a given context
- * with optional arguments.
- *
- * setTimeout (Object context, function func, number delay[, arg1[, ...]]);
- * setTimeout (function func, number delay[, arg1[, ...]]);
- */
- dojo.lang.setTimeout = function(func, delay){
- var context = window, argsStart = 2;
- if(!dojo.lang.isFunction(func)){
- context = func;
- func = delay;
- delay = arguments[2];
- argsStart++;
- }
- if(dojo.lang.isString(func)){
- func = context[func];
- }
-
- var args = [];
- for (var i = argsStart; i < arguments.length; i++) {
- args.push(arguments[i]);
- }
- return setTimeout(function () { func.apply(context, args); }, delay);
- }
- /**
- * Partial implmentation of is* functions from
- * http://www.crockford.com/javascript/recommend.html
- * NOTE: some of these may not be the best thing to use in all situations
- * as they aren't part of core JS and therefore can't work in every case.
- * See WARNING messages inline for tips.
- *
- * The following is* functions are fairly "safe"
- */
- dojo.lang.isObject = function(wh) {
- return typeof wh == "object" || dojo.lang.isArray(wh) || dojo.lang.isFunction(wh);
- }
- dojo.lang.isArray = function(wh) {
- return (wh instanceof Array || typeof wh == "array");
- }
- dojo.lang.isArrayLike = function(wh) {
- if(dojo.lang.isString(wh)){ return false; }
- if(dojo.lang.isArray(wh)){ return true; }
- if(dojo.lang.isNumber(wh.length) && isFinite(wh)){ return true; }
- return false;
- }
- dojo.lang.isFunction = function(wh) {
- return (wh instanceof Function || typeof wh == "function");
- }
- dojo.lang.isString = function(wh) {
- return (wh instanceof String || typeof wh == "string");
- }
- dojo.lang.isAlien = function(wh) {
- return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(wh));
- }
- dojo.lang.isBoolean = function(wh) {
- return (wh instanceof Boolean || typeof wh == "boolean");
- }
- /**
- * The following is***() functions are somewhat "unsafe". Fortunately,
- * there are workarounds the the language provides and are mentioned
- * in the WARNING messages.
- *
- * WARNING: In most cases, isNaN(wh) is sufficient to determine whether or not
- * something is a number or can be used as such. For example, a number or string
- * can be used interchangably when accessing array items (arr["1"] is the same as
- * arr[1]) and isNaN will return false for both values ("1" and 1). Should you
- * use isNumber("1"), that will return false, which is generally not too useful.
- * Also, isNumber(NaN) returns true, again, this isn't generally useful, but there
- * are corner cases (like when you want to make sure that two things are really
- * the same type of thing). That is really where isNumber "shines".
- *
- * RECOMMENDATION: Use isNaN(wh) when possible
- */
- dojo.lang.isNumber = function(wh) {
- return (wh instanceof Number || typeof wh == "number");
- }
- /**
- * WARNING: In some cases, isUndefined will not behave as you
- * might expect. If you do isUndefined(foo) and there is no earlier
- * reference to foo, an error will be thrown before isUndefined is
- * called. It behaves correctly if you scope yor object first, i.e.
- * isUndefined(foo.bar) where foo is an object and bar isn't a
- * property of the object.
- *
- * RECOMMENDATION: Use `typeof foo == "undefined"` when possible
- *
- * FIXME: Should isUndefined go away since it is error prone?
- */
- dojo.lang.isUndefined = function(wh) {
- return ((wh == undefined)&&(typeof wh == "undefined"));
- }
- // end Crockford functions
- dojo.lang.whatAmI = function(wh) {
- try {
- if(dojo.lang.isArray(wh)) { return "array"; }
- if(dojo.lang.isFunction(wh)) { return "function"; }
- if(dojo.lang.isString(wh)) { return "string"; }
- if(dojo.lang.isNumber(wh)) { return "number"; }
- if(dojo.lang.isBoolean(wh)) { return "boolean"; }
- if(dojo.lang.isAlien(wh)) { return "alien"; }
- if(dojo.lang.isUndefined(wh)) { return "undefined"; }
- // FIXME: should this go first?
- for(var name in dojo.lang.whatAmI.custom) {
- if(dojo.lang.whatAmI.custom[name](wh)) {
- return name;
- }
- }
- if(dojo.lang.isObject(wh)) { return "object"; }
- } catch(E) {}
- return "unknown";
- }
- /*
- * dojo.lang.whatAmI.custom[typeName] = someFunction
- * will return typeName is someFunction(wh) returns true
- */
- dojo.lang.whatAmI.custom = {};
- dojo.lang.find = function(arr, val, identity){
- // support both (arr, val) and (val, arr)
- if(!dojo.lang.isArray(arr) && dojo.lang.isArray(val)) {
- var a = arr;
- arr = val;
- val = a;
- }
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- if(identity){
- for(var i=0;i<arr.length;++i){
- if(arr[i] === val){ return i; }
- }
- }else{
- for(var i=0;i<arr.length;++i){
- if(arr[i] == val){ return i; }
- }
- }
- return -1;
- }
- dojo.lang.indexOf = dojo.lang.find;
- dojo.lang.findLast = function(arr, val, identity) {
- // support both (arr, val) and (val, arr)
- if(!dojo.lang.isArray(arr) && dojo.lang.isArray(val)) {
- var a = arr;
- arr = val;
- val = a;
- }
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- if(identity){
- for(var i = arr.length-1; i >= 0; i--) {
- if(arr[i] === val){ return i; }
- }
- }else{
- for(var i = arr.length-1; i >= 0; i--) {
- if(arr[i] == val){ return i; }
- }
- }
- return -1;
- }
- dojo.lang.lastIndexOf = dojo.lang.findLast;
- dojo.lang.inArray = function(arr, val){
- return dojo.lang.find(arr, val) > -1;
- }
- dojo.lang.getNameInObj = function(ns, item){
- if(!ns){ ns = dj_global; }
- for(var x in ns){
- if(ns[x] === item){
- return new String(x);
- }
- }
- return null;
- }
- // FIXME: Is this worthless since you can do: if(name in obj)
- // is this the right place for this?
- dojo.lang.has = function(obj, name){
- return (typeof obj[name] !== 'undefined');
- }
- dojo.lang.isEmpty = function(obj) {
- if(dojo.lang.isObject(obj)) {
- var tmp = {};
- var count = 0;
- for(var x in obj){
- if(obj[x] && (!tmp[x])){
- count++;
- break;
- }
- }
- return (count == 0);
- } else if(dojo.lang.isArray(obj) || dojo.lang.isString(obj)) {
- return obj.length == 0;
- }
- }
- dojo.lang.forEach = function(arr, unary_func, fix_length){
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- var il = arr.length;
- for(var i=0; i< ((fix_length) ? il : arr.length); i++){
- if(unary_func(arr[i], i, arr) == "break"){
- break;
- }
- }
- }
- dojo.lang.map = function(arr, obj, unary_func){
- var isString = dojo.lang.isString(arr);
- if(isString){
- arr = arr.split("");
- }
- if(dojo.lang.isFunction(obj)&&(!unary_func)){
- unary_func = obj;
- obj = dj_global;
- }else if(dojo.lang.isFunction(obj) && unary_func){
- // ff 1.5 compat
- var tmpObj = obj;
- obj = unary_func;
- unary_func = tmpObj;
- }
- if(Array.map){
- var outArr = Array.map(arr, unary_func, obj);
- }else{
- var outArr = [];
- for(var i=0;i<arr.length;++i){
- outArr.push(unary_func.call(obj, arr[i]));
- }
- }
- if(isString) {
- return outArr.join("");
- } else {
- return outArr;
- }
- }
- dojo.lang.tryThese = function(){
- for(var x=0; x<arguments.length; x++){
- try{
- if(typeof arguments[x] == "function"){
- var ret = (arguments[x]());
- if(ret){
- return ret;
- }
- }
- }catch(e){
- dojo.debug(e);
- }
- }
- }
- dojo.lang.delayThese = function(farr, cb, delay, onend){
- /**
- * alternate: (array funcArray, function callback, function onend)
- * alternate: (array funcArray, function callback)
- * alternate: (array funcArray)
- */
- if(!farr.length){
- if(typeof onend == "function"){
- onend();
- }
- return;
- }
- if((typeof delay == "undefined")&&(typeof cb == "number")){
- delay = cb;
- cb = function(){};
- }else if(!cb){
- cb = function(){};
- if(!delay){ delay = 0; }
- }
- setTimeout(function(){
- (farr.shift())();
- cb();
- dojo.lang.delayThese(farr, cb, delay, onend);
- }, delay);
- }
- dojo.lang.shallowCopy = function(obj) {
- var ret = {}, key;
- for(key in obj) {
- if(dojo.lang.isUndefined(ret[key])) {
- ret[key] = obj[key];
- }
- }
- return ret;
- }
- dojo.lang.every = function(arr, callback, thisObject) {
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- if(Array.every) {
- return Array.every(arr, callback, thisObject);
- } else {
- if(!thisObject) {
- if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
- thisObject = dj_global;
- }
- for(var i = 0; i < arr.length; i++) {
- if(!callback.call(thisObject, arr[i], i, arr)) {
- return false;
- }
- }
- return true;
- }
- }
- dojo.lang.some = function(arr, callback, thisObject) {
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- if(Array.some) {
- return Array.some(arr, callback, thisObject);
- } else {
- if(!thisObject) {
- if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
- thisObject = dj_global;
- }
- for(var i = 0; i < arr.length; i++) {
- if(callback.call(thisObject, arr[i], i, arr)) {
- return true;
- }
- }
- return false;
- }
- }
- dojo.lang.filter = function(arr, callback, thisObject) {
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- if(Array.filter) {
- var outArr = Array.filter(arr, callback, thisObject);
- } else {
- if(!thisObject) {
- if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
- thisObject = dj_global;
- }
- var outArr = [];
- for(var i = 0; i < arr.length; i++) {
- if(callback.call(thisObject, arr[i], i, arr)) {
- outArr.push(arr[i]);
- }
- }
- }
- if(isString) {
- return outArr.join("");
- } else {
- return outArr;
- }
- }
- dojo.AdapterRegistry = function(){
- /***
- A registry to facilitate adaptation.
- Pairs is an array of [name, check, wrap] triples
-
- All check/wrap functions in this registry should be of the same arity.
- ***/
- this.pairs = [];
- }
- dojo.lang.extend(dojo.AdapterRegistry, {
- register: function (name, check, wrap, /* optional */ override){
- /***
- The check function should return true if the given arguments are
- appropriate for the wrap function.
- If override is given and true, the check function will be given
- highest priority. Otherwise, it will be the lowest priority
- adapter.
- ***/
- if (override) {
- this.pairs.unshift([name, check, wrap]);
- } else {
- this.pairs.push([name, check, wrap]);
- }
- },
- match: function (/* ... */) {
- /***
- Find an adapter for the given arguments.
- If no suitable adapter is found, throws NotFound.
- ***/
- for(var i = 0; i < this.pairs.length; i++){
- var pair = this.pairs[i];
- if(pair[1].apply(this, arguments)){
- return pair[2].apply(this, arguments);
- }
- }
- dojo.raise("No match found");
- },
- unregister: function (name) {
- /***
- Remove a named adapter from the registry
- ***/
- for(var i = 0; i < this.pairs.length; i++){
- var pair = this.pairs[i];
- if(pair[0] == name){
- this.pairs.splice(i, 1);
- return true;
- }
- }
- return false;
- }
- });
- dojo.lang.reprRegistry = new dojo.AdapterRegistry();
- dojo.lang.registerRepr = function(name, check, wrap, /*optional*/ override){
- /***
- Register a repr function. repr functions should take
- one argument and return a string representation of it
- suitable for developers, primarily used when debugging.
- If override is given, it is used as the highest priority
- repr, otherwise it will be used as the lowest.
- ***/
- dojo.lang.reprRegistry.register(name, check, wrap, override);
- };
- dojo.lang.repr = function(obj){
- /***
- Return a "programmer representation" for an object
- ***/
- if(typeof(obj) == "undefined"){
- return "undefined";
- }else if(obj === null){
- return "null";
- }
- try{
- if(typeof(obj["__repr__"]) == 'function'){
- return obj["__repr__"]();
- }else if((typeof(obj["repr"]) == 'function')&&(obj.repr != arguments.callee)){
- return obj["repr"]();
- }
- return dojo.lang.reprRegistry.match(obj);
- }catch(e){
- if(typeof(obj.NAME) == 'string' && (
- obj.toString == Function.prototype.toString ||
- obj.toString == Object.prototype.toString
- )){
- return o.NAME;
- }
- }
- if(typeof(obj) == "function"){
- obj = (obj + "").replace(/^\s+/, "");
- var idx = obj.indexOf("{");
- if(idx != -1){
- obj = obj.substr(0, idx) + "{...}";
- }
- }
- return obj + "";
- }
- dojo.lang.reprArrayLike = function(arr){
- try{
- var na = dojo.lang.map(arr, dojo.lang.repr);
- return "[" + na.join(", ") + "]";
- }catch(e){ }
- };
- dojo.lang.reprString = function(str){
- return ('"' + str.replace(/(["\\])/g, '\\$1') + '"'
- ).replace(/[\f]/g, "\\f"
- ).replace(/[\b]/g, "\\b"
- ).replace(/[\n]/g, "\\n"
- ).replace(/[\t]/g, "\\t"
- ).replace(/[\r]/g, "\\r");
- };
- dojo.lang.reprNumber = function(num){
- return num + "";
- };
- (function(){
- var m = dojo.lang;
- m.registerRepr("arrayLike", m.isArrayLike, m.reprArrayLike);
- m.registerRepr("string", m.isString, m.reprString);
- m.registerRepr("numbers", m.isNumber, m.reprNumber);
- m.registerRepr("boolean", m.isBoolean, m.reprNumber);
- // m.registerRepr("numbers", m.typeMatcher("number", "boolean"), m.reprNumber);
- })();
- /**
- * Creates a 1-D array out of all the arguments passed,
- * unravelling any array-like objects in the process
- *
- * Ex:
- * unnest(1, 2, 3) ==> [1, 2, 3]
- * unnest(1, [2, [3], [[[4]]]]) ==> [1, 2, 3, 4]
- */
- dojo.lang.unnest = function(/* ... */) {
- var out = [];
- for(var i = 0; i < arguments.length; i++) {
- if(dojo.lang.isArrayLike(arguments[i])) {
- var add = dojo.lang.unnest.apply(this, arguments[i]);
- out = out.concat(add);
- } else {
- out.push(arguments[i]);
- }
- }
- return out;
- }
-
- dojo.provide("dojo.string");
- dojo.require("dojo.lang");
- /**
- * Trim whitespace from 'str'. If 'wh' > 0,
- * only trim from start, if 'wh' < 0, only trim
- * from end, otherwise trim both ends
- */
- dojo.string.trim = function(str, wh){
- if(!dojo.lang.isString(str)){ return str; }
- if(!str.length){ return str; }
- if(wh > 0) {
- return str.replace(/^\s+/, "");
- } else if(wh < 0) {
- return str.replace(/\s+$/, "");
- } else {
- return str.replace(/^\s+|\s+$/g, "");
- }
- }
- /**
- * Trim whitespace at the beginning of 'str'
- */
- dojo.string.trimStart = function(str) {
- return dojo.string.trim(str, 1);
- }
- /**
- * Trim whitespace at the end of 'str'
- */
- dojo.string.trimEnd = function(str) {
- return dojo.string.trim(str, -1);
- }
- /**
- * Parameterized string function
- * str - formatted string with %{values} to be replaces
- * pairs - object of name: "value" value pairs
- * killExtra - remove all remaining %{values} after pairs are inserted
- */
- dojo.string.paramString = function(str, pairs, killExtra) {
- for(var name in pairs) {
- var re = new RegExp("\\%\\{" + name + "\\}", "g");
- str = str.replace(re, pairs[name]);
- }
- if(killExtra) { str = str.replace(/%\{([^\}\s]+)\}/g, ""); }
- return str;
- }
- /** Uppercases the first letter of each word */
- dojo.string.capitalize = function (str) {
- if (!dojo.lang.isString(str)) { return ""; }
- if (arguments.length == 0) { str = this; }
- var words = str.split(' ');
- var retval = "";
- var len = words.length;
- for (var i=0; i<len; i++) {
- var word = words[i];
- word = word.charAt(0).toUpperCase() + word.substring(1, word.length);
- retval += word;
- if (i < len-1)
- retval += " ";
- }
-
- return new String(retval);
- }
- /**
- * Return true if the entire string is whitespace characters
- */
- dojo.string.isBlank = function (str) {
- if(!dojo.lang.isString(str)) { return true; }
- return (dojo.string.trim(str).length == 0);
- }
- dojo.string.encodeAscii = function(str) {
- if(!dojo.lang.isString(str)) { return str; }
- var ret = "";
- var value = escape(str);
- var match, re = /%u([0-9A-F]{4})/i;
- while((match = value.match(re))) {
- var num = Number("0x"+match[1]);
- var newVal = escape("&#" + num + ";");
- ret += value.substring(0, match.index) + newVal;
- value = value.substring(match.index+match[0].length);
- }
- ret += value.replace(/\+/g, "%2B");
- return ret;
- }
- // TODO: make an HTML version
- dojo.string.summary = function(str, len) {
- if(!len || str.length <= len) {
- return str;
- } else {
- return str.substring(0, len).replace(/\.+$/, "") + "...";
- }
- }
- dojo.string.escape = function(type, str) {
- switch(type.toLowerCase()) {
- case "xml":
- case "html":
- case "xhtml":
- return dojo.string.escapeXml(str);
- case "sql":
- return dojo.string.escapeSql(str);
- case "regexp":
- case "regex":
- return dojo.string.escapeRegExp(str);
- case "javascript":
- case "jscript":
- case "js":
- return dojo.string.escapeJavaScript(str);
- case "ascii":
- // so it's encode, but it seems useful
- return dojo.string.encodeAscii(str);
- default:
- return str;
- }
- }
- dojo.string.escapeXml = function(str) {
- return str.replace(/&/gm, "&").replace(/</gm, "<")
- .replace(/>/gm, ">").replace(/"/gm, """).replace(/'/gm, "'");
- }
- dojo.string.escapeSql = function(str) {
- return str.replace(/'/gm, "''");
- }
- dojo.string.escapeRegExp = function(str) {
- return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n…
Large files files are truncated, but you can click here to view the full file