📄 bootstrap1.js
字号:
/*** @file bootstrap1.js** summary: First file that is loaded that 'bootstraps' the entire dojo library suite.* note: Must run before hostenv_*.js file.** @author Copyright 2004 Mark D. Anderson (mda@discerning.com)* 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 $*/// TODOC: HOW TO DOC THE BELOW?// @global: djConfig// summary: // Application code can set the global 'djConfig' prior to loading// the library to override certain global settings for how dojo works. // description: The variables that can be set are as follows:// - isDebug: false// - allowQueryConfig: false// - baseScriptUri: ""// - baseRelativePath: ""// - libraryScriptUri: ""// - iePreventClobber: false// - ieClobberMinimal: true// - preventBackButtonFix: true// - searchIds: []// - parseWidgets: true// TODOC: HOW TO DOC THESE VARIABLES?// TODOC: IS THIS A COMPLETE LIST?// note:// 'djConfig' does not exist under 'dojo.*' so that it can be set before the // 'dojo' variable exists. // note:// Setting any of these variables *after* the library has loaded does nothing at all. // TODOC: is this still true? Release notes for 0.3 indicated they could be set after load.////TODOC: HOW TO DOC THIS?// @global: dj_global// summary: // an alias for the top-level global object in the host environment// (e.g., the window object in a browser).// description: // Refer to 'dj_global' rather than referring to window to ensure your// code runs correctly in contexts other than web browsers (eg: Rhino on a server).var dj_global = this;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}// make sure djConfig is definedif(dj_undef("djConfig")){ 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")){ var dojo = {}; }//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]), toString: function(){ with(dojo.version){ return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String } }}dojo.evalProp = function(/*String*/ name, /*Object*/ object, /*Boolean?*/ create){ // summary: Returns 'object[name]'. If not defined and 'create' is true, will return a new Object. // 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}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'. // create: If true, Objects will be created at any point along the 'path' that is undefined. var object = (context != null ? context : dj_global); var names = path.split('.'); var prop = names.pop(); for (var i=0,l=names.length;i<l && object;i++){ object = dojo.evalProp(names[i], object, create); } 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; } // fast path for no periods if(path.indexOf('.') == -1){ return dojo.evalProp(path, dj_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); 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. // TODO: overriding Error.prototype.toString won't accomplish this? // ... since natively generated Error objects do not always reflect such things? if(!dj_undef("message", exception)){ return exception.message; // String }else if(!dj_undef("description", exception)){ return exception.description; // String }else{ return exception; // Error }}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'. 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) {} throw Error(message);}//Stub functions so things don't break.//TODOC: HOW TO DOC THESE?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. // note: // - 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. 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. var message = "'" + funcname + "' not implemented"; if (extra != null) { message += " " + extra; } 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. // removal: Text to indicate when in the future the behavior will be removed. var message = "DEPRECATED: " + behaviour; if(extra){ message += " " + extra; } if(removal){ message += " -- will be removed in version: " + removal; } 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. // TODOC: is this something many folks will interact with? If so, we should doc the structure created... function vscaffold(prefs, names){ var tmp = { capable: false, support: { builtin: false, plugin: false }, prefixes: prefs }; for(var prop in names){ tmp[prop] = 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(){ // TODOC: HOW TO DOC THIS? // summary: Provides encapsulation of behavior that changes across different 'host environments' // (different browsers, server via Rhino, etc). // description: None of these methods should ever be called directly by library users. // Use public methods such as 'loadModule' instead. // 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]; } } } return { name_: '(unset)', version_: '(unset)', getName: function(){ // sumary: Return the name of the host environment. return this.name_; // String }, getVersion: function(){ // summary: Return the version of the hostenv. return this.version_; // String }, getText: function(/*String*/ uri){ // summary: Read the plain/text contents at the specified 'uri'. // description: // If 'getText()' is not implemented, then it is necessary to override // 'loadUri()' with an implementation that doesn't rely on it. dojo.unimplemented('getText', "uri=" + uri); } };})();dojo.hostenv.getBaseScriptUri = function(){ // summary: Return the base script uri that other scripts are found relative to. // TODOC: HUH? This comment means nothing to me. What other scripts? Is this the path to other dojo libraries? // MAYBE: Return the base uri to scripts in the dojo library. ??? // return: Empty string or a path ending in '/'. if(djConfig.baseScriptUri.length){ return djConfig.baseScriptUri; } // MOW: Why not: // uri = djConfig.libraryScriptUri || djConfig.baseRelativePath // ??? Why 'new String(...)' var uri = new String(djConfig.libraryScriptUri||djConfig.baseRelativePath); if (!uri) { dojo.raise("Nothing returned by getLibraryScriptUri(): " + uri); } // MOW: uri seems to not be actually used. Seems to be hard-coding to djConfig.baseRelativePath... ??? var lastslash = uri.lastIndexOf('/'); // MOW ??? djConfig.baseScriptUri = djConfig.baseRelativePath; return djConfig.baseScriptUri; // String}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -