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