domReady.js 887 Bytes
//>>built
define(["./global","./has"],function(n,f){function d(a){c.push(a);e&&p()}function p(){if(!h){for(h=!0;c.length;)try{c.shift()(b)}catch(a){console.error(a,"in domReady callback",a.stack)}h=!1;d._onQEmpty()}}var b=document,k={loaded:1,complete:1},l="string"!=typeof b.readyState,e=!!k[b.readyState],c=[],h;d.load=function(a,b,c){d(c)};d._Q=c;d._onQEmpty=function(){};l&&(b.readyState="loading");if(!e){var g=[],m=function(a){a=a||n.event;e||"readystatechange"==a.type&&!k[b.readyState]||(l&&(b.readyState=
"complete"),e=1,p())};f=function(a,b){a.addEventListener(b,m,!1);c.push(function(){a.removeEventListener(b,m,!1)})};f(b,"DOMContentLoaded");f(n,"load");"onreadystatechange"in b?f(b,"readystatechange"):l||g.push(function(){return k[b.readyState]});if(g.length){var q=function(){if(!e){for(var a=g.length;a--;)if(g[a]()){m("poller");return}setTimeout(q,30)}};q()}}return d});