You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2006/11/10 10:15:40 UTC
svn commit: r473277 [4/45] - in
/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/c...
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/dojo.js.uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/dojo.js.uncompressed.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/dojo.js.uncompressed.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/dojo.js.uncompressed.js Fri Nov 10 01:15:01 2006
@@ -10,7 +10,7 @@
* TODOC: should the copyright be changed to Dojo Foundation?
* @license Licensed under the Academic Free License 2.1 http://www.opensource.org/licenses/afl-2.1.php
*
-* $Id: bootstrap1.js 4342 2006-06-11 23:03:30Z alex $
+* $Id: bootstrap1.js 6258 2006-10-20 03:12:36Z jburke $
*/
// TODOC: HOW TO DOC THE BELOW?
@@ -26,6 +26,8 @@
// - libraryScriptUri: ""
// - iePreventClobber: false
// - ieClobberMinimal: true
+// - locale: undefined
+// - extraLocale: undefined
// - preventBackButtonFix: true
// - searchIds: []
// - parseWidgets: true
@@ -40,7 +42,6 @@
//
-
//TODOC: HOW TO DOC THIS?
// @global: dj_global
// summary:
@@ -51,34 +52,58 @@
// code runs correctly in contexts other than web browsers (eg: Rhino on a server).
var dj_global = this;
+//TODOC: HOW TO DOC THIS?
+// @global: dj_currentContext
+// summary:
+// Private global context object. Where 'dj_global' always refers to the boot-time
+// global context, 'dj_currentContext' can be modified for temporary context shifting.
+// dojo.global() returns dj_currentContext.
+// description:
+// Refer to dojo.global() rather than referring to dj_global to ensure your
+// code runs correctly in managed contexts.
+var dj_currentContext = this;
+
+// ****************************************************************
+// global public utils
+// TODOC: DO WE WANT TO NOTE THAT THESE ARE GLOBAL PUBLIC UTILS?
+// ****************************************************************
function dj_undef(/*String*/ name, /*Object?*/ object){
//summary: Returns true if 'name' is defined on 'object' (or globally if 'object' is null).
//description: Note that 'defined' and 'exists' are not the same concept.
- if(object==null){ object = dj_global; }
- // exception if object is not an Object
- return (typeof object[name] == "undefined"); // Boolean
+ return (typeof (object || dj_currentContext)[name] == "undefined"); // Boolean
}
-
// make sure djConfig is defined
-if(dj_undef("djConfig")){
+if(dj_undef("djConfig", this)){
var djConfig = {};
}
-
//TODOC: HOW TO DOC THIS?
// dojo is the root variable of (almost all) our public symbols -- make sure it is defined.
-if(dj_undef("dojo")){
+if(dj_undef("dojo", this)){
var dojo = {};
}
+dojo.global = function(){
+ // summary:
+ // return the current global context object
+ // (e.g., the window object in a browser).
+ // description:
+ // Refer to 'dojo.global()' rather than referring to window to ensure your
+ // code runs correctly in contexts other than web browsers (eg: Rhino on a server).
+ return dj_currentContext;
+}
+
+// Override locale setting, if specified
+dojo.locale = djConfig.locale;
+
//TODOC: HOW TO DOC THIS?
dojo.version = {
// summary: version number of this instance of dojo.
- major: 0, minor: 3, patch: 1, flag: "",
- revision: Number("$Rev: 4342 $".match(/[0-9]+/)[0]),
+ major: 0, minor: 4, patch: 0, flag: "",
+ revision: Number("$Rev: 6258 $".match(/[0-9]+/)[0]),
toString: function(){
with(dojo.version){
return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String
@@ -91,19 +116,20 @@
// description:
// Returns null if 'object[name]' is not defined and 'create' is not true.
// Note: 'defined' and 'exists' are not the same concept.
- return (object && !dj_undef(name, object) ? object[name] : (create ? (object[name]={}) : undefined)); // mixed
+ if((!object)||(!name)) return undefined; // undefined
+ if(!dj_undef(name, object)) return object[name]; // mixed
+ return (create ? (object[name]={}) : undefined); // mixed
}
-
dojo.parseObjPath = function(/*String*/ path, /*Object?*/ context, /*Boolean?*/ create){
// summary: Parse string path to an object, and return corresponding object reference and property name.
// description:
// Returns an object with two properties, 'obj' and 'prop'.
// 'obj[prop]' is the reference indicated by 'path'.
// path: Path to an object, in the form "A.B.C".
- // context: Object to use as root of path. Defaults to 'dj_global'.
+ // context: Object to use as root of path. Defaults to 'dojo.global()'.
// create: If true, Objects will be created at any point along the 'path' that is undefined.
- var object = (context != null ? context : dj_global);
+ var object = (context || dojo.global());
var names = path.split('.');
var prop = names.pop();
for (var i=0,l=names.length;i<l && object;i++){
@@ -112,32 +138,26 @@
return {obj: object, prop: prop}; // Object: {obj: Object, prop: String}
}
-
dojo.evalObjPath = function(/*String*/ path, /*Boolean?*/ create){
// summary: Return the value of object at 'path' in the global scope, without using 'eval()'.
// path: Path to an object, in the form "A.B.C".
// create: If true, Objects will be created at any point along the 'path' that is undefined.
if(typeof path != "string"){
- return dj_global;
+ return dojo.global();
}
// fast path for no periods
if(path.indexOf('.') == -1){
- return dojo.evalProp(path, dj_global, create); // mixed
+ return dojo.evalProp(path, dojo.global(), create); // mixed
}
//MOW: old 'with' syntax was confusing and would throw an error if parseObjPath returned null.
- var ref = dojo.parseObjPath(path, dj_global, create);
+ var ref = dojo.parseObjPath(path, dojo.global(), create);
if(ref){
return dojo.evalProp(ref.prop, ref.obj, create); // mixed
}
return null;
}
-// ****************************************************************
-// global public utils
-// TODOC: DO WE WANT TO NOTE THAT THESE ARE GLOBAL PUBLIC UTILS?
-// ****************************************************************
-
dojo.errorToString = function(/*Error*/ exception){
// summary: Return an exception's 'message', 'description' or text.
@@ -152,27 +172,27 @@
}
}
-
dojo.raise = function(/*String*/ message, /*Error?*/ exception){
- // summary: Throw an error message, appending text of 'exception' if provided.
- // note: Also prints a message to the user using 'dojo.hostenv.println'.
+ // summary: Common point for raising exceptions in Dojo to enable logging.
+ // Throws an error message with text of 'exception' if provided, or
+ // rethrows exception object.
+
if(exception){
message = message + ": "+dojo.errorToString(exception);
}
// print the message to the user if hostenv.println is defined
- try { dojo.hostenv.println("FATAL: "+message); } catch (e) {}
+ try { if(djConfig.isDebug){ dojo.hostenv.println("FATAL exception raised: "+message); } } catch (e) {}
- throw Error(message);
+ throw exception || Error(message);
}
//Stub functions so things don't break.
//TODOC: HOW TO DOC THESE?
-dojo.debug = function(){}
-dojo.debugShallow = function(obj){}
+dojo.debug = function(){};
+dojo.debugShallow = function(obj){};
dojo.profile = { start: function(){}, end: function(){}, stop: function(){}, dump: function(){} };
-
function dj_eval(/*String*/ scriptFragment){
// summary: Perform an evaluation in the global scope. Use this rather than calling 'eval()' directly.
// description: Placed in a separate function to minimize size of trapped evaluation context.
@@ -183,8 +203,6 @@
return dj_global.eval ? dj_global.eval(scriptFragment) : eval(scriptFragment); // mixed
}
-
-
dojo.unimplemented = function(/*String*/ funcname, /*String?*/ extra){
// summary: Throw an exception because some function is not implemented.
// extra: Text to append to the exception message.
@@ -193,7 +211,6 @@
dojo.raise(message);
}
-
dojo.deprecated = function(/*String*/ behaviour, /*String?*/ extra, /*String?*/ removal){
// summary: Log a debug message to indicate that a behavior has been deprecated.
// extra: Text to append to the message.
@@ -204,20 +221,6 @@
dojo.debug(message);
}
-
-
-dojo.inherits = function(/*Function*/ subclass, /*Function*/ superclass){
- // summary: Set up inheritance between two classes.
- if(typeof superclass != 'function'){
- dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: [" + subclass + "']");
- }
- subclass.prototype = new superclass();
- subclass.prototype.constructor = subclass;
- subclass.superclass = superclass.prototype;
- // DEPRICATED: super is a reserved word, use 'superclass'
- subclass['super'] = superclass.prototype;
-}
-
dojo.render = (function(){
//TODOC: HOW TO DOC THIS?
// summary: Details rendering support, OS and browser of the current environment.
@@ -231,8 +234,8 @@
},
prefixes: prefs
};
- for(var prop in names){
- tmp[prop] = false;
+ for(var i=0; i<names.length; i++){
+ tmp[names[i]] = false;
}
return tmp;
}
@@ -278,6 +281,7 @@
iePreventClobber: false,
ieClobberMinimal: true,
preventBackButtonFix: true,
+ delayMozLoadingFix: false,
searchIds: [],
parseWidgets: true
};
@@ -341,7 +345,7 @@
}
/*
- * loader.js - runs before the hostenv_*.js file. Contains all of the package loading methods.
+ * loader.js - A bootstrap module. Runs before the hostenv_*.js file. Contains all of the package loading methods.
*/
//A semi-colon is at the start of the line because after doing a build, this function definition
@@ -366,18 +370,24 @@
modulePrefixes_: {
dojo: {name: "dojo", value: "src"}
},
-
-
- setModulePrefix: function(module, prefix){
+
+ setModulePrefix: function(/*String*/module, /*String*/prefix){
+ // summary: establishes module/prefix pair
this.modulePrefixes_[module] = {name: module, value: prefix};
},
-
- getModulePrefix: function(module){
+
+ moduleHasPrefix: function(/*String*/module){
+ // summary: checks to see if module has been established
var mp = this.modulePrefixes_;
- if((mp[module])&&(mp[module]["name"])){
- return mp[module].value;
+ return Boolean(mp[module] && mp[module].value); // Boolean
+ },
+
+ getModulePrefix: function(/*String*/module){
+ // summary: gets the prefix associated with module
+ if(this.moduleHasPrefix(module)){
+ return this.modulePrefixes_[module].value; // String
}
- return module;
+ return module; // String
},
getTextStack: [],
@@ -399,24 +409,27 @@
}
})();
-/**
- * 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.
- * @param cb a function to pass the result of evaluating the script (optional)
- */
-dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
+dojo.hostenv.loadPath = function(/*String*/relpath, /*String?*/module, /*Function?*/cb){
+// summary:
+// Load a Javascript module given a relative path
+//
+// description:
+// 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().
+//
+// relpath: A relative path to a script (no leading '/', and typically
+// ending in '.js').
+// module: A module whose existance to check for after loading a path.
+// Can be used to determine success or failure of the load.
+// cb: a callback function to pass the result of evaluating the script
+
var uri;
- if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){
+ if(relpath.charAt(0) == '/' || relpath.match(/^\w+:/)){
// dojo.raise("relpath '" + relpath + "'; must be relative");
uri = relpath;
}else{
@@ -426,46 +439,48 @@
uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,"");
}
try{
- return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
+ return !module ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb); // Boolean
}catch(e){
dojo.debug(e);
- return false;
+ return false; // Boolean
}
}
-/**
- * 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 TODO: now it is; was this a deliberate restriction?
- *
- * @param uri a uri which points at the script to be loaded
- * @param cb a function to process the result of evaluating the script as an expression (optional)
- */
-dojo.hostenv.loadUri = function(uri, cb /*optional*/){
+dojo.hostenv.loadUri = function(/*String (URL)*/uri, /*Function?*/cb){
+// summary:
+// Loads JavaScript from a URI
+//
+// description:
+// Reads the contents of the URI, and evaluates the contents. This is used to load modules as well
+// as resource bundles. Returns true if it succeeded. Returns false if the URI reading failed.
+// Throws if the evaluation throws.
+//
+// uri: a uri which points at the script to be loaded
+// cb: a callback function to process the result of evaluating the script as an expression, typically
+// used by the resource bundle loader to load JSON-style resources
+
if(this.loadedUris[uri]){
- return 1;
+ return true; // Boolean
}
var contents = this.getText(uri, null, true);
- if(contents == null){ return 0; }
+ if(!contents){ return false; } // Boolean
this.loadedUris[uri] = true;
if(cb){ contents = '('+contents+')'; }
var value = dj_eval(contents);
- if(cb){
- cb(value);
- }
- return 1;
+ if(cb){ cb(value); }
+ return true; // Boolean
}
// FIXME: probably need to add logging to this method
-dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
+dojo.hostenv.loadUriAndCheck = function(/*String (URL)*/uri, /*String*/moduleName, /*Function?*/cb){
+ // summary: calls loadUri then findModule and returns true if both succeed
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;
+ return Boolean(ok && this.findModule(moduleName, false)); // Boolean
}
dojo.loaded = function(){ }
@@ -495,18 +510,24 @@
dojo.unloaded();
}
-/*
-Call styles:
- dojo.addOnLoad(functionPointer)
- dojo.addOnLoad(object, "functionName")
-*/
-dojo.addOnLoad = function(obj, fcnName) {
+dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName) {
+// summary:
+// Registers a function to be triggered after the DOM has finished loading
+// and widgets declared in markup have been instantiated. Images and CSS files
+// may or may not have finished downloading when the specified function is called.
+// (Note that widgets' CSS and HTML code is guaranteed to be downloaded before said
+// widgets are instantiated.)
+//
+// usage:
+// dojo.addOnLoad(functionPointer)
+// dojo.addOnLoad(object, "functionName")
+
var dh = dojo.hostenv;
if(arguments.length == 1) {
dh.modulesLoadedListeners.push(obj);
} else if(arguments.length > 1) {
dh.modulesLoadedListeners.push(function() {
- obj[fcnName]();
+ obj[functionName]();
});
}
@@ -519,20 +540,25 @@
}
}
-dojo.addOnUnload = function(obj, fcnName){
+dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
+// summary: registers a function to be triggered when the page unloads
+//
+// usage:
+// dojo.addOnLoad(functionPointer)
+// dojo.addOnLoad(object, "functionName")
var dh = dojo.hostenv;
if(arguments.length == 1){
dh.unloadListeners.push(obj);
} else if(arguments.length > 1) {
dh.unloadListeners.push(function() {
- obj[fcnName]();
+ obj[functionName]();
});
}
}
dojo.hostenv.modulesLoaded = function(){
if(this.post_load_){ return; }
- if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
+ if(this.loadUriStack.length==0 && this.getTextStack.length==0){
if(this.inFlightCount > 0){
dojo.debug("files still in flight!");
return;
@@ -549,194 +575,214 @@
}
}
-dojo.hostenv.getModuleSymbols = function(modulename) {
+dojo.hostenv.getModuleSymbols = function(/*String*/modulename){
+// summary:
+// Converts a module name in dotted JS notation to an array representing the path in the source tree
+
var syms = modulename.split(".");
- for(var i = syms.length - 1; i > 0; i--){
+ for(var i = syms.length; i>0; i--){
var parentModule = syms.slice(0, i).join(".");
- var parentModulePath = this.getModulePrefix(parentModule);
- if(parentModulePath != parentModule){
- syms.splice(0, i, parentModulePath);
- break;
+ if ((i==1) && !this.moduleHasPrefix(parentModule)){
+ //Support default module directory (sibling of dojo)
+ syms[0] = "../" + syms[0];
+ }else{
+ var parentModulePath = this.getModulePrefix(parentModule);
+ if(parentModulePath != parentModule){
+ syms.splice(0, i, parentModulePath);
+ break;
+ }
}
}
- return syms;
+ return syms; // Array
}
-/**
-* 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){
- if(!modulename){ return; }
- omit_module_check = this._global_omit_module_check || omit_module_check;
- var module = this.findModule(modulename, false);
+dojo.hostenv.loadModule = function(/*String*/moduleName, /*Boolean?*/exactOnly, /*Boolean?*/omitModuleCheck){
+// summary:
+// loads a Javascript module from the appropriate URI
+//
+// description:
+// 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
+
+ if(!moduleName){ return; }
+ omitModuleCheck = this._global_omit_module_check || omitModuleCheck;
+ 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);
+ if(dj_undef(moduleName, this.loading_modules_)){
+ this.addedToLoadingCount.push(moduleName);
}
- this.loading_modules_[modulename] = 1;
+ this.loading_modules_[moduleName] = 1;
// convert periods to slashes
- var relpath = modulename.replace(/\./g, '/') + '.js';
+ var relpath = moduleName.replace(/\./g, '/') + '.js';
+
+ var nsyms = moduleName.split(".");
+
+ // this line allowed loading of a module manifest as if it were a namespace
+ // it's an interesting idea, but shouldn't be combined with 'namespaces' proper
+ // and leads to unwanted dependencies
+ // the effect can be achieved in other (albeit less-flexible) ways now, so I am
+ // removing this pending further design work
+ // perhaps we can explicitly define this idea of a 'module manifest', and subclass
+ // 'namespace manifest' from that
+ //dojo.getNamespace(nsyms[0]);
- var syms = this.getModuleSymbols(modulename);
- var startedRelative = ((syms[0].charAt(0) != '/')&&(!syms[0].match(/^\w+:/)));
+ var syms = this.getModuleSymbols(moduleName);
+ var startedRelative = ((syms[0].charAt(0) != '/') && !syms[0].match(/^\w+:/));
var last = syms[syms.length - 1];
+ var ok;
// figure out if we're looking for a full package, if so, we want to do
// things slightly diffrently
- var nsyms = modulename.split(".");
if(last=="*"){
- modulename = (nsyms.slice(0, -1)).join('.');
-
+ moduleName = nsyms.slice(0, -1).join('.');
while(syms.length){
syms.pop();
syms.push(this.pkgFileName);
relpath = syms.join("/") + '.js';
- if(startedRelative && (relpath.charAt(0)=="/")){
+ if(startedRelative && relpath.charAt(0)=="/"){
relpath = relpath.slice(1);
}
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ ok = this.loadPath(relpath, !omitModuleCheck ? 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)){
+ moduleName = nsyms.join('.');
+ var modArg = !omitModuleCheck ? moduleName : null;
+ ok = this.loadPath(relpath, modArg);
+ if(!ok && !exactOnly){
syms.pop();
while(syms.length){
relpath = syms.join('/') + '.js';
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ ok = this.loadPath(relpath, modArg);
if(ok){ break; }
syms.pop();
relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
- if(startedRelative && (relpath.charAt(0)=="/")){
+ if(startedRelative && relpath.charAt(0)=="/"){
relpath = relpath.slice(1);
}
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ ok = this.loadPath(relpath, modArg);
if(ok){ break; }
}
}
- if((!ok)&&(!omit_module_check)){
- dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
+ if(!ok && !omitModuleCheck){
+ dojo.raise("Could not load '" + moduleName + "'; last tried '" + relpath + "'");
}
}
// check that the symbol was defined
//Don't bother if we're doing xdomain (asynchronous) loading.
- if(!omit_module_check && !this["isXDomain"]){
+ if(!omitModuleCheck && !this["isXDomain"]){
// pass in false so we can give better error
- module = this.findModule(modulename, false);
+ module = this.findModule(moduleName, false);
if(!module){
- dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
+ 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 modref = dojo.evalObjPath((packname.split(".").slice(0, -1)).join('.'));
- this.loaded_modules_[(new String(packname)).toLowerCase()] = modref;
+dojo.hostenv.startPackage = function(/*String*/packageName){
+// summary:
+// Creates a JavaScript package
+//
+// description:
+// startPackage("A.B") follows the path, and at each level creates a new empty
+// object or uses what already exists. It returns the result.
+//
+// packageName: the package to be created as a String in dot notation
+
+ //Make sure we have a string.
+ var fullPkgName = String(packageName);
+ var strippedPkgName = fullPkgName;
- var syms = packname.split(/\./);
+ var syms = packageName.split(/\./);
if(syms[syms.length-1]=="*"){
syms.pop();
+ strippedPkgName = syms.join(".");
}
- return dojo.evalObjPath(syms.join("."), true);
+ var evaledPkg = dojo.evalObjPath(strippedPkgName, true);
+ this.loaded_modules_[fullPkgName] = evaledPkg;
+ this.loaded_modules_[strippedPkgName] = evaledPkg;
+
+ return evaledPkg; // Object
}
-/**
- * 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];
- }
- */
+dojo.hostenv.findModule = function(/*String*/moduleName, /*Boolean?*/mustExist){
+// summary:
+// Returns the Object representing the module, if it exists, otherwise null.
+//
+// moduleName A fully qualified module including package name, like 'A.B'.
+// mustExist Optional, default false. throw instead of returning null
+// if the module does not currently exist.
- var lmn = (new String(modulename)).toLowerCase();
+ var lmn = String(moduleName);
if(this.loaded_modules_[lmn]){
- return this.loaded_modules_[lmn];
- }
-
- // see if symbol is defined anyway
- var module = dojo.evalObjPath(modulename);
- if((modulename)&&(typeof module != 'undefined')&&(module)){
- this.loaded_modules_[lmn] = module;
- return module;
+ return this.loaded_modules_[lmn]; // Object
}
- if(must_exist){
- dojo.raise("no loaded module named '" + modulename + "'");
+ if(mustExist){
+ dojo.raise("no loaded module named '" + moduleName + "'");
}
- return null;
+ return null; // null
}
//Start of old bootstrap2:
-/*
- * 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.kwCompoundRequire({
- * 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.kwCompoundRequire = function(modMap){
+dojo.kwCompoundRequire = function(/*Object containing Arrays*/modMap){
+// description:
+// 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.kwCompoundRequire({
+// 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.*" ]
+// });
+
var common = modMap["common"]||[];
- var result = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
+ 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];
@@ -748,12 +794,27 @@
}
}
-dojo.require = function(){
+dojo.require = function(/*String*/ resourceName){
+ // summary
+ // Ensure that the given resource (ie, javascript
+ // source file) has been loaded.
+ // description
+ // dojo.require() is similar to C's #include command or java's "import" command.
+ // You call dojo.require() to pull in the resources (ie, javascript source files)
+ // that define the functions you are using.
+ //
+ // Note that in the case of a build, many resources have already been included
+ // into dojo.js (ie, many of the javascript source files have been compressed and
+ // concatened into dojo.js), so many dojo.require() calls will simply return
+ // without downloading anything.
dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
}
-dojo.requireIf = function(){
- if((arguments[0] === true)||(arguments[0]=="common")||(arguments[0] && dojo.render[arguments[0]].capable)){
+dojo.requireIf = function(/*Boolean*/ condition, /*String*/ resourceName){
+ // summary
+ // If the condition is true then call dojo.require() for the specified resource
+ var arg0 = arguments[0];
+ if((arg0 === true)||(arg0=="common")||(arg0 && dojo.render[arg0].capable)){
var args = [];
for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
dojo.require.apply(dojo, args);
@@ -762,31 +823,249 @@
dojo.requireAfterIf = dojo.requireIf;
-dojo.provide = function(){
+dojo.provide = function(/*String*/ resourceName){
+ // summary
+ // Each javascript source file must have (exactly) one dojo.provide()
+ // call at the top of the file, corresponding to the file name.
+ // For example, dojo/src/foo.js must have dojo.provide("dojo.foo"); at the top of the file.
+ //
+ // description
+ // Each javascript source file is called a resource. When a resource
+ // is loaded by the browser, dojo.provide() registers that it has
+ // been loaded.
+ //
+ // For backwards compatibility reasons, in addition to registering the resource,
+ // dojo.provide() also ensures that the javascript object for the module exists. For
+ // example, dojo.provide("dojo.html.common"), in addition to registering that common.js
+ // is a resource for the dojo.html module, will ensure that the dojo.html javascript object
+ // exists, so that calls like dojo.html.foo = function(){ ... } don't fail.
+ //
+ // In the case of a build (or in the future, a rollup), where multiple javascript source
+ // files are combined into one bigger file (similar to a .lib or .jar file), that file
+ // will contain multiple dojo.provide() calls, to note that it includes
+ // multiple resources.
return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
}
-dojo.setModulePrefix = function(module, prefix){
+dojo.registerModulePath = function(/*String*/module, /*String*/prefix){
+ // summary: maps a module name to a path
+ // description: An unregistered module is given the default path of ../<module>,
+ // relative to Dojo root. For example, module acme is mapped to ../acme.
+ // If you want to use a different module name, use dojo.registerModulePath.
return dojo.hostenv.setModulePrefix(module, prefix);
}
-// 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){
+dojo.setModulePrefix = function(/*String*/module, /*String*/prefix){
+ // summary: maps a module name to a path
+ dojo.deprecated('dojo.setModulePrefix("' + module + '", "' + prefix + '")', "replaced by dojo.registerModulePath", "0.5");
+ return dojo.registerModulePath(module, prefix);
+}
+
+dojo.exists = function(/*Object*/obj, /*String*/name){
+ // summary: determine if an object supports a given method
+ // description: useful for longer api chains where you have to test each object in the chain
var p = name.split(".");
for(var i = 0; i < p.length; i++){
- if(!(obj[p[i]])) return false;
+ if(!obj[p[i]]){ return false; } // Boolean
obj = obj[p[i]];
}
- return true;
+ return true; // Boolean
}
+// Localization routines
+
+dojo.hostenv.normalizeLocale = function(/*String?*/locale){
+// summary:
+// Returns canonical form of locale, as used by Dojo. All variants are case-insensitive and are separated by '-'
+// as specified in RFC 3066. If no locale is specified, the user agent's default is returned.
+
+ return locale ? locale.toLowerCase() : dojo.locale; // String
};
-if(typeof window == 'undefined'){
- dojo.raise("no window object");
+dojo.hostenv.searchLocalePath = function(/*String*/locale, /*Boolean*/down, /*Function*/searchFunc){
+// summary:
+// A helper method to assist in searching for locale-based resources. Will iterate through
+// the variants of a particular locale, either up or down, executing a callback function.
+// For example, "en-us" and true will try "en-us" followed by "en" and finally "ROOT".
+
+ locale = dojo.hostenv.normalizeLocale(locale);
+
+ var elements = locale.split('-');
+ var searchlist = [];
+ for(var i = elements.length; i > 0; i--){
+ searchlist.push(elements.slice(0, i).join('-'));
+ }
+ searchlist.push(false);
+ if(down){searchlist.reverse();}
+
+ for(var j = searchlist.length - 1; j >= 0; j--){
+ var loc = searchlist[j] || "ROOT";
+ var stop = searchFunc(loc);
+ if(stop){ break; }
+ }
+}
+
+//These two functions are placed outside of preloadLocalizations
+//So that the xd loading can use/override them.
+dojo.hostenv.localesGenerated /***BUILD:localesGenerated***/; // value will be inserted here at build time, if necessary
+
+dojo.hostenv.registerNlsPrefix = function(){
+// summary:
+// Register module "nls" to point where Dojo can find pre-built localization files
+ dojo.registerModulePath("nls","nls");
+}
+
+dojo.hostenv.preloadLocalizations = function(){
+// summary:
+// Load built, flattened resource bundles, if available for all locales used in the page.
+// Execute only once. Note that this is a no-op unless there is a build.
+
+ if(dojo.hostenv.localesGenerated){
+ dojo.hostenv.registerNlsPrefix();
+
+ function preload(locale){
+ locale = dojo.hostenv.normalizeLocale(locale);
+ dojo.hostenv.searchLocalePath(locale, true, function(loc){
+ for(var i=0; i<dojo.hostenv.localesGenerated.length;i++){
+ if(dojo.hostenv.localesGenerated[i] == loc){
+ dojo["require"]("nls.dojo_"+loc);
+ return true; // Boolean
+ }
+ }
+ return false; // Boolean
+ });
+ }
+ preload();
+ var extra = djConfig.extraLocale||[];
+ for(var i=0; i<extra.length; i++){
+ preload(extra[i]);
+ }
+ }
+ dojo.hostenv.preloadLocalizations = function(){};
}
+dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale){
+// summary:
+// Declares translated resources and loads them if necessary, in the same style as dojo.require.
+// Contents of the resource bundle are typically strings, but may be any name/value pair,
+// represented in JSON format. See also dojo.i18n.getLocalization.
+//
+// moduleName: name of the package containing the "nls" directory in which the bundle is found
+// bundleName: bundle name, i.e. the filename without the '.js' suffix
+// locale: the locale to load (optional) By default, the browser's user locale as defined by dojo.locale
+//
+// description:
+// Load translated resource bundles provided underneath the "nls" directory within a package.
+// Translated resources may be located in different packages throughout the source tree. For example,
+// a particular widget may define one or more resource bundles, structured in a program as follows,
+// where moduleName is mycode.mywidget and bundleNames available include bundleone and bundletwo:
+// ...
+// mycode/
+// mywidget/
+// nls/
+// bundleone.js (the fallback translation, English in this example)
+// bundletwo.js (also a fallback translation)
+// de/
+// bundleone.js
+// bundletwo.js
+// de-at/
+// bundleone.js
+// en/
+// (empty; use the fallback translation)
+// en-us/
+// bundleone.js
+// en-gb/
+// bundleone.js
+// es/
+// bundleone.js
+// bundletwo.js
+// ...etc
+// ...
+// Each directory is named for a locale as specified by RFC 3066, (http://www.ietf.org/rfc/rfc3066.txt),
+// normalized in lowercase. Note that the two bundles in the example do not define all the same variants.
+// For a given locale, bundles will be loaded for that locale and all more general locales above it, including
+// a fallback at the root directory. For example, a declaration for the "de-at" locale will first
+// load nls/de-at/bundleone.js, then nls/de/bundleone.js and finally nls/bundleone.js. The data will
+// be flattened into a single Object so that lookups will follow this cascading pattern. An optional build
+// step can preload the bundles to avoid data redundancy and the multiple network hits normally required to
+// load these resources.
+
+ dojo.hostenv.preloadLocalizations();
+ var bundlePackage = [moduleName, "nls", bundleName].join(".");
+//NOTE: When loading these resources, the packaging does not match what is on disk. This is an
+// implementation detail, as this is just a private data structure to hold the loaded resources.
+// e.g. tests/hello/nls/en-us/salutations.js is loaded as the object tests.hello.nls.salutations.en_us={...}
+// The structure on disk is intended to be most convenient for developers and translators, but in memory
+// it is more logical and efficient to store in a different order. Locales cannot use dashes, since the
+// resulting path will not evaluate as valid JS, so we translate them to underscores.
+
+ var bundle = dojo.hostenv.findModule(bundlePackage);
+ if(bundle){
+ if(djConfig.localizationComplete && bundle._built){return;}
+ var jsLoc = dojo.hostenv.normalizeLocale(locale).replace('-', '_');
+ var translationPackage = bundlePackage+"."+jsLoc;
+ if(dojo.hostenv.findModule(translationPackage)){return;}
+ }
+
+ bundle = dojo.hostenv.startPackage(bundlePackage);
+ var syms = dojo.hostenv.getModuleSymbols(moduleName);
+ var modpath = syms.concat("nls").join("/");
+ var parent;
+ dojo.hostenv.searchLocalePath(locale, false, function(loc){
+ var jsLoc = loc.replace('-', '_');
+ var translationPackage = bundlePackage + "." + jsLoc;
+ var loaded = false;
+ if(!dojo.hostenv.findModule(translationPackage)){
+ // Mark loaded whether it's found or not, so that further load attempts will not be made
+ dojo.hostenv.startPackage(translationPackage);
+ var module = [modpath];
+ if(loc != "ROOT"){module.push(loc);}
+ module.push(bundleName);
+ var filespec = module.join("/") + '.js';
+ loaded = dojo.hostenv.loadPath(filespec, null, function(hash){
+ // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath
+ var clazz = function(){};
+ clazz.prototype = parent;
+ bundle[jsLoc] = new clazz();
+ for(var j in hash){ bundle[jsLoc][j] = hash[j]; }
+ });
+ }else{
+ loaded = true;
+ }
+ if(loaded && bundle[jsLoc]){
+ parent = bundle[jsLoc];
+ }else{
+ bundle[jsLoc] = parent;
+ }
+ });
+};
+
+(function(){
+ // If other locales are used, dojo.requireLocalization should load them as well, by default.
+ // Override dojo.requireLocalization to do load the default bundle, then iterate through the
+ // extraLocale list and load those translations as well, unless a particular locale was requested.
+
+ var extra = djConfig.extraLocale;
+ if(extra){
+ if(!extra instanceof Array){
+ extra = [extra];
+ }
+
+ var req = dojo.requireLocalization;
+ dojo.requireLocalization = function(m, b, locale){
+ req(m,b,locale);
+ if(locale){return;}
+ for(var i=0; i<extra.length; i++){
+ req(m,b,extra[i]);
+ }
+ };
+ }
+})();
+
+};
+
+if (typeof window != 'undefined') {
+
// 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
@@ -834,8 +1113,8 @@
var dr = dojo.render;
var drh = dojo.render.html;
var drs = dojo.render.svg;
- var dua = drh.UA = navigator.userAgent;
- var dav = drh.AV = navigator.appVersion;
+ var dua = (drh.UA = navigator.userAgent);
+ var dav = (drh.AV = navigator.appVersion);
var t = true;
var f = false;
drh.capable = t;
@@ -862,21 +1141,34 @@
drh.ie60 = drh.ie && dav.indexOf("MSIE 6.0")>=0;
drh.ie70 = drh.ie && dav.indexOf("MSIE 7.0")>=0;
+ var cm = document["compatMode"];
+ drh.quirks = (cm == "BackCompat")||(cm == "QuirksMode")||drh.ie55||drh.ie50;
+
// TODO: is the HTML LANG attribute relevant?
- dojo.locale = (drh.ie ? navigator.userLanguage : navigator.language).toLowerCase();
+ dojo.locale = dojo.locale || (drh.ie ? navigator.userLanguage : navigator.language).toLowerCase();
dr.vml.capable=drh.ie;
drs.capable = f;
drs.support.plugin = f;
drs.support.builtin = f;
- if (document.implementation
- && document.implementation.hasFeature
- && document.implementation.hasFeature("org.w3c.dom.svg", "1.0")
- ){
+ var tdoc = window["document"];
+ var tdi = tdoc["implementation"];
+
+ if((tdi)&&(tdi["hasFeature"])&&(tdi.hasFeature("org.w3c.dom.svg", "1.0"))){
drs.capable = t;
drs.support.builtin = t;
drs.support.plugin = f;
}
+ // webkits after 420 support SVG natively. The test string is "AppleWebKit/420+"
+ if(drh.safari){
+ var tmp = dua.split("AppleWebKit/")[1];
+ var ver = parseFloat(tmp.split(" ")[0]);
+ if(ver >= 420){
+ drs.capable = t;
+ drs.support.builtin = t;
+ drs.support.plugin = f;
+ }
+ }
})();
dojo.hostenv.startPackage("dojo.hostenv");
@@ -931,16 +1223,35 @@
* @param fail_ok Default false. If fail_ok and !async_cb and loading fails,
* return null instead of throwing.
*/
+dojo.hostenv._blockAsync = false;
dojo.hostenv.getText = function(uri, async_cb, fail_ok){
+ // need to block async callbacks from snatching this thread as the result
+ // of an async callback might call another sync XHR, this hangs khtml forever
+ // hostenv._blockAsync must also be checked in BrowserIO's watchInFlight()
+ // NOTE: must be declared before scope switches ie. this.getXmlhttpObject()
+ if(!async_cb){ this._blockAsync = true; }
var http = this.getXmlhttpObject();
+ function isDocumentOk(http){
+ var stat = http["status"];
+ // allow a 304 use cache, needed in konq (is this compliant with the http spec?)
+ return Boolean((!stat)||((200 <= stat)&&(300 > stat))||(stat==304));
+ }
+
if(async_cb){
+ var _this = this, timer = null, gbl = dojo.global();
+ var xhr = dojo.evalObjPath("dojo.io.XMLHTTPTransport");
http.onreadystatechange = function(){
- if(4==http.readyState){
- if((!http["status"])||((200 <= http.status)&&(300 > http.status))){
- // dojo.debug("LOADED URI: "+uri);
- async_cb(http.responseText);
+ if(timer){ gbl.clearTimeout(timer); timer = null; }
+ if(_this._blockAsync || (xhr && xhr._blockAsync)){
+ timer = gbl.setTimeout(function () { http.onreadystatechange.apply(this); }, 10);
+ }else{
+ if(4==http.readyState){
+ if(isDocumentOk(http)){
+ // dojo.debug("LOADED URI: "+uri);
+ async_cb(http.responseText);
+ }
}
}
}
@@ -952,10 +1263,14 @@
if(async_cb){
return null;
}
- if((http["status"])&&((200 > http.status)||(300 <= http.status))){
- throw Error("Unable to load "+uri+" status:"+ http.status);
+ if(!isDocumentOk(http)){
+ var err = Error("Unable to load "+uri+" status:"+ http.status);
+ err.status = http.status;
+ err.responseText = http.responseText;
+ throw err;
}
}catch(e){
+ this._blockAsync = false;
if((fail_ok)&&(!async_cb)){
return null;
}else{
@@ -963,6 +1278,7 @@
}
}
+ this._blockAsync = false;
return http.responseText;
}
@@ -1001,7 +1317,7 @@
try {
var console = document.getElementById(djConfig.debugContainerId ?
djConfig.debugContainerId : dojo.hostenv.defaultDebugContainerId);
- if(!console) { console = document.getElementsByTagName("body")[0] || document.body; }
+ if(!console) { console = dojo.body(); }
var div = document.createElement("div");
div.appendChild(document.createTextNode(line));
@@ -1033,30 +1349,18 @@
return true;
}
-
-/* Uncomment this to allow init after DOMLoad, not after window.onload
-
-// Mozilla exposes the event we could use
-if (dojo.render.html.mozilla) {
- document.addEventListener("DOMContentLoaded", dj_load_init, null);
-}
-// for Internet Explorer. readyState will not be achieved on init call, but dojo doesn't need it
-//Tighten up the comments below to allow init after DOMLoad, not after window.onload
-/ * @cc_on @ * /
-/ * @if (@_win32)
- document.write("<script defer>dj_load_init()<"+"/script>");
-/ * @end @ * /
-*/
-
-// default for other browsers
-// potential TODO: apply setTimeout approach for other browsers
-// that will cause flickering though ( document is loaded and THEN is processed)
-// maybe show/hide required in this case..
-// TODO: other browsers may support DOMContentLoaded/defer attribute. Add them to above.
-dj_addNodeEvtHdlr(window, "load", function(){
+// BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/)
+function dj_load_init(e){
// allow multiple calls, only first one will take effect
- if(arguments.callee.initialized){ return; }
+ // A bug in khtml calls events callbacks for document for event which isnt supported
+ // for example a created contextmenu event calls DOMContentLoaded, workaround
+ var type = (e && e.type) ? e.type.toLowerCase() : "load";
+ if(arguments.callee.initialized || (type!="domcontentloaded" && type!="load")){ return; }
arguments.callee.initialized = true;
+ if(typeof(_timer) != 'undefined'){
+ clearInterval(_timer);
+ delete _timer;
+ }
var initFunc = function(){
//perform initialization
@@ -1071,10 +1375,59 @@
}else{
dojo.addOnLoad(initFunc);
}
-});
+}
+
+// START DOMContentLoaded
+// Mozilla and Opera 9 expose the event we could use
+if(document.addEventListener){
+ if(dojo.render.html.opera || (dojo.render.html.moz && !djConfig.delayMozLoadingFix)){
+ document.addEventListener("DOMContentLoaded", dj_load_init, null);
+ }
+
+ // mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already.
+ // also used for Mozilla because of trac #1640
+ window.addEventListener("load", dj_load_init, null);
+}
+
+// for Internet Explorer. readyState will not be achieved on init call, but dojo doesn't need it
+// however, we'll include it because we don't know if there are other functions added that might.
+// Note that this has changed because the build process strips all comments--including conditional
+// ones.
+if(dojo.render.html.ie && dojo.render.os.win){
+ document.attachEvent("onreadystatechange", function(e){
+ if(document.readyState == "complete"){
+ dj_load_init();
+ }
+ });
+}
+
+if (/(WebKit|khtml)/i.test(navigator.userAgent)) { // sniff
+ var _timer = setInterval(function() {
+ if (/loaded|complete/.test(document.readyState)) {
+ dj_load_init(); // call the onload handler
+ }
+ }, 10);
+}
+// END DOMContentLoaded
+
+// IE WebControl hosted in an application can fire "beforeunload" and "unload"
+// events when control visibility changes, causing Dojo to unload too soon. The
+// following code fixes the problem
+// Reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;199155
+if(dojo.render.html.ie){
+ dj_addNodeEvtHdlr(window, "beforeunload", function(){
+ dojo.hostenv._unloading = true;
+ window.setTimeout(function() {
+ dojo.hostenv._unloading = false;
+ }, 0);
+ });
+}
dj_addNodeEvtHdlr(window, "unload", function(){
dojo.hostenv.unloaded();
+ if((!dojo.render.html.ie)||(dojo.render.html.ie && dojo.hostenv._unloading)){
+ dojo.hostenv.unloaded();
+ }
});
dojo.hostenv.makeWidgets = function(){
@@ -1092,7 +1445,7 @@
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.
+ // (IE bug)
var parser = new dojo.xml.Parse();
if(sids.length > 0){
for(var x=0; x<sids.length; x++){
@@ -1102,7 +1455,7 @@
dojo.widget.getParser().createComponents(frag);
}
}else if(djConfig.parseWidgets){
- var frag = parser.parseElement(document.getElementsByTagName("body")[0] || document.body, null, true);
+ var frag = parser.parseElement(dojo.body(), null, true);
dojo.widget.getParser().createComponents(frag);
}
}
@@ -1117,8 +1470,8 @@
try {
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"/>');
+ document.namespaces.add("v","urn:schemas-microsoft-com:vml");
+ document.createStyleSheet().addRule("v\\:*", "behavior:url(#default#VML)");
}
} catch (e) { }
@@ -1126,14 +1479,110 @@
// breaking when it's not included
dojo.hostenv.writeIncludes = function(){}
+//TODOC: HOW TO DOC THIS?
+// @global: dj_currentDocument
+// summary:
+// Current document object. 'dj_currentDocument' can be modified for temporary context shifting.
+// description:
+// dojo.doc() returns dojo.currentDocument.
+// Refer to dojo.doc() rather than referring to 'window.document' to ensure your
+// code runs correctly in managed contexts.
+if(!dj_undef("document", this)){
+ dj_currentDocument = this.document;
+}
+
+dojo.doc = function(){
+ // summary:
+ // return the document object associated with the dojo.global()
+ return dj_currentDocument;
+}
+
+dojo.body = function(){
+ // summary:
+ // return the body object associated with dojo.doc()
+ // Note: document.body is not defined for a strict xhtml document
+ return dojo.doc().body || dojo.doc().getElementsByTagName("body")[0];
+}
+
dojo.byId = function(id, doc){
- if(id && (typeof id == "string" || id instanceof String)){
- if(!doc){ doc = document; }
- return doc.getElementById(id);
+ if((id)&&((typeof id == "string")||(id instanceof String))){
+ if (!doc) { doc = dj_currentDocument; }
+ var ele = doc.getElementById(id);
+ // workaround bug in IE and Opera 8.2 where getElementById returns wrong element
+ if (ele && (ele.id != id) && doc.all) {
+ ele = null;
+ // get all matching elements with this id
+ eles = doc.all[id];
+ if (eles) {
+ // if more than 1, choose first with the correct id
+ if (eles.length) {
+ for (var i=0; i < eles.length; i++) {
+ if (eles[i].id == id) {
+ ele = eles[i];
+ break;
+ }
+ }
+ // return 1 and only element
+ } else { ele = eles; }
+ }
+ }
+ return ele;
}
return id; // assume it's a node
}
+dojo.setContext = function(/*Object*/globalObject, /*Object*/ globalDocument){
+ dj_currentContext = globalObject;
+ dj_currentDocument = globalDocument;
+};
+
+dojo._fireCallback = function(callback, context, cbArguments) {
+ if((context)&&((typeof callback == "string")||(callback instanceof String))){
+ callback=context[callback];
+ }
+ return (context ? callback.apply(context, cbArguments || [ ]) : callback());
+}
+
+dojo.withGlobal = function(/*Object*/globalObject, /*Function*/callback, /*Object?*/thisObject, /*Array?*/cbArguments){
+ // summary:
+ // Call callback with globalObject as dojo.global() and globalObject.document
+ // as dojo.doc(). If provided, globalObject will be executed in the context of
+ // object thisObject
+ // description:
+ // When callback() returns or throws an error, the dojo.global() and dojo.doc() will
+ // be restored to its previous state.
+ var rval;
+ var oldGlob = dj_currentContext;
+ var oldDoc = dj_currentDocument;
+ try{
+ dojo.setContext(globalObject, globalObject.document);
+ rval = dojo._fireCallback(callback, thisObject, cbArguments);
+ }finally{
+ dojo.setContext(oldGlob, oldDoc);
+ }
+ return rval;
+}
+
+dojo.withDoc = function (/*Object*/documentObject, /*Function*/callback, /*Object?*/thisObject, /*Array?*/cbArguments) {
+ // summary:
+ // Call callback with documentObject as dojo.doc(). If provided, callback will be executed
+ // in the context of object thisObject
+ // description:
+ // When callback() returns or throws an error, the dojo.doc() will
+ // be restored to its previous state.
+ var rval;
+ var oldDoc = dj_currentDocument;
+ try{
+ dj_currentDocument = documentObject;
+ rval = dojo._fireCallback(callback, thisObject, cbArguments);
+ }finally{
+ dj_currentDocument = oldDoc;
+ }
+ return rval;
+}
+
+} //if (typeof window != 'undefined')
+
//Semicolon is for when this file is integrated with a custom build on one line
//with some other file's contents. Sometimes that makes things not get defined
//properly, particularly with the using the closure below to do all the work.
@@ -1163,13 +1612,6 @@
tmps.push("browser_debug.js");
}
- //Support compatibility packages. Right now this only allows setting one
- //compatibility package. Might need to revisit later down the line to support
- //more than one.
- if((this["djConfig"])&&(djConfig["compat"])){
- tmps.push("compat/" + djConfig["compat"] + ".js");
- }
-
var loaderRoot = djConfig["baseScriptUri"];
if((this["djConfig"])&&(djConfig["baseLoaderUri"])){
loaderRoot = djConfig["baseLoaderUri"];
@@ -1191,209 +1633,196 @@
}
})();
-// Localization routines
-
-/**
- * The locale to look for string bundles if none are defined for your locale. Translations for all strings
- * should be provided in this locale.
- */
-//TODO: this really belongs in translation metadata, not in code
-dojo.fallback_locale = 'en';
-
-/**
- * Returns canonical form of locale, as used by Dojo. All variants are case-insensitive and are separated by '-'
- * as specified in RFC 3066
- */
-dojo.normalizeLocale = function(locale) {
- return locale ? locale.toLowerCase() : dojo.locale;
-};
+dojo.provide("dojo.string.common");
-/**
- * requireLocalization() is for loading translated bundles provided within a package in the namespace.
- * Contents are typically strings, but may be any name/value pair, represented in JSON format.
- * A bundle is structured in a program as follows:
- *
- * <package>/
- * nls/
- * de/
- * mybundle.js
- * de-at/
- * mybundle.js
- * en/
- * mybundle.js
- * en-us/
- * mybundle.js
- * en-gb/
- * mybundle.js
- * es/
- * mybundle.js
- * ...etc
- *
- * where package is part of the namespace as used by dojo.require(). Each directory is named for a
- * locale as specified by RFC 3066, (http://www.ietf.org/rfc/rfc3066.txt), normalized in lowercase.
- *
- * For a given locale, string bundles will be loaded for that locale and all general locales above it, as well
- * as a system-specified fallback. For example, "de_at" will also load "de" and "en". Lookups will traverse
- * the locales in this order. A build step can preload the bundles to avoid data redundancy and extra network hits.
- *
- * @param modulename package in which the bundle is found
- * @param bundlename bundle name, typically the filename without the '.js' suffix
- * @param locale the locale to load (optional) By default, the browser's user locale as defined
- * in dojo.locale
- */
-dojo.requireLocalization = function(modulename, bundlename, locale /*optional*/){
+dojo.string.trim = function(/* string */str, /* integer? */wh){
+ // summary
+ // Trim whitespace from str. If wh > 0, trim from start, if wh < 0, trim from end, else both
+ if(!str.replace){ return str; }
+ if(!str.length){ return str; }
+ var re = (wh > 0) ? (/^\s+/) : (wh < 0) ? (/\s+$/) : (/^\s+|\s+$/g);
+ return str.replace(re, ""); // string
+}
- dojo.debug("EXPERIMENTAL: dojo.requireLocalization"); //dojo.experimental
+dojo.string.trimStart = function(/* string */str) {
+ // summary
+ // Trim whitespace at the beginning of 'str'
+ return dojo.string.trim(str, 1); // string
+}
- var syms = dojo.hostenv.getModuleSymbols(modulename);
- var modpath = syms.concat("nls").join("/");
+dojo.string.trimEnd = function(/* string */str) {
+ // summary
+ // Trim whitespace at the end of 'str'
+ return dojo.string.trim(str, -1);
+}
- locale = dojo.normalizeLocale(locale);
+dojo.string.repeat = function(/* string */str, /* integer */count, /* string? */separator) {
+ // summary
+ // Return 'str' repeated 'count' times, optionally placing 'separator' between each rep
+ var out = "";
+ for(var i = 0; i < count; i++) {
+ out += str;
+ if(separator && i < count - 1) {
+ out += separator;
+ }
+ }
+ return out; // string
+}
- var elements = locale.split('-');
- var searchlist = [];
- for(var i = elements.length; i > 0; i--){
- searchlist.push(elements.slice(0, i).join('-'));
+dojo.string.pad = function(/* string */str, /* integer */len/*=2*/, /* string */ c/*='0'*/, /* integer */dir/*=1*/) {
+ // summary
+ // Pad 'str' to guarantee that it is at least 'len' length with the character 'c' at either the
+ // start (dir=1) or end (dir=-1) of the string
+ var out = String(str);
+ if(!c) {
+ c = '0';
}
- if(searchlist[searchlist.length-1] != dojo.fallback_locale){
- searchlist.push(dojo.fallback_locale);
+ if(!dir) {
+ dir = 1;
+ }
+ while(out.length < len) {
+ if(dir > 0) {
+ out = c + out;
+ } else {
+ out += c;
+ }
}
+ return out; // string
+}
- var bundlepackage = [modulename, "_nls", bundlename].join(".");
- var bundle = dojo.hostenv.startPackage(bundlepackage);
- dojo.hostenv.loaded_modules_[bundlepackage] = bundle;
-
- var inherit = false;
- for(var i = searchlist.length - 1; i >= 0; i--){
- var loc = searchlist[i];
- var pkg = [bundlepackage, loc].join(".");
- var loaded = false;
- if(!dojo.hostenv.findModule(pkg)){
- // Mark loaded whether it's found or not, so that further load attempts will not be made
- dojo.hostenv.loaded_modules_[pkg] = null;
+dojo.string.padLeft = function(/* string */str, /* integer */len, /* string */c) {
+ // summary
+ // same as dojo.string.pad(str, len, c, 1)
+ return dojo.string.pad(str, len, c, 1); // string
+}
- var filespec = [modpath, loc, bundlename].join("/") + '.js';
- loaded = dojo.hostenv.loadPath(filespec, null, function(hash) {
- bundle[loc] = hash;
- if(inherit){
- // Use mixins approach to copy string references from inherit bundle, but skip overrides.
- for(var x in inherit){
- if(!bundle[loc][x]){
- bundle[loc][x] = inherit[x];
- }
- }
- }
-/*
- // Use prototype to point to other bundle, then copy in result from loadPath
- bundle[loc] = new function(){};
- if(inherit){ bundle[loc].prototype = inherit; }
- for(var i in hash){ bundle[loc][i] = hash[i]; }
-*/
- });
- }else{
- loaded = true;
- }
- if(loaded && bundle[loc]){
- inherit = bundle[loc];
- }
- }
-};
+dojo.string.padRight = function(/* string */str, /* integer */len, /* string */c) {
+ // summary
+ // same as dojo.string.pad(str, len, c, -1)
+ return dojo.string.pad(str, len, c, -1); // string
+}
+
+dojo.provide("dojo.string");
dojo.provide("dojo.lang.common");
-dojo.require("dojo.lang");
-/*
- * Adds the given properties/methods to the specified object
- */
-dojo.lang._mixin = function(obj, props){
+dojo.lang.inherits = function(/*Function*/ subclass, /*Function*/ superclass){
+ // summary: Set up inheritance between two classes.
+ if(typeof superclass != 'function'){
+ dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: ["+subclass+"']");
+ }
+ subclass.prototype = new superclass();
+ subclass.prototype.constructor = subclass;
+ subclass.superclass = superclass.prototype;
+ // DEPRECATED: super is a reserved word, use 'superclass'
+ subclass['super'] = superclass.prototype;
+}
+
+dojo.lang._mixin = function(/*Object*/ obj, /*Object*/ props){
+ // summary: Adds all properties and methods of props to obj.
var tobj = {};
for(var x in props){
// the "tobj" condition avoid copying properties in "props"
// inherited from Object.prototype. For example, if obj has a custom
// toString() method, don't overwrite it with the toString() method
// that props inherited from Object.protoype
- if(typeof tobj[x] == "undefined" || tobj[x] != props[x]) {
+ if((typeof tobj[x] == "undefined") || (tobj[x] != props[x])){
obj[x] = props[x];
}
}
// IE doesn't recognize custom toStrings in for..in
- if(dojo.render.html.ie && dojo.lang.isFunction(props["toString"]) && props["toString"] != obj["toString"]) {
+ if(dojo.render.html.ie
+ && (typeof(props["toString"]) == "function")
+ && (props["toString"] != obj["toString"])
+ && (props["toString"] != tobj["toString"]))
+ {
obj.toString = props.toString;
}
- return obj;
+ return obj; // Object
}
-/*
- * Adds the properties/methods of argument Objects to obj
- */
-dojo.lang.mixin = function(obj, props /*, props, ..., props */){
+dojo.lang.mixin = function(/*Object*/ obj, /*Object...*/props){
+ // summary: Adds all properties and methods of props to obj.
for(var i=1, l=arguments.length; i<l; i++){
dojo.lang._mixin(obj, arguments[i]);
}
- return obj;
+ return obj; // Object
}
-/*
- * Adds the properties/methods of argument Objects to ctor's prototype
- */
-dojo.lang.extend = function(ctor /*function*/, props /*, props, ..., props */){
+dojo.lang.extend = function(/*Object*/ constructor, /*Object...*/ props){
+ // summary: Adds all properties and methods of props to constructor's prototype,
+ // making them available to all instances created with constructor.
for(var i=1, l=arguments.length; i<l; i++){
- dojo.lang._mixin(ctor.prototype, arguments[i]);
+ dojo.lang._mixin(constructor.prototype, arguments[i]);
}
- return ctor;
+ return constructor; // Object
}
-/**
- * See if val is in arr. Call signatures:
- * find(array, value, identity) // recommended
- * find(value, array, identity)
-**/
-dojo.lang.find = function( /*Array*/ arr,
- /*Object*/ val,
- /*boolean*/ identity,
- /*boolean*/ findLast){
- // support both (arr, val) and (val, arr)
- if(!dojo.lang.isArrayLike(arr) && dojo.lang.isArrayLike(val)) {
- var a = arr;
- arr = val;
- val = a;
+// Promote to dojo module
+dojo.inherits = dojo.lang.inherits;
+//dojo.lang._mixin = dojo.lang._mixin;
+dojo.mixin = dojo.lang.mixin;
+dojo.extend = dojo.lang.extend;
+
+dojo.lang.find = function( /*Array*/ array,
+ /*Object*/ value,
+ /*Boolean?*/ identity,
+ /*Boolean?*/ findLast){
+ // summary: Return the index of value in array, returning -1 if not found.
+ // identity: If true, matches with identity comparison (===).
+ // If false, uses normal comparison (==).
+ // findLast: If true, returns index of last instance of value.
+
+ // examples:
+ // find(array, value[, identity [findLast]]) // recommended
+ // find(value, array[, identity [findLast]]) // deprecated
+
+ // support both (array, value) and (value, array)
+ if(!dojo.lang.isArrayLike(array) && dojo.lang.isArrayLike(value)) {
+ dojo.deprecated('dojo.lang.find(value, array)', 'use dojo.lang.find(array, value) instead', "0.5");
+ var temp = array;
+ array = value;
+ value = temp;
}
- var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
+ var isString = dojo.lang.isString(array);
+ if(isString) { array = array.split(""); }
if(findLast) {
var step = -1;
- var i = arr.length - 1;
+ var i = array.length - 1;
var end = -1;
} else {
var step = 1;
var i = 0;
- var end = arr.length;
+ var end = array.length;
}
if(identity){
while(i != end) {
- if(arr[i] === val){ return i; }
+ if(array[i] === value){ return i; }
i += step;
}
}else{
while(i != end) {
- if(arr[i] == val){ return i; }
+ if(array[i] == value){ return i; }
i += step;
}
}
- return -1;
+ return -1; // number
}
dojo.lang.indexOf = dojo.lang.find;
-dojo.lang.findLast = function(/*Array*/ arr, /*Object*/ val, /*boolean*/ identity){
- return dojo.lang.find(arr, val, identity, true);
+dojo.lang.findLast = function(/*Array*/ array, /*Object*/ value, /*boolean?*/ identity){
+ // summary: Return index of last occurance of value in array, returning -1 if not found.
+ // identity: If true, matches with identity comparison (===). If false, uses normal comparison (==).
+ return dojo.lang.find(array, value, identity, true); // number
}
dojo.lang.lastIndexOf = dojo.lang.findLast;
-dojo.lang.inArray = function(arr /*Array*/, val /*Object*/){
- return dojo.lang.find(arr, val) > -1; // return: boolean
+dojo.lang.inArray = function(array /*Array*/, value /*Object*/){
+ // summary: Return true if value is present in array.
+ return dojo.lang.find(array, value) > -1; // boolean
}
/**
@@ -1406,40 +1835,51 @@
* The following is* functions are fairly "safe"
*/
-dojo.lang.isObject = function(wh){
- if(typeof wh == "undefined"){ return false; }
- return (typeof wh == "object" || wh === null || dojo.lang.isArray(wh) || dojo.lang.isFunction(wh));
+dojo.lang.isObject = function(/*anything*/ it){
+ // summary: Return true if it is an Object, Array or Function.
+ if(typeof it == "undefined"){ return false; }
+ return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it)); // Boolean
}
-dojo.lang.isArray = function(wh){
- return (wh instanceof Array || typeof wh == "array");
+dojo.lang.isArray = function(/*anything*/ it){
+ // summary: Return true if it is an Array.
+ return (it && it instanceof Array || typeof it == "array"); // Boolean
}
-dojo.lang.isArrayLike = function(wh){
- if(dojo.lang.isString(wh)){ return false; }
- if(dojo.lang.isFunction(wh)){ return false; } // keeps out built-in ctors (Number, String, ...) which have length properties
- if(dojo.lang.isArray(wh)){ return true; }
- if(typeof wh != "undefined" && wh
- && dojo.lang.isNumber(wh.length) && isFinite(wh.length)){ return true; }
- return false;
+dojo.lang.isArrayLike = function(/*anything*/ it){
+ // summary: Return true if it can be used as an array (i.e. is an object with an integer length property).
+ if((!it)||(dojo.lang.isUndefined(it))){ return false; }
+ if(dojo.lang.isString(it)){ return false; }
+ if(dojo.lang.isFunction(it)){ return false; } // keeps out built-in constructors (Number, String, ...) which have length properties
+ if(dojo.lang.isArray(it)){ return true; }
+ // form node itself is ArrayLike, but not always iterable. Use form.elements instead.
+ if((it.tagName)&&(it.tagName.toLowerCase()=='form')){ return false; }
+ if(dojo.lang.isNumber(it.length) && isFinite(it.length)){ return true; }
+ return false; // Boolean
}
-dojo.lang.isFunction = function(wh){
- if(!wh){ return false; }
- return (wh instanceof Function || typeof wh == "function");
+dojo.lang.isFunction = function(/*anything*/ it){
+ // summary: Return true if it is a Function.
+ if(!it){ return false; }
+ // webkit treats NodeList as a function, which is bad
+ if((typeof(it) == "function") && (it == "[object NodeList]")) { return false; }
+ return (it instanceof Function || typeof it == "function"); // Boolean
}
-dojo.lang.isString = function(wh){
- return (wh instanceof String || typeof wh == "string");
+dojo.lang.isString = function(/*anything*/ it){
+ // summary: Return true if it is a String.
+ return (typeof it == "string" || it instanceof String);
}
-dojo.lang.isAlien = function(wh){
- if(!wh){ return false; }
- return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(wh));
+dojo.lang.isAlien = function(/*anything*/ it){
+ // summary: Return true if it is not a built-in function.
+ if(!it){ return false; }
+ return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean
}
-dojo.lang.isBoolean = function(wh){
- return (wh instanceof Boolean || typeof wh == "boolean");
+dojo.lang.isBoolean = function(/*anything*/ it){
+ // summary: Return true if it is a Boolean.
+ return (it instanceof Boolean || typeof it == "boolean"); // Boolean
}
/**
@@ -1447,3669 +1887,2743 @@
* 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");
+dojo.lang.isNumber = function(/*anything*/ it){
+ // summary: Return true if it is a number.
+ // description:
+ // WARNING - In most cases, isNaN(it) 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 (array["1"] is the same as
+ // array[1]) and isNaN will return false for both values ("1" and 1). However,
+ // isNumber("1") 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(it) when possible
+
+ return (it instanceof Number || typeof it == "number"); // Boolean
}
-/**
- * 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"));
+dojo.lang.isUndefined = function(/*anything*/ it){
+ // summary: Return true if it is not defined.
+ // description:
+ // 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
+
+ return ((typeof(it) == "undefined")&&(it == undefined)); // Boolean
}
// end Crockford functions
-dojo.provide("dojo.lang");
-dojo.provide("dojo.lang.Lang");
-
-dojo.require("dojo.lang.common");
-
-dojo.provide("dojo.lang.func");
+dojo.provide("dojo.lang.extras");
-dojo.require("dojo.lang.common");
-/**
- * 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;
- }
+dojo.lang.setTimeout = function(/*Function*/func, /*int*/delay /*, ...*/){
+ // summary:
+ // Sets a timeout in milliseconds to execute a function in a given context
+ // with optional arguments.
+ //
+ // usage:
+ // setTimeout (Object context, function func, number delay[, arg1[, ...]]);
+ // setTimeout (function func, number delay[, arg1[, ...]]);
- return function() {
- return fcn.apply(thisObject, arguments);
+ var context = window, argsStart = 2;
+ if(!dojo.lang.isFunction(func)){
+ context = func;
+ func = delay;
+ delay = arguments[2];
+ argsStart++;
}
-}
-dojo.lang.anonCtr = 0;
-dojo.lang.anon = {};
-dojo.lang.nameAnonFunc = function(anonFuncPtr, namespaceObj, searchForNames){
- var nso = (namespaceObj || dojo.lang.anon);
- if( (searchForNames) ||
- ((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)) ){
- for(var x in nso){
- if(nso[x] === anonFuncPtr){
- return x;
- }
- }
+ if(dojo.lang.isString(func)){
+ func = context[func];
}
- var ret = "__"+dojo.lang.anonCtr++;
- while(typeof nso[ret] != "undefined"){
- ret = "__"+dojo.lang.anonCtr++;
+
+ var args = [];
+ for (var i = argsStart; i < arguments.length; i++){
+ args.push(arguments[i]);
}
- nso[ret] = anonFuncPtr;
- return ret;
+ return dojo.global().setTimeout(function () { func.apply(context, args); }, delay); // int
}
-dojo.lang.forward = function(funcName){
- // Returns a function that forwards a method call to this.func(...)
- return function(){
- return this[funcName].apply(this, arguments);
- };
+dojo.lang.clearTimeout = function(/*int*/timer){
+ // summary: clears timer by number from the execution queue
+ dojo.global().clearTimeout(timer);
}
-dojo.lang.curry = function(ns, func /* args ... */){
- var outerArgs = [];
- ns = ns||dj_global;
- if(dojo.lang.isString(func)){
- func = ns[func];
- }
- for(var x=2; x<arguments.length; x++){
- outerArgs.push(arguments[x]);
- }
- // since the event system replaces the original function with a new
- // join-point runner with an arity of 0, we check to see if it's left us
- // any clues about the original arity in lieu of the function's actual
- // length property
- var ecount = (func["__preJoinArity"]||func.length) - outerArgs.length;
- // borrowed from svend tofte
- function gather(nextArgs, innerArgs, expected){
- var texpected = expected;
- var totalArgs = innerArgs.slice(0); // copy
- for(var x=0; x<nextArgs.length; x++){
- totalArgs.push(nextArgs[x]);
- }
- // check the list of provided nextArgs to see if it, plus the
- // number of innerArgs already supplied, meets the total
- // expected.
- expected = expected-nextArgs.length;
- if(expected<=0){
- var res = func.apply(ns, totalArgs);
- expected = texpected;
- return res;
- }else{
- return function(){
- return gather(arguments,// check to see if we've been run
- // with enough args
- totalArgs, // a copy
- expected); // how many more do we need to run?;
- }
+dojo.lang.getNameInObj = function(/*Object*/ns, /*unknown*/item){
+ // summary: looks for a value in the object ns with a value matching item and returns the property name
+ // ns: if null, dj_global is used
+ // item: value to match
+ if(!ns){ ns = dj_global; }
+
+ for(var x in ns){
+ if(ns[x] === item){
+ return new String(x); // String
}
}
- return gather([], outerArgs, ecount);
+ return null; // null
}
-dojo.lang.curryArguments = function(ns, func, args, offset){
- var targs = [];
- var x = offset||0;
- for(x=offset; x<args.length; x++){
- targs.push(args[x]); // ensure that it's an arr
- }
- return dojo.lang.curry.apply(dojo.lang, [ns, func].concat(targs));
-}
+dojo.lang.shallowCopy = function(/*Object*/obj, /*Boolean?*/deep){
+ // summary: copies object obj one level deep, or full depth if deep is true
+ var i, ret;
-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;
- }
+ if(obj === null){ /*obj: null*/ return null; } // null
+
+ if(dojo.lang.isObject(obj)){
+ // obj: Object
+ ret = new obj.constructor();
+ for(i in obj){
+ if(dojo.lang.isUndefined(ret[i])){
+ ret[i] = deep ? dojo.lang.shallowCopy(obj[i], deep) : obj[i];
}
- }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();
+ } else if(dojo.lang.isArray(obj)){
+ // obj: Array
+ ret = [];
+ for(i=0; i<obj.length; i++){
+ ret[i] = deep ? dojo.lang.shallowCopy(obj[i], deep) : obj[i];
}
- return;
- }
- if((typeof delay == "undefined")&&(typeof cb == "number")){
- delay = cb;
- cb = function(){};
- }else if(!cb){
- cb = function(){};
- if(!delay){ delay = 0; }
+ } else {
+ // obj: unknown
+ ret = obj;
}
- setTimeout(function(){
- (farr.shift())();
- cb();
- dojo.lang.delayThese(farr, cb, delay, onend);
- }, delay);
-}
-
-dojo.provide("dojo.lang.array");
-dojo.require("dojo.lang.common");
-
-// 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){
- try{
- return (typeof obj[name] != "undefined");
- }catch(e){ return false; }
+ return ret; // unknown
}
-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;
- }
+dojo.lang.firstValued = function(/* ... */){
+ // summary: Return the first argument that isn't undefined
+
+ for(var i = 0; i < arguments.length; i++){
+ if(typeof arguments[i] != "undefined"){
+ return arguments[i]; // unknown
}
- return (count == 0);
- } else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)) {
- return obj.length == 0;
}
+ return undefined; // undefined
}
-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.getObjPathValue = function(/*String*/objpath, /*Object?*/context, /*Boolean?*/create){
+ // summary:
+ // Gets a value from a reference specified as a string descriptor,
+ // (e.g. "A.B") in the given context.
+ //
+ // context: if not specified, dj_global is used
+ // create: if true, undefined objects in the path are created.
+
+ with(dojo.parseObjPath(objpath, context, create)){
+ return dojo.evalProp(prop, obj, create); // unknown
}
}
-// http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:forEach
-dojo.lang.forEach = function(anArray /* Array */, callback /* Function */, thisObject /* Object */){
- if(dojo.lang.isString(anArray)){
- anArray = anArray.split("");
+dojo.lang.setObjPathValue = function(/*String*/objpath, /*unknown*/value, /*Object?*/context, /*Boolean?*/create){
+ // summary:
+ // Sets a value on a reference specified as a string descriptor.
+ // (e.g. "A.B") in the given context.
+ //
+ // context: if not specified, dj_global is used
+ // create: if true, undefined objects in the path are created.
+
+ if(arguments.length < 4){
+ create = true;
}
- if(Array.forEach){
- Array.forEach(anArray, callback, thisObject);
- }else{
- // FIXME: there are several ways of handilng thisObject. Is dj_global always the default context?
- if(!thisObject){
- thisObject=dj_global;
- }
- for(var i=0,l=anArray.length; i<l; i++){
- callback.call(thisObject, anArray[i], i, anArray);
+ with(dojo.parseObjPath(objpath, context, create)){
+ if(obj && (create || (prop in obj))){
+ obj[prop] = value;
}
}
}
-dojo.lang._everyOrSome = function(every, arr, callback, thisObject){
- if(dojo.lang.isString(arr)){
- arr = arr.split("");
- }
- if(Array.every){
- return Array[ (every) ? "every" : "some" ](arr, callback, thisObject);
- }else{
- if(!thisObject){
- thisObject = dj_global;
- }
- for(var i=0,l=arr.length; i<l; i++){
- var result = callback.call(thisObject, arr[i], i, arr);
- if((every)&&(!result)){
- return false;
- }else if((!every)&&(result)){
- return true;
- }
- }
- return (every) ? true : false;
- }
-}
-
-dojo.lang.every = function(arr, callback, thisObject){
- return this._everyOrSome(true, arr, callback, thisObject);
-}
-
-dojo.lang.some = function(arr, callback, thisObject){
- return this._everyOrSome(false, arr, callback, thisObject);
-}
-
-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.provide("dojo.io.common");
-/**
- * Creates a 1-D array out of all the arguments passed,
- * unravelling any array-like objects in the process
+/******************************************************************************
+ * Notes about dojo.io design:
+ *
+ * The dojo.io.* package has the unenviable task of making a lot of different
+ * types of I/O feel natural, despite a universal lack of good (or even
+ * reasonable!) I/O capability in the host environment. So lets pin this down
+ * a little bit further.
*
- * 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;
-}
+ * Rhino:
+ * perhaps the best situation anywhere. Access to Java classes allows you
+ * to do anything one might want in terms of I/O, both synchronously and
+ * async. Can open TCP sockets and perform low-latency client/server
+ * interactions. HTTP transport is available through Java HTTP client and
+ * server classes. Wish it were always this easy.
+ *
+ * xpcshell:
+ * XPCOM for I/O.
+ *
+ * spidermonkey:
+ * S.O.L.
+ *
+ * Browsers:
+ * Browsers generally do not provide any useable filesystem access. We are
+ * therefore limited to HTTP for moving information to and from Dojo
+ * instances living in a browser.
+ *
+ * XMLHTTP:
+ * Sync or async, allows reading of arbitrary text files (including
+ * JS, which can then be eval()'d), writing requires server
+ * cooperation and is limited to HTTP mechanisms (POST and GET).
+ *
+ * <iframe> hacks:
+ * iframe document hacks allow browsers to communicate asynchronously
+ * with a server via HTTP POST and GET operations. With significant
+ * effort and server cooperation, low-latency data transit between
+ * client and server can be acheived via iframe mechanisms (repubsub).
+ *
+ * SVG:
+ * Adobe's SVG viewer implements helpful primitives for XML-based
+ * requests, but receipt of arbitrary text data seems unlikely w/o
+ * <![CDATA[]]> sections.
+ *
+ *
+ * A discussion between Dylan, Mark, Tom, and Alex helped to lay down a lot
+ * the IO API interface. A transcript of it can be found at:
+ * http://dojotoolkit.org/viewcvs/viewcvs.py/documents/irc/irc_io_api_log.txt?rev=307&view=auto
+ *
+ * Also referenced in the design of the API was the DOM 3 L&S spec:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html
+ ******************************************************************************/
-/**
- * Converts an array-like object (i.e. arguments, DOMCollection)
- * to an array
-**/
-dojo.lang.toArray = function(arrayLike, startOffset) {
- var array = [];
- for(var i = startOffset||0; i < arrayLike.length; i++) {
- array.push(arrayLike[i]);
+// a map of the available transport options. Transports should add themselves
+// by calling add(name)
+dojo.io.transports = [];
+dojo.io.hdlrFuncNames = [ "load", "error", "timeout" ]; // we're omitting a progress() event for now
+
+dojo.io.Request = function(/*String*/ url, /*String*/ mimetype, /*String*/ transport, /*String or Boolean*/ changeUrl){
+// summary:
+// Constructs a Request object that is used by dojo.io.bind(). dojo.io.bind() will create one of these for you if
+// you call dojo.io.bind() with an plain object containing the bind parameters.
+// This method can either take the arguments specified, or an Object containing all of the parameters that you
+// want to use to create the dojo.io.Request (similar to how dojo.io.bind() is called.
+// The named parameters to this constructor represent the minimum set of parameters need
+ if((arguments.length == 1)&&(arguments[0].constructor == Object)){
+ this.fromKwArgs(arguments[0]);
+ }else{
+ this.url = url;
+ if(mimetype){ this.mimetype = mimetype; }
+ if(transport){ this.transport = transport; }
+ if(arguments.length >= 4){ this.changeUrl = changeUrl; }
}
- return array;
}
-dojo.provide("dojo.dom");
-dojo.require("dojo.lang.array");
+dojo.lang.extend(dojo.io.Request, {
-dojo.dom.ELEMENT_NODE = 1;
-dojo.dom.ATTRIBUTE_NODE = 2;
-dojo.dom.TEXT_NODE = 3;
-dojo.dom.CDATA_SECTION_NODE = 4;
-dojo.dom.ENTITY_REFERENCE_NODE = 5;
-dojo.dom.ENTITY_NODE = 6;
-dojo.dom.PROCESSING_INSTRUCTION_NODE = 7;
-dojo.dom.COMMENT_NODE = 8;
-dojo.dom.DOCUMENT_NODE = 9;
-dojo.dom.DOCUMENT_TYPE_NODE = 10;
-dojo.dom.DOCUMENT_FRAGMENT_NODE = 11;
-dojo.dom.NOTATION_NODE = 12;
+ /** The URL to hit */
+ url: "",
-dojo.dom.dojoml = "http://www.dojotoolkit.org/2004/dojoml";
+ /** The mime type used to interrpret the response body */
+ mimetype: "text/plain",
+
+ /** The HTTP method to use */
+ method: "GET",
+
+ /** An Object containing key-value pairs to be included with the request */
+ content: undefined, // Object
+
+ /** The transport medium to use */
+ transport: undefined, // String
+
+ /** If defined the URL of the page is physically changed */
+ changeUrl: undefined, // String
+
+ /** A form node to use in the request */
+ formNode: undefined, // HTMLFormElement
+
+ /** Whether the request should be made synchronously */
+ sync: false,
+
+ bindSuccess: false,
-/**
- * comprehensive list of XML namespaces
-**/
-dojo.dom.xmlns = {
- svg : "http://www.w3.org/2000/svg",
- smil : "http://www.w3.org/2001/SMIL20/",
- mml : "http://www.w3.org/1998/Math/MathML",
- cml : "http://www.xml-cml.org",
- xlink : "http://www.w3.org/1999/xlink",
- xhtml : "http://www.w3.org/1999/xhtml",
- xul : "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- xbl : "http://www.mozilla.org/xbl",
- fo : "http://www.w3.org/1999/XSL/Format",
- xsl : "http://www.w3.org/1999/XSL/Transform",
- xslt : "http://www.w3.org/1999/XSL/Transform",
- xi : "http://www.w3.org/2001/XInclude",
- xforms : "http://www.w3.org/2002/01/xforms",
- saxon : "http://icl.com/saxon",
- xalan : "http://xml.apache.org/xslt",
- xsd : "http://www.w3.org/2001/XMLSchema",
- dt: "http://www.w3.org/2001/XMLSchema-datatypes",
- xsi : "http://www.w3.org/2001/XMLSchema-instance",
- rdf : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
- rdfs : "http://www.w3.org/2000/01/rdf-schema#",
- dc : "http://purl.org/dc/elements/1.1/",
- dcq: "http://purl.org/dc/qualifiers/1.0",
- "soap-env" : "http://schemas.xmlsoap.org/soap/envelope/",
- wsdl : "http://schemas.xmlsoap.org/wsdl/",
- AdobeExtensions : "http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
-};
+ /** Cache/look for the request in the cache before attempting to request?
+ * NOTE: this isn't a browser cache, this is internal and would only cache in-page
+ */
+ useCache: false,
-dojo.dom.isNode = function(wh){
- if(typeof Element == "object") {
- try {
- return wh instanceof Element;
- } catch(E) {}
- } else {
- // best-guess
- return wh && !isNaN(wh.nodeType);
- }
-}
+ /** Prevent the browser from caching this by adding a query string argument to the URL */
+ preventCache: false,
+
+ // events stuff
+ load: function(/*String*/ type, /*Object*/ data, /*Object*/ transportImplementation, /*Object*/ kwArgs){
+ // summary:
+ // Called on successful completion of a bind.
+ // type:
+ // A string with value "load"
+ // data:
+ // The object representing the result of the bind. The actual structure
+ // of the data object will depend on the mimetype that was given to bind
+ // in the bind arguments.
+ // transportImplementation:
[... 21364 lines stripped ...]