X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent.js;h=4bf96fca1f6c0b2e78d9c78c6f1d55551e3ebb46;hb=ab551c2b14ac6b0511cf3da10ca224ce461a0f10;hp=90abe037fe6995727b2fbeef218225d7d9233816;hpb=69cbcf863769e64f0a11c68a1846cd0e9785d25f;p=jquery.git diff --git a/src/event.js b/src/event.js index 90abe03..4bf96fc 100644 --- a/src/event.js +++ b/src/event.js @@ -21,7 +21,7 @@ jQuery.event = { handler.guid = this.guid++; // if data is passed, bind to handler - if( data != undefined ) { + if ( data !== undefined ) { // Create temporary function pointer to original handler var fn = handler; @@ -40,7 +40,7 @@ jQuery.event = { handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ // Handle the second event of a trigger and when // an event is called after a page has unloaded - if ( typeof jQuery != "undefined" && !jQuery.event.triggered ) + if ( typeof jQuery !== "undefined" && !jQuery.event.triggered ) return jQuery.event.handle.apply(arguments.callee.elem, arguments); }); // Add elem as a property of the handle function @@ -99,7 +99,7 @@ jQuery.event = { if ( events ) { // Unbind all events for the element - if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") ) + if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") ) for ( var type in events ) this.remove( elem, type + (types || "") ); else { @@ -219,7 +219,7 @@ jQuery.event = { // call the extra function and tack the current return value on the end for possible inspection ret = extra.apply( elem, val == null ? data : data.concat( val ) ); // if anything is returned, give it precedence and have it overwrite the previous value - if (ret !== undefined) + if ( ret !== undefined ) val = ret; } @@ -467,7 +467,7 @@ jQuery.fn.extend({ }, hover: function(fnOver, fnOut) { - return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut); + return this.mouseenter(fnOver).mouseleave(fnOut); }, ready: function(fn) { @@ -526,21 +526,33 @@ function bindReady(){ // Use the handy event callback document.addEventListener( "DOMContentLoaded", jQuery.ready, false ); - // If IE is used and is not in a frame - // Continually check to see if the document is ready - if ( jQuery.browser.msie && window == top ) (function(){ - if (jQuery.isReady) return; - try { - // If IE is used, use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - document.documentElement.doScroll("left"); - } catch( error ) { - setTimeout( arguments.callee, 0 ); - return; - } - // and execute any waiting functions - jQuery.ready(); - })(); + // If IE event model is used + if ( document.attachEvent ) + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent("onreadystatechange", function(e) { + if ( document.readyState == "complete" ) { + document.detachEvent("onreadystatechange", arguments.callee ); + jQuery.ready(); + } + }); + + // If IE and not an iframe + if ( document.documentElement.doScroll && !window.frameElement ) + // continually check to see if the document is ready + (function(){ + if (jQuery.isReady) return; + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch( error ) { + setTimeout( arguments.callee, 0 ); + return; + } + // and execute any waiting functions + jQuery.ready(); + })(); if ( jQuery.browser.opera ) document.addEventListener( "DOMContentLoaded", function () {