2 * A number of helper functions used for managing events.
3 * Many of the ideas behind this code orignated from
4 * Dean Edwards' addEvent library.
8 // Bind an event to an element
9 // Original by Dean Edwards
10 add: function(element, type, handler, data) {
11 // For whatever reason, IE has trouble passing the window object
12 // around, causing it to be cloned in the process
13 if ( jQuery.browser.msie && element.setInterval != undefined )
16 // Make sure that the function being executed has a unique ID
18 handler.guid = this.guid++;
20 // if data is passed, bind to handler
21 if( data != undefined ) {
22 // Create temporary function pointer to original handler
25 // Create unique handler function, wrapped around original handler
26 handler = function() {
27 // Pass arguments and context to original handler
28 return fn.apply(this, arguments);
31 // Store data in unique handler
34 // Set the guid of unique handler to the same of original handler, so it can be removed
35 handler.guid = fn.guid;
38 // Init the element's event structure
43 element.$handle = function() {
44 // returned undefined or false
47 // Handle the second event of a trigger and when
48 // an event is called after a page has unloaded
49 if ( typeof jQuery == "undefined" || jQuery.event.triggered )
52 val = jQuery.event.handle.apply(element, arguments);
57 // Get the current list of functions bound to this event
58 var handlers = element.$events[type];
60 // Init the event handler queue
62 handlers = element.$events[type] = {};
64 // And bind the global event handler to the element
65 if (element.addEventListener)
66 element.addEventListener(type, element.$handle, false);
68 element.attachEvent("on" + type, element.$handle);
71 // Add the function to the element's handler list
72 handlers[handler.guid] = handler;
74 // Remember the function in a global list (for triggering)
75 if (!this.global[type])
76 this.global[type] = [];
77 // Only add the element to the global list once
78 if (jQuery.inArray(element, this.global[type]) == -1)
79 this.global[type].push( element );
85 // Detach an event or set of events from an element
86 remove: function(element, type, handler) {
87 var events = element.$events, ret, index;
90 // type is actually an event object here
91 if ( type && type.type ) {
92 handler = type.handler;
97 for ( type in events )
98 this.remove( element, type );
100 } else if ( events[type] ) {
101 // remove the given handler for the given type
103 delete events[type][handler.guid];
105 // remove all handlers for the given type
107 for ( handler in element.$events[type] )
108 delete events[type][handler];
110 // remove generic event handler if no more handlers exist
111 for ( ret in events[type] ) break;
113 if (element.removeEventListener)
114 element.removeEventListener(type, element.$handle, false);
116 element.detachEvent("on" + type, element.$handle);
120 // Remove element from the global event type cache
121 while ( this.global[type] && ( (index = jQuery.inArray(element, this.global[type])) >= 0 ) )
122 delete this.global[type][index];
126 // Remove the expando if it's no longer used
127 for ( ret in events ) break;
129 element.$handle = element.$events = null;
133 trigger: function(type, data, element) {
134 // Clone the incoming data, if any
135 data = jQuery.makeArray(data || []);
137 // Handle a global trigger
139 jQuery.each( this.global[type] || [], function(){
140 jQuery.event.trigger( type, data, this );
143 // Handle triggering a single element
145 var val, ret, fn = jQuery.isFunction( element[ type ] || null );
147 // Pass along a fake event
148 data.unshift( this.fix({ type: type, target: element }) );
151 if ( jQuery.isFunction(element.$handle) && (val = element.$handle.apply( element, data )) !== false )
152 this.triggered = true;
154 if ( fn && val !== false && !jQuery.nodeName(element, 'a') )
157 this.triggered = false;
161 handle: function(event) {
162 // returned undefined or false
165 // Empty object is for triggered events with no data
166 event = jQuery.event.fix( event || window.event || {} );
168 var c = this.$events && this.$events[event.type], args = [].slice.call( arguments, 1 );
169 args.unshift( event );
172 // Pass in a reference to the handler function itself
173 // So that we can later remove it
174 args[0].handler = c[j];
175 args[0].data = c[j].data;
177 if ( c[j].apply( this, args ) === false ) {
178 event.preventDefault();
179 event.stopPropagation();
184 // Clean up added properties in IE to prevent memory leak
185 if (jQuery.browser.msie)
186 event.target = event.preventDefault = event.stopPropagation =
187 event.handler = event.data = null;
192 fix: function(event) {
193 // store a copy of the original event object
194 // and clone to set read-only properties
195 var originalEvent = event;
196 event = jQuery.extend({}, originalEvent);
198 // add preventDefault and stopPropagation since
199 // they will not work on the clone
200 event.preventDefault = function() {
201 // if preventDefault exists run it on the original event
202 if (originalEvent.preventDefault)
203 return originalEvent.preventDefault();
204 // otherwise set the returnValue property of the original event to false (IE)
205 originalEvent.returnValue = false;
207 event.stopPropagation = function() {
208 // if stopPropagation exists run it on the original event
209 if (originalEvent.stopPropagation)
210 return originalEvent.stopPropagation();
211 // otherwise set the cancelBubble property of the original event to true (IE)
212 originalEvent.cancelBubble = true;
215 // Fix target property, if necessary
216 if ( !event.target && event.srcElement )
217 event.target = event.srcElement;
219 // check if target is a textnode (safari)
220 if (jQuery.browser.safari && event.target.nodeType == 3)
221 event.target = originalEvent.target.parentNode;
223 // Add relatedTarget, if necessary
224 if ( !event.relatedTarget && event.fromElement )
225 event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
227 // Calculate pageX/Y if missing and clientX/Y available
228 if ( event.pageX == null && event.clientX != null ) {
229 var e = document.documentElement, b = document.body;
230 event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft);
231 event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop);
234 // Add which for key events
235 if ( !event.which && (event.charCode || event.keyCode) )
236 event.which = event.charCode || event.keyCode;
238 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
239 if ( !event.metaKey && event.ctrlKey )
240 event.metaKey = event.ctrlKey;
242 // Add which for click: 1 == left; 2 == middle; 3 == right
243 // Note: button is not normalized, so don't use it
244 if ( !event.which && event.button )
245 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
254 * Binds a handler to a particular event (like click) for each matched element.
255 * The event handler is passed an event object that you can use to prevent
256 * default behaviour. To stop both default action and event bubbling, your handler
257 * has to return false.
259 * In most cases, you can define your event handlers as anonymous functions
260 * (see first example). In cases where that is not possible, you can pass additional
261 * data as the second parameter (and the handler function as the third), see
264 * Calling bind with an event type of "unload" will automatically
265 * use the one method instead of bind to prevent memory leaks.
267 * @example $("p").bind("click", function(){
268 * alert( $(this).text() );
270 * @before <p>Hello</p>
271 * @result alert("Hello")
273 * @example function handler(event) {
274 * alert(event.data.foo);
276 * $("p").bind("click", {foo: "bar"}, handler)
277 * @result alert("bar")
278 * @desc Pass some additional data to the event handler.
280 * @example $("form").bind("submit", function() { return false; })
281 * @desc Cancel a default action and prevent it from bubbling by returning false
282 * from your function.
284 * @example $("form").bind("submit", function(event){
285 * event.preventDefault();
287 * @desc Cancel only the default action by using the preventDefault method.
290 * @example $("form").bind("submit", function(event){
291 * event.stopPropagation();
293 * @desc Stop only an event from bubbling by using the stopPropagation method.
297 * @param String type An event type
298 * @param Object data (optional) Additional data passed to the event handler as event.data
299 * @param Function fn A function to bind to the event on each of the set of matched elements
302 bind: function( type, data, fn ) {
303 return type == "unload" ? this.one(type, data, fn) : this.each(function(){
304 jQuery.event.add( this, type, fn || data, fn && data );
309 * Binds a handler to a particular event (like click) for each matched element.
310 * The handler is executed only once for each element. Otherwise, the same rules
311 * as described in bind() apply.
312 * The event handler is passed an event object that you can use to prevent
313 * default behaviour. To stop both default action and event bubbling, your handler
314 * has to return false.
316 * In most cases, you can define your event handlers as anonymous functions
317 * (see first example). In cases where that is not possible, you can pass additional
318 * data as the second paramter (and the handler function as the third), see
321 * @example $("p").one("click", function(){
322 * alert( $(this).text() );
324 * @before <p>Hello</p>
325 * @result alert("Hello")
329 * @param String type An event type
330 * @param Object data (optional) Additional data passed to the event handler as event.data
331 * @param Function fn A function to bind to the event on each of the set of matched elements
334 one: function( type, data, fn ) {
335 return this.each(function(){
336 jQuery.event.add( this, type, function(event) {
337 jQuery(this).unbind(event);
338 return (fn || data).apply( this, arguments);
344 * The opposite of bind, removes a bound event from each of the matched
347 * Without any arguments, all bound events are removed.
349 * If the type is provided, all bound events of that type are removed.
351 * If the function that was passed to bind is provided as the second argument,
352 * only that specific event handler is removed.
354 * @example $("p").unbind()
355 * @before <p onclick="alert('Hello');">Hello</p>
356 * @result [ <p>Hello</p> ]
358 * @example $("p").unbind( "click" )
359 * @before <p onclick="alert('Hello');">Hello</p>
360 * @result [ <p>Hello</p> ]
362 * @example $("p").unbind( "click", function() { alert("Hello"); } )
363 * @before <p onclick="alert('Hello');">Hello</p>
364 * @result [ <p>Hello</p> ]
368 * @param String type (optional) An event type
369 * @param Function fn (optional) A function to unbind from the event on each of the set of matched elements
372 unbind: function( type, fn ) {
373 return this.each(function(){
374 jQuery.event.remove( this, type, fn );
379 * Trigger a type of event on every matched element. This will also cause
380 * the default action of the browser with the same name (if one exists)
381 * to be executed. For example, passing 'submit' to the trigger()
382 * function will also cause the browser to submit the form. This
383 * default action can be prevented by returning false from one of
384 * the functions bound to the event.
386 * You can also trigger custom events registered with bind.
388 * @example $("p").trigger("click")
389 * @before <p click="alert('hello')">Hello</p>
390 * @result alert('hello')
392 * @example $("p").click(function(event, a, b) {
393 * // when a normal click fires, a and b are undefined
394 * // for a trigger like below a refers too "foo" and b refers to "bar"
395 * }).trigger("click", ["foo", "bar"]);
396 * @desc Example of how to pass arbitrary data to an event
398 * @example $("p").bind("myEvent",function(event,message1,message2) {
399 * alert(message1 + ' ' + message2);
401 * $("p").trigger("myEvent",["Hello","World"]);
402 * @result alert('Hello World') // One for each paragraph
406 * @param String type An event type to trigger.
407 * @param Array data (optional) Additional data to pass as arguments (after the event object) to the event handler
410 trigger: function( type, data ) {
411 return this.each(function(){
412 jQuery.event.trigger( type, data, this );
417 * Toggle between two function calls every other click.
418 * Whenever a matched element is clicked, the first specified function
419 * is fired, when clicked again, the second is fired. All subsequent
420 * clicks continue to rotate through the two functions.
422 * Use unbind("click") to remove.
424 * @example $("p").toggle(function(){
425 * $(this).addClass("selected");
427 * $(this).removeClass("selected");
432 * @param Function even The function to execute on every even click.
433 * @param Function odd The function to execute on every odd click.
437 // Save reference to arguments for access in closure
440 return this.click(function(e) {
441 // Figure out which function to execute
442 this.lastToggle = 0 == this.lastToggle ? 1 : 0;
444 // Make sure that clicks stop
447 // and execute the function
448 return a[this.lastToggle].apply( this, [e] ) || false;
453 * A method for simulating hovering (moving the mouse on, and off,
454 * an object). This is a custom method which provides an 'in' to a
457 * Whenever the mouse cursor is moved over a matched
458 * element, the first specified function is fired. Whenever the mouse
459 * moves off of the element, the second specified function fires.
460 * Additionally, checks are in place to see if the mouse is still within
461 * the specified element itself (for example, an image inside of a div),
462 * and if it is, it will continue to 'hover', and not move out
463 * (a common error in using a mouseout event handler).
465 * @example $("p").hover(function(){
466 * $(this).addClass("hover");
468 * $(this).removeClass("hover");
473 * @param Function over The function to fire whenever the mouse is moved over a matched element.
474 * @param Function out The function to fire whenever the mouse is moved off of a matched element.
477 hover: function(f,g) {
479 // A private function for handling mouse 'hovering'
480 function handleHover(e) {
481 // Check if mouse(over|out) are still within the same parent element
482 var p = e.relatedTarget;
484 // Traverse up the tree
485 while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
487 // If we actually just moused on to a sub-element, ignore it
488 if ( p == this ) return false;
490 // Execute the right function
491 return (e.type == "mouseover" ? f : g).apply(this, [e]);
494 // Bind the function to the two event listeners
495 return this.mouseover(handleHover).mouseout(handleHover);
499 * Bind a function to be executed whenever the DOM is ready to be
500 * traversed and manipulated. This is probably the most important
501 * function included in the event module, as it can greatly improve
502 * the response times of your web applications.
504 * In a nutshell, this is a solid replacement for using window.onload,
505 * and attaching a function to that. By using this method, your bound function
506 * will be called the instant the DOM is ready to be read and manipulated,
507 * which is when what 99.99% of all JavaScript code needs to run.
509 * There is one argument passed to the ready event handler: A reference to
510 * the jQuery function. You can name that argument whatever you like, and
511 * can therefore stick with the $ alias without risk of naming collisions.
513 * Please ensure you have no code in your <body> onload event handler,
514 * otherwise $(document).ready() may not fire.
516 * You can have as many $(document).ready events on your page as you like.
517 * The functions are then executed in the order they were added.
519 * @example $(document).ready(function(){ Your code here... });
521 * @example jQuery(function($) {
522 * // Your code using failsafe $ alias here...
524 * @desc Uses both the [[Core#.24.28_fn_.29|shortcut]] for $(document).ready() and the argument
525 * to write failsafe jQuery code using the $ alias, without relying on the
530 * @param Function fn The function to be executed when the DOM is ready.
532 * @see $.noConflict()
536 // If the DOM is already ready
537 if ( jQuery.isReady )
538 // Execute the function immediately
539 f.apply( document, [jQuery] );
541 // Otherwise, remember the function for later
543 // Add the function to the wait list
544 jQuery.readyList.push( function() { return f.apply(this, [jQuery]) } );
552 * All the code that makes DOM Ready work nicely.
557 // Handle when the DOM is ready
559 // Make sure that the DOM is not already loaded
560 if ( !jQuery.isReady ) {
561 // Remember that the DOM is ready
562 jQuery.isReady = true;
564 // If there are functions bound, to execute
565 if ( jQuery.readyList ) {
566 // Execute all of them
567 jQuery.each( jQuery.readyList, function(){
568 this.apply( document );
571 // Reset the list of functions
572 jQuery.readyList = null;
574 // Remove event listener to avoid memory leak
575 if ( jQuery.browser.mozilla || jQuery.browser.opera )
576 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
578 // Remove script element used by IE hack
579 if( !window.frames.length ) // don't remove if frames are present (#1187)
580 jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });
588 * Bind a function to the scroll event of each matched element.
590 * @example $("p").scroll( function() { alert("Hello"); } );
591 * @before <p>Hello</p>
592 * @result <p onscroll="alert('Hello');">Hello</p>
596 * @param Function fn A function to bind to the scroll event on each of the matched elements.
601 * Bind a function to the submit event of each matched element.
603 * @example $("#myform").submit( function() {
604 * return $("input", this).val().length > 0;
606 * @before <form id="myform"><input /></form>
607 * @desc Prevents the form submission when the input has no value entered.
611 * @param Function fn A function to bind to the submit event on each of the matched elements.
616 * Trigger the submit event of each matched element. This causes all of the functions
617 * that have been bound to that submit event to be executed, and calls the browser's
618 * default submit action on the matching element(s). This default action can be prevented
619 * by returning false from one of the functions bound to the submit event.
621 * Note: This does not execute the submit method of the form element! If you need to
622 * submit the form via code, you have to use the DOM method, eg. $("form")[0].submit();
624 * @example $("form").submit();
625 * @desc Triggers all submit events registered to the matched form(s), and submits them.
633 * Bind a function to the focus event of each matched element.
635 * @example $("p").focus( function() { alert("Hello"); } );
636 * @before <p>Hello</p>
637 * @result <p onfocus="alert('Hello');">Hello</p>
641 * @param Function fn A function to bind to the focus event on each of the matched elements.
646 * Trigger the focus event of each matched element. This causes all of the functions
647 * that have been bound to thet focus event to be executed.
649 * Note: This does not execute the focus method of the underlying elements! If you need to
650 * focus an element via code, you have to use the DOM method, eg. $("#myinput")[0].focus();
652 * @example $("p").focus();
653 * @before <p onfocus="alert('Hello');">Hello</p>
654 * @result alert('Hello');
662 * Bind a function to the keydown event of each matched element.
664 * @example $("p").keydown( function() { alert("Hello"); } );
665 * @before <p>Hello</p>
666 * @result <p onkeydown="alert('Hello');">Hello</p>
670 * @param Function fn A function to bind to the keydown event on each of the matched elements.
675 * Bind a function to the dblclick event of each matched element.
677 * @example $("p").dblclick( function() { alert("Hello"); } );
678 * @before <p>Hello</p>
679 * @result <p ondblclick="alert('Hello');">Hello</p>
683 * @param Function fn A function to bind to the dblclick event on each of the matched elements.
688 * Bind a function to the keypress event of each matched element.
690 * @example $("p").keypress( function() { alert("Hello"); } );
691 * @before <p>Hello</p>
692 * @result <p onkeypress="alert('Hello');">Hello</p>
696 * @param Function fn A function to bind to the keypress event on each of the matched elements.
701 * Bind a function to the error event of each matched element.
703 * @example $("p").error( function() { alert("Hello"); } );
704 * @before <p>Hello</p>
705 * @result <p onerror="alert('Hello');">Hello</p>
709 * @param Function fn A function to bind to the error event on each of the matched elements.
714 * Bind a function to the blur event of each matched element.
716 * @example $("p").blur( function() { alert("Hello"); } );
717 * @before <p>Hello</p>
718 * @result <p onblur="alert('Hello');">Hello</p>
722 * @param Function fn A function to bind to the blur event on each of the matched elements.
727 * Trigger the blur event of each matched element. This causes all of the functions
728 * that have been bound to that blur event to be executed, and calls the browser's
729 * default blur action on the matching element(s). This default action can be prevented
730 * by returning false from one of the functions bound to the blur event.
732 * Note: This does not execute the blur method of the underlying elements! If you need to
733 * blur an element via code, you have to use the DOM method, eg. $("#myinput")[0].blur();
735 * @example $("p").blur();
736 * @before <p onblur="alert('Hello');">Hello</p>
737 * @result alert('Hello');
745 * Bind a function to the load event of each matched element.
747 * @example $("p").load( function() { alert("Hello"); } );
748 * @before <p>Hello</p>
749 * @result <p onload="alert('Hello');">Hello</p>
753 * @param Function fn A function to bind to the load event on each of the matched elements.
758 * Bind a function to the select event of each matched element.
760 * @example $("p").select( function() { alert("Hello"); } );
761 * @before <p>Hello</p>
762 * @result <p onselect="alert('Hello');">Hello</p>
766 * @param Function fn A function to bind to the select event on each of the matched elements.
771 * Trigger the select event of each matched element. This causes all of the functions
772 * that have been bound to that select event to be executed, and calls the browser's
773 * default select action on the matching element(s). This default action can be prevented
774 * by returning false from one of the functions bound to the select event.
776 * @example $("p").select();
777 * @before <p onselect="alert('Hello');">Hello</p>
778 * @result alert('Hello');
786 * Bind a function to the mouseup event of each matched element.
788 * @example $("p").mouseup( function() { alert("Hello"); } );
789 * @before <p>Hello</p>
790 * @result <p onmouseup="alert('Hello');">Hello</p>
794 * @param Function fn A function to bind to the mouseup event on each of the matched elements.
799 * Bind a function to the unload event of each matched element.
801 * @example $("p").unload( function() { alert("Hello"); } );
802 * @before <p>Hello</p>
803 * @result <p onunload="alert('Hello');">Hello</p>
807 * @param Function fn A function to bind to the unload event on each of the matched elements.
812 * Bind a function to the change event of each matched element.
814 * @example $("p").change( function() { alert("Hello"); } );
815 * @before <p>Hello</p>
816 * @result <p onchange="alert('Hello');">Hello</p>
820 * @param Function fn A function to bind to the change event on each of the matched elements.
825 * Bind a function to the mouseout event of each matched element.
827 * @example $("p").mouseout( function() { alert("Hello"); } );
828 * @before <p>Hello</p>
829 * @result <p onmouseout="alert('Hello');">Hello</p>
833 * @param Function fn A function to bind to the mouseout event on each of the matched elements.
838 * Bind a function to the keyup event of each matched element.
840 * @example $("p").keyup( function() { alert("Hello"); } );
841 * @before <p>Hello</p>
842 * @result <p onkeyup="alert('Hello');">Hello</p>
846 * @param Function fn A function to bind to the keyup event on each of the matched elements.
851 * Bind a function to the click event of each matched element.
853 * @example $("p").click( function() { alert("Hello"); } );
854 * @before <p>Hello</p>
855 * @result <p onclick="alert('Hello');">Hello</p>
859 * @param Function fn A function to bind to the click event on each of the matched elements.
864 * Trigger the click event of each matched element. This causes all of the functions
865 * that have been bound to thet click event to be executed.
867 * @example $("p").click();
868 * @before <p onclick="alert('Hello');">Hello</p>
869 * @result alert('Hello');
877 * Bind a function to the resize event of each matched element.
879 * @example $("p").resize( function() { alert("Hello"); } );
880 * @before <p>Hello</p>
881 * @result <p onresize="alert('Hello');">Hello</p>
885 * @param Function fn A function to bind to the resize event on each of the matched elements.
890 * Bind a function to the mousemove event of each matched element.
892 * @example $("p").mousemove( function() { alert("Hello"); } );
893 * @before <p>Hello</p>
894 * @result <p onmousemove="alert('Hello');">Hello</p>
898 * @param Function fn A function to bind to the mousemove event on each of the matched elements.
903 * Bind a function to the mousedown event of each matched element.
905 * @example $("p").mousedown( function() { alert("Hello"); } );
906 * @before <p>Hello</p>
907 * @result <p onmousedown="alert('Hello');">Hello</p>
911 * @param Function fn A function to bind to the mousedown event on each of the matched elements.
916 * Bind a function to the mouseover event of each matched element.
918 * @example $("p").mouseover( function() { alert("Hello"); } );
919 * @before <p>Hello</p>
920 * @result <p onmouseover="alert('Hello');">Hello</p>
924 * @param Function fn A function to bind to the mousedown event on each of the matched elements.
927 jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
928 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
929 "submit,keydown,keypress,keyup,error").split(","), function(i,o){
931 // Handle event binding
932 jQuery.fn[o] = function(f){
933 return f ? this.bind(o, f) : this.trigger(o);
938 // If Mozilla is used
939 if ( jQuery.browser.mozilla || jQuery.browser.opera )
940 // Use the handy event callback
941 document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
943 // If IE is used, use the excellent hack by Matthias Miller
944 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
945 else if ( jQuery.browser.msie ) {
947 // Only works if you document.write() it
948 document.write("<scr" + "ipt id=__ie_init defer=true " +
949 "src=//:><\/script>");
951 // Use the defer script hack
952 var script = document.getElementById("__ie_init");
954 // script does not exist if jQuery is loaded dynamically
956 script.onreadystatechange = function() {
957 if ( document.readyState != "complete" ) return;
965 } else if ( jQuery.browser.safari )
966 // Continually check to see if the document.readyState is valid
967 jQuery.safariTimer = setInterval(function(){
968 // loaded and complete are both valid states
969 if ( document.readyState == "loaded" ||
970 document.readyState == "complete" ) {
972 // If either one are found, remove the timer
973 clearInterval( jQuery.safariTimer );
974 jQuery.safariTimer = null;
976 // and execute any waiting functions
981 // A fallback to window.onload, that will always work
982 jQuery.event.add( window, "load", jQuery.ready );
986 // Clean up after IE to avoid memory leaks
987 if (jQuery.browser.msie)
988 jQuery(window).one("unload", function() {
989 var global = jQuery.event.global;
990 for ( var type in global ) {
991 var els = global[type], i = els.length;
992 if ( i && type != 'unload' )
994 els[i-1] && jQuery.event.remove(els[i-1], type);