X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fevent%2Fevent.js;h=7f0ec64e5ed8d27192b9e8e0fc22d4d5dad807cb;hb=25e83d27cb20ba8aa5dec7fec2d05e4da52d9fee;hp=cbad528f3e9f3a4e8a67c4fc006b9cf899fa70c9;hpb=bd78d4f65dea2fc5fbfd58a0f099f8839ee9707d;p=jquery.git diff --git a/src/event/event.js b/src/event/event.js index cbad528..7f0ec64 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -130,7 +130,7 @@ jQuery.event = { if ( !element ) { // Only trigger if we've ever bound an event for it if ( this.global[type] ) - jQuery("*").trigger(type, data); + jQuery("*").add([window, document]).trigger(type, data); // Handle triggering a single element } else { @@ -170,10 +170,14 @@ jQuery.event = { args[0].handler = c[j]; args[0].data = c[j].data; - if ( c[j].apply( this, args ) === false ) { + var tmp = c[j].apply( this, args ); + + if ( val !== false ) + val = tmp; + + if ( tmp === false ) { event.preventDefault(); event.stopPropagation(); - val = false; } } @@ -529,6 +533,9 @@ jQuery.fn.extend({ * @see $(Function) */ ready: function(f) { + // Attach the listeners + bindReady(); + // If the DOM is already ready if ( jQuery.isReady ) // Execute the function immediately @@ -578,8 +585,6 @@ jQuery.extend({ } }); -new function(){ - /** * Bind a function to the scroll event of each matched element. * @@ -930,7 +935,13 @@ new function(){ }; }); - + +var readyBound = false; + +function bindReady(){ + if ( readyBound ) return; + readyBound = true; + // If Mozilla is used if ( jQuery.browser.mozilla || jQuery.browser.opera ) // Use the handy event callback @@ -976,5 +987,4 @@ new function(){ // A fallback to window.onload, that will always work jQuery.event.add( window, "load", jQuery.ready ); - -}; +}