Fixed docs for #134
[jquery.git] / src / event / event.js
1 jQuery.fn.extend({
2
3         // We're overriding the old toggle function, so
4         // remember it for later
5         _toggle: jQuery.fn.toggle,
6         
7         /**
8          * Toggle between two function calls every other click.
9          * Whenever a matched element is clicked, the first specified function 
10          * is fired, when clicked again, the second is fired. All subsequent 
11          * clicks continue to rotate through the two functions.
12          *
13          * @example $("p").toggle(function(){
14          *   $(this).addClass("selected");
15          * },function(){
16          *   $(this).removeClass("selected");
17          * });
18          * 
19          * @name toggle
20          * @type jQuery
21          * @param Function even The function to execute on every even click.
22          * @param Function odd The function to execute on every odd click.
23          * @cat Events
24          */
25         toggle: function(a,b) {
26                 // If two functions are passed in, we're
27                 // toggling on a click
28                 return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){
29                         // Figure out which function to execute
30                         this.last = this.last == a ? b : a;
31                         
32                         // Make sure that clicks stop
33                         e.preventDefault();
34                         
35                         // and execute the function
36                         return this.last.apply( this, [e] ) || false;
37                 }) :
38                 
39                 // Otherwise, execute the old toggle function
40                 this._toggle.apply( this, arguments );
41         },
42         
43         /**
44          * A method for simulating hovering (moving the mouse on, and off,
45          * an object). This is a custom method which provides an 'in' to a 
46          * frequent task.
47          *
48          * Whenever the mouse cursor is moved over a matched 
49          * element, the first specified function is fired. Whenever the mouse 
50          * moves off of the element, the second specified function fires. 
51          * Additionally, checks are in place to see if the mouse is still within 
52          * the specified element itself (for example, an image inside of a div), 
53          * and if it is, it will continue to 'hover', and not move out 
54          * (a common error in using a mouseout event handler).
55          *
56          * @example $("p").hover(function(){
57          *   $(this).addClass("over");
58          * },function(){
59          *   $(this).addClass("out");
60          * });
61          *
62          * @name hover
63          * @type jQuery
64          * @param Function over The function to fire whenever the mouse is moved over a matched element.
65          * @param Function out The function to fire whenever the mouse is moved off of a matched element.
66          * @cat Events
67          */
68         hover: function(f,g) {
69                 
70                 // A private function for haandling mouse 'hovering'
71                 function handleHover(e) {
72                         // Check if mouse(over|out) are still within the same parent element
73                         var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
74         
75                         // Traverse up the tree
76                         while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
77                         
78                         // If we actually just moused on to a sub-element, ignore it
79                         if ( p == this ) return false;
80                         
81                         // Execute the right function
82                         return (e.type == "mouseover" ? f : g).apply(this, [e]);
83                 }
84                 
85                 // Bind the function to the two event listeners
86                 return this.mouseover(handleHover).mouseout(handleHover);
87         },
88         
89         /**
90          * Bind a function to be executed whenever the DOM is ready to be
91          * traversed and manipulated. This is probably the most important 
92          * function included in the event module, as it can greatly improve
93          * the response times of your web applications.
94          *
95          * In a nutshell, this is a solid replacement for using window.onload, 
96          * and attaching a function to that. By using this method, your bound Function 
97          * will be called the instant the DOM is ready to be read and manipulated, 
98          * which is exactly what 99.99% of all Javascript code needs to run.
99          * 
100          * Please ensure you have no code in your <body> onload event handler, 
101          * otherwise $(document).ready() may not fire.
102          *
103          * You can have as many $(document).ready events on your page as you like.
104          *
105          * @example $(document).ready(function(){ Your code here... });
106          *
107          * @name ready
108          * @type jQuery
109          * @param Function fn The function to be executed when the DOM is ready.
110          * @cat Events
111          */
112         ready: function(f) {
113                 // If the DOM is already ready
114                 if ( jQuery.isReady )
115                         // Execute the function immediately
116                         f.apply( document );
117                         
118                 // Otherwise, remember the function for later
119                 else {
120                         // Add the function to the wait list
121                         jQuery.readyList.push( f );
122                 }
123         
124                 return this;
125         }
126 });
127
128 jQuery.extend({
129         /*
130          * All the code that makes DOM Ready work nicely.
131          */
132         isReady: false,
133         readyList: [],
134         
135         // Handle when the DOM is ready
136         ready: function() {
137                 // Make sure that the DOM is not already loaded
138                 if ( !jQuery.isReady ) {
139                         // Remember that the DOM is ready
140                         jQuery.isReady = true;
141                         
142                         // If there are functions bound, to execute
143                         if ( jQuery.readyList ) {
144                                 // Execute all of them
145                                 for ( var i = 0; i < jQuery.readyList.length; i++ )
146                                         jQuery.readyList[i].apply( document );
147                                 
148                                 // Reset the list of functions
149                                 jQuery.readyList = null;
150                         }
151                         // Remove event lisenter to avoid memory leak
152                         if ( jQuery.browser.mozilla || jQuery.browser.opera )
153                                 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
154                 }
155         }
156 });
157
158 new function(){
159
160                 /**
161                  * Bind a function to the scroll event of each matched element.
162                  *
163                  * @example $("p").scroll( function() { alert("Hello"); } );
164                  * @before <p>Hello</p>
165                  * @result <p onscroll="alert('Hello');">Hello</p>
166                  *
167                  * @name scroll
168                  * @type jQuery
169                  * @param Function fn A function to bind to the scroll event on each of the matched elements.
170                  * @cat Events/Browser
171                  */
172
173                 /**
174                  * Trigger the scroll event of each matched element. This causes all of the functions
175                  * that have been bound to thet scroll event to be executed.
176                  *
177                  * @example $("p").scroll();
178                  * @before <p onscroll="alert('Hello');">Hello</p>
179                  * @result alert('Hello');
180                  *
181                  * @name scroll
182                  * @type jQuery
183                  * @cat Events/Browser
184                  */
185
186                 /**
187                  * Bind a function to the scroll event of each matched element, which will only be executed once.
188                  * Unlike a call to the normal .scroll() method, calling .onescroll() causes the bound function to be
189                  * only executed the first time it is triggered, and never again (unless it is re-bound).
190                  *
191                  * @example $("p").onescroll( function() { alert("Hello"); } );
192                  * @before <p onscroll="alert('Hello');">Hello</p>
193                  * @result alert('Hello'); // Only executed for the first scroll
194                  *
195                  * @name onescroll
196                  * @type jQuery
197                  * @param Function fn A function to bind to the scroll event on each of the matched elements.
198                  * @cat Events/Browser
199                  */
200
201                 /**
202                  * Removes a bound scroll event from each of the matched
203                  * elements. You must pass the identical function that was used in the original 
204                  * bind method.
205                  *
206                  * @example $("p").unscroll( myFunction );
207                  * @before <p onscroll="myFunction">Hello</p>
208                  * @result <p>Hello</p>
209                  *
210                  * @name unscroll
211                  * @type jQuery
212                  * @param Function fn A function to unbind from the scroll event on each of the matched elements.
213                  * @cat Events/Browser
214                  */
215
216                 /**
217                  * Removes all bound scroll events from each of the matched elements.
218                  *
219                  * @example $("p").unscroll();
220                  * @before <p onscroll="alert('Hello');">Hello</p>
221                  * @result <p>Hello</p>
222                  *
223                  * @name unscroll
224                  * @type jQuery
225                  * @cat Events/Browser
226                  */
227
228                 /**
229                  * Bind a function to the submit event of each matched element.
230                  *
231                  * @example $("#myform").submit( function() {
232                  *   return $("input", this).val().length > 0;
233                  * } );
234                  * @before <form id="myform"><input /></form>
235                  * @desc Prevents the form submission when the input has no value entered.
236                  *
237                  * @name submit
238                  * @type jQuery
239                  * @param Function fn A function to bind to the submit event on each of the matched elements.
240                  * @cat Events/Form
241                  */
242
243                 /**
244                  * Trigger the submit event of each matched element. This causes all of the functions
245                  * that have been bound to thet submit event to be executed.
246                  *
247                  * Note: This does not execute the submit method of the form element! If you need to
248                  * submit the form via code, you have to use the DOM method, eg. $("form")[0].submit();
249                  *
250                  * @example $("form").submit();
251                  * @desc Triggers all submit events registered for forms, but does not submit the form
252                  *
253                  * @name submit
254                  * @type jQuery
255                  * @cat Events/Form
256                  */
257
258                 /**
259                  * Bind a function to the submit event of each matched element, which will only be executed once.
260                  * Unlike a call to the normal .submit() method, calling .onesubmit() causes the bound function to be
261                  * only executed the first time it is triggered, and never again (unless it is re-bound).
262                  *
263                  * @example $("p").onesubmit( function() { alert("Hello"); } );
264                  * @before <p onsubmit="alert('Hello');">Hello</p>
265                  * @result alert('Hello'); // Only executed for the first submit
266                  *
267                  * @name onesubmit
268                  * @type jQuery
269                  * @param Function fn A function to bind to the submit event on each of the matched elements.
270                  * @cat Events/Form
271                  */
272
273                 /**
274                  * Removes a bound submit event from each of the matched
275                  * elements. You must pass the identical function that was used in the original 
276                  * bind method.
277                  *
278                  * @example $("p").unsubmit( myFunction );
279                  * @before <p onsubmit="myFunction">Hello</p>
280                  * @result <p>Hello</p>
281                  *
282                  * @name unsubmit
283                  * @type jQuery
284                  * @param Function fn A function to unbind from the submit event on each of the matched elements.
285                  * @cat Events/Form
286                  */
287
288                 /**
289                  * Removes all bound submit events from each of the matched elements.
290                  *
291                  * @example $("p").unsubmit();
292                  * @before <p onsubmit="alert('Hello');">Hello</p>
293                  * @result <p>Hello</p>
294                  *
295                  * @name unsubmit
296                  * @type jQuery
297                  * @cat Events/Form
298                  */
299
300                 /**
301                  * Bind a function to the focus event of each matched element.
302                  *
303                  * @example $("p").focus( function() { alert("Hello"); } );
304                  * @before <p>Hello</p>
305                  * @result <p onfocus="alert('Hello');">Hello</p>
306                  *
307                  * @name focus
308                  * @type jQuery
309                  * @param Function fn A function to bind to the focus event on each of the matched elements.
310                  * @cat Events/UI
311                  */
312
313                 /**
314                  * Trigger the focus event of each matched element. This causes all of the functions
315                  * that have been bound to thet focus event to be executed.
316                  *
317                  * @example $("p").focus();
318                  * @before <p onfocus="alert('Hello');">Hello</p>
319                  * @result alert('Hello');
320                  *
321                  * @name focus
322                  * @type jQuery
323                  * @cat Events/UI
324                  */
325
326                 /**
327                  * Bind a function to the focus event of each matched element, which will only be executed once.
328                  * Unlike a call to the normal .focus() method, calling .onefocus() causes the bound function to be
329                  * only executed the first time it is triggered, and never again (unless it is re-bound).
330                  *
331                  * @example $("p").onefocus( function() { alert("Hello"); } );
332                  * @before <p onfocus="alert('Hello');">Hello</p>
333                  * @result alert('Hello'); // Only executed for the first focus
334                  *
335                  * @name onefocus
336                  * @type jQuery
337                  * @param Function fn A function to bind to the focus event on each of the matched elements.
338                  * @cat Events/UI
339                  */
340
341                 /**
342                  * Removes a bound focus event from each of the matched
343                  * elements. You must pass the identical function that was used in the original 
344                  * bind method.
345                  *
346                  * @example $("p").unfocus( myFunction );
347                  * @before <p onfocus="myFunction">Hello</p>
348                  * @result <p>Hello</p>
349                  *
350                  * @name unfocus
351                  * @type jQuery
352                  * @param Function fn A function to unbind from the focus event on each of the matched elements.
353                  * @cat Events/UI
354                  */
355
356                 /**
357                  * Removes all bound focus events from each of the matched elements.
358                  *
359                  * @example $("p").unfocus();
360                  * @before <p onfocus="alert('Hello');">Hello</p>
361                  * @result <p>Hello</p>
362                  *
363                  * @name unfocus
364                  * @type jQuery
365                  * @cat Events/UI
366                  */
367
368                 /**
369                  * Bind a function to the keydown event of each matched element.
370                  *
371                  * @example $("p").keydown( function() { alert("Hello"); } );
372                  * @before <p>Hello</p>
373                  * @result <p onkeydown="alert('Hello');">Hello</p>
374                  *
375                  * @name keydown
376                  * @type jQuery
377                  * @param Function fn A function to bind to the keydown event on each of the matched elements.
378                  * @cat Events/Keyboard
379                  */
380
381                 /**
382                  * Trigger the keydown event of each matched element. This causes all of the functions
383                  * that have been bound to thet keydown event to be executed.
384                  *
385                  * @example $("p").keydown();
386                  * @before <p onkeydown="alert('Hello');">Hello</p>
387                  * @result alert('Hello');
388                  *
389                  * @name keydown
390                  * @type jQuery
391                  * @cat Events/Keyboard
392                  */
393
394                 /**
395                  * Bind a function to the keydown event of each matched element, which will only be executed once.
396                  * Unlike a call to the normal .keydown() method, calling .onekeydown() causes the bound function to be
397                  * only executed the first time it is triggered, and never again (unless it is re-bound).
398                  *
399                  * @example $("p").onekeydown( function() { alert("Hello"); } );
400                  * @before <p onkeydown="alert('Hello');">Hello</p>
401                  * @result alert('Hello'); // Only executed for the first keydown
402                  *
403                  * @name onekeydown
404                  * @type jQuery
405                  * @param Function fn A function to bind to the keydown event on each of the matched elements.
406                  * @cat Events/Keyboard
407                  */
408
409                 /**
410                  * Removes a bound keydown event from each of the matched
411                  * elements. You must pass the identical function that was used in the original 
412                  * bind method.
413                  *
414                  * @example $("p").unkeydown( myFunction );
415                  * @before <p onkeydown="myFunction">Hello</p>
416                  * @result <p>Hello</p>
417                  *
418                  * @name unkeydown
419                  * @type jQuery
420                  * @param Function fn A function to unbind from the keydown event on each of the matched elements.
421                  * @cat Events/Keyboard
422                  */
423
424                 /**
425                  * Removes all bound keydown events from each of the matched elements.
426                  *
427                  * @example $("p").unkeydown();
428                  * @before <p onkeydown="alert('Hello');">Hello</p>
429                  * @result <p>Hello</p>
430                  *
431                  * @name unkeydown
432                  * @type jQuery
433                  * @cat Events/Keyboard
434                  */
435
436                 /**
437                  * Bind a function to the dblclick event of each matched element.
438                  *
439                  * @example $("p").dblclick( function() { alert("Hello"); } );
440                  * @before <p>Hello</p>
441                  * @result <p ondblclick="alert('Hello');">Hello</p>
442                  *
443                  * @name dblclick
444                  * @type jQuery
445                  * @param Function fn A function to bind to the dblclick event on each of the matched elements.
446                  * @cat Events/Mouse
447                  */
448
449                 /**
450                  * Trigger the dblclick event of each matched element. This causes all of the functions
451                  * that have been bound to thet dblclick event to be executed.
452                  *
453                  * @example $("p").dblclick();
454                  * @before <p ondblclick="alert('Hello');">Hello</p>
455                  * @result alert('Hello');
456                  *
457                  * @name dblclick
458                  * @type jQuery
459                  * @cat Events/Mouse
460                  */
461
462                 /**
463                  * Bind a function to the dblclick event of each matched element, which will only be executed once.
464                  * Unlike a call to the normal .dblclick() method, calling .onedblclick() causes the bound function to be
465                  * only executed the first time it is triggered, and never again (unless it is re-bound).
466                  *
467                  * @example $("p").onedblclick( function() { alert("Hello"); } );
468                  * @before <p ondblclick="alert('Hello');">Hello</p>
469                  * @result alert('Hello'); // Only executed for the first dblclick
470                  *
471                  * @name onedblclick
472                  * @type jQuery
473                  * @param Function fn A function to bind to the dblclick event on each of the matched elements.
474                  * @cat Events/Mouse
475                  */
476
477                 /**
478                  * Removes a bound dblclick event from each of the matched
479                  * elements. You must pass the identical function that was used in the original 
480                  * bind method.
481                  *
482                  * @example $("p").undblclick( myFunction );
483                  * @before <p ondblclick="myFunction">Hello</p>
484                  * @result <p>Hello</p>
485                  *
486                  * @name undblclick
487                  * @type jQuery
488                  * @param Function fn A function to unbind from the dblclick event on each of the matched elements.
489                  * @cat Events/Mouse
490                  */
491
492                 /**
493                  * Removes all bound dblclick events from each of the matched elements.
494                  *
495                  * @example $("p").undblclick();
496                  * @before <p ondblclick="alert('Hello');">Hello</p>
497                  * @result <p>Hello</p>
498                  *
499                  * @name undblclick
500                  * @type jQuery
501                  * @cat Events/Mouse
502                  */
503
504                 /**
505                  * Bind a function to the keypress event of each matched element.
506                  *
507                  * @example $("p").keypress( function() { alert("Hello"); } );
508                  * @before <p>Hello</p>
509                  * @result <p onkeypress="alert('Hello');">Hello</p>
510                  *
511                  * @name keypress
512                  * @type jQuery
513                  * @param Function fn A function to bind to the keypress event on each of the matched elements.
514                  * @cat Events/Keyboard
515                  */
516
517                 /**
518                  * Trigger the keypress event of each matched element. This causes all of the functions
519                  * that have been bound to thet keypress event to be executed.
520                  *
521                  * @example $("p").keypress();
522                  * @before <p onkeypress="alert('Hello');">Hello</p>
523                  * @result alert('Hello');
524                  *
525                  * @name keypress
526                  * @type jQuery
527                  * @cat Events/Keyboard
528                  */
529
530                 /**
531                  * Bind a function to the keypress event of each matched element, which will only be executed once.
532                  * Unlike a call to the normal .keypress() method, calling .onekeypress() causes the bound function to be
533                  * only executed the first time it is triggered, and never again (unless it is re-bound).
534                  *
535                  * @example $("p").onekeypress( function() { alert("Hello"); } );
536                  * @before <p onkeypress="alert('Hello');">Hello</p>
537                  * @result alert('Hello'); // Only executed for the first keypress
538                  *
539                  * @name onekeypress
540                  * @type jQuery
541                  * @param Function fn A function to bind to the keypress event on each of the matched elements.
542                  * @cat Events/Keyboard
543                  */
544
545                 /**
546                  * Removes a bound keypress event from each of the matched
547                  * elements. You must pass the identical function that was used in the original 
548                  * bind method.
549                  *
550                  * @example $("p").unkeypress( myFunction );
551                  * @before <p onkeypress="myFunction">Hello</p>
552                  * @result <p>Hello</p>
553                  *
554                  * @name unkeypress
555                  * @type jQuery
556                  * @param Function fn A function to unbind from the keypress event on each of the matched elements.
557                  * @cat Events/Keyboard
558                  */
559
560                 /**
561                  * Removes all bound keypress events from each of the matched elements.
562                  *
563                  * @example $("p").unkeypress();
564                  * @before <p onkeypress="alert('Hello');">Hello</p>
565                  * @result <p>Hello</p>
566                  *
567                  * @name unkeypress
568                  * @type jQuery
569                  * @cat Events/Keyboard
570                  */
571
572                 /**
573                  * Bind a function to the error event of each matched element.
574                  *
575                  * @example $("p").error( function() { alert("Hello"); } );
576                  * @before <p>Hello</p>
577                  * @result <p onerror="alert('Hello');">Hello</p>
578                  *
579                  * @name error
580                  * @type jQuery
581                  * @param Function fn A function to bind to the error event on each of the matched elements.
582                  * @cat Events/Browser
583                  */
584
585                 /**
586                  * Trigger the error event of each matched element. This causes all of the functions
587                  * that have been bound to thet error event to be executed.
588                  *
589                  * @example $("p").error();
590                  * @before <p onerror="alert('Hello');">Hello</p>
591                  * @result alert('Hello');
592                  *
593                  * @name error
594                  * @type jQuery
595                  * @cat Events/Browser
596                  */
597
598                 /**
599                  * Bind a function to the error event of each matched element, which will only be executed once.
600                  * Unlike a call to the normal .error() method, calling .oneerror() causes the bound function to be
601                  * only executed the first time it is triggered, and never again (unless it is re-bound).
602                  *
603                  * @example $("p").oneerror( function() { alert("Hello"); } );
604                  * @before <p onerror="alert('Hello');">Hello</p>
605                  * @result alert('Hello'); // Only executed for the first error
606                  *
607                  * @name oneerror
608                  * @type jQuery
609                  * @param Function fn A function to bind to the error event on each of the matched elements.
610                  * @cat Events/Browser
611                  */
612
613                 /**
614                  * Removes a bound error event from each of the matched
615                  * elements. You must pass the identical function that was used in the original 
616                  * bind method.
617                  *
618                  * @example $("p").unerror( myFunction );
619                  * @before <p onerror="myFunction">Hello</p>
620                  * @result <p>Hello</p>
621                  *
622                  * @name unerror
623                  * @type jQuery
624                  * @param Function fn A function to unbind from the error event on each of the matched elements.
625                  * @cat Events/Browser
626                  */
627
628                 /**
629                  * Removes all bound error events from each of the matched elements.
630                  *
631                  * @example $("p").unerror();
632                  * @before <p onerror="alert('Hello');">Hello</p>
633                  * @result <p>Hello</p>
634                  *
635                  * @name unerror
636                  * @type jQuery
637                  * @cat Events/Browser
638                  */
639
640                 /**
641                  * Bind a function to the blur event of each matched element.
642                  *
643                  * @example $("p").blur( function() { alert("Hello"); } );
644                  * @before <p>Hello</p>
645                  * @result <p onblur="alert('Hello');">Hello</p>
646                  *
647                  * @name blur
648                  * @type jQuery
649                  * @param Function fn A function to bind to the blur event on each of the matched elements.
650                  * @cat Events/UI
651                  */
652
653                 /**
654                  * Trigger the blur event of each matched element. This causes all of the functions
655                  * that have been bound to thet blur event to be executed.
656                  *
657                  * @example $("p").blur();
658                  * @before <p onblur="alert('Hello');">Hello</p>
659                  * @result alert('Hello');
660                  *
661                  * @name blur
662                  * @type jQuery
663                  * @cat Events/UI
664                  */
665
666                 /**
667                  * Bind a function to the blur event of each matched element, which will only be executed once.
668                  * Unlike a call to the normal .blur() method, calling .oneblur() causes the bound function to be
669                  * only executed the first time it is triggered, and never again (unless it is re-bound).
670                  *
671                  * @example $("p").oneblur( function() { alert("Hello"); } );
672                  * @before <p onblur="alert('Hello');">Hello</p>
673                  * @result alert('Hello'); // Only executed for the first blur
674                  *
675                  * @name oneblur
676                  * @type jQuery
677                  * @param Function fn A function to bind to the blur event on each of the matched elements.
678                  * @cat Events/UI
679                  */
680
681                 /**
682                  * Removes a bound blur event from each of the matched
683                  * elements. You must pass the identical function that was used in the original 
684                  * bind method.
685                  *
686                  * @example $("p").unblur( myFunction );
687                  * @before <p onblur="myFunction">Hello</p>
688                  * @result <p>Hello</p>
689                  *
690                  * @name unblur
691                  * @type jQuery
692                  * @param Function fn A function to unbind from the blur event on each of the matched elements.
693                  * @cat Events/UI
694                  */
695
696                 /**
697                  * Removes all bound blur events from each of the matched elements.
698                  *
699                  * @example $("p").unblur();
700                  * @before <p onblur="alert('Hello');">Hello</p>
701                  * @result <p>Hello</p>
702                  *
703                  * @name unblur
704                  * @type jQuery
705                  * @cat Events/UI
706                  */
707
708                 /**
709                  * Bind a function to the load event of each matched element.
710                  *
711                  * @example $("p").load( function() { alert("Hello"); } );
712                  * @before <p>Hello</p>
713                  * @result <p onload="alert('Hello');">Hello</p>
714                  *
715                  * @name load
716                  * @type jQuery
717                  * @param Function fn A function to bind to the load event on each of the matched elements.
718                  * @cat Events/Browser
719                  */
720
721                 /**
722                  * Trigger the load event of each matched element. This causes all of the functions
723                  * that have been bound to thet load event to be executed.
724                  *
725                  * Marked as private: Calling load() without arguments throws exception because the ajax load
726                  * does not handle it.
727                  *
728                  * @example $("p").load();
729                  * @before <p onload="alert('Hello');">Hello</p>
730                  * @result alert('Hello');
731                  *
732                  * @name load
733                  * @private
734                  * @type jQuery
735                  * @cat Events/Browser
736                  */
737
738                 /**
739                  * Bind a function to the load event of each matched element, which will only be executed once.
740                  * Unlike a call to the normal .load() method, calling .oneload() causes the bound function to be
741                  * only executed the first time it is triggered, and never again (unless it is re-bound).
742                  *
743                  * @example $("p").oneload( function() { alert("Hello"); } );
744                  * @before <p onload="alert('Hello');">Hello</p>
745                  * @result alert('Hello'); // Only executed for the first load
746                  *
747                  * @name oneload
748                  * @type jQuery
749                  * @param Function fn A function to bind to the load event on each of the matched elements.
750                  * @cat Events/Browser
751                  */
752
753                 /**
754                  * Removes a bound load event from each of the matched
755                  * elements. You must pass the identical function that was used in the original 
756                  * bind method.
757                  *
758                  * @example $("p").unload( myFunction );
759                  * @before <p onload="myFunction">Hello</p>
760                  * @result <p>Hello</p>
761                  *
762                  * @name unload
763                  * @type jQuery
764                  * @param Function fn A function to unbind from the load event on each of the matched elements.
765                  * @cat Events/Browser
766                  */
767
768                 /**
769                  * Removes all bound load events from each of the matched elements.
770                  *
771                  * @example $("p").unload();
772                  * @before <p onload="alert('Hello');">Hello</p>
773                  * @result <p>Hello</p>
774                  *
775                  * @name unload
776                  * @type jQuery
777                  * @cat Events/Browser
778                  */
779
780                 /**
781                  * Bind a function to the select event of each matched element.
782                  *
783                  * @example $("p").select( function() { alert("Hello"); } );
784                  * @before <p>Hello</p>
785                  * @result <p onselect="alert('Hello');">Hello</p>
786                  *
787                  * @name select
788                  * @type jQuery
789                  * @param Function fn A function to bind to the select event on each of the matched elements.
790                  * @cat Events/Form
791                  */
792
793                 /**
794                  * Trigger the select event of each matched element. This causes all of the functions
795                  * that have been bound to thet select event to be executed.
796                  *
797                  * @example $("p").select();
798                  * @before <p onselect="alert('Hello');">Hello</p>
799                  * @result alert('Hello');
800                  *
801                  * @name select
802                  * @type jQuery
803                  * @cat Events/Form
804                  */
805
806                 /**
807                  * Bind a function to the select event of each matched element, which will only be executed once.
808                  * Unlike a call to the normal .select() method, calling .oneselect() causes the bound function to be
809                  * only executed the first time it is triggered, and never again (unless it is re-bound).
810                  *
811                  * @example $("p").oneselect( function() { alert("Hello"); } );
812                  * @before <p onselect="alert('Hello');">Hello</p>
813                  * @result alert('Hello'); // Only executed for the first select
814                  *
815                  * @name oneselect
816                  * @type jQuery
817                  * @param Function fn A function to bind to the select event on each of the matched elements.
818                  * @cat Events/Form
819                  */
820
821                 /**
822                  * Removes a bound select event from each of the matched
823                  * elements. You must pass the identical function that was used in the original 
824                  * bind method.
825                  *
826                  * @example $("p").unselect( myFunction );
827                  * @before <p onselect="myFunction">Hello</p>
828                  * @result <p>Hello</p>
829                  *
830                  * @name unselect
831                  * @type jQuery
832                  * @param Function fn A function to unbind from the select event on each of the matched elements.
833                  * @cat Events/Form
834                  */
835
836                 /**
837                  * Removes all bound select events from each of the matched elements.
838                  *
839                  * @example $("p").unselect();
840                  * @before <p onselect="alert('Hello');">Hello</p>
841                  * @result <p>Hello</p>
842                  *
843                  * @name unselect
844                  * @type jQuery
845                  * @cat Events/Form
846                  */
847
848                 /**
849                  * Bind a function to the mouseup event of each matched element.
850                  *
851                  * @example $("p").mouseup( function() { alert("Hello"); } );
852                  * @before <p>Hello</p>
853                  * @result <p onmouseup="alert('Hello');">Hello</p>
854                  *
855                  * @name mouseup
856                  * @type jQuery
857                  * @param Function fn A function to bind to the mouseup event on each of the matched elements.
858                  * @cat Events/Mouse
859                  */
860
861                 /**
862                  * Trigger the mouseup event of each matched element. This causes all of the functions
863                  * that have been bound to thet mouseup event to be executed.
864                  *
865                  * @example $("p").mouseup();
866                  * @before <p onmouseup="alert('Hello');">Hello</p>
867                  * @result alert('Hello');
868                  *
869                  * @name mouseup
870                  * @type jQuery
871                  * @cat Events/Mouse
872                  */
873
874                 /**
875                  * Bind a function to the mouseup event of each matched element, which will only be executed once.
876                  * Unlike a call to the normal .mouseup() method, calling .onemouseup() causes the bound function to be
877                  * only executed the first time it is triggered, and never again (unless it is re-bound).
878                  *
879                  * @example $("p").onemouseup( function() { alert("Hello"); } );
880                  * @before <p onmouseup="alert('Hello');">Hello</p>
881                  * @result alert('Hello'); // Only executed for the first mouseup
882                  *
883                  * @name onemouseup
884                  * @type jQuery
885                  * @param Function fn A function to bind to the mouseup event on each of the matched elements.
886                  * @cat Events/Mouse
887                  */
888
889                 /**
890                  * Removes a bound mouseup event from each of the matched
891                  * elements. You must pass the identical function that was used in the original 
892                  * bind method.
893                  *
894                  * @example $("p").unmouseup( myFunction );
895                  * @before <p onmouseup="myFunction">Hello</p>
896                  * @result <p>Hello</p>
897                  *
898                  * @name unmouseup
899                  * @type jQuery
900                  * @param Function fn A function to unbind from the mouseup event on each of the matched elements.
901                  * @cat Events/Mouse
902                  */
903
904                 /**
905                  * Removes all bound mouseup events from each of the matched elements.
906                  *
907                  * @example $("p").unmouseup();
908                  * @before <p onmouseup="alert('Hello');">Hello</p>
909                  * @result <p>Hello</p>
910                  *
911                  * @name unmouseup
912                  * @type jQuery
913                  * @cat Events/Mouse
914                  */
915
916                 /**
917                  * Bind a function to the unload event of each matched element.
918                  *
919                  * @example $("p").unload( function() { alert("Hello"); } );
920                  * @before <p>Hello</p>
921                  * @result <p onunload="alert('Hello');">Hello</p>
922                  *
923                  * @name unload
924                  * @type jQuery
925                  * @param Function fn A function to bind to the unload event on each of the matched elements.
926                  * @cat Events/Browser
927                  */
928
929                 /**
930                  * Trigger the unload event of each matched element. This causes all of the functions
931                  * that have been bound to thet unload event to be executed.
932                  *
933                  * @example $("p").unload();
934                  * @before <p onunload="alert('Hello');">Hello</p>
935                  * @result alert('Hello');
936                  *
937                  * @name unload
938                  * @type jQuery
939                  * @cat Events/Browser
940                  */
941
942                 /**
943                  * Bind a function to the unload event of each matched element, which will only be executed once.
944                  * Unlike a call to the normal .unload() method, calling .oneunload() causes the bound function to be
945                  * only executed the first time it is triggered, and never again (unless it is re-bound).
946                  *
947                  * @example $("p").oneunload( function() { alert("Hello"); } );
948                  * @before <p onunload="alert('Hello');">Hello</p>
949                  * @result alert('Hello'); // Only executed for the first unload
950                  *
951                  * @name oneunload
952                  * @type jQuery
953                  * @param Function fn A function to bind to the unload event on each of the matched elements.
954                  * @cat Events/Browser
955                  */
956
957                 /**
958                  * Removes a bound unload event from each of the matched
959                  * elements. You must pass the identical function that was used in the original 
960                  * bind method.
961                  *
962                  * @example $("p").ununload( myFunction );
963                  * @before <p onunload="myFunction">Hello</p>
964                  * @result <p>Hello</p>
965                  *
966                  * @name ununload
967                  * @type jQuery
968                  * @param Function fn A function to unbind from the unload event on each of the matched elements.
969                  * @cat Events/Browser
970                  */
971
972                 /**
973                  * Removes all bound unload events from each of the matched elements.
974                  *
975                  * @example $("p").ununload();
976                  * @before <p onunload="alert('Hello');">Hello</p>
977                  * @result <p>Hello</p>
978                  *
979                  * @name ununload
980                  * @type jQuery
981                  * @cat Events/Browser
982                  */
983
984                 /**
985                  * Bind a function to the change event of each matched element.
986                  *
987                  * @example $("p").change( function() { alert("Hello"); } );
988                  * @before <p>Hello</p>
989                  * @result <p onchange="alert('Hello');">Hello</p>
990                  *
991                  * @name change
992                  * @type jQuery
993                  * @param Function fn A function to bind to the change event on each of the matched elements.
994                  * @cat Events/Form
995                  */
996
997                 /**
998                  * Trigger the change event of each matched element. This causes all of the functions
999                  * that have been bound to thet change event to be executed.
1000                  *
1001                  * @example $("p").change();
1002                  * @before <p onchange="alert('Hello');">Hello</p>
1003                  * @result alert('Hello');
1004                  *
1005                  * @name change
1006                  * @type jQuery
1007                  * @cat Events/Form
1008                  */
1009
1010                 /**
1011                  * Bind a function to the change event of each matched element, which will only be executed once.
1012                  * Unlike a call to the normal .change() method, calling .onechange() causes the bound function to be
1013                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1014                  *
1015                  * @example $("p").onechange( function() { alert("Hello"); } );
1016                  * @before <p onchange="alert('Hello');">Hello</p>
1017                  * @result alert('Hello'); // Only executed for the first change
1018                  *
1019                  * @name onechange
1020                  * @type jQuery
1021                  * @param Function fn A function to bind to the change event on each of the matched elements.
1022                  * @cat Events/Form
1023                  */
1024
1025                 /**
1026                  * Removes a bound change event from each of the matched
1027                  * elements. You must pass the identical function that was used in the original 
1028                  * bind method.
1029                  *
1030                  * @example $("p").unchange( myFunction );
1031                  * @before <p onchange="myFunction">Hello</p>
1032                  * @result <p>Hello</p>
1033                  *
1034                  * @name unchange
1035                  * @type jQuery
1036                  * @param Function fn A function to unbind from the change event on each of the matched elements.
1037                  * @cat Events/Form
1038                  */
1039
1040                 /**
1041                  * Removes all bound change events from each of the matched elements.
1042                  *
1043                  * @example $("p").unchange();
1044                  * @before <p onchange="alert('Hello');">Hello</p>
1045                  * @result <p>Hello</p>
1046                  *
1047                  * @name unchange
1048                  * @type jQuery
1049                  * @cat Events/Form
1050                  */
1051
1052                 /**
1053                  * Bind a function to the mouseout event of each matched element.
1054                  *
1055                  * @example $("p").mouseout( function() { alert("Hello"); } );
1056                  * @before <p>Hello</p>
1057                  * @result <p onmouseout="alert('Hello');">Hello</p>
1058                  *
1059                  * @name mouseout
1060                  * @type jQuery
1061                  * @param Function fn A function to bind to the mouseout event on each of the matched elements.
1062                  * @cat Events/Mouse
1063                  */
1064
1065                 /**
1066                  * Trigger the mouseout event of each matched element. This causes all of the functions
1067                  * that have been bound to thet mouseout event to be executed.
1068                  *
1069                  * @example $("p").mouseout();
1070                  * @before <p onmouseout="alert('Hello');">Hello</p>
1071                  * @result alert('Hello');
1072                  *
1073                  * @name mouseout
1074                  * @type jQuery
1075                  * @cat Events/Mouse
1076                  */
1077
1078                 /**
1079                  * Bind a function to the mouseout event of each matched element, which will only be executed once.
1080                  * Unlike a call to the normal .mouseout() method, calling .onemouseout() causes the bound function to be
1081                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1082                  *
1083                  * @example $("p").onemouseout( function() { alert("Hello"); } );
1084                  * @before <p onmouseout="alert('Hello');">Hello</p>
1085                  * @result alert('Hello'); // Only executed for the first mouseout
1086                  *
1087                  * @name onemouseout
1088                  * @type jQuery
1089                  * @param Function fn A function to bind to the mouseout event on each of the matched elements.
1090                  * @cat Events/Mouse
1091                  */
1092
1093                 /**
1094                  * Removes a bound mouseout event from each of the matched
1095                  * elements. You must pass the identical function that was used in the original 
1096                  * bind method.
1097                  *
1098                  * @example $("p").unmouseout( myFunction );
1099                  * @before <p onmouseout="myFunction">Hello</p>
1100                  * @result <p>Hello</p>
1101                  *
1102                  * @name unmouseout
1103                  * @type jQuery
1104                  * @param Function fn A function to unbind from the mouseout event on each of the matched elements.
1105                  * @cat Events/Mouse
1106                  */
1107
1108                 /**
1109                  * Removes all bound mouseout events from each of the matched elements.
1110                  *
1111                  * @example $("p").unmouseout();
1112                  * @before <p onmouseout="alert('Hello');">Hello</p>
1113                  * @result <p>Hello</p>
1114                  *
1115                  * @name unmouseout
1116                  * @type jQuery
1117                  * @cat Events/Mouse
1118                  */
1119
1120                 /**
1121                  * Bind a function to the keyup event of each matched element.
1122                  *
1123                  * @example $("p").keyup( function() { alert("Hello"); } );
1124                  * @before <p>Hello</p>
1125                  * @result <p onkeyup="alert('Hello');">Hello</p>
1126                  *
1127                  * @name keyup
1128                  * @type jQuery
1129                  * @param Function fn A function to bind to the keyup event on each of the matched elements.
1130                  * @cat Events/Keyboard
1131                  */
1132
1133                 /**
1134                  * Trigger the keyup event of each matched element. This causes all of the functions
1135                  * that have been bound to thet keyup event to be executed.
1136                  *
1137                  * @example $("p").keyup();
1138                  * @before <p onkeyup="alert('Hello');">Hello</p>
1139                  * @result alert('Hello');
1140                  *
1141                  * @name keyup
1142                  * @type jQuery
1143                  * @cat Events/Keyboard
1144                  */
1145
1146                 /**
1147                  * Bind a function to the keyup event of each matched element, which will only be executed once.
1148                  * Unlike a call to the normal .keyup() method, calling .onekeyup() causes the bound function to be
1149                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1150                  *
1151                  * @example $("p").onekeyup( function() { alert("Hello"); } );
1152                  * @before <p onkeyup="alert('Hello');">Hello</p>
1153                  * @result alert('Hello'); // Only executed for the first keyup
1154                  *
1155                  * @name onekeyup
1156                  * @type jQuery
1157                  * @param Function fn A function to bind to the keyup event on each of the matched elements.
1158                  * @cat Events/Keyboard
1159                  */
1160
1161                 /**
1162                  * Removes a bound keyup event from each of the matched
1163                  * elements. You must pass the identical function that was used in the original 
1164                  * bind method.
1165                  *
1166                  * @example $("p").unkeyup( myFunction );
1167                  * @before <p onkeyup="myFunction">Hello</p>
1168                  * @result <p>Hello</p>
1169                  *
1170                  * @name unkeyup
1171                  * @type jQuery
1172                  * @param Function fn A function to unbind from the keyup event on each of the matched elements.
1173                  * @cat Events/Keyboard
1174                  */
1175
1176                 /**
1177                  * Removes all bound keyup events from each of the matched elements.
1178                  *
1179                  * @example $("p").unkeyup();
1180                  * @before <p onkeyup="alert('Hello');">Hello</p>
1181                  * @result <p>Hello</p>
1182                  *
1183                  * @name unkeyup
1184                  * @type jQuery
1185                  * @cat Events/Keyboard
1186                  */
1187
1188                 /**
1189                  * Bind a function to the click event of each matched element.
1190                  *
1191                  * @example $("p").click( function() { alert("Hello"); } );
1192                  * @before <p>Hello</p>
1193                  * @result <p onclick="alert('Hello');">Hello</p>
1194                  *
1195                  * @name click
1196                  * @type jQuery
1197                  * @param Function fn A function to bind to the click event on each of the matched elements.
1198                  * @cat Events/Mouse
1199                  */
1200
1201                 /**
1202                  * Trigger the click event of each matched element. This causes all of the functions
1203                  * that have been bound to thet click event to be executed.
1204                  *
1205                  * @example $("p").click();
1206                  * @before <p onclick="alert('Hello');">Hello</p>
1207                  * @result alert('Hello');
1208                  *
1209                  * @name click
1210                  * @type jQuery
1211                  * @cat Events/Mouse
1212                  */
1213
1214                 /**
1215                  * Bind a function to the click event of each matched element, which will only be executed once.
1216                  * Unlike a call to the normal .click() method, calling .oneclick() causes the bound function to be
1217                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1218                  *
1219                  * @example $("p").oneclick( function() { alert("Hello"); } );
1220                  * @before <p onclick="alert('Hello');">Hello</p>
1221                  * @result alert('Hello'); // Only executed for the first click
1222                  *
1223                  * @name oneclick
1224                  * @type jQuery
1225                  * @param Function fn A function to bind to the click event on each of the matched elements.
1226                  * @cat Events/Mouse
1227                  */
1228
1229                 /**
1230                  * Removes a bound click event from each of the matched
1231                  * elements. You must pass the identical function that was used in the original 
1232                  * bind method.
1233                  *
1234                  * @example $("p").unclick( myFunction );
1235                  * @before <p onclick="myFunction">Hello</p>
1236                  * @result <p>Hello</p>
1237                  *
1238                  * @name unclick
1239                  * @type jQuery
1240                  * @param Function fn A function to unbind from the click event on each of the matched elements.
1241                  * @cat Events/Mouse
1242                  */
1243
1244                 /**
1245                  * Removes all bound click events from each of the matched elements.
1246                  *
1247                  * @example $("p").unclick();
1248                  * @before <p onclick="alert('Hello');">Hello</p>
1249                  * @result <p>Hello</p>
1250                  *
1251                  * @name unclick
1252                  * @type jQuery
1253                  * @cat Events/Mouse
1254                  */
1255
1256                 /**
1257                  * Bind a function to the resize event of each matched element.
1258                  *
1259                  * @example $("p").resize( function() { alert("Hello"); } );
1260                  * @before <p>Hello</p>
1261                  * @result <p onresize="alert('Hello');">Hello</p>
1262                  *
1263                  * @name resize
1264                  * @type jQuery
1265                  * @param Function fn A function to bind to the resize event on each of the matched elements.
1266                  * @cat Events/Browser
1267                  */
1268
1269                 /**
1270                  * Trigger the resize event of each matched element. This causes all of the functions
1271                  * that have been bound to thet resize event to be executed.
1272                  *
1273                  * @example $("p").resize();
1274                  * @before <p onresize="alert('Hello');">Hello</p>
1275                  * @result alert('Hello');
1276                  *
1277                  * @name resize
1278                  * @type jQuery
1279                  * @cat Events/Browser
1280                  */
1281
1282                 /**
1283                  * Bind a function to the resize event of each matched element, which will only be executed once.
1284                  * Unlike a call to the normal .resize() method, calling .oneresize() causes the bound function to be
1285                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1286                  *
1287                  * @example $("p").oneresize( function() { alert("Hello"); } );
1288                  * @before <p onresize="alert('Hello');">Hello</p>
1289                  * @result alert('Hello'); // Only executed for the first resize
1290                  *
1291                  * @name oneresize
1292                  * @type jQuery
1293                  * @param Function fn A function to bind to the resize event on each of the matched elements.
1294                  * @cat Events/Browser
1295                  */
1296
1297                 /**
1298                  * Removes a bound resize event from each of the matched
1299                  * elements. You must pass the identical function that was used in the original 
1300                  * bind method.
1301                  *
1302                  * @example $("p").unresize( myFunction );
1303                  * @before <p onresize="myFunction">Hello</p>
1304                  * @result <p>Hello</p>
1305                  *
1306                  * @name unresize
1307                  * @type jQuery
1308                  * @param Function fn A function to unbind from the resize event on each of the matched elements.
1309                  * @cat Events/Browser
1310                  */
1311
1312                 /**
1313                  * Removes all bound resize events from each of the matched elements.
1314                  *
1315                  * @example $("p").unresize();
1316                  * @before <p onresize="alert('Hello');">Hello</p>
1317                  * @result <p>Hello</p>
1318                  *
1319                  * @name unresize
1320                  * @type jQuery
1321                  * @cat Events/Browser
1322                  */
1323
1324                 /**
1325                  * Bind a function to the mousemove event of each matched element.
1326                  *
1327                  * @example $("p").mousemove( function() { alert("Hello"); } );
1328                  * @before <p>Hello</p>
1329                  * @result <p onmousemove="alert('Hello');">Hello</p>
1330                  *
1331                  * @name mousemove
1332                  * @type jQuery
1333                  * @param Function fn A function to bind to the mousemove event on each of the matched elements.
1334                  * @cat Events/Mouse
1335                  */
1336
1337                 /**
1338                  * Trigger the mousemove event of each matched element. This causes all of the functions
1339                  * that have been bound to thet mousemove event to be executed.
1340                  *
1341                  * @example $("p").mousemove();
1342                  * @before <p onmousemove="alert('Hello');">Hello</p>
1343                  * @result alert('Hello');
1344                  *
1345                  * @name mousemove
1346                  * @type jQuery
1347                  * @cat Events/Mouse
1348                  */
1349
1350                 /**
1351                  * Bind a function to the mousemove event of each matched element, which will only be executed once.
1352                  * Unlike a call to the normal .mousemove() method, calling .onemousemove() causes the bound function to be
1353                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1354                  *
1355                  * @example $("p").onemousemove( function() { alert("Hello"); } );
1356                  * @before <p onmousemove="alert('Hello');">Hello</p>
1357                  * @result alert('Hello'); // Only executed for the first mousemove
1358                  *
1359                  * @name onemousemove
1360                  * @type jQuery
1361                  * @param Function fn A function to bind to the mousemove event on each of the matched elements.
1362                  * @cat Events/Mouse
1363                  */
1364
1365                 /**
1366                  * Removes a bound mousemove event from each of the matched
1367                  * elements. You must pass the identical function that was used in the original 
1368                  * bind method.
1369                  *
1370                  * @example $("p").unmousemove( myFunction );
1371                  * @before <p onmousemove="myFunction">Hello</p>
1372                  * @result <p>Hello</p>
1373                  *
1374                  * @name unmousemove
1375                  * @type jQuery
1376                  * @param Function fn A function to unbind from the mousemove event on each of the matched elements.
1377                  * @cat Events/Mouse
1378                  */
1379
1380                 /**
1381                  * Removes all bound mousemove events from each of the matched elements.
1382                  *
1383                  * @example $("p").unmousemove();
1384                  * @before <p onmousemove="alert('Hello');">Hello</p>
1385                  * @result <p>Hello</p>
1386                  *
1387                  * @name unmousemove
1388                  * @type jQuery
1389                  * @cat Events/Mouse
1390                  */
1391
1392                 /**
1393                  * Bind a function to the mousedown event of each matched element.
1394                  *
1395                  * @example $("p").mousedown( function() { alert("Hello"); } );
1396                  * @before <p>Hello</p>
1397                  * @result <p onmousedown="alert('Hello');">Hello</p>
1398                  *
1399                  * @name mousedown
1400                  * @type jQuery
1401                  * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1402                  * @cat Events/Mouse
1403                  */
1404
1405                 /**
1406                  * Trigger the mousedown event of each matched element. This causes all of the functions
1407                  * that have been bound to thet mousedown event to be executed.
1408                  *
1409                  * @example $("p").mousedown();
1410                  * @before <p onmousedown="alert('Hello');">Hello</p>
1411                  * @result alert('Hello');
1412                  *
1413                  * @name mousedown
1414                  * @type jQuery
1415                  * @cat Events/Mouse
1416                  */
1417
1418                 /**
1419                  * Bind a function to the mousedown event of each matched element, which will only be executed once.
1420                  * Unlike a call to the normal .mousedown() method, calling .onemousedown() causes the bound function to be
1421                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1422                  *
1423                  * @example $("p").onemousedown( function() { alert("Hello"); } );
1424                  * @before <p onmousedown="alert('Hello');">Hello</p>
1425                  * @result alert('Hello'); // Only executed for the first mousedown
1426                  *
1427                  * @name onemousedown
1428                  * @type jQuery
1429                  * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1430                  * @cat Events/Mouse
1431                  */
1432
1433                 /**
1434                  * Removes a bound mousedown event from each of the matched
1435                  * elements. You must pass the identical function that was used in the original 
1436                  * bind method.
1437                  *
1438                  * @example $("p").unmousedown( myFunction );
1439                  * @before <p onmousedown="myFunction">Hello</p>
1440                  * @result <p>Hello</p>
1441                  *
1442                  * @name unmousedown
1443                  * @type jQuery
1444                  * @param Function fn A function to unbind from the mousedown event on each of the matched elements.
1445                  * @cat Events/Mouse
1446                  */
1447
1448                 /**
1449                  * Removes all bound mousedown events from each of the matched elements.
1450                  *
1451                  * @example $("p").unmousedown();
1452                  * @before <p onmousedown="alert('Hello');">Hello</p>
1453                  * @result <p>Hello</p>
1454                  *
1455                  * @name unmousedown
1456                  * @type jQuery
1457                  * @cat Events/Mouse
1458                  */
1459                  
1460                 /**
1461                  * Bind a function to the mouseover event of each matched element.
1462                  *
1463                  * @example $("p").mouseover( function() { alert("Hello"); } );
1464                  * @before <p>Hello</p>
1465                  * @result <p onmouseover="alert('Hello');">Hello</p>
1466                  *
1467                  * @name mouseover
1468                  * @type jQuery
1469                  * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1470                  * @cat Events/Mouse
1471                  */
1472
1473                 /**
1474                  * Trigger the mouseover event of each matched element. This causes all of the functions
1475                  * that have been bound to thet mousedown event to be executed.
1476                  *
1477                  * @example $("p").mouseover();
1478                  * @before <p onmouseover="alert('Hello');">Hello</p>
1479                  * @result alert('Hello');
1480                  *
1481                  * @name mouseover
1482                  * @type jQuery
1483                  * @cat Events/Mouse
1484                  */
1485
1486                 /**
1487                  * Bind a function to the mouseover event of each matched element, which will only be executed once.
1488                  * Unlike a call to the normal .mouseover() method, calling .onemouseover() causes the bound function to be
1489                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1490                  *
1491                  * @example $("p").onemouseover( function() { alert("Hello"); } );
1492                  * @before <p onmouseover="alert('Hello');">Hello</p>
1493                  * @result alert('Hello'); // Only executed for the first mouseover
1494                  *
1495                  * @name onemouseover
1496                  * @type jQuery
1497                  * @param Function fn A function to bind to the mouseover event on each of the matched elements.
1498                  * @cat Events/Mouse
1499                  */
1500
1501                 /**
1502                  * Removes a bound mouseover event from each of the matched
1503                  * elements. You must pass the identical function that was used in the original 
1504                  * bind method.
1505                  *
1506                  * @example $("p").unmouseover( myFunction );
1507                  * @before <p onmouseover="myFunction">Hello</p>
1508                  * @result <p>Hello</p>
1509                  *
1510                  * @name unmouseover
1511                  * @type jQuery
1512                  * @param Function fn A function to unbind from the mouseover event on each of the matched elements.
1513                  * @cat Events/Mouse
1514                  */
1515
1516                 /**
1517                  * Removes all bound mouseover events from each of the matched elements.
1518                  *
1519                  * @example $("p").unmouseover();
1520                  * @before <p onmouseover="alert('Hello');">Hello</p>
1521                  * @result <p>Hello</p>
1522                  *
1523                  * @name unmouseover
1524                  * @type jQuery
1525                  * @cat Events/Mouse
1526                  */
1527
1528         var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
1529                 "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," + 
1530                 "submit,keydown,keypress,keyup,error").split(",");
1531
1532         // Go through all the event names, but make sure that
1533         // it is enclosed properly
1534         for ( var i = 0; i < e.length; i++ ) new function(){
1535                         
1536                 var o = e[i];
1537                 
1538                 // Handle event binding
1539                 jQuery.fn[o] = function(f){
1540                         return f ? this.bind(o, f) : this.trigger(o);
1541                 };
1542                 
1543                 // Handle event unbinding
1544                 jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
1545                 
1546                 // Finally, handle events that only fire once
1547                 jQuery.fn["one"+o] = function(f){
1548                         // save cloned reference to this
1549                         var element = jQuery(this);
1550                         var handler = function() {
1551                                 // unbind itself when executed
1552                                 element.unbind(o, handler);
1553                                 element = null;
1554                                 // apply original handler with the same arguments
1555                                 return f.apply(this, arguments);
1556                         };
1557                         return this.bind(o, handler);
1558                 };
1559                         
1560         };
1561         
1562         // If Mozilla is used
1563         if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
1564                 // Use the handy event callback
1565                 document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
1566         
1567         // If IE is used, use the excellent hack by Matthias Miller
1568         // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
1569         } else if ( jQuery.browser.msie ) {
1570         
1571                 // Only works if you document.write() it
1572                 document.write("<scr" + "ipt id=__ie_init defer=true " + 
1573                         "src=//:><\/script>");
1574         
1575                 // Use the defer script hack
1576                 var script = document.getElementById("__ie_init");
1577                 if (script) // script does not exist if jQuery is loaded dynamically
1578                         script.onreadystatechange = function() {
1579                                 if ( this.readyState != "complete" ) return;
1580                                 this.parentNode.removeChild( this );
1581                                 jQuery.ready();
1582                         };
1583         
1584                 // Clear from memory
1585                 script = null;
1586         
1587         // If Safari  is used
1588         } else if ( jQuery.browser.safari ) {
1589                 // Continually check to see if the document.readyState is valid
1590                 jQuery.safariTimer = setInterval(function(){
1591                         // loaded and complete are both valid states
1592                         if ( document.readyState == "loaded" || 
1593                                 document.readyState == "complete" ) {
1594         
1595                                 // If either one are found, remove the timer
1596                                 clearInterval( jQuery.safariTimer );
1597                                 jQuery.safariTimer = null;
1598         
1599                                 // and execute any waiting functions
1600                                 jQuery.ready();
1601                         }
1602                 }, 10);
1603         } 
1604
1605         // A fallback to window.onload, that will always work
1606         jQuery.event.add( window, "load", jQuery.ready );
1607         
1608 };
1609
1610 // Clean up after IE to avoid memory leaks
1611 if (jQuery.browser.msie) jQuery(window).unload(function() {
1612         var event = jQuery.event, global = event.global;
1613         for (var type in global) {
1614                 var els = global[type], i = els.length;
1615                 if (i>0) do if (type != 'unload') event.remove(els[i-1], type); while (--i);
1616         }
1617 });