Ticket #1124: jquery-1.3.2+1124.patch
File jquery-1.3.2+1124.patch, 4.1 KB (added by , 13 years ago) |
---|
-
jquery-1.3.2.js.
old new 2955 2955 }, 2956 2956 2957 2957 ready: function(fn) { 2958 var doc = this[0]; 2959 2958 2960 // Attach the listeners 2959 bindReady( );2961 bindReady(doc); 2960 2962 2961 2963 // If the DOM is already ready 2962 if ( jQuery.isReady)2964 if ( this.data('isReady') ) 2963 2965 // Execute the function immediately 2964 fn.call( doc ument, jQuery );2966 fn.call( doc, jQuery ); 2965 2967 2966 2968 // Otherwise, remember the function for later 2967 2969 else 2968 2970 // Add the function to the wait list 2969 jQuery.readyList.push(fn );2971 this.queue( 'readyList', fn ); 2970 2972 2971 2973 return this; 2972 2974 }, … … 3016 3018 } 3017 3019 3018 3020 jQuery.extend({ 3019 isReady: false,3020 readyList: [],3021 // NOTE: if official API, uncomment these two lines 3022 // isReady: false, 3021 3023 // Handle when the DOM is ready 3022 ready: function() { 3024 ready: function(doc) { 3025 var $doc = jQuery(doc); 3023 3026 // Make sure that the DOM is not already loaded 3024 if ( ! jQuery.isReady) {3027 if ( !$doc.data('isReady') ) { 3025 3028 // Remember that the DOM is ready 3026 jQuery.isReady = true; 3029 // NOTE: if official API, uncomment these two lines 3030 // if ( doc === document ) jQuery.isReady = true; 3031 $doc.data( 'isReady', true ); 3027 3032 3028 3033 // If there are functions bound, to execute 3029 if ( jQuery.readyList) {3034 if ( $doc.queue( 'readyList' ).length ) { 3030 3035 // Execute all of them 3031 jQuery.each( jQuery.readyList, function(){3032 this.call( doc ument, jQuery );3036 jQuery.each($doc.queue('readyList'), function(){ 3037 this.call( doc, jQuery ); 3033 3038 }); 3034 3039 3035 3040 // Reset the list of functions 3036 jQuery.readyList = null;3041 $doc.queue('readyList', []); 3037 3042 } 3038 3043 3039 3044 // Trigger any bound ready events 3040 jQuery(document).triggerHandler("ready");3045 $doc.triggerHandler("ready"); 3041 3046 } 3042 3047 } 3043 3048 }); 3044 3049 3045 var readyBound = false; 3050 function bindReady(doc){ 3051 if (!doc) doc = document; 3052 var $doc = jQuery(doc); 3053 if ( $doc.data('readyBound') ) return; 3054 $doc.data('readyBound', true); 3046 3055 3047 function bindReady(){ 3048 if ( readyBound ) return; 3049 readyBound = true; 3056 var win = doc.defaultView || doc.parentWindow; 3050 3057 3051 3058 // Mozilla, Opera and webkit nightlies currently support this event 3052 if ( doc ument.addEventListener ) {3059 if ( doc.addEventListener ) { 3053 3060 // Use the handy event callback 3054 doc ument.addEventListener( "DOMContentLoaded", function(){3055 doc ument.removeEventListener( "DOMContentLoaded", arguments.callee, false );3056 jQuery.ready( );3061 doc.addEventListener( "DOMContentLoaded", function(){ 3062 doc.removeEventListener( "DOMContentLoaded", arguments.callee, false ); 3063 jQuery.ready(doc); 3057 3064 }, false ); 3058 3065 3059 3066 // If IE event model is used 3060 } else if ( doc ument.attachEvent ) {3067 } else if ( doc.attachEvent ) { 3061 3068 // ensure firing before onload, 3062 3069 // maybe late but safe also for iframes 3063 doc ument.attachEvent("onreadystatechange", function(){3064 if ( doc ument.readyState === "complete" ) {3065 doc ument.detachEvent( "onreadystatechange", arguments.callee );3066 jQuery.ready( );3070 doc.attachEvent("onreadystatechange", function(){ 3071 if ( doc.readyState === "complete" ) { 3072 doc.detachEvent( "onreadystatechange", arguments.callee ); 3073 jQuery.ready(doc); 3067 3074 } 3068 3075 }); 3069 3076 3070 3077 // If IE and not an iframe 3071 3078 // continually check to see if the document is ready 3072 if ( doc ument.documentElement.doScroll && window == window.top ) (function(){3073 if ( jQuery.isReady) return;3079 if ( doc.documentElement.doScroll && win == win.top ) (function(){ 3080 if ( $doc.data( 'isReady' ) ) return; 3074 3081 3075 3082 try { 3076 3083 // If IE is used, use the trick by Diego Perini 3077 3084 // http://javascript.nwbox.com/IEContentLoaded/ 3078 doc ument.documentElement.doScroll("left");3085 doc.documentElement.doScroll("left"); 3079 3086 } catch( error ) { 3080 3087 setTimeout( arguments.callee, 0 ); 3081 3088 return; 3082 3089 } 3083 3090 3084 3091 // and execute any waiting functions 3085 jQuery.ready( );3092 jQuery.ready(doc); 3086 3093 })(); 3087 3094 } 3088 3095 3089 3096 // A fallback to window.onload, that will always work 3090 jQuery.event.add( win dow, "load", jQuery.ready);3097 jQuery.event.add( win, "load", function () { jQuery.ready(doc); } ); 3091 3098 } 3092 3099 3093 3100 jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +