X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=event%2Fevent.js;h=5511b351e2e4898c3d27fdf998c49b118fd384d2;hb=dea19250497716bbd6f9128eacaa785a620aafde;hp=dcc0e884a30c2ac0b861220c6252fd3f6180a158;hpb=08bb08fede9392f8c7047e88d6989e0b8583b31e;p=jquery.git diff --git a/event/event.js b/event/event.js index dcc0e88..5511b35 100644 --- a/event/event.js +++ b/event/event.js @@ -41,82 +41,76 @@ $.fn.hover = function(f,g) { }); }; -// Handle when the DOM is ready -$.ready = function(isFinal) { - // If the timer was running, stop it - if ( $.$$timer ) { - clearInterval( $.$$timer ); - $.$$timer = null; - } - - // If the last script to fire was in the body, - // we assume that it's trying to do a document.write - var s = document.getElementsByTagName("script"); - s = s[s.length-1].parentNode.nodeName == "HEAD"; +$.$$isReady = false; +$.$$ready = []; - // Only execute if we're doing a sane way, or the window - // is loaded, or the final script is in the head - // and there's something to execute - if ( ( !$.badReady || isFinal || s ) && $.$$ready ) { +// Handle when the DOM is ready +$.ready = function() { + $.$$isReady = true; + if ( $.$$ready ) { for ( var i = 0; i < $.$$ready.length; i++ ) { $.apply( document, $.$$ready[i] ); } - $.$$ready = null; + $.$$ready = []; } }; -// Based off of: -// http://linguiste.org/projects/behaviour-DOMContentLoaded/example.html - // If Mozilla is used if ( $.browser == "mozilla" ) { // Use the handy event callback document.addEventListener( "DOMContentLoaded", $.ready, null ); -// If IE is used +// If IE is used, use the excellent hack by Matthias Miller +// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited } else if ( $.browser == "msie" ) { + + // Only works if you document.write() it + document.write('