]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/kernel.js.uncompressed.js
1 define("dojo/_base/kernel", ["../has", "./config", "require", "module"], function(has
, config
, require
, module
){
5 // This module is the foundational module of the dojo boot sequence; it defines the dojo object.
8 // loop variables for this module
11 // create dojo, dijit, and dojox
12 // FIXME: in 2.0 remove dijit, dojox being created by dojo
17 // This module is the foundational module of the dojo boot sequence; it defines the dojo object.
19 // notice dojo takes ownership of the value of the config module
27 // Configure the scope map. For a 100% AMD application, the scope map is not needed other than to provide
28 // a _scopeName property for the dojo, dijit, and dojox root object so those packages can create
29 // unique names in the global space.
31 // Built, legacy modules use the scope map to allow those modules to be expressed as if dojo, dijit, and dojox,
32 // where global when in fact they are either global under different names or not global at all. In v1.6-, the
33 // config variable "scopeMap" was used to map names as used within a module to global names. This has been
34 // subsumed by the AMD map configuration variable which can relocate packages to different names. For backcompat,
35 // only the "*" mapping is supported. See http://livedocs.dojotoolkit.org/developer/design/loader#legacy-cross-domain-mode for details.
37 // The following computations contort the packageMap for this dojo instance into a scopeMap.
39 // a map from a name used in a legacy module to the (global variable name, object addressed by that name)
40 // always map dojo, dijit, and dojox
43 dijit
:["dijit", dijit
],
44 dojox
:["dojox", dojox
]
48 // the package map for this dojo instance; note, a foreign loader or no pacakgeMap results in the above default config
49 (require
.map
&& require
.map
[module
.id
.match(/[^\/]+/)[0]]),
54 // process all mapped top-level names for this instance of dojo
57 // mapped dojo, dijit, or dojox
58 scopeMap
[p
][0] = packageMap
[p
];
60 // some other top-level name
61 scopeMap
[p
] = [packageMap
[p
], {}];
65 // publish those names to _scopeName and, optionally, the global namespace
68 item
[1]._scopeName
= item
[0];
69 if(!config
.noGlobals
){
70 this[item
[0]] = item
[1];
73 dojo
.scopeMap
= scopeMap
;
75 /*===== dojo.__docParserConfigureScopeMap(scopeMap); =====*/
77 // FIXME: dojo.baseUrl and dojo.config.baseUrl should be deprecated
78 dojo
.baseUrl
= dojo
.config
.baseUrl
= require
.baseUrl
;
79 dojo
.isAsync
= ! 1 || require
.async
;
80 dojo
.locale
= config
.locale
;
82 var rev
= "$Rev: 30226 $".match(/\d+/);
85 // Version number of the Dojo Toolkit
87 // Hash about the version, including
89 // - major: Integer: Major version. If total version is "1.2.0beta1", will be 1
90 // - minor: Integer: Minor version. If total version is "1.2.0beta1", will be 2
91 // - patch: Integer: Patch version. If total version is "1.2.0beta1", will be 0
92 // - flag: String: Descriptor flag. If total version is "1.2.0beta1", will be "beta1"
93 // - revision: Number: The SVN rev from which dojo was pulled
95 major
: 1, minor
: 8, patch
: 3, flag
: "",
96 revision
: rev
? +rev
[0] : NaN
,
99 return v
.major
+ "." + v
.minor
+ "." + v
.patch
+ v
.flag
+ " (" + v
.revision
+ ")"; // String
103 // If 1 is truthy, then as a dojo module is defined it should push it's definitions
104 // into the dojo object, and conversely. In 2.0, it will likely be unusual to augment another object
105 // as a result of defining a module. This has feature gives a way to force 2.0 behavior as the code
106 // is migrated. Absent specific advice otherwise, set extend-dojo to truthy.
107 1 || has
.add("extend-dojo", 1);
110 (Function("d", "d.eval = function(){return d.global.eval ? d.global.eval(arguments[0]) : eval(arguments[0]);}"))(dojo
);
112 dojo.eval = function(scriptText){
114 // A legacy method created for use exclusively by internal Dojo methods. Do not use this method
115 // directly unless you understand its possibly-different implications on the platforms your are targeting.
117 // Makes an attempt to evaluate scriptText in the global scope. The function works correctly for browsers
118 // that support indirect eval.
120 // As usual, IE does not. On IE, the only way to implement global eval is to
121 // use execScript. Unfortunately, execScript does not return a value and breaks some current usages of dojo.eval.
122 // This implementation uses the technique of executing eval in the scope of a function that is a single scope
123 // frame below the global scope; thereby coming close to the global scope. Note carefully that
125 // dojo.eval("var pi = 3.14;");
127 // will define global pi in non-IE environments, but define pi only in a temporary local scope for IE. If you want
128 // to define a global variable using dojo.eval, write something like
130 // dojo.eval("window.pi = 3.14;")
132 // The text to evaluation.
134 // The result of the evaluation. Often `undefined`
140 dojo
.exit = function(exitcode
){
144 dojo
.exit = function(){
148 1 || has
.add("dojo-guarantee-console",
149 // ensure that console.log, console.warn, etc. are defined
153 typeof console
!= "undefined" || (console
= {});
154 // Be careful to leave 'log' always at the end
156 "assert", "count", "debug", "dir", "dirxml", "error", "group",
157 "groupEnd", "info", "profile", "profileEnd", "time", "timeEnd",
158 "trace", "warn", "log"
162 while((tn
= cn
[i
++])){
166 console
[tcn
] = ('log' in console
) ? function(){
167 var a
= Array
.apply({}, arguments
);
168 a
.unshift(tcn
+ ":");
169 console
["log"](a
.join(" "));
171 console
[tcn
]._fake
= true;
177 has
.add("dojo-debug-messages",
178 // include dojo.deprecated/dojo.experimental implementations
181 dojo
.deprecated
= dojo
.experimental = function(){};
182 if(has("dojo-debug-messages")){
183 dojo
.deprecated = function(/*String*/ behaviour
, /*String?*/ extra
, /*String?*/ removal
){
185 // Log a debug message to indicate that a behavior has been
188 // The API or behavior being deprecated. Usually in the form
189 // of "myApp.someFunction()".
191 // Text to append to the message. Often provides advice on a
192 // new function or facility to achieve the same goal during
193 // the deprecation period.
195 // Text to indicate when in the future the behavior will be
196 // removed. Usually a version number.
198 // | dojo.deprecated("myApp.getTemp()", "use myApp.getLocaleTemp() instead", "1.0");
200 var message
= "DEPRECATED: " + behaviour
;
201 if(extra
){ message
+= " " + extra
; }
202 if(removal
){ message
+= " -- will be removed in version: " + removal
; }
203 console
.warn(message
);
206 dojo
.experimental = function(/* String */ moduleName
, /* String? */ extra
){
208 // Marks code as experimental.
210 // This can be used to mark a function, file, or module as
211 // experimental. Experimental code is not ready to be used, and the
212 // APIs are subject to change without notice. Experimental code may be
213 // completed deleted without going through the normal deprecation
215 // moduleName: String
216 // The name of a module, or the name of a module file or a specific
219 // some additional message for the user
221 // | dojo.experimental("dojo.data.Result");
223 // | dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
225 var message
= "EXPERIMENTAL: " + moduleName
+ " -- APIs subject to change without notice.";
226 if(extra
){ message
+= " " + extra
; }
227 console
.warn(message
);
231 1 || has
.add("dojo-modulePaths",
232 // consume dojo.modulePaths processing
236 // notice that modulePaths won't be applied to any require's before the dojo/_base/kernel factory is run;
237 // this is the v1.6- behavior.
238 if(config
.modulePaths
){
239 dojo
.deprecated("dojo.modulePaths", "use paths configuration");
241 for(p
in config
.modulePaths
){
242 paths
[p
.replace(/\./g, "/")] = config
.modulePaths
[p
];
244 require({paths
:paths
});
248 1 || has
.add("dojo-moduleUrl",
249 // include dojo.moduleUrl
253 dojo
.moduleUrl = function(/*String*/module
, /*String?*/url
){
255 // Returns a URL relative to a module.
257 // | var pngPath = dojo.moduleUrl("acme","images/small.png");
258 // | console.dir(pngPath); // list the object properties
259 // | // create an image and set it's source to pngPath's value:
260 // | var img = document.createElement("img");
261 // | img.src = pngPath;
262 // | // add our image to the document
263 // | dojo.body().appendChild(img);
265 // you may de-reference as far as you like down the package
266 // hierarchy. This is sometimes handy to avoid lenghty relative
267 // urls or for building portable sub-packages. In this example,
268 // the `acme.widget` and `acme.util` directories may be located
269 // under different roots (see `dojo.registerModulePath`) but the
270 // the modules which reference them can be unaware of their
271 // relative locations on the filesystem:
272 // | // somewhere in a configuration block
273 // | dojo.registerModulePath("acme.widget", "../../acme/widget");
274 // | dojo.registerModulePath("acme.util", "../../util");
278 // | // code in a module using acme resources
279 // | var tmpltPath = dojo.moduleUrl("acme.widget","templates/template.html");
280 // | var dataPath = dojo.moduleUrl("acme.util","resources/data.json");
282 dojo
.deprecated("dojo.moduleUrl()", "use require.toUrl", "2.0");
284 // require.toUrl requires a filetype; therefore, just append the suffix "/*.*" to guarantee a filetype, then
285 // remove the suffix from the result. This way clients can request a url w/out a filetype. This should be
286 // rare, but it maintains backcompat for the v1.x line (note: dojo.moduleUrl will be removed in v2.0).
287 // Notice * is an illegal filename so it won't conflict with any real path map that may exist the paths config.
290 result
= require
.toUrl(module
.replace(/\./g, "/") + (url
? ("/" + url
) : "") + "/*.*").replace(/\/\*\.\*/, "") + (url
? "" : "/");
296 dojo
._hasResource
= {}; // for backward compatibility with layers built with 1.6 tooling