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