2150 |
mathias |
1 |
// TODOC: HOW TO DOC THE BELOW?
|
|
|
2 |
// @global: djConfig
|
|
|
3 |
// summary:
|
|
|
4 |
// Application code can set the global 'djConfig' prior to loading
|
|
|
5 |
// the library to override certain global settings for how dojo works.
|
|
|
6 |
// description: The variables that can be set are as follows:
|
|
|
7 |
// - isDebug: false
|
|
|
8 |
// - libraryScriptUri: ""
|
|
|
9 |
// - locale: undefined
|
|
|
10 |
// - extraLocale: undefined
|
|
|
11 |
// - preventBackButtonFix: true
|
|
|
12 |
// note:
|
|
|
13 |
// 'djConfig' does not exist under 'dojo.*' so that it can be set before the
|
|
|
14 |
// 'dojo' variable exists.
|
|
|
15 |
// note:
|
|
|
16 |
// Setting any of these variables *after* the library has loaded does
|
|
|
17 |
// nothing at all.
|
|
|
18 |
|
|
|
19 |
(function(){
|
|
|
20 |
// make sure djConfig is defined
|
|
|
21 |
if(typeof this["djConfig"] == "undefined"){
|
|
|
22 |
this.djConfig = {};
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
// firebug stubs
|
|
|
26 |
if((!this["console"])||(!console["firebug"])){
|
|
|
27 |
this.console = {};
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
var cn = [
|
|
|
31 |
"assert", "count", "debug", "dir", "dirxml", "error", "group",
|
|
|
32 |
"groupEnd", "info", "log", "profile", "profileEnd", "time",
|
|
|
33 |
"timeEnd", "trace", "warn"
|
|
|
34 |
];
|
|
|
35 |
var i=0, tn;
|
|
|
36 |
while((tn=cn[i++])){
|
|
|
37 |
if(!console[tn]){
|
|
|
38 |
console[tn] = function(){};
|
|
|
39 |
}
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
//TODOC: HOW TO DOC THIS?
|
|
|
43 |
// dojo is the root variable of (almost all) our public symbols -- make sure it is defined.
|
|
|
44 |
if(typeof this["dojo"] == "undefined"){
|
|
|
45 |
this.dojo = {};
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
var d = dojo;
|
|
|
49 |
|
|
|
50 |
// summary:
|
|
|
51 |
// return the current global context object
|
|
|
52 |
// (e.g., the window object in a browser).
|
|
|
53 |
// description:
|
|
|
54 |
// Refer to 'dojo.global' rather than referring to window to ensure your
|
|
|
55 |
// code runs correctly in contexts other than web browsers (eg: Rhino on a server).
|
|
|
56 |
dojo.global = this;
|
|
|
57 |
|
|
|
58 |
var _config =/*===== djConfig = =====*/{
|
|
|
59 |
isDebug: false,
|
|
|
60 |
libraryScriptUri: "",
|
|
|
61 |
preventBackButtonFix: true,
|
|
|
62 |
delayMozLoadingFix: false
|
|
|
63 |
};
|
|
|
64 |
|
|
|
65 |
for(var option in _config){
|
|
|
66 |
if(typeof djConfig[option] == "undefined"){
|
|
|
67 |
djConfig[option] = _config[option];
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
var _platforms = ["Browser", "Rhino", "Spidermonkey", "Mobile"];
|
|
|
72 |
var t;
|
|
|
73 |
while(t=_platforms.shift()){
|
|
|
74 |
d["is"+t] = false;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
// Override locale setting, if specified
|
|
|
78 |
dojo.locale = djConfig.locale;
|
|
|
79 |
|
|
|
80 |
//TODOC: HOW TO DOC THIS?
|
|
|
81 |
dojo.version = {
|
|
|
82 |
// summary: version number of this instance of dojo.
|
|
|
83 |
major: 1, minor: 0, patch: 2, flag: "",
|
|
|
84 |
revision: Number("$Rev: 11832 $".match(/[0-9]+/)[0]),
|
|
|
85 |
toString: function(){
|
|
|
86 |
with(d.version){
|
|
|
87 |
return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
// Register with the OpenAjax hub
|
|
|
93 |
if(typeof OpenAjax != "undefined"){
|
|
|
94 |
OpenAjax.hub.registerLibrary("dojo", "http://dojotoolkit.org", d.version.toString());
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
dojo._mixin = function(/*Object*/ obj, /*Object*/ props){
|
|
|
98 |
// summary:
|
|
|
99 |
// Adds all properties and methods of props to obj. This addition is
|
|
|
100 |
// "prototype extension safe", so that instances of objects will not
|
|
|
101 |
// pass along prototype defaults.
|
|
|
102 |
var tobj = {};
|
|
|
103 |
for(var x in props){
|
|
|
104 |
// the "tobj" condition avoid copying properties in "props"
|
|
|
105 |
// inherited from Object.prototype. For example, if obj has a custom
|
|
|
106 |
// toString() method, don't overwrite it with the toString() method
|
|
|
107 |
// that props inherited from Object.prototype
|
|
|
108 |
if(tobj[x] === undefined || tobj[x] != props[x]){
|
|
|
109 |
obj[x] = props[x];
|
|
|
110 |
}
|
|
|
111 |
}
|
|
|
112 |
// IE doesn't recognize custom toStrings in for..in
|
|
|
113 |
if(d["isIE"] && props){
|
|
|
114 |
var p = props.toString;
|
|
|
115 |
if(typeof p == "function" && p != obj.toString && p != tobj.toString &&
|
|
|
116 |
p != "\nfunction toString() {\n [native code]\n}\n"){
|
|
|
117 |
obj.toString = props.toString;
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
return obj; // Object
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
dojo.mixin = function(/*Object*/obj, /*Object...*/props){
|
|
|
124 |
// summary: Adds all properties and methods of props to obj.
|
|
|
125 |
for(var i=1, l=arguments.length; i<l; i++){
|
|
|
126 |
d._mixin(obj, arguments[i]);
|
|
|
127 |
}
|
|
|
128 |
return obj; // Object
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
dojo._getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
|
|
|
132 |
var obj=context||d.global;
|
|
|
133 |
for(var i=0, p; obj&&(p=parts[i]); i++){
|
|
|
134 |
obj = (p in obj ? obj[p] : (create ? obj[p]={} : undefined));
|
|
|
135 |
}
|
|
|
136 |
return obj; // mixed
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
dojo.setObject = function(/*String*/name, /*mixed*/value, /*Object*/context){
|
|
|
140 |
// summary:
|
|
|
141 |
// Set a property from a dot-separated string, such as "A.B.C"
|
|
|
142 |
// description:
|
|
|
143 |
// Useful for longer api chains where you have to test each object in
|
|
|
144 |
// the chain, or when you have an object reference in string format.
|
|
|
145 |
// Objects are created as needed along 'path'.
|
|
|
146 |
// name:
|
|
|
147 |
// Path to a property, in the form "A.B.C".
|
|
|
148 |
// context:
|
|
|
149 |
// Optional. Object to use as root of path. Defaults to
|
|
|
150 |
// 'dojo.global'. Null may be passed.
|
|
|
151 |
var parts=name.split("."), p=parts.pop(), obj=d._getProp(parts, true, context);
|
|
|
152 |
return (obj && p ? (obj[p]=value) : undefined); // mixed
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
dojo.getObject = function(/*String*/name, /*Boolean*/create, /*Object*/context){
|
|
|
156 |
// summary:
|
|
|
157 |
// Get a property from a dot-separated string, such as "A.B.C"
|
|
|
158 |
// description:
|
|
|
159 |
// Useful for longer api chains where you have to test each object in
|
|
|
160 |
// the chain, or when you have an object reference in string format.
|
|
|
161 |
// name:
|
|
|
162 |
// Path to an property, in the form "A.B.C".
|
|
|
163 |
// context:
|
|
|
164 |
// Optional. Object to use as root of path. Defaults to
|
|
|
165 |
// 'dojo.global'. Null may be passed.
|
|
|
166 |
// create:
|
|
|
167 |
// Optional. If true, Objects will be created at any point along the
|
|
|
168 |
// 'path' that is undefined.
|
|
|
169 |
return d._getProp(name.split("."), create, context); // mixed
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
dojo.exists = function(/*String*/name, /*Object?*/obj){
|
|
|
173 |
// summary:
|
|
|
174 |
// determine if an object supports a given method
|
|
|
175 |
// description:
|
|
|
176 |
// useful for longer api chains where you have to test each object in
|
|
|
177 |
// the chain
|
|
|
178 |
// name:
|
|
|
179 |
// Path to an object, in the form "A.B.C".
|
|
|
180 |
// obj:
|
|
|
181 |
// Object to use as root of path. Defaults to
|
|
|
182 |
// 'dojo.global'. Null may be passed.
|
|
|
183 |
return !!d.getObject(name, false, obj); // Boolean
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
dojo["eval"] = function(/*String*/ scriptFragment){
|
|
|
188 |
// summary:
|
|
|
189 |
// Perform an evaluation in the global scope. Use this rather than
|
|
|
190 |
// calling 'eval()' directly.
|
|
|
191 |
// description:
|
|
|
192 |
// Placed in a separate function to minimize size of trapped
|
|
|
193 |
// evaluation context.
|
|
|
194 |
// note:
|
|
|
195 |
// - JSC eval() takes an optional second argument which can be 'unsafe'.
|
|
|
196 |
// - Mozilla/SpiderMonkey eval() takes an optional second argument which is the
|
|
|
197 |
// scope object for new symbols.
|
|
|
198 |
|
|
|
199 |
// FIXME: investigate Joseph Smarr's technique for IE:
|
|
|
200 |
// http://josephsmarr.com/2007/01/31/fixing-eval-to-use-global-scope-in-ie/
|
|
|
201 |
// see also:
|
|
|
202 |
// http://trac.dojotoolkit.org/ticket/744
|
|
|
203 |
return d.global.eval ? d.global.eval(scriptFragment) : eval(scriptFragment); // mixed
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
/*=====
|
|
|
207 |
dojo.deprecated = function(behaviour, extra, removal){
|
|
|
208 |
// summary:
|
|
|
209 |
// Log a debug message to indicate that a behavior has been
|
|
|
210 |
// deprecated.
|
|
|
211 |
// behaviour: String
|
|
|
212 |
// The API or behavior being deprecated. Usually in the form
|
|
|
213 |
// of "myApp.someFunction()".
|
|
|
214 |
// extra: String?
|
|
|
215 |
// Text to append to the message. Often provides advice on a
|
|
|
216 |
// new function or facility to achieve the same goal during
|
|
|
217 |
// the deprecation period.
|
|
|
218 |
// removal: String?
|
|
|
219 |
// Text to indicate when in the future the behavior will be
|
|
|
220 |
// removed. Usually a version number.
|
|
|
221 |
// example:
|
|
|
222 |
// | dojo.deprecated("myApp.getTemp()", "use myApp.getLocaleTemp() instead", "1.0");
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
dojo.experimental = function(moduleName, extra){
|
|
|
226 |
// summary: Marks code as experimental.
|
|
|
227 |
// description:
|
|
|
228 |
// This can be used to mark a function, file, or module as
|
|
|
229 |
// experimental. Experimental code is not ready to be used, and the
|
|
|
230 |
// APIs are subject to change without notice. Experimental code may be
|
|
|
231 |
// completed deleted without going through the normal deprecation
|
|
|
232 |
// process.
|
|
|
233 |
// moduleName: String
|
|
|
234 |
// The name of a module, or the name of a module file or a specific
|
|
|
235 |
// function
|
|
|
236 |
// extra: String?
|
|
|
237 |
// some additional message for the user
|
|
|
238 |
// example:
|
|
|
239 |
// | dojo.experimental("dojo.data.Result");
|
|
|
240 |
// example:
|
|
|
241 |
// | dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
|
|
|
242 |
}
|
|
|
243 |
=====*/
|
|
|
244 |
|
|
|
245 |
//Real functions declared in dojo._firebug.firebug.
|
|
|
246 |
d.deprecated = d.experimental = function(){};
|
|
|
247 |
|
|
|
248 |
})();
|
|
|
249 |
// vim:ai:ts=4:noet
|