]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/domReady.js.uncompressed.js
1 define("dojo/domReady", ['./has'], function(has
){
4 readyStates
= { 'loaded': 1, 'complete': 1 },
5 fixReadyState
= typeof doc
.readyState
!= "string",
6 ready
= !!readyStates
[doc
.readyState
];
9 if(fixReadyState
){ doc
.readyState
= "loading"; }
12 var readyQ
= [], tests
= [],
13 detectReady = function(evt
){
14 evt
= evt
|| global
.event
;
15 if(ready
|| (evt
.type
== "readystatechange" && !readyStates
[doc
.readyState
])){ return; }
19 if(fixReadyState
){ doc
.readyState
= "complete"; }
22 (readyQ
.shift())(doc
);
25 on = function(node
, event
){
26 node
.addEventListener(event
, detectReady
, false);
27 readyQ
.push(function(){ node
.removeEventListener(event
, detectReady
, false); });
30 if(!has("dom-addeventlistener")){
31 on = function(node
, event
){
33 node
.attachEvent(event
, detectReady
);
34 readyQ
.push(function(){ node
.detachEvent(event
, detectReady
); });
37 var div
= doc
.createElement("div");
39 if(div
.doScroll
&& global
.frameElement
=== null){
40 // the doScroll test is only useful if we're in the top-most frame
41 tests
.push(function(){
42 // Derived with permission from Diego Perini's IEContentLoaded
43 // http://javascript.nwbox.com/IEContentLoaded/
53 on(doc
, "DOMContentLoaded");
56 if("onreadystatechange" in doc
){
57 on(doc
, "readystatechange");
58 }else if(!fixReadyState
){
59 // if the ready state property exists and there's
60 // no readystatechange event, poll for the state
62 tests
.push(function(){
63 return readyStates
[doc
.readyState
];
68 var poller = function(){
73 detectReady("poller");
77 setTimeout(poller
, 30);
83 function domReady(callback
){
85 // Plugin to delay require()/define() callback from firing until the DOM has finished loading.
89 readyQ
.push(callback
);
92 domReady
.load = function(id
, req
, load
){