]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/ready.js.uncompressed.js
1 define("dojo/ready", ["./_base/kernel", "./has", "require", "./domReady", "./_base/lang"], function(dojo
, has
, require
, domReady
, lang
){
5 // This module should be unnecessary in dojo 2.0
8 // truthy if DOMContentLoaded or better (e.g., window.onload fired) has been achieved
11 // a function to call to cause onLoad to be called when all requested modules have been loaded
12 requestCompleteSignal
,
14 // The queue of functions waiting to execute as soon as dojo.ready conditions satisfied
17 // prevent recursion in onLoad
18 onLoadRecursiveGuard
= 0,
20 handleDomReady = function(){
22 dojo
._postLoad
= dojo
.config
.afterOnLoad
= true;
24 requestCompleteSignal(onLoad
);
28 // run the next function queued with dojo.ready
30 if(isDomReady
&& !onLoadRecursiveGuard
&& loadQ
.length
){
31 //guard against recursions into this function
32 onLoadRecursiveGuard
= 1;
33 var f
= loadQ
.shift();
37 // FIXME: signal the error via require.on
39 onLoadRecursiveGuard
= 0;
41 onLoadRecursiveGuard
= 0;
43 requestCompleteSignal(onLoad
);
48 require
.on("idle", onLoad
);
49 requestCompleteSignal = function(){
52 } // else do nothing, onLoad will be called with the next idle signal
55 var ready
= dojo
.ready
= dojo
.addOnLoad = function(priority
, context
, callback
){
57 // Add a function to execute on DOM content loaded and all requested modules have arrived and been evaluated.
58 // In most cases, the `domReady` plug-in should suffice and this method should not be needed.
60 // The order in which to exec this callback relative to other callbacks, defaults to 1000
61 // context: Object?|Function
62 // The context in which to run execute callback, or a callback if not using context
63 // callback: Function?
64 // The function to execute.
67 // Simple DOM and Modules ready syntax
68 // | require(["dojo/ready"], function(ready){
69 // | ready(function(){ alert("Dom ready!"); });
74 // | require(["dojo/ready"], function(ready){
75 // | ready(2, function(){ alert("low priority ready!"); })
80 // | require(["dojo/ready"], function(ready){
81 // | ready(foo, function(){
82 // | // in here, this == foo
87 // Using dojo/hitch style args:
88 // | require(["dojo/ready"], function(ready){
89 // | var foo = { dojoReady: function(){ console.warn(this, "dojo dom and modules ready."); } };
90 // | ready(foo, "dojoReady");
93 var hitchArgs
= lang
._toArray(arguments
);
94 if(typeof priority
!= "number"){
101 callback
= callback
?
102 lang
.hitch
.apply(dojo
, hitchArgs
) :
106 callback
.priority
= priority
;
107 for(var i
= 0; i
< loadQ
.length
&& priority
>= loadQ
[i
].priority
; i
++){}
108 loadQ
.splice(i
, 0, callback
);
109 requestCompleteSignal();
112 1 || has
.add("dojo-config-addOnLoad", 1);
114 var dca
= dojo
.config
.addOnLoad
;
116 ready
[(lang
.isArray(dca
) ? "apply" : "call")](dojo
, dca
);
120 if( 1 && dojo
.config
.parseOnLoad
&& !dojo
.isAsync
){
121 ready(99, function(){
123 dojo
.deprecated("Add explicit require(['dojo/parser']);", "", "2.0");
124 require(["dojo/parser"]);
130 domReady(handleDomReady
);