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