| 29 | | //TODOC: HOW TO DOC THIS? |
| 30 | | // @global: dj_global |
| 31 | | // summary: |
| 32 | | // an alias for the top-level global object in the host environment |
| 33 | | // (e.g., the window object in a browser). |
| 34 | | // description: |
| 35 | | // Refer to 'dj_global' rather than referring to window to ensure your |
| 36 | | // code runs correctly in contexts other than web browsers (eg: Rhino on a server). |
| 37 | | var dj_global = this; |
| 38 | | |
| 39 | | //TODOC: HOW TO DOC THIS? |
| 40 | | // @global: dj_currentContext |
| 41 | | // summary: |
| 42 | | // Private global context object. Where 'dj_global' always refers to the boot-time |
| 43 | | // global context, 'dj_currentContext' can be modified for temporary context shifting. |
| 44 | | // dojo.global() returns dj_currentContext. |
| 45 | | // description: |
| 46 | | // Refer to dojo.global() rather than referring to dj_global to ensure your |
| 47 | | // code runs correctly in managed contexts. |
| 48 | | var dj_currentContext = this; |
| 49 | | |
| 50 | | |
| 51 | | // **************************************************************** |
| 52 | | // global public utils |
| 53 | | // TODOC: DO WE WANT TO NOTE THAT THESE ARE GLOBAL PUBLIC UTILS? |
| 54 | | // **************************************************************** |
| 55 | | |
| 56 | | function dj_undef(/*String*/ name, /*Object?*/ object){ |
| 57 | | //summary: Returns true if 'name' is defined on 'object' (or globally if 'object' is null). |
| 58 | | //description: Note that 'defined' and 'exists' are not the same concept. |
| 59 | | return (typeof (object || dj_currentContext)[name] == "undefined"); // Boolean |
| 60 | | } |
| 61 | | |
| 62 | | // make sure djConfig is defined |
| 63 | | if(dj_undef("djConfig", this)){ |
| 64 | | var djConfig = {}; |
| 65 | | } |
| 66 | | |
| 67 | | //TODOC: HOW TO DOC THIS? |
| 68 | | // dojo is the root variable of (almost all) our public symbols -- make sure it is defined. |
| 69 | | if(dj_undef("dojo", this)){ |
| 70 | | var dojo = {}; |
| 71 | | } |
| 72 | | |
| 73 | | dojo.global = function(){ |
| 74 | | // summary: |
| 75 | | // return the current global context object |
| 76 | | // (e.g., the window object in a browser). |
| 77 | | // description: |
| 78 | | // Refer to 'dojo.global()' rather than referring to window to ensure your |
| 79 | | // code runs correctly in contexts other than web browsers (eg: Rhino on a server). |
| 80 | | return dj_currentContext; |
| 81 | | } |
| | 23 | (function(){ |
| | 24 | // make sure djConfig is defined |
| | 25 | if(typeof this["djConfig"] == "undefined"){ |
| | 26 | this.djConfig = {}; |
| | 27 | } |
| | 28 | |
| | 29 | //TODOC: HOW TO DOC THIS? |
| | 30 | // dojo is the root variable of (almost all) our public symbols -- make sure it is defined. |
| | 31 | if(typeof this["dojo"] == "undefined"){ |
| | 32 | this.dojo = {}; |
| | 33 | } |
| | 34 | |
| | 35 | dojo._currentContext = this; |
| | 36 | |
| | 37 | dojo.global = function(){ |
| | 38 | // summary: |
| | 39 | // return the current global context object |
| | 40 | // (e.g., the window object in a browser). |
| | 41 | // description: |
| | 42 | // Refer to 'dojo.global()' rather than referring to window to ensure your |
| | 43 | // code runs correctly in contexts other than web browsers (eg: Rhino on a server). |
| | 44 | return this._currentContext; |
| | 45 | } |
| | 46 | |
| | 47 | var _config = { |
| | 48 | isDebug: false, |
| | 49 | allowQueryConfig: false, |
| | 50 | baseScriptUri: "", |
| | 51 | baseRelativePath: "", |
| | 52 | libraryScriptUri: "", |
| | 53 | preventBackButtonFix: true, |
| | 54 | delayMozLoadingFix: false |
| | 55 | }; |
| | 56 | |
| | 57 | for(var option in _config){ |
| | 58 | if(typeof djConfig[option] == "undefined"){ |
| | 59 | djConfig[option] = _config[option]; |
| | 60 | } |
| | 61 | } |
| | 62 | |
| | 63 | var _platforms = ["Browser", "Rhino", "Spidermonkey", "Mobile"]; |
| | 64 | var t; |
| | 65 | while(t=_platforms.shift()){ |
| | 66 | dojo["is"+t] = false; |
| | 67 | } |
| | 68 | })(); |
| | 69 | |
| 159 | | } |
| 160 | | |
| 161 | | dojo.evalProp = function(/*String*/name, /*Object*/object, /*Boolean?*/create){ |
| 162 | | // summary: |
| 163 | | // DEPRECATED. Returns 'object[name]'. If not defined and 'create' is |
| 164 | | // true, will return a new Object. |
| 165 | | // description: |
| 166 | | // Returns null if 'object[name]' is not defined and 'create' is not true. |
| 167 | | // Note: 'defined' and 'exists' are not the same concept. |
| 168 | | dojo.deprecated("dojo.evalProp", "just use hash syntax. Sheesh.", "0.6"); |
| 169 | | return object[name] || (create ? (object[name]={}) : undefined); // mixed |
| 170 | | } |
| 171 | | |
| 172 | | dojo.parseObjPath = function(/*String*/ path, /*Object?*/ context, /*Boolean?*/ create){ |
| 173 | | // summary: |
| 174 | | // DEPRECATED. Parse string path to an object, and return |
| 175 | | // corresponding object reference and property name. |
| 176 | | // description: |
| 177 | | // Returns an object with two properties, 'obj' and 'prop'. |
| 178 | | // 'obj[prop]' is the reference indicated by 'path'. |
| 179 | | // path: Path to an object, in the form "A.B.C". |
| 180 | | // context: Object to use as root of path. Defaults to 'dojo.global()'. |
| 181 | | // create: |
| 182 | | // If true, Objects will be created at any point along the 'path' that |
| 183 | | // is undefined. |
| 184 | | dojo.deprecated("dojo.parseObjPath", "use dojo.getObject(path, create, context, true)", "0.6"); |
| 185 | | return dojo.getObject(path, create, context, true); // Object: {obj: Object, prop: String} |
| 186 | | } |
| 187 | | |
| 188 | | dojo.evalObjPath = function(/*String*/path, /*Boolean?*/create){ |
| 189 | | // summary: |
| 190 | | // DEPRECATED. Return the value of object at 'path' in the global |
| 191 | | // scope, without using 'eval()'. |
| 192 | | // path: Path to an object, in the form "A.B.C". |
| 193 | | // create: |
| 194 | | // If true, Objects will be created at any point along the 'path' that |
| 195 | | // is undefined. |
| 196 | | dojo.deprecated("dojo.evalObjPath", "use dojo.getObject(path, create)", "0.6"); |
| 197 | | return dojo.getObject(path, create); // Object |
| 198 | | } |
| 199 | | |
| 200 | | dojo.errorToString = function(/*Error*/ exception){ |
| 201 | | // summary: Return an exception's 'message', 'description' or text. |
| 202 | | |
| 203 | | // TODO: overriding Error.prototype.toString won't accomplish this? |
| 204 | | // ... since natively generated Error objects do not always reflect such things? |
| 205 | | /* |
| 206 | | if(!dj_undef("message", exception)){ |
| 207 | | return exception.message; // String |
| 208 | | }else if(!dj_undef("description", exception)){ |
| 209 | | return exception.description; // String |
| 210 | | }else{ |
| 211 | | return exception; // Error |
| 212 | | } |
| 213 | | */ |
| 214 | | return (exception["message"]||exception["description"]||exception); |
| 215 | | } |
| 216 | | |
| 217 | | dojo.raise = function(/*String*/ message, /*Error?*/ exception){ |
| 218 | | // summary: |
| 219 | | // Common point for raising exceptions in Dojo to enable logging. |
| 220 | | // Throws an error message with text of 'exception' if provided, or |
| 221 | | // rethrows exception object. |
| 222 | | |
| 223 | | if(exception){ |
| 224 | | message = message + ": "+dojo.errorToString(exception); |
| 225 | | }else{ |
| 226 | | message = dojo.errorToString(message); |
| 227 | | } |
| 228 | | |
| 229 | | // print the message to the user if hostenv.println is defined |
| 230 | | try{ |
| 231 | | if(djConfig.isDebug){ |
| 232 | | dojo.hostenv.println("FATAL exception raised: "+message); |
| 233 | | } |
| 234 | | }catch(e){} |
| 235 | | |
| 236 | | throw exception || Error(message); |
| 285 | | dojo.render = (function(){ |
| 286 | | // summary: |
| 287 | | // Builds the dojo.render object which details rendering support, OS |
| 288 | | // and browser of the current environment. |
| | 174 | dojo.experimental = function(/* String */ moduleName, /* String? */ extra){ |
| | 175 | // summary: Marks code as experimental. |
| | 176 | // description: |
| | 177 | // This can be used to mark a function, file, or module as |
| | 178 | // experimental. Experimental code is not ready to be used, and the |
| | 179 | // APIs are subject to change without notice. Experimental code may be |
| | 180 | // completed deleted without going through the normal deprecation |
| | 181 | // process. |
| | 182 | // moduleName: |
| | 183 | // The name of a module, or the name of a module file or a specific |
| | 184 | // function |
| | 185 | // extra: |
| | 186 | // some additional message for the user |
| | 187 | // examples: |
| | 188 | // dojo.experimental("dojo.data.Result"); |
| | 189 | // dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA"); |
| | 190 | var message = "EXPERIMENTAL: " + moduleName; |
| | 191 | message += " -- Not yet ready for use. APIs subject to change without notice."; |
| | 192 | if(extra){ message += " " + extra; } |
| | 193 | dojo.debug(message); |
| | 194 | } |
| | 195 | |
| | 196 | dojo._getText = function(/*String*/ uri){ |
| | 197 | // summary: |
| | 198 | // Read the plain/text contents at the specified 'uri'. |
| 290 | | // commonly used properties of dojo.render (in HTML environments) |
| 291 | | // include: |
| 292 | | // |
| 293 | | // dojo.render.html.ie |
| 294 | | // dojo.render.html.opera |
| 295 | | // dojo.render.html.khtml |
| 296 | | // dojo.render.html.safari |
| 297 | | // dojo.render.html.moz |
| 298 | | // dojo.render.html.mozilla |
| 299 | | // |
| 300 | | // additional objects are provided to detail support for other types |
| 301 | | // of media and environments. For instance, the following determines |
| 302 | | // if there's native SVG support in a browser: |
| 303 | | // |
| 304 | | // if(dojo.render.svg.capable && dojo.render.svg.builtin){ |
| 305 | | // ... |
| 306 | | // } |
| 307 | | // |
| 308 | | // Other properties of note: |
| 309 | | // |
| 310 | | // dojo.render.os.win |
| 311 | | // dojo.render.os.osx |
| 312 | | // dojo.render.os.linux |
| 313 | | // dojo.render.html.UA (navigator.userAgent) |
| 314 | | // dojo.render.html.AV (navigator.appVersion) |
| 315 | | // dojo.render.html.ie50 (MSIE 5.0) |
| 316 | | // dojo.render.html.ie55 (MSIE 5.5) |
| 317 | | // dojo.render.html.ie60 (MSIE 6.0) |
| 318 | | // dojo.render.html.ie70 (MSIE 7.0) |
| 319 | | // |
| 320 | | // All reasonable measures are taken to ensure that the values in |
| 321 | | // dojo.render represent the real environment and not, say, a browser |
| 322 | | // "masquerading" as a different browser version. Only supported |
| 323 | | // environments and browsers will likely have entires in dojo.render. |
| 324 | | function vscaffold(prefs, names){ |
| 325 | | var tmp = { |
| 326 | | capable: false, |
| 327 | | support: { |
| 328 | | builtin: false, |
| 329 | | plugin: false |
| 330 | | }, |
| 331 | | prefixes: prefs |
| 332 | | }; |
| 333 | | for(var i=0; i<names.length; i++){ |
| 334 | | tmp[names[i]] = false; |
| 335 | | } |
| 336 | | return tmp; |
| 337 | | } |
| 338 | | |
| 339 | | return { |
| 340 | | name: "", |
| 341 | | ver: dojo.version, |
| 342 | | os: { win: false, linux: false, osx: false }, |
| 343 | | html: vscaffold(["html"], ["ie", "opera", "khtml", "safari", "moz"]), |
| 344 | | svg: vscaffold(["svg"], ["corel", "adobe", "batik"]), |
| 345 | | vml: vscaffold(["vml"], ["ie"]), |
| 346 | | swf: vscaffold(["Swf", "Flash", "Mm"], ["mm"]), |
| 347 | | swt: vscaffold(["Swt"], ["ibm"]) |
| 348 | | }; |
| 349 | | })(); |
| 350 | | |
| 351 | | // **************************************************************** |
| 352 | | // dojo.hostenv methods that must be defined in hostenv_*.js |
| 353 | | // **************************************************************** |
| 354 | | |
| 355 | | /** |
| 356 | | * The interface definining the interaction with the EcmaScript host environment. |
| 357 | | */ |
| 358 | | |
| 359 | | /* |
| 360 | | * None of these methods should ever be called directly by library users. |
| 361 | | * Instead public methods such as loadModule should be called instead. |
| 362 | | */ |
| 363 | | dojo.hostenv = (function(){ |
| 364 | | // TODOC: HOW TO DOC THIS? |
| 365 | | // summary: |
| 366 | | // Provides encapsulation of behavior that changes across different |
| 367 | | // 'host environments' (different browsers, server via Rhino, etc). |
| 368 | | // description: |
| 369 | | // None of these methods should ever be called directly by library |
| 370 | | // users. Use public methods such as 'loadModule' instead. |
| 371 | | |
| 372 | | // default configuration options |
| 373 | | var config = { |
| 374 | | isDebug: false, |
| 375 | | allowQueryConfig: false, |
| 376 | | baseScriptUri: "", |
| 377 | | baseRelativePath: "", |
| 378 | | libraryScriptUri: "", |
| 379 | | iePreventClobber: false, |
| 380 | | ieClobberMinimal: true, |
| 381 | | preventBackButtonFix: true, |
| 382 | | delayMozLoadingFix: false, |
| 383 | | searchIds: [], |
| 384 | | parseWidgets: true |
| 385 | | }; |
| 386 | | |
| 387 | | if(typeof djConfig == "undefined"){ |
| 388 | | djConfig = config; |
| 389 | | }else{ |
| 390 | | for(var option in config){ |
| 391 | | if(typeof djConfig[option] == "undefined"){ |
| 392 | | djConfig[option] = config[option]; |
| 393 | | } |
| 394 | | } |
| 395 | | } |
| 396 | | |
| 397 | | return { |
| 398 | | name_: '(unset)', |
| 399 | | version_: '(unset)', |
| 400 | | |
| 401 | | |
| 402 | | getName: function(){ |
| 403 | | // sumary: Return the name of the host environment. |
| 404 | | return this.name_; // String |
| 405 | | }, |
| 406 | | |
| 407 | | |
| 408 | | getVersion: function(){ |
| 409 | | // summary: Return the version of the hostenv. |
| 410 | | return this.version_; // String |
| 411 | | }, |
| 412 | | |
| 413 | | getText: function(/*String*/ uri){ |
| 414 | | // summary: |
| 415 | | // Read the plain/text contents at the specified 'uri'. |
| 416 | | // description: |
| 417 | | // If 'getText()' is not implemented, then it is necessary to |
| 418 | | // override 'loadUri()' with an implementation that doesn't |
| 419 | | // rely on it. |
| 420 | | dojo.unimplemented('getText', "uri=" + uri); |
| 421 | | } |
| 422 | | }; |
| 423 | | })(); |
| 424 | | |
| 425 | | |
| 426 | | dojo.hostenv.getBaseScriptUri = function(){ |
| 427 | | // summary: |
| 428 | | // Return the base script uri that other scripts are found relative to. |
| 429 | | // MAYBE: Return the base uri to scripts in the dojo library. ??? |
| 430 | | // return: Empty string or a path ending in '/'. |
| 431 | | |
| 432 | | |
| 433 | | // TODOC: |
| 434 | | // HUH? This comment means nothing to me. What other scripts? Is |
| 435 | | // this the path to other dojo libraries? |
| 436 | | if(djConfig.baseScriptUri.length){ |
| 437 | | return djConfig.baseScriptUri; |
| 438 | | } |
| 439 | | |
| 440 | | // MOW: Why not: |
| 441 | | // uri = djConfig.libraryScriptUri || djConfig.baseRelativePath |
| 442 | | // ??? Why 'new String(...)' |
| 443 | | var uri = new String(djConfig.libraryScriptUri||djConfig.baseRelativePath); |
| 444 | | if(!uri){ |
| 445 | | dojo.raise("Nothing returned by getLibraryScriptUri(): " + uri); |
| 446 | | } |
| 447 | | // MOW: |
| 448 | | // uri seems to not be actually used. Seems to be hard-coding to |
| 449 | | // djConfig.baseRelativePath... ??? |
| 450 | | |
| 451 | | djConfig.baseScriptUri = djConfig.baseRelativePath; |
| 452 | | return djConfig.baseScriptUri; // String |
| 453 | | } |
| | 200 | // If 'getText()' is not implemented, then it is necessary to |
| | 201 | // override 'loadUri()' with an implementation that doesn't |
| | 202 | // rely on it. |
| | 203 | |
| | 204 | // NOTE: platform specializations need to implement this |
| | 205 | } |
| | 206 | |