jQuery.merge speedup, bug#444
[jquery.git] / src / jquery / jquery.js
1 /*\r
2  * jQuery @VERSION - New Wave Javascript\r
3  *\r
4  * Copyright (c) 2006 John Resig (jquery.com)\r
5  * Dual licensed under the MIT (MIT-LICENSE.txt)\r
6  * and GPL (GPL-LICENSE.txt) licenses.\r
7  *\r
8  * $Date$\r
9  * $Rev$\r
10  */\r
11 \r
12 // Global undefined variable\r
13 window.undefined = window.undefined;\r
14 \r
15 /**\r
16  * Create a new jQuery Object\r
17  *\r
18  * @constructor\r
19  * @private\r
20  * @name jQuery\r
21  * @cat Core\r
22  */\r
23 var jQuery = function(a,c) {\r
24 \r
25         // Shortcut for document ready\r
26         if ( a && typeof a == "function" && jQuery.fn.ready && !a.nodeType && a[0] == undefined ) // Safari reports typeof on DOM NodeLists as a function\r
27                 return jQuery(document).ready(a);\r
28 \r
29         // Make sure that a selection was provided\r
30         a = a || document;\r
31 \r
32         // Watch for when a jQuery object is passed as the selector\r
33         if ( a.jquery )\r
34                 return jQuery( jQuery.merge( a, [] ) );\r
35 \r
36         // Watch for when a jQuery object is passed at the context\r
37         if ( c && c.jquery )\r
38                 return jQuery( c ).find(a);\r
39 \r
40         // If the context is global, return a new object\r
41         if ( window == this )\r
42                 return new jQuery(a,c);\r
43 \r
44         // Handle HTML strings\r
45         if ( typeof a  == "string" ) {\r
46                 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);\r
47                 if ( m ) a = jQuery.clean( [ m[1] ] );\r
48         }\r
49 \r
50         // Watch for when an array is passed in\r
51         this.set( a.constructor == Array || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType ?\r
52                 // Assume that it is an array of DOM Elements\r
53                 jQuery.merge( a, [] ) :\r
54 \r
55                 // Find the matching elements and save them for later\r
56                 jQuery.find( a, c ) );\r
57 \r
58         // See if an extra function was provided\r
59         var fn = arguments[ arguments.length - 1 ];\r
60 \r
61         // If so, execute it in context\r
62         if ( fn && typeof fn == "function" )\r
63                 this.each(fn);\r
64 \r
65         return this;\r
66 };\r
67 \r
68 // Map over the $ in case of overwrite\r
69 if ( typeof $ != "undefined" )\r
70         jQuery._$ = $;\r
71         \r
72 // Map the jQuery namespace to the '$' one\r
73 var $ = jQuery;\r
74 \r
75 /**\r
76  * This function accepts a string containing a CSS or\r
77  * basic XPath selector which is then used to match a set of elements.\r
78  *\r
79  * The core functionality of jQuery centers around this function.\r
80  * Everything in jQuery is based upon this, or uses this in some way.\r
81  * The most basic use of this function is to pass in an expression\r
82  * (usually consisting of CSS or XPath), which then finds all matching\r
83  * elements.\r
84  *\r
85  * By default, $() looks for DOM elements within the context of the\r
86  * current HTML document.\r
87  *\r
88  * @example $("div > p")\r
89  * @desc This finds all p elements that are children of a div element.\r
90  * @before <p>one</p> <div><p>two</p></div> <p>three</p>\r
91  * @result [ <p>two</p> ]\r
92  *\r
93  * @example $("input:radio", document.forms[0])\r
94  * @desc Searches for all inputs of type radio within the first form in the document\r
95  *\r
96  * @example $("div", xml.responseXML)\r
97  * @desc This finds all div elements within the specified XML document.\r
98  *\r
99  * @name $\r
100  * @param String expr An expression to search with\r
101  * @param Element context (optional) A DOM Element, or Document, representing the base context.\r
102  * @cat Core\r
103  * @type jQuery\r
104  * @see $(Element)\r
105  * @see $(Element<Array>)\r
106  */\r
107  \r
108 /**\r
109  * This function accepts a string of raw HTML.\r
110  *\r
111  * The HTML string is different from the traditional selectors in that\r
112  * it creates the DOM elements representing that HTML string, on the fly,\r
113  * to be (assumedly) inserted into the document later.\r
114  *\r
115  * @example $("<div><p>Hello</p></div>").appendTo("#body")\r
116  * @desc Creates a div element (and all of its contents) dynamically, \r
117  * and appends it to the element with the ID of body. Internally, an\r
118  * element is created and it's innerHTML property set to the given markup.\r
119  * It is therefore both quite flexible and limited. \r
120  *\r
121  * @name $\r
122  * @param String html A string of HTML to create on the fly.\r
123  * @cat Core\r
124  * @type jQuery\r
125  */\r
126 \r
127 /**\r
128  * Wrap jQuery functionality around a specific DOM Element.\r
129  * This function also accepts XML Documents and Window objects\r
130  * as valid arguments (even though they are not DOM Elements).\r
131  *\r
132  * @example $(document).find("div > p")\r
133  * @before <p>one</p> <div><p>two</p></div> <p>three</p>\r
134  * @result [ <p>two</p> ]\r
135  *\r
136  * @example $(document.body).background( "black" );\r
137  * @desc Sets the background color of the page to black.\r
138  *\r
139  * @name $\r
140  * @param Element elem A DOM element to be encapsulated by a jQuery object.\r
141  * @cat Core\r
142  * @type jQuery\r
143  */\r
144 \r
145 /**\r
146  * Wrap jQuery functionality around a set of DOM Elements.\r
147  *\r
148  * @example $( myForm.elements ).hide()\r
149  * @desc Hides all the input elements within a form\r
150  *\r
151  * @name $\r
152  * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.\r
153  * @cat Core\r
154  * @type jQuery\r
155  */\r
156 \r
157 /**\r
158  * A shorthand for $(document).ready(), allowing you to bind a function\r
159  * to be executed when the DOM document has finished loading. This function\r
160  * behaves just like $(document).ready(), in that it should be used to wrap\r
161  * all of the other $() operations on your page. While this function is,\r
162  * technically, chainable - there really isn't much use for chaining against it.\r
163  * You can have as many $(document).ready events on your page as you like.\r
164  *\r
165  * @example $(function(){\r
166  *   // Document is ready\r
167  * });\r
168  * @desc Executes the function when the DOM is ready to be used.\r
169  *\r
170  * @name $\r
171  * @param Function fn The function to execute when the DOM is ready.\r
172  * @cat Core\r
173  * @type jQuery\r
174  */\r
175 \r
176 /**\r
177  * A means of creating a cloned copy of a jQuery object. This function\r
178  * copies the set of matched elements from one jQuery object and creates\r
179  * another, new, jQuery object containing the same elements.\r
180  *\r
181  * @example var div = $("div");\r
182  * $( div ).find("p");\r
183  * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div' (as would normally be the case if a simple div.find("p") was done).\r
184  *\r
185  * @name $\r
186  * @param jQuery obj The jQuery object to be cloned.\r
187  * @cat Core\r
188  * @type jQuery\r
189  */\r
190 \r
191 jQuery.fn = jQuery.prototype = {\r
192         /**\r
193          * The current version of jQuery.\r
194          *\r
195          * @private\r
196          * @property\r
197          * @name jquery\r
198          * @type String\r
199          * @cat Core\r
200          */\r
201         jquery: "@VERSION",\r
202 \r
203         /**\r
204          * The number of elements currently matched.\r
205          *\r
206          * @example $("img").length;\r
207          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>\r
208          * @result 2\r
209          *\r
210          * @property\r
211          * @name length\r
212          * @type Number\r
213          * @cat Core\r
214          */\r
215 \r
216         /**\r
217          * The number of elements currently matched.\r
218          *\r
219          * @example $("img").size();\r
220          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>\r
221          * @result 2\r
222          *\r
223          * @name size\r
224          * @type Number\r
225          * @cat Core\r
226          */\r
227         size: function() {\r
228                 return this.length;\r
229         },\r
230 \r
231         /**\r
232          * Access all matched elements. This serves as a backwards-compatible\r
233          * way of accessing all matched elements (other than the jQuery object\r
234          * itself, which is, in fact, an array of elements).\r
235          *\r
236          * @example $("img").get();\r
237          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>\r
238          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]\r
239          *\r
240          * @name get\r
241          * @type Array<Element>\r
242          * @cat Core\r
243          */\r
244 \r
245         /**\r
246          * Access a single matched element. num is used to access the\r
247          * Nth element matched.\r
248          *\r
249          * @example $("img").get(1);\r
250          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>\r
251          * @result [ <img src="test1.jpg"/> ]\r
252          *\r
253          * @name get\r
254          * @type Element\r
255          * @param Number num Access the element in the Nth position.\r
256          * @cat Core\r
257          */\r
258         get: function( num ) {\r
259                 return num == undefined ?\r
260 \r
261                         // Return a 'clean' array\r
262                         jQuery.merge( this, [] ) :\r
263 \r
264                         // Return just the object\r
265                         this[num];\r
266         },\r
267         \r
268         /**\r
269          * Set the jQuery object to an array of elements.\r
270          *\r
271          * @example $("img").set([ document.body ]);\r
272          * @result $("img").set() == [ document.body ]\r
273          *\r
274          * @private\r
275          * @name set\r
276          * @type jQuery\r
277          * @param Elements elems An array of elements\r
278          * @cat Core\r
279          */\r
280         set: function( array ) {\r
281                 // Use a tricky hack to make the jQuery object\r
282                 // look and feel like an array\r
283                 this.length = 0;\r
284                 [].push.apply( this, array );\r
285                 return this;\r
286         },\r
287 \r
288         /**\r
289          * Execute a function within the context of every matched element.\r
290          * This means that every time the passed-in function is executed\r
291          * (which is once for every element matched) the 'this' keyword\r
292          * points to the specific element.\r
293          *\r
294          * Additionally, the function, when executed, is passed a single\r
295          * argument representing the position of the element in the matched\r
296          * set.\r
297          *\r
298          * @example $("img").each(function(i){\r
299          *   this.src = "test" + i + ".jpg";\r
300          * });\r
301          * @before <img/> <img/>\r
302          * @result <img src="test0.jpg"/> <img src="test1.jpg"/>\r
303          * @desc Iterates over two images and sets their src property\r
304          *\r
305          * @name each\r
306          * @type jQuery\r
307          * @param Function fn A function to execute\r
308          * @cat Core\r
309          */\r
310         each: function( fn, args ) {\r
311                 return jQuery.each( this, fn, args );\r
312         },\r
313 \r
314         /**\r
315          * Searches every matched element for the object and returns\r
316          * the index of the element, if found, starting with zero. \r
317          * Returns -1 if the object wasn't found.\r
318          *\r
319          * @example $("*").index(document.getElementById('foobar')) \r
320          * @before <div id="foobar"></div><b></b><span id="foo"></span>\r
321          * @result 0\r
322          *\r
323          * @example $("*").index(document.getElementById('foo')) \r
324          * @before <div id="foobar"></div><b></b><span id="foo"></span>\r
325          * @result 2\r
326          *\r
327          * @example $("*").index(document.getElementById('bar')) \r
328          * @before <div id="foobar"></div><b></b><span id="foo"></span>\r
329          * @result -1\r
330          *\r
331          * @name index\r
332          * @type Number\r
333          * @param Object obj Object to search for\r
334          * @cat Core\r
335          */\r
336         index: function( obj ) {\r
337                 var pos = -1;\r
338                 this.each(function(i){\r
339                         if ( this == obj ) pos = i;\r
340                 });\r
341                 return pos;\r
342         },\r
343 \r
344         /**\r
345          * Access a property on the first matched element.\r
346          * This method makes it easy to retrieve a property value\r
347          * from the first matched element.\r
348          *\r
349          * @example $("img").attr("src");\r
350          * @before <img src="test.jpg"/>\r
351          * @result test.jpg\r
352          *\r
353          * @name attr\r
354          * @type Object\r
355          * @param String name The name of the property to access.\r
356          * @cat DOM\r
357          */\r
358 \r
359         /**\r
360          * Set a hash of key/value object properties to all matched elements.\r
361          * This serves as the best way to set a large number of properties\r
362          * on all matched elements.\r
363          *\r
364          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });\r
365          * @before <img/>\r
366          * @result <img src="test.jpg" alt="Test Image"/>\r
367          *\r
368          * @name attr\r
369          * @type jQuery\r
370          * @param Hash prop A set of key/value pairs to set as object properties.\r
371          * @cat DOM\r
372          */\r
373 \r
374         /**\r
375          * Set a single property to a value, on all matched elements.\r
376          *\r
377          * Note that you can't set the name property of input elements in IE.\r
378          * Use $(html) or $().append(html) or $().html(html) to create elements\r
379          * on the fly including the name property.\r
380          *\r
381          * @example $("img").attr("src","test.jpg");\r
382          * @before <img/>\r
383          * @result <img src="test.jpg"/>\r
384          *\r
385          * @name attr\r
386          * @type jQuery\r
387          * @param String key The name of the property to set.\r
388          * @param Object value The value to set the property to.\r
389          * @cat DOM\r
390          */\r
391         attr: function( key, value, type ) {\r
392                 // Check to see if we're setting style values\r
393                 return typeof key != "string" || value != undefined ?\r
394                         this.each(function(){\r
395                                 // See if we're setting a hash of styles\r
396                                 if ( value == undefined )\r
397                                         // Set all the styles\r
398                                         for ( var prop in key )\r
399                                                 jQuery.attr(\r
400                                                         type ? this.style : this,\r
401                                                         prop, key[prop]\r
402                                                 );\r
403 \r
404                                 // See if we're setting a single key/value style\r
405                                 else\r
406                                         jQuery.attr(\r
407                                                 type ? this.style : this,\r
408                                                 key, value\r
409                                         );\r
410                         }) :\r
411 \r
412                         // Look for the case where we're accessing a style value\r
413                         jQuery[ type || "attr" ]( this[0], key );\r
414         },\r
415 \r
416         /**\r
417          * Access a style property on the first matched element.\r
418          * This method makes it easy to retrieve a style property value\r
419          * from the first matched element.\r
420          *\r
421          * @example $("p").css("color");\r
422          * @before <p style="color:red;">Test Paragraph.</p>\r
423          * @result red\r
424          * @desc Retrieves the color style of the first paragraph\r
425          *\r
426          * @example $("p").css("fontWeight");\r
427          * @before <p style="font-weight: bold;">Test Paragraph.</p>\r
428          * @result bold\r
429          * @desc Retrieves the font-weight style of the first paragraph.\r
430          * Note that for all style properties with a dash (like 'font-weight'), you have to\r
431          * write it in camelCase. In other words: Every time you have a '-' in a \r
432          * property, remove it and replace the next character with an uppercase \r
433          * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,\r
434          * borderStyle, borderBottomWidth etc.\r
435          *\r
436          * @name css\r
437          * @type Object\r
438          * @param String name The name of the property to access.\r
439          * @cat CSS\r
440          */\r
441 \r
442         /**\r
443          * Set a hash of key/value style properties to all matched elements.\r
444          * This serves as the best way to set a large number of style properties\r
445          * on all matched elements.\r
446          *\r
447          * @example $("p").css({ color: "red", background: "blue" });\r
448          * @before <p>Test Paragraph.</p>\r
449          * @result <p style="color:red; background:blue;">Test Paragraph.</p>\r
450          *\r
451          * @name css\r
452          * @type jQuery\r
453          * @param Hash prop A set of key/value pairs to set as style properties.\r
454          * @cat CSS\r
455          */\r
456 \r
457         /**\r
458          * Set a single style property to a value, on all matched elements.\r
459          *\r
460          * @example $("p").css("color","red");\r
461          * @before <p>Test Paragraph.</p>\r
462          * @result <p style="color:red;">Test Paragraph.</p>\r
463          * @desc Changes the color of all paragraphs to red\r
464          *\r
465          * @name css\r
466          * @type jQuery\r
467          * @param String key The name of the property to set.\r
468          * @param Object value The value to set the property to.\r
469          * @cat CSS\r
470          */\r
471         css: function( key, value ) {\r
472                 return this.attr( key, value, "curCSS" );\r
473         },\r
474 \r
475         /**\r
476          * Retrieve the text contents of all matched elements. The result is\r
477          * a string that contains the combined text contents of all matched\r
478          * elements. This method works on both HTML and XML documents.\r
479          *\r
480          * @example $("p").text();\r
481          * @before <p>Test Paragraph.</p>\r
482          * @result Test Paragraph.\r
483          *\r
484          * @name text\r
485          * @type String\r
486          * @cat DOM\r
487          */\r
488         text: function(e) {\r
489                 e = e || this;\r
490                 var t = "";\r
491                 for ( var j = 0; j < e.length; j++ ) {\r
492                         var r = e[j].childNodes;\r
493                         for ( var i = 0; i < r.length; i++ )\r
494                                 if ( r[i].nodeType != 8 )\r
495                                         t += r[i].nodeType != 1 ?\r
496                                                 r[i].nodeValue : jQuery.fn.text([ r[i] ]);\r
497                 }\r
498                 return t;\r
499         },\r
500 \r
501         /**\r
502          * Wrap all matched elements with a structure of other elements.\r
503          * This wrapping process is most useful for injecting additional\r
504          * stucture into a document, without ruining the original semantic\r
505          * qualities of a document.\r
506          *\r
507          * This works by going through the first element\r
508          * provided (which is generated, on the fly, from the provided HTML)\r
509          * and finds the deepest ancestor element within its\r
510          * structure - it is that element that will en-wrap everything else.\r
511          *\r
512          * This does not work with elements that contain text. Any necessary text\r
513          * must be added after the wrapping is done.\r
514          *\r
515          * @example $("p").wrap("<div class='wrap'></div>");\r
516          * @before <p>Test Paragraph.</p>\r
517          * @result <div class='wrap'><p>Test Paragraph.</p></div>\r
518          * \r
519          * @name wrap\r
520          * @type jQuery\r
521          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.\r
522          * @cat DOM/Manipulation\r
523          */\r
524 \r
525         /**\r
526          * Wrap all matched elements with a structure of other elements.\r
527          * This wrapping process is most useful for injecting additional\r
528          * stucture into a document, without ruining the original semantic\r
529          * qualities of a document.\r
530          *\r
531          * This works by going through the first element\r
532          * provided and finding the deepest ancestor element within its\r
533          * structure - it is that element that will en-wrap everything else.\r
534          *\r
535          * This does not work with elements that contain text. Any necessary text\r
536          * must be added after the wrapping is done.\r
537          *\r
538          * @example $("p").wrap( document.getElementById('content') );\r
539          * @before <p>Test Paragraph.</p><div id="content"></div>\r
540          * @result <div id="content"><p>Test Paragraph.</p></div>\r
541          *\r
542          * @name wrap\r
543          * @type jQuery\r
544          * @param Element elem A DOM element that will be wrapped.\r
545          * @cat DOM/Manipulation\r
546          */\r
547         wrap: function() {\r
548                 // The elements to wrap the target around\r
549                 var a = jQuery.clean(arguments);\r
550 \r
551                 // Wrap each of the matched elements individually\r
552                 return this.each(function(){\r
553                         // Clone the structure that we're using to wrap\r
554                         var b = a[0].cloneNode(true);\r
555 \r
556                         // Insert it before the element to be wrapped\r
557                         this.parentNode.insertBefore( b, this );\r
558 \r
559                         // Find the deepest point in the wrap structure\r
560                         while ( b.firstChild )\r
561                                 b = b.firstChild;\r
562 \r
563                         // Move the matched element to within the wrap structure\r
564                         b.appendChild( this );\r
565                 });\r
566         },\r
567 \r
568         /**\r
569          * Append any number of elements to the inside of every matched elements,\r
570          * generated from the provided HTML.\r
571          * This operation is similar to doing an appendChild to all the\r
572          * specified elements, adding them into the document.\r
573          *\r
574          * @example $("p").append("<b>Hello</b>");\r
575          * @before <p>I would like to say: </p>\r
576          * @result <p>I would like to say: <b>Hello</b></p>\r
577          *\r
578          * @name append\r
579          * @type jQuery\r
580          * @param String html A string of HTML, that will be created on the fly and appended to the target.\r
581          * @cat DOM/Manipulation\r
582          */\r
583 \r
584         /**\r
585          * Append an element to the inside of all matched elements.\r
586          * This operation is similar to doing an appendChild to all the\r
587          * specified elements, adding them into the document.\r
588          *\r
589          * @example $("p").append( $("#foo")[0] );\r
590          * @before <p>I would like to say: </p><b id="foo">Hello</b>\r
591          * @result <p>I would like to say: <b id="foo">Hello</b></p>\r
592          *\r
593          * @name append\r
594          * @type jQuery\r
595          * @param Element elem A DOM element that will be appended.\r
596          * @cat DOM/Manipulation\r
597          */\r
598 \r
599         /**\r
600          * Append any number of elements to the inside of all matched elements.\r
601          * This operation is similar to doing an appendChild to all the\r
602          * specified elements, adding them into the document.\r
603          *\r
604          * @example $("p").append( $("b") );\r
605          * @before <p>I would like to say: </p><b>Hello</b>\r
606          * @result <p>I would like to say: <b>Hello</b></p>\r
607          *\r
608          * @name append\r
609          * @type jQuery\r
610          * @param Array<Element> elems An array of elements, all of which will be appended.\r
611          * @cat DOM/Manipulation\r
612          */\r
613         append: function() {\r
614                 return this.domManip(arguments, true, 1, function(a){\r
615                         this.appendChild( a );\r
616                 });\r
617         },\r
618 \r
619         /**\r
620          * Prepend any number of elements to the inside of every matched elements,\r
621          * generated from the provided HTML.\r
622          * This operation is the best way to insert dynamically created elements\r
623          * inside, at the beginning, of all the matched element.\r
624          *\r
625          * @example $("p").prepend("<b>Hello</b>");\r
626          * @before <p>I would like to say: </p>\r
627          * @result <p><b>Hello</b>I would like to say: </p>\r
628          *\r
629          * @name prepend\r
630          * @type jQuery\r
631          * @param String html A string of HTML, that will be created on the fly and appended to the target.\r
632          * @cat DOM/Manipulation\r
633          */\r
634 \r
635         /**\r
636          * Prepend an element to the inside of all matched elements.\r
637          * This operation is the best way to insert an element inside, at the\r
638          * beginning, of all the matched element.\r
639          *\r
640          * @example $("p").prepend( $("#foo")[0] );\r
641          * @before <p>I would like to say: </p><b id="foo">Hello</b>\r
642          * @result <p><b id="foo">Hello</b>I would like to say: </p>\r
643          *       \r
644          * @name prepend\r
645          * @type jQuery\r
646          * @param Element elem A DOM element that will be appended.\r
647          * @cat DOM/Manipulation\r
648          */\r
649 \r
650         /**\r
651          * Prepend any number of elements to the inside of all matched elements.\r
652          * This operation is the best way to insert a set of elements inside, at the\r
653          * beginning, of all the matched element.\r
654          *\r
655          * @example $("p").prepend( $("b") );\r
656          * @before <p>I would like to say: </p><b>Hello</b>\r
657          * @result <p><b>Hello</b>I would like to say: </p>\r
658          *\r
659          * @name prepend\r
660          * @type jQuery\r
661          * @param Array<Element> elems An array of elements, all of which will be appended.\r
662          * @cat DOM/Manipulation\r
663          */\r
664         prepend: function() {\r
665                 return this.domManip(arguments, true, -1, function(a){\r
666                         this.insertBefore( a, this.firstChild );\r
667                 });\r
668         },\r
669 \r
670         /**\r
671          * Insert any number of dynamically generated elements before each of the\r
672          * matched elements.\r
673          *\r
674          * @example $("p").before("<b>Hello</b>");\r
675          * @before <p>I would like to say: </p>\r
676          * @result <b>Hello</b><p>I would like to say: </p>\r
677          *\r
678          * @name before\r
679          * @type jQuery\r
680          * @param String html A string of HTML, that will be created on the fly and appended to the target.\r
681          * @cat DOM/Manipulation\r
682          */\r
683 \r
684         /**\r
685          * Insert an element before each of the matched elements.\r
686          *\r
687          * @example $("p").before( $("#foo")[0] );\r
688          * @before <p>I would like to say: </p><b id="foo">Hello</b>\r
689          * @result <b id="foo">Hello</b><p>I would like to say: </p>\r
690          *\r
691          * @name before\r
692          * @type jQuery\r
693          * @param Element elem A DOM element that will be appended.\r
694          * @cat DOM/Manipulation\r
695          */\r
696 \r
697         /**\r
698          * Insert any number of elements before each of the matched elements.\r
699          *\r
700          * @example $("p").before( $("b") );\r
701          * @before <p>I would like to say: </p><b>Hello</b>\r
702          * @result <b>Hello</b><p>I would like to say: </p>\r
703          *\r
704          * @name before\r
705          * @type jQuery\r
706          * @param Array<Element> elems An array of elements, all of which will be appended.\r
707          * @cat DOM/Manipulation\r
708          */\r
709         before: function() {\r
710                 return this.domManip(arguments, false, 1, function(a){\r
711                         this.parentNode.insertBefore( a, this );\r
712                 });\r
713         },\r
714 \r
715         /**\r
716          * Insert any number of dynamically generated elements after each of the\r
717          * matched elements.\r
718          *\r
719          * @example $("p").after("<b>Hello</b>");\r
720          * @before <p>I would like to say: </p>\r
721          * @result <p>I would like to say: </p><b>Hello</b>\r
722          *\r
723          * @name after\r
724          * @type jQuery\r
725          * @param String html A string of HTML, that will be created on the fly and appended to the target.\r
726          * @cat DOM/Manipulation\r
727          */\r
728 \r
729         /**\r
730          * Insert an element after each of the matched elements.\r
731          *\r
732          * @example $("p").after( $("#foo")[0] );\r
733          * @before <b id="foo">Hello</b><p>I would like to say: </p>\r
734          * @result <p>I would like to say: </p><b id="foo">Hello</b>\r
735          *\r
736          * @name after\r
737          * @type jQuery\r
738          * @param Element elem A DOM element that will be appended.\r
739          * @cat DOM/Manipulation\r
740          */\r
741 \r
742         /**\r
743          * Insert any number of elements after each of the matched elements.\r
744          *\r
745          * @example $("p").after( $("b") );\r
746          * @before <b>Hello</b><p>I would like to say: </p>\r
747          * @result <p>I would like to say: </p><b>Hello</b>\r
748          *\r
749          * @name after\r
750          * @type jQuery\r
751          * @param Array<Element> elems An array of elements, all of which will be appended.\r
752          * @cat DOM/Manipulation\r
753          */\r
754         after: function() {\r
755                 return this.domManip(arguments, false, -1, function(a){\r
756                         this.parentNode.insertBefore( a, this.nextSibling );\r
757                 });\r
758         },\r
759 \r
760         /**\r
761          * End the most recent 'destructive' operation, reverting the list of matched elements\r
762          * back to its previous state. After an end operation, the list of matched elements will\r
763          * revert to the last state of matched elements.\r
764          *\r
765          * @example $("p").find("span").end();\r
766          * @before <p><span>Hello</span>, how are you?</p>\r
767          * @result $("p").find("span").end() == [ <p>...</p> ]\r
768          *\r
769          * @name end\r
770          * @type jQuery\r
771          * @cat DOM/Traversing\r
772          */\r
773         end: function() {\r
774                 if( !(this.stack && this.stack.length) )\r
775                         return this;\r
776                 return this.set( this.stack.pop() );\r
777         },\r
778 \r
779         /**\r
780          * Searches for all elements that match the specified expression.\r
781          * This method is the optimal way of finding additional descendant\r
782          * elements with which to process.\r
783          *\r
784          * All searching is done using a jQuery expression. The expression can be\r
785          * written using CSS 1-3 Selector syntax, or basic XPath.\r
786          *\r
787          * @example $("p").find("span");\r
788          * @before <p><span>Hello</span>, how are you?</p>\r
789          * @result $("p").find("span") == [ <span>Hello</span> ]\r
790          *\r
791          * @name find\r
792          * @type jQuery\r
793          * @param String expr An expression to search with.\r
794          * @cat DOM/Traversing\r
795          */\r
796         find: function(t) {\r
797                 return this.pushStack( jQuery.map( this, function(a){\r
798                         return jQuery.find(t,a);\r
799                 }), arguments );\r
800         },\r
801 \r
802         /**\r
803          * Create cloned copies of all matched DOM Elements. This does\r
804          * not create a cloned copy of this particular jQuery object,\r
805          * instead it creates duplicate copies of all DOM Elements.\r
806          * This is useful for moving copies of the elements to another\r
807          * location in the DOM.\r
808          *\r
809          * @example $("b").clone().prependTo("p");\r
810          * @before <b>Hello</b><p>, how are you?</p>\r
811          * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>\r
812          *\r
813          * @name clone\r
814          * @type jQuery\r
815          * @cat DOM/Manipulation\r
816          */\r
817         clone: function(deep) {\r
818                 return this.pushStack( jQuery.map( this, function(a){\r
819                         return a.cloneNode( deep != undefined ? deep : true );\r
820                 }), arguments );\r
821         },\r
822 \r
823         /**\r
824          * Removes all elements from the set of matched elements that do not\r
825          * match the specified expression. This method is used to narrow down\r
826          * the results of a search.\r
827          *\r
828          * All searching is done using a jQuery expression. The expression\r
829          * can be written using CSS 1-3 Selector syntax, or basic XPath.\r
830          *\r
831          * @example $("p").filter(".selected")\r
832          * @before <p class="selected">Hello</p><p>How are you?</p>\r
833          * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]\r
834          *\r
835          * @name filter\r
836          * @type jQuery\r
837          * @param String expr An expression to search with.\r
838          * @cat DOM/Traversing\r
839          */\r
840 \r
841         /**\r
842          * Removes all elements from the set of matched elements that do not\r
843          * match at least one of the expressions passed to the function. This\r
844          * method is used when you want to filter the set of matched elements\r
845          * through more than one expression.\r
846          *\r
847          * Elements will be retained in the jQuery object if they match at\r
848          * least one of the expressions passed.\r
849          *\r
850          * @example $("p").filter([".selected", ":first"])\r
851          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>\r
852          * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]\r
853          *\r
854          * @name filter\r
855          * @type jQuery\r
856          * @param Array<String> exprs A set of expressions to evaluate against\r
857          * @cat DOM/Traversing\r
858          */\r
859         filter: function(t) {\r
860                 return this.pushStack(\r
861                         t.constructor == Array &&\r
862                         jQuery.map(this,function(a){\r
863                                 for ( var i = 0; i < t.length; i++ )\r
864                                         if ( jQuery.filter(t[i],[a]).r.length )\r
865                                                 return a;\r
866                                 return null;\r
867                         }) ||\r
868 \r
869                         t.constructor == Boolean &&\r
870                         ( t ? this.get() : [] ) ||\r
871 \r
872                         typeof t == "function" &&\r
873                         jQuery.grep( this, t ) ||\r
874 \r
875                         jQuery.filter(t,this).r, arguments );\r
876         },\r
877 \r
878         /**\r
879          * Removes the specified Element from the set of matched elements. This\r
880          * method is used to remove a single Element from a jQuery object.\r
881          *\r
882          * @example $("p").not( document.getElementById("selected") )\r
883          * @before <p>Hello</p><p id="selected">Hello Again</p>\r
884          * @result [ <p>Hello</p> ]\r
885          *\r
886          * @name not\r
887          * @type jQuery\r
888          * @param Element el An element to remove from the set\r
889          * @cat DOM/Traversing\r
890          */\r
891 \r
892         /**\r
893          * Removes elements matching the specified expression from the set\r
894          * of matched elements. This method is used to remove one or more\r
895          * elements from a jQuery object.\r
896          *\r
897          * @example $("p").not("#selected")\r
898          * @before <p>Hello</p><p id="selected">Hello Again</p>\r
899          * @result [ <p>Hello</p> ]\r
900          *\r
901          * @name not\r
902          * @type jQuery\r
903          * @param String expr An expression with which to remove matching elements\r
904          * @cat DOM/Traversing\r
905          */\r
906         not: function(t) {\r
907                 return this.pushStack( typeof t == "string" ?\r
908                         jQuery.filter(t,this,false).r :\r
909                         jQuery.grep(this,function(a){ return a != t; }), arguments );\r
910         },\r
911 \r
912         /**\r
913          * Adds the elements matched by the expression to the jQuery object. This\r
914          * can be used to concatenate the result sets of two expressions.\r
915          *\r
916          * @example $("p").add("span")\r
917          * @before <p>Hello</p><p><span>Hello Again</span></p>\r
918          * @result [ <p>Hello</p>, <span>Hello Again</span> ]\r
919          *\r
920          * @name add\r
921          * @type jQuery\r
922          * @param String expr An expression whose matched elements are added\r
923          * @cat DOM/Traversing\r
924          */\r
925 \r
926         /**\r
927          * Adds each of the Elements in the array to the set of matched elements.\r
928          * This is used to add a set of Elements to a jQuery object.\r
929          *\r
930          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])\r
931          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>\r
932          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]\r
933          *\r
934          * @name add\r
935          * @type jQuery\r
936          * @param Array<Element> els An array of Elements to add\r
937          * @cat DOM/Traversing\r
938          */\r
939 \r
940         /**\r
941          * Adds a single Element to the set of matched elements. This is used to\r
942          * add a single Element to a jQuery object.\r
943          *\r
944          * @example $("p").add( document.getElementById("a") )\r
945          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>\r
946          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]\r
947          *\r
948          * @name add\r
949          * @type jQuery\r
950          * @param Element el An Element to add\r
951          * @cat DOM/Traversing\r
952          */\r
953         add: function(t) {\r
954                 return this.pushStack( jQuery.merge( this, typeof t == "string" ?\r
955                         jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );\r
956         },\r
957 \r
958         /**\r
959          * Checks the current selection against an expression and returns true,\r
960          * if at least one element of the selection fits the given expression.\r
961          * Does return false, if no element fits or the expression is not valid.\r
962          *\r
963          * @example $("input[@type='checkbox']").parent().is("form")\r
964          * @before <form><input type="checkbox" /></form>\r
965          * @result true\r
966          * @desc Returns true, because the parent of the input is a form element\r
967          * \r
968          * @example $("input[@type='checkbox']").parent().is("form")\r
969          * @before <form><p><input type="checkbox" /></p></form>\r
970          * @result false\r
971          * @desc Returns false, because the parent of the input is a p element\r
972          *\r
973          * @example $("form").is(null)\r
974          * @before <form></form>\r
975          * @result false\r
976          * @desc An invalid expression always returns false.\r
977          *\r
978          * @name is\r
979          * @type Boolean\r
980          * @param String expr The expression with which to filter\r
981          * @cat DOM/Traversing\r
982          */\r
983         is: function(expr) {\r
984                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;\r
985         },\r
986         \r
987         /**\r
988          * @private\r
989          * @name domManip\r
990          * @param Array args\r
991          * @param Boolean table Insert TBODY in TABLEs if one is not found.\r
992          * @param Number dir If dir<0, process args in reverse order.\r
993          * @param Function fn The function doing the DOM manipulation.\r
994          * @type jQuery\r
995          * @cat Core\r
996          */\r
997         domManip: function(args, table, dir, fn){\r
998                 var clone = this.length > 1; \r
999                 var a = jQuery.clean(args);\r
1000                 if ( dir < 0 )\r
1001                         a.reverse();\r
1002 \r
1003                 return this.each(function(){\r
1004                         var obj = this;\r
1005 \r
1006                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )\r
1007                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));\r
1008 \r
1009                         for ( var i=0; i < a.length; i++ )\r
1010                                 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );\r
1011 \r
1012                 });\r
1013         },\r
1014 \r
1015         /**\r
1016          *\r
1017          *\r
1018          * @private\r
1019          * @name pushStack\r
1020          * @param Array a\r
1021          * @param Array args\r
1022          * @type jQuery\r
1023          * @cat Core\r
1024          */\r
1025         pushStack: function(a,args) {\r
1026                 var fn = args && args.length > 1 && args[args.length-1];\r
1027                 var fn2 = args && args.length > 2 && args[args.length-2];\r
1028                 \r
1029                 if ( fn && fn.constructor != Function ) fn = null;\r
1030                 if ( fn2 && fn2.constructor != Function ) fn2 = null;\r
1031 \r
1032                 if ( !fn ) {\r
1033                         if ( !this.stack ) this.stack = [];\r
1034                         this.stack.push( this.get() );\r
1035                         this.set( a );\r
1036                 } else {\r
1037                         var old = this.get();\r
1038                         this.set( a );\r
1039 \r
1040                         if ( fn2 && a.length || !fn2 )\r
1041                                 this.each( fn2 || fn ).set( old );\r
1042                         else\r
1043                                 this.set( old ).each( fn );\r
1044                 }\r
1045 \r
1046                 return this;\r
1047         }\r
1048 };\r
1049 \r
1050 /**\r
1051  * Extends the jQuery object itself. Can be used to add functions into\r
1052  * the jQuery namespace and to add plugin methods (plugins).\r
1053  * \r
1054  * @example jQuery.fn.extend({\r
1055  *   check: function() {\r
1056  *     return this.each(function() { this.checked = true; });\r
1057  *   ),\r
1058  *   uncheck: function() {\r
1059  *     return this.each(function() { this.checked = false; });\r
1060  *   }\r
1061  * });\r
1062  * $("input[@type=checkbox]").check();\r
1063  * $("input[@type=radio]").uncheck();\r
1064  * @desc Adds two plugin methods.\r
1065  *\r
1066  * @example jQuery.extend({\r
1067  *   min: function(a, b) { return a < b ? a : b; },\r
1068  *   max: function(a, b) { return a > b ? a : b; }\r
1069  * });\r
1070  * @desc Adds two functions into the jQuery namespace\r
1071  *\r
1072  * @name $.extend\r
1073  * @param Object prop The object that will be merged into the jQuery object\r
1074  * @type Object\r
1075  * @cat Core\r
1076  */\r
1077 \r
1078 /**\r
1079  * Extend one object with one or more others, returning the original,\r
1080  * modified, object. This is a great utility for simple inheritance.\r
1081  * \r
1082  * @example var settings = { validate: false, limit: 5, name: "foo" };\r
1083  * var options = { validate: true, name: "bar" };\r
1084  * jQuery.extend(settings, options);\r
1085  * @result settings == { validate: true, limit: 5, name: "bar" }\r
1086  * @desc Merge settings and options, modifying settings\r
1087  *\r
1088  * @example var defaults = { validate: false, limit: 5, name: "foo" };\r
1089  * var options = { validate: true, name: "bar" };\r
1090  * var settings = jQuery.extend({}, defaults, options);\r
1091  * @result settings == { validate: true, limit: 5, name: "bar" }\r
1092  * @desc Merge defaults and options, without modifying the defaults\r
1093  *\r
1094  * @name $.extend\r
1095  * @param Object target The object to extend\r
1096  * @param Object prop1 The object that will be merged into the first.\r
1097  * @param Object propN (optional) More objects to merge into the first\r
1098  * @type Object\r
1099  * @cat Javascript\r
1100  */\r
1101 jQuery.extend = jQuery.fn.extend = function() {\r
1102         // copy reference to target object\r
1103         var target = arguments[0],\r
1104                 a = 1;\r
1105 \r
1106         // extend jQuery itself if only one argument is passed\r
1107         if ( arguments.length == 1 ) {\r
1108                 target = this;\r
1109                 a = 0;\r
1110         }\r
1111         var prop;\r
1112         while (prop = arguments[a++])\r
1113                 // Extend the base object\r
1114                 for ( var i in prop ) target[i] = prop[i];\r
1115 \r
1116         // Return the modified object\r
1117         return target;\r
1118 };\r
1119 \r
1120 jQuery.extend({\r
1121         /**\r
1122          * @private\r
1123          * @name init\r
1124          * @type undefined\r
1125          * @cat Core\r
1126          */\r
1127         init: function(){\r
1128                 jQuery.initDone = true;\r
1129 \r
1130                 jQuery.each( jQuery.macros.axis, function(i,n){\r
1131                         jQuery.fn[ i ] = function(a) {\r
1132                                 var ret = jQuery.map(this,n);\r
1133                                 if ( a && typeof a == "string" )\r
1134                                         ret = jQuery.filter(a,ret).r;\r
1135                                 return this.pushStack( ret, arguments );\r
1136                         };\r
1137                 });\r
1138 \r
1139                 jQuery.each( jQuery.macros.to, function(i,n){\r
1140                         jQuery.fn[ i ] = function(){\r
1141                                 var a = arguments;\r
1142                                 return this.each(function(){\r
1143                                         for ( var j = 0; j < a.length; j++ )\r
1144                                                 jQuery(a[j])[n]( this );\r
1145                                 });\r
1146                         };\r
1147                 });\r
1148 \r
1149                 jQuery.each( jQuery.macros.each, function(i,n){\r
1150                         jQuery.fn[ i ] = function() {\r
1151                                 return this.each( n, arguments );\r
1152                         };\r
1153                 });\r
1154 \r
1155                 jQuery.each( jQuery.macros.filter, function(i,n){\r
1156                         jQuery.fn[ n ] = function(num,fn) {\r
1157                                 return this.filter( ":" + n + "(" + num + ")", fn );\r
1158                         };\r
1159                 });\r
1160 \r
1161                 jQuery.each( jQuery.macros.attr, function(i,n){\r
1162                         n = n || i;\r
1163                         jQuery.fn[ i ] = function(h) {\r
1164                                 return h == undefined ?\r
1165                                         this.length ? this[0][n] : null :\r
1166                                         this.attr( n, h );\r
1167                         };\r
1168                 });\r
1169 \r
1170                 jQuery.each( jQuery.macros.css, function(i,n){\r
1171                         jQuery.fn[ n ] = function(h) {\r
1172                                 return h == undefined ?\r
1173                                         ( this.length ? jQuery.css( this[0], n ) : null ) :\r
1174                                         this.css( n, h );\r
1175                         };\r
1176                 });\r
1177 \r
1178         },\r
1179 \r
1180         /**\r
1181          * A generic iterator function, which can be used to seemlessly\r
1182          * iterate over both objects and arrays. This function is not the same\r
1183          * as $().each() - which is used to iterate, exclusively, over a jQuery\r
1184          * object. This function can be used to iterate over anything.\r
1185          *\r
1186          * @example $.each( [0,1,2], function(i){\r
1187          *   alert( "Item #" + i + ": " + this );\r
1188          * });\r
1189          * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.\r
1190          *\r
1191          * @example $.each( { name: "John", lang: "JS" }, function(i){\r
1192          *   alert( "Name: " + i + ", Value: " + this );\r
1193          * });\r
1194          * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.\r
1195          *\r
1196          * @name $.each\r
1197          * @param Object obj The object, or array, to iterate over.\r
1198          * @param Function fn The function that will be executed on every object.\r
1199          * @type Object\r
1200          * @cat Javascript\r
1201          */\r
1202         // args is for internal usage only\r
1203         each: function( obj, fn, args ) {\r
1204                 if ( obj.length == undefined )\r
1205                         for ( var i in obj )\r
1206                                 fn.apply( obj[i], args || [i, obj[i]] );\r
1207                 else\r
1208                         for ( var i = 0; i < obj.length; i++ )\r
1209                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;\r
1210                 return obj;\r
1211         },\r
1212 \r
1213         className: {\r
1214                 add: function(o,c){\r
1215                         if (jQuery.className.has(o,c)) return;\r
1216                         o.className += ( o.className ? " " : "" ) + c;\r
1217                 },\r
1218                 remove: function(o,c){\r
1219                         if( !c ) {\r
1220                                 o.className = "";\r
1221                         } else {\r
1222                                 var classes = o.className.split(" ");\r
1223                                 for(var i=0; i<classes.length; i++) {\r
1224                                         if(classes[i] == c) {\r
1225                                                 classes.splice(i, 1);\r
1226                                                 break;\r
1227                                         }\r
1228                                 }\r
1229                                 o.className = classes.join(' ');\r
1230                         }\r
1231                 },\r
1232                 has: function(e,a) {\r
1233                         if ( e.className != undefined )\r
1234                                 e = e.className;\r
1235                         return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);\r
1236                 }\r
1237         },\r
1238 \r
1239         /**\r
1240          * Swap in/out style options.\r
1241          * @private\r
1242          */\r
1243         swap: function(e,o,f) {\r
1244                 for ( var i in o ) {\r
1245                         e.style["old"+i] = e.style[i];\r
1246                         e.style[i] = o[i];\r
1247                 }\r
1248                 f.apply( e, [] );\r
1249                 for ( var i in o )\r
1250                         e.style[i] = e.style["old"+i];\r
1251         },\r
1252 \r
1253         css: function(e,p) {\r
1254                 if ( p == "height" || p == "width" ) {\r
1255                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];\r
1256 \r
1257                         for ( var i=0; i<d.length; i++ ) {\r
1258                                 old["padding" + d[i]] = 0;\r
1259                                 old["border" + d[i] + "Width"] = 0;\r
1260                         }\r
1261 \r
1262                         jQuery.swap( e, old, function() {\r
1263                                 if (jQuery.css(e,"display") != "none") {\r
1264                                         oHeight = e.offsetHeight;\r
1265                                         oWidth = e.offsetWidth;\r
1266                                 } else {\r
1267                                         e = jQuery(e.cloneNode(true))\r
1268                                                 .find(":radio").removeAttr("checked").end()\r
1269                                                 .css({\r
1270                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"\r
1271                                                 }).appendTo(e.parentNode)[0];\r
1272 \r
1273                                         var parPos = jQuery.css(e.parentNode,"position");\r
1274                                         if ( parPos == "" || parPos == "static" )\r
1275                                                 e.parentNode.style.position = "relative";\r
1276 \r
1277                                         oHeight = e.clientHeight;\r
1278                                         oWidth = e.clientWidth;\r
1279 \r
1280                                         if ( parPos == "" || parPos == "static" )\r
1281                                                 e.parentNode.style.position = "static";\r
1282 \r
1283                                         e.parentNode.removeChild(e);\r
1284                                 }\r
1285                         });\r
1286 \r
1287                         return p == "height" ? oHeight : oWidth;\r
1288                 }\r
1289 \r
1290                 return jQuery.curCSS( e, p );\r
1291         },\r
1292 \r
1293         curCSS: function(elem, prop, force) {\r
1294                 var ret;\r
1295                 \r
1296                 if (prop == 'opacity' && jQuery.browser.msie)\r
1297                         return jQuery.attr(elem.style, 'opacity');\r
1298                         \r
1299                 if (prop == "float" || prop == "cssFloat")\r
1300                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";\r
1301 \r
1302                 if (!force && elem.style[prop]) {\r
1303 \r
1304                         ret = elem.style[prop];\r
1305 \r
1306                 } else if (document.defaultView && document.defaultView.getComputedStyle) {\r
1307 \r
1308                         if (prop == "cssFloat" || prop == "styleFloat")\r
1309                                 prop = "float";\r
1310 \r
1311                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();\r
1312                         var cur = document.defaultView.getComputedStyle(elem, null);\r
1313 \r
1314                         if ( cur )\r
1315                                 ret = cur.getPropertyValue(prop);\r
1316                         else if ( prop == 'display' )\r
1317                                 ret = 'none';\r
1318                         else\r
1319                                 jQuery.swap(elem, { display: 'block' }, function() {\r
1320                                     var c = document.defaultView.getComputedStyle(this, '');\r
1321                                     ret = c && c.getPropertyValue(prop) || '';\r
1322                                 });\r
1323 \r
1324                 } else if (elem.currentStyle) {\r
1325 \r
1326                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});\r
1327                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];\r
1328                         \r
1329                 }\r
1330 \r
1331                 return ret;\r
1332         },\r
1333         \r
1334                 clean: function(a) {\r
1335                 var r = [];\r
1336                 for ( var i = 0; i < a.length; i++ ) {\r
1337                         var arg = a[i];\r
1338                         if ( typeof arg == "string" ) { // Convert html string into DOM nodes\r
1339                                 // Trim whitespace, otherwise indexOf won't work as expected\r
1340                                 var s = jQuery.trim(arg), s3 = s.substring(0,3), s6 = s.substring(0,6),\r
1341                                         div = document.createElement("div"), wrap = [0,"",""];\r
1342 \r
1343                                 if ( s.substring(0,4) == "<opt" ) // option or optgroup\r
1344                                         wrap = [1, "<select>", "</select>"];\r
1345                                 else if ( s6 == "<thead" || s6 == "<tbody" || s6 == "<tfoot" )\r
1346                                         wrap = [1, "<table>", "</table>"];\r
1347                                 else if ( s3 == "<tr" )\r
1348                                         wrap = [2, "<table><tbody>", "</tbody></table>"];\r
1349                                 else if ( s3 == "<td" || s3 == "<th" ) // <thead> matched above\r
1350                                         wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];\r
1351 \r
1352                                 // Go to html and back, then peel off extra wrappers\r
1353                                 div.innerHTML = wrap[1] + s + wrap[2];\r
1354                                 while ( wrap[0]-- ) div = div.firstChild;\r
1355                                 \r
1356                                 // Remove IE's autoinserted <tbody> from table fragments\r
1357                                 if ( jQuery.browser.msie ) {\r
1358                                         var tb = null;\r
1359                                         // String was a <table>, *may* have spurious <tbody>\r
1360                                         if ( s6 == "<table" && s.indexOf("<tbody") < 0 ) \r
1361                                                 tb = div.firstChild && div.firstChild.childNodes;\r
1362                                         // String was a bare <thead> or <tfoot>\r
1363                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )\r
1364                                                 tb = div.childNodes;\r
1365                                         if ( tb ) {\r
1366                                                 for ( var n = tb.length-1; n >= 0 ; --n )\r
1367                                                         if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )\r
1368                                                                 tb[n].parentNode.removeChild(tb[n]);\r
1369                                         }\r
1370                                 }\r
1371                                 \r
1372                                 arg = div.childNodes;\r
1373                         } \r
1374                         \r
1375                         \r
1376                         if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function\r
1377                                 for ( var n = 0; n < arg.length; n++ ) // Handles Array, jQuery, DOM NodeList collections\r
1378                                         r.push(arg[n]);\r
1379                         else\r
1380                                 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );\r
1381                 }\r
1382 \r
1383                 return r;\r
1384         },\r
1385 \r
1386         expr: {\r
1387                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",\r
1388                 "#": "a.getAttribute('id')==m[2]",\r
1389                 ":": {\r
1390                         // Position Checks\r
1391                         lt: "i<m[3]-0",\r
1392                         gt: "i>m[3]-0",\r
1393                         nth: "m[3]-0==i",\r
1394                         eq: "m[3]-0==i",\r
1395                         first: "i==0",\r
1396                         last: "i==r.length-1",\r
1397                         even: "i%2==0",\r
1398                         odd: "i%2",\r
1399 \r
1400                         // Child Checks\r
1401                         "nth-child": "jQuery.sibling(a,m[3]).cur",\r
1402                         "first-child": "jQuery.sibling(a,0).cur",\r
1403                         "last-child": "jQuery.sibling(a,0).last",\r
1404                         "only-child": "jQuery.sibling(a).length==1",\r
1405 \r
1406                         // Parent Checks\r
1407                         parent: "a.childNodes.length",\r
1408                         empty: "!a.childNodes.length",\r
1409 \r
1410                         // Text Check\r
1411                         contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",\r
1412 \r
1413                         // Visibility\r
1414                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",\r
1415                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",\r
1416 \r
1417                         // Form attributes\r
1418                         enabled: "!a.disabled",\r
1419                         disabled: "a.disabled",\r
1420                         checked: "a.checked",\r
1421                         selected: "a.selected || jQuery.attr(a, 'selected')",\r
1422 \r
1423                         // Form elements\r
1424                         text: "a.type=='text'",\r
1425                         radio: "a.type=='radio'",\r
1426                         checkbox: "a.type=='checkbox'",\r
1427                         file: "a.type=='file'",\r
1428                         password: "a.type=='password'",\r
1429                         submit: "a.type=='submit'",\r
1430                         image: "a.type=='image'",\r
1431                         reset: "a.type=='reset'",\r
1432                         button: "a.type=='button'",\r
1433                         input: "/input|select|textarea|button/i.test(a.nodeName)"\r
1434                 },\r
1435                 ".": "jQuery.className.has(a,m[2])",\r
1436                 "@": {\r
1437                         "=": "z==m[4]",\r
1438                         "!=": "z!=m[4]",\r
1439                         "^=": "z && !z.indexOf(m[4])",\r
1440                         "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",\r
1441                         "*=": "z && z.indexOf(m[4])>=0",\r
1442                         "": "z"\r
1443                 },\r
1444                 "[": "jQuery.find(m[2],a).length"\r
1445         },\r
1446 \r
1447         token: [\r
1448                 "\\.\\.|/\\.\\.", "a.parentNode",\r
1449                 ">|/", "jQuery.sibling(a.firstChild)",\r
1450                 "\\+", "jQuery.sibling(a).next",\r
1451                 "~", function(a){\r
1452                         var s = jQuery.sibling(a);\r
1453                         return s.n >= 0 ? s.slice(s.n+1) : [];\r
1454                 }\r
1455         ],\r
1456 \r
1457         /**\r
1458          * @name $.find\r
1459          * @type Array<Element>\r
1460          * @private\r
1461          * @cat Core\r
1462          */\r
1463         find: function( t, context ) {\r
1464                 // Make sure that the context is a DOM Element\r
1465                 if ( context && context.nodeType == undefined )\r
1466                         context = null;\r
1467 \r
1468                 // Set the correct context (if none is provided)\r
1469                 context = context || document;\r
1470 \r
1471                 if ( typeof t != "string" ) return [t];\r
1472 \r
1473                 if ( !t.indexOf("//") ) {\r
1474                         context = context.documentElement;\r
1475                         t = t.substr(2,t.length);\r
1476                 } else if ( !t.indexOf("/") ) {\r
1477                         context = context.documentElement;\r
1478                         t = t.substr(1,t.length);\r
1479                         // FIX Assume the root element is right :(\r
1480                         if ( t.indexOf("/") >= 1 )\r
1481                                 t = t.substr(t.indexOf("/"),t.length);\r
1482                 }\r
1483 \r
1484                 var ret = [context];\r
1485                 var done = [];\r
1486                 var last = null;\r
1487 \r
1488                 while ( t.length > 0 && last != t ) {\r
1489                         var r = [];\r
1490                         last = t;\r
1491 \r
1492                         t = jQuery.trim(t).replace( /^\/\//i, "" );\r
1493 \r
1494                         var foundToken = false;\r
1495 \r
1496                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {\r
1497                                 if ( foundToken ) continue;\r
1498 \r
1499                                 var re = new RegExp("^(" + jQuery.token[i] + ")");\r
1500                                 var m = re.exec(t);\r
1501 \r
1502                                 if ( m ) {\r
1503                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );\r
1504                                         t = jQuery.trim( t.replace( re, "" ) );\r
1505                                         foundToken = true;\r
1506                                 }\r
1507                         }\r
1508 \r
1509                         if ( !foundToken ) {\r
1510                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {\r
1511                                         if ( ret[0] == context ) ret.shift();\r
1512                                         done = jQuery.merge( done, ret );\r
1513                                         r = ret = [context];\r
1514                                         t = " " + t.substr(1,t.length);\r
1515                                 } else {\r
1516                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;\r
1517                                         var m = re2.exec(t);\r
1518 \r
1519                                         if ( m[1] == "#" && ret[ret.length-1].getElementById ) {\r
1520                                                 // Optimization for HTML document case\r
1521                                                 var oid = ret[ret.length-1].getElementById(m[2]);\r
1522                                                 r = ret = oid ? [oid] : [];\r
1523                                                 t = t.replace( re2, "" );\r
1524                                         } else {\r
1525                                                 if ( !m[2] || m[1] == "." || m[1] == "#" ) m[2] = "*";\r
1526 \r
1527                                                 for ( var i = 0; i < ret.length; i++ )\r
1528                                                         r = jQuery.merge( r,\r
1529                                                                 m[2] == "*" ?\r
1530                                                                         jQuery.getAll(ret[i]) :\r
1531                                                                         ret[i].getElementsByTagName(m[2])\r
1532                                                         );\r
1533                                         }\r
1534                                 }\r
1535 \r
1536                         }\r
1537 \r
1538                         if ( t ) {\r
1539                                 var val = jQuery.filter(t,r);\r
1540                                 ret = r = val.r;\r
1541                                 t = jQuery.trim(val.t);\r
1542                         }\r
1543                 }\r
1544 \r
1545                 if ( ret && ret[0] == context ) ret.shift();\r
1546                 done = jQuery.merge( done, ret );\r
1547 \r
1548                 return done;\r
1549         },\r
1550 \r
1551         getAll: function(o,r) {\r
1552                 r = r || [];\r
1553                 var s = o.childNodes;\r
1554                 for ( var i = 0; i < s.length; i++ )\r
1555                         if ( s[i].nodeType == 1 ) {\r
1556                                 r.push( s[i] );\r
1557                                 jQuery.getAll( s[i], r );\r
1558                         }\r
1559                 return r;\r
1560         },\r
1561 \r
1562         attr: function(elem, name, value){\r
1563                 var fix = {\r
1564                         "for": "htmlFor",\r
1565                         "class": "className",\r
1566                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",\r
1567                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",\r
1568                         innerHTML: "innerHTML",\r
1569                         className: "className",\r
1570                         value: "value",\r
1571                         disabled: "disabled",\r
1572                         checked: "checked",\r
1573                         readonly: "readOnly"\r
1574                 };\r
1575                 \r
1576                 // IE actually uses filters for opacity ... elem is actually elem.style\r
1577                 if (name == "opacity" && jQuery.browser.msie && value != undefined) {\r
1578                         // IE has trouble with opacity if it does not have layout\r
1579                         // Would prefer to check element.hasLayout first but don't have access to the element here\r
1580                         elem['zoom'] = 1; \r
1581                         if (value == 1) // Remove filter to avoid more IE weirdness\r
1582                                 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");\r
1583                         else\r
1584                                 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";\r
1585                 } else if (name == "opacity" && jQuery.browser.msie) {\r
1586                         return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;\r
1587                 }\r
1588                 \r
1589                 // Mozilla doesn't play well with opacity 1\r
1590                 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;\r
1591 \r
1592                 if ( fix[name] ) {\r
1593                         if ( value != undefined ) elem[fix[name]] = value;\r
1594                         return elem[fix[name]];\r
1595                 } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {\r
1596                         return elem.getAttributeNode(name).nodeValue;\r
1597                 } else if ( elem.tagName ) { // IE elem.getAttribute passes even for style\r
1598                         if ( value != undefined ) elem.setAttribute( name, value );\r
1599                         return elem.getAttribute( name );\r
1600                 } else {\r
1601                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});\r
1602                         if ( value != undefined ) elem[name] = value;\r
1603                         return elem[name];\r
1604                 }\r
1605         },\r
1606 \r
1607         // The regular expressions that power the parsing engine\r
1608         parse: [\r
1609                 // Match: [@value='test'], [@foo]\r
1610                 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",\r
1611 \r
1612                 // Match: [div], [div p]\r
1613                 "(\\[)\s*(.*?)\s*\\]",\r
1614 \r
1615                 // Match: :contains('foo')\r
1616                 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",\r
1617 \r
1618                 // Match: :even, :last-chlid\r
1619                 "([:.#]*)S"\r
1620         ],\r
1621 \r
1622         filter: function(t,r,not) {\r
1623                 // Figure out if we're doing regular, or inverse, filtering\r
1624                 var g = not !== false ? jQuery.grep :\r
1625                         function(a,f) {return jQuery.grep(a,f,true);};\r
1626 \r
1627                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {\r
1628 \r
1629                         var p = jQuery.parse;\r
1630 \r
1631                         for ( var i = 0; i < p.length; i++ ) {\r
1632                 \r
1633                                 // Look for, and replace, string-like sequences\r
1634                                 // and finally build a regexp out of it\r
1635                                 var re = new RegExp(\r
1636                                         "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );\r
1637 \r
1638                                 var m = re.exec( t );\r
1639 \r
1640                                 if ( m ) {\r
1641                                         // Re-organize the first match\r
1642                                         if ( !i )\r
1643                                                 m = ["",m[1], m[3], m[2], m[5]];\r
1644 \r
1645                                         // Remove what we just matched\r
1646                                         t = t.replace( re, "" );\r
1647 \r
1648                                         break;\r
1649                                 }\r
1650                         }\r
1651 \r
1652                         // :not() is a special case that can be optimized by\r
1653                         // keeping it out of the expression list\r
1654                         if ( m[1] == ":" && m[2] == "not" )\r
1655                                 r = jQuery.filter(m[3],r,false).r;\r
1656 \r
1657                         // Otherwise, find the expression to execute\r
1658                         else {\r
1659                                 var f = jQuery.expr[m[1]];\r
1660                                 if ( typeof f != "string" )\r
1661                                         f = jQuery.expr[m[1]][m[2]];\r
1662 \r
1663                                 // Build a custom macro to enclose it\r
1664                                 eval("f = function(a,i){" +\r
1665                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +\r
1666                                         "return " + f + "}");\r
1667 \r
1668                                 // Execute it against the current filter\r
1669                                 r = g( r, f );\r
1670                         }\r
1671                 }\r
1672 \r
1673                 // Return an array of filtered elements (r)\r
1674                 // and the modified expression string (t)\r
1675                 return { r: r, t: t };\r
1676         },\r
1677 \r
1678         /**\r
1679          * Remove the whitespace from the beginning and end of a string.\r
1680          *\r
1681          * @example $.trim("  hello, how are you?  ");\r
1682          * @result "hello, how are you?"\r
1683          *\r
1684          * @name $.trim\r
1685          * @type String\r
1686          * @param String str The string to trim.\r
1687          * @cat Javascript\r
1688          */\r
1689         trim: function(t){\r
1690                 return t.replace(/^\s+|\s+$/g, "");\r
1691         },\r
1692 \r
1693         /**\r
1694          * All ancestors of a given element.\r
1695          *\r
1696          * @private\r
1697          * @name $.parents\r
1698          * @type Array<Element>\r
1699          * @param Element elem The element to find the ancestors of.\r
1700          * @cat DOM/Traversing\r
1701          */\r
1702         parents: function( elem ){\r
1703                 var matched = [];\r
1704                 var cur = elem.parentNode;\r
1705                 while ( cur && cur != document ) {\r
1706                         matched.push( cur );\r
1707                         cur = cur.parentNode;\r
1708                 }\r
1709                 return matched;\r
1710         },\r
1711 \r
1712         /**\r
1713          * All elements on a specified axis.\r
1714          *\r
1715          * @private\r
1716          * @name $.sibling\r
1717          * @type Array\r
1718          * @param Element elem The element to find all the siblings of (including itself).\r
1719          * @cat DOM/Traversing\r
1720          */\r
1721         sibling: function(elem, pos, not) {\r
1722                 var elems = [];\r
1723                 \r
1724                 if(elem) {\r
1725                         var siblings = elem.parentNode.childNodes;\r
1726                         for ( var i = 0; i < siblings.length; i++ ) {\r
1727                                 if ( not === true && siblings[i] == elem ) continue;\r
1728         \r
1729                                 if ( siblings[i].nodeType == 1 )\r
1730                                         elems.push( siblings[i] );\r
1731                                 if ( siblings[i] == elem )\r
1732                                         elems.n = elems.length - 1;\r
1733                         }\r
1734                 }\r
1735 \r
1736                 return jQuery.extend( elems, {\r
1737                         last: elems.n == elems.length - 1,\r
1738                         cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,\r
1739                         prev: elems[elems.n - 1],\r
1740                         next: elems[elems.n + 1]\r
1741                 });\r
1742         },\r
1743 \r
1744         /**\r
1745          * Merge two arrays together, removing all duplicates. The final order\r
1746          * or the new array is: All the results from the first array, followed\r
1747          * by the unique results from the second array.\r
1748          *\r
1749          * @example $.merge( [0,1,2], [2,3,4] )\r
1750          * @result [0,1,2,3,4]\r
1751          *\r
1752          * @example $.merge( [3,2,1], [4,3,2] )\r
1753          * @result [3,2,1,4]\r
1754          *\r
1755          * @name $.merge\r
1756          * @type Array\r
1757          * @param Array first The first array to merge.\r
1758          * @param Array second The second array to merge.\r
1759          * @cat Javascript\r
1760          */\r
1761         merge: function(first, second) {\r
1762                 var result = [];\r
1763 \r
1764                 // Move b over to the new array (this helps to avoid\r
1765                 // StaticNodeList instances)\r
1766                 for ( var k = 0; k < first.length; k++ )\r
1767                         result[k] = first[k];\r
1768 \r
1769                 // Now check for duplicates between a and b\r
1770                 // and only add the unique items\r
1771            DupCheck:\r
1772                 for ( var i = 0; i < second.length; i++ ) {\r
1773                         for ( var j = 0; j < first.length; j++ )\r
1774                                 if ( second[i] == first[j] )\r
1775                                         continue DupCheck;\r
1776                         // The item is unique, add it\r
1777                         result.push( second[i] );\r
1778                 }\r
1779 \r
1780                 return result;\r
1781         },\r
1782 \r
1783         /**\r
1784          * Filter items out of an array, by using a filter function.\r
1785          * The specified function will be passed two arguments: The\r
1786          * current array item and the index of the item in the array. The\r
1787          * function should return 'true' if you wish to keep the item in\r
1788          * the array, false if it should be removed.\r
1789          *\r
1790          * @example $.grep( [0,1,2], function(i){\r
1791          *   return i > 0;\r
1792          * });\r
1793          * @result [1, 2]\r
1794          *\r
1795          * @name $.grep\r
1796          * @type Array\r
1797          * @param Array array The Array to find items in.\r
1798          * @param Function fn The function to process each item against.\r
1799          * @param Boolean inv Invert the selection - select the opposite of the function.\r
1800          * @cat Javascript\r
1801          */\r
1802         grep: function(elems, fn, inv) {\r
1803                 // If a string is passed in for the function, make a function\r
1804                 // for it (a handy shortcut)\r
1805                 if ( typeof fn == "string" )\r
1806                         fn = new Function("a","i","return " + fn);\r
1807 \r
1808                 var result = [];\r
1809 \r
1810                 // Go through the array, only saving the items\r
1811                 // that pass the validator function\r
1812                 for ( var i = 0; i < elems.length; i++ )\r
1813                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )\r
1814                                 result.push( elems[i] );\r
1815 \r
1816                 return result;\r
1817         },\r
1818 \r
1819         /**\r
1820          * Translate all items in an array to another array of items. \r
1821          * The translation function that is provided to this method is \r
1822          * called for each item in the array and is passed one argument: \r
1823          * The item to be translated. The function can then return:\r
1824          * The translated value, 'null' (to remove the item), or \r
1825          * an array of values - which will be flattened into the full array.\r
1826          *\r
1827          * @example $.map( [0,1,2], function(i){\r
1828          *   return i + 4;\r
1829          * });\r
1830          * @result [4, 5, 6]\r
1831          *\r
1832          * @example $.map( [0,1,2], function(i){\r
1833          *   return i > 0 ? i + 1 : null;\r
1834          * });\r
1835          * @result [2, 3]\r
1836          * \r
1837          * @example $.map( [0,1,2], function(i){\r
1838          *   return [ i, i + 1 ];\r
1839          * });\r
1840          * @result [0, 1, 1, 2, 2, 3]\r
1841          *\r
1842          * @name $.map\r
1843          * @type Array\r
1844          * @param Array array The Array to translate.\r
1845          * @param Function fn The function to process each item against.\r
1846          * @cat Javascript\r
1847          */\r
1848         map: function(elems, fn) {\r
1849                 // If a string is passed in for the function, make a function\r
1850                 // for it (a handy shortcut)\r
1851                 if ( typeof fn == "string" )\r
1852                         fn = new Function("a","return " + fn);\r
1853 \r
1854                 var result = [];\r
1855 \r
1856                 // Go through the array, translating each of the items to their\r
1857                 // new value (or values).\r
1858                 for ( var i = 0; i < elems.length; i++ ) {\r
1859                         var val = fn(elems[i],i);\r
1860 \r
1861                         if ( val !== null && val != undefined ) {\r
1862                                 if ( val.constructor != Array ) val = [val];\r
1863                                 result = jQuery.merge( result, val );\r
1864                         }\r
1865                 }\r
1866 \r
1867                 return result;\r
1868         },\r
1869 \r
1870         /*\r
1871          * A number of helper functions used for managing events.\r
1872          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.\r
1873          */\r
1874         event: {\r
1875 \r
1876                 // Bind an event to an element\r
1877                 // Original by Dean Edwards\r
1878                 add: function(element, type, handler) {\r
1879                         // For whatever reason, IE has trouble passing the window object\r
1880                         // around, causing it to be cloned in the process\r
1881                         if ( jQuery.browser.msie && element.setInterval != undefined )\r
1882                                 element = window;\r
1883 \r
1884                         // Make sure that the function being executed has a unique ID\r
1885                         if ( !handler.guid )\r
1886                                 handler.guid = this.guid++;\r
1887 \r
1888                         // Init the element's event structure\r
1889                         if (!element.events)\r
1890                                 element.events = {};\r
1891 \r
1892                         // Get the current list of functions bound to this event\r
1893                         var handlers = element.events[type];\r
1894 \r
1895                         // If it hasn't been initialized yet\r
1896                         if (!handlers) {\r
1897                                 // Init the event handler queue\r
1898                                 handlers = element.events[type] = {};\r
1899 \r
1900                                 // Remember an existing handler, if it's already there\r
1901                                 if (element["on" + type])\r
1902                                         handlers[0] = element["on" + type];\r
1903                         }\r
1904 \r
1905                         // Add the function to the element's handler list\r
1906                         handlers[handler.guid] = handler;\r
1907 \r
1908                         // And bind the global event handler to the element\r
1909                         element["on" + type] = this.handle;\r
1910 \r
1911                         // Remember the function in a global list (for triggering)\r
1912                         if (!this.global[type])\r
1913                                 this.global[type] = [];\r
1914                         this.global[type].push( element );\r
1915                 },\r
1916 \r
1917                 guid: 1,\r
1918                 global: {},\r
1919 \r
1920                 // Detach an event or set of events from an element\r
1921                 remove: function(element, type, handler) {\r
1922                         if (element.events)\r
1923                                 if (type && element.events[type])\r
1924                                         if ( handler )\r
1925                                                 delete element.events[type][handler.guid];\r
1926                                         else\r
1927                                                 for ( var i in element.events[type] )\r
1928                                                         delete element.events[type][i];\r
1929                                 else\r
1930                                         for ( var j in element.events )\r
1931                                                 this.remove( element, j );\r
1932                 },\r
1933 \r
1934                 trigger: function(type,data,element) {\r
1935                         // Clone the incoming data, if any\r
1936                         data = $.merge([], data || []);\r
1937 \r
1938                         // Handle a global trigger\r
1939                         if ( !element ) {\r
1940                                 var g = this.global[type];\r
1941                                 if ( g )\r
1942                                         for ( var i = 0; i < g.length; i++ )\r
1943                                                 this.trigger( type, data, g[i] );\r
1944 \r
1945                         // Handle triggering a single element\r
1946                         } else if ( element["on" + type] ) {\r
1947                                 // Pass along a fake event\r
1948                                 data.unshift( this.fix({ type: type, target: element }) );\r
1949 \r
1950                                 // Trigger the event\r
1951                                 element["on" + type].apply( element, data );\r
1952                         }\r
1953                 },\r
1954 \r
1955                 handle: function(event) {\r
1956                         if ( typeof jQuery == "undefined" ) return false;\r
1957 \r
1958                         event = jQuery.event.fix( event || window.event || {} ); // Empty object is for triggered events with no data\r
1959 \r
1960                         // If no correct event was found, fail\r
1961                         if ( !event ) return false;\r
1962 \r
1963                         var returnValue = true;\r
1964 \r
1965                         var c = this.events[event.type];\r
1966 \r
1967                         var args = [].slice.call( arguments, 1 );\r
1968                         args.unshift( event );\r
1969 \r
1970                         for ( var j in c ) {\r
1971                                 if ( c[j].apply( this, args ) === false ) {\r
1972                                         event.preventDefault();\r
1973                                         event.stopPropagation();\r
1974                                         returnValue = false;\r
1975                                 }\r
1976                         }\r
1977 \r
1978                         // Clean up added properties in IE to prevent memory leak\r
1979                         if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = null;\r
1980 \r
1981                         return returnValue;\r
1982                 },\r
1983 \r
1984                 fix: function(event) {\r
1985                         // check IE\r
1986                         if(jQuery.browser.msie) {\r
1987                                 // fix target property, if available\r
1988                                 // check prevents overwriting of fake target coming from trigger\r
1989                                 if(event.srcElement)\r
1990                                         event.target = event.srcElement;\r
1991                                         \r
1992                                 // calculate pageX/Y\r
1993                                 var e = document.documentElement, b = document.body;\r
1994                                 event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);\r
1995                                 event.pageY = event.clientY + (e.scrollTop || b.scrollTop);\r
1996                                         \r
1997                         // check safari and if target is a textnode\r
1998                         } else if(jQuery.browser.safari && event.target.nodeType == 3) {\r
1999                                 // target is readonly, clone the event object\r
2000                                 event = jQuery.extend({}, event);\r
2001                                 // get parentnode from textnode\r
2002                                 event.target = event.target.parentNode;\r
2003                         }\r
2004                         \r
2005                         // fix preventDefault and stopPropagation\r
2006                         if (!event.preventDefault)\r
2007                                 event.preventDefault = function() {\r
2008                                         this.returnValue = false;\r
2009                                 };\r
2010                                 \r
2011                         if (!event.stopPropagation)\r
2012                                 event.stopPropagation = function() {\r
2013                                         this.cancelBubble = true;\r
2014                                 };\r
2015                                 \r
2016                         return event;\r
2017                 }\r
2018         }\r
2019 });\r
2020 \r
2021 /**\r
2022  * Contains flags for the useragent, read from navigator.userAgent.\r
2023  * Available flags are: safari, opera, msie, mozilla\r
2024  * This property is available before the DOM is ready, therefore you can\r
2025  * use it to add ready events only for certain browsers.\r
2026  *\r
2027  * There are situations where object detections is not reliable enough, in that\r
2028  * cases it makes sense to use browser detection. Simply try to avoid both!\r
2029  *\r
2030  * A combination of browser and object detection yields quite reliable results.\r
2031  *\r
2032  * @example $.browser.msie\r
2033  * @desc Returns true if the current useragent is some version of microsoft's internet explorer\r
2034  *\r
2035  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }\r
2036  * @desc Alerts "this is safari!" only for safari browsers\r
2037  *\r
2038  * @property\r
2039  * @name $.browser\r
2040  * @type Boolean\r
2041  * @cat Javascript\r
2042  */\r
2043  \r
2044 /*\r
2045  * Wheather the W3C compliant box model is being used.\r
2046  *\r
2047  * @property\r
2048  * @name $.boxModel\r
2049  * @type Boolean\r
2050  * @cat Javascript\r
2051  */\r
2052 new function() {\r
2053         var b = navigator.userAgent.toLowerCase();\r
2054 \r
2055         // Figure out what browser is being used\r
2056         jQuery.browser = {\r
2057                 safari: /webkit/.test(b),\r
2058                 opera: /opera/.test(b),\r
2059                 msie: /msie/.test(b) && !/opera/.test(b),\r
2060                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)\r
2061         };\r
2062 \r
2063         // Check to see if the W3C box model is being used\r
2064         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";\r
2065 };\r
2066 \r
2067 jQuery.macros = {\r
2068         to: {\r
2069                 /**\r
2070                  * Append all of the matched elements to another, specified, set of elements.\r
2071                  * This operation is, essentially, the reverse of doing a regular\r
2072                  * $(A).append(B), in that instead of appending B to A, you're appending\r
2073                  * A to B.\r
2074                  *\r
2075                  * @example $("p").appendTo("#foo");\r
2076                  * @before <p>I would like to say: </p><div id="foo"></div>\r
2077                  * @result <div id="foo"><p>I would like to say: </p></div>\r
2078                  *\r
2079                  * @name appendTo\r
2080                  * @type jQuery\r
2081                  * @param String expr A jQuery expression of elements to match.\r
2082                  * @cat DOM/Manipulation\r
2083                  */\r
2084                 appendTo: "append",\r
2085 \r
2086                 /**\r
2087                  * Prepend all of the matched elements to another, specified, set of elements.\r
2088                  * This operation is, essentially, the reverse of doing a regular\r
2089                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending\r
2090                  * A to B.\r
2091                  *\r
2092                  * @example $("p").prependTo("#foo");\r
2093                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>\r
2094                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>\r
2095                  *\r
2096                  * @name prependTo\r
2097                  * @type jQuery\r
2098                  * @param String expr A jQuery expression of elements to match.\r
2099                  * @cat DOM/Manipulation\r
2100                  */\r
2101                 prependTo: "prepend",\r
2102 \r
2103                 /**\r
2104                  * Insert all of the matched elements before another, specified, set of elements.\r
2105                  * This operation is, essentially, the reverse of doing a regular\r
2106                  * $(A).before(B), in that instead of inserting B before A, you're inserting\r
2107                  * A before B.\r
2108                  *\r
2109                  * @example $("p").insertBefore("#foo");\r
2110                  * @before <div id="foo">Hello</div><p>I would like to say: </p>\r
2111                  * @result <p>I would like to say: </p><div id="foo">Hello</div>\r
2112                  *\r
2113                  * @name insertBefore\r
2114                  * @type jQuery\r
2115                  * @param String expr A jQuery expression of elements to match.\r
2116                  * @cat DOM/Manipulation\r
2117                  */\r
2118                 insertBefore: "before",\r
2119 \r
2120                 /**\r
2121                  * Insert all of the matched elements after another, specified, set of elements.\r
2122                  * This operation is, essentially, the reverse of doing a regular\r
2123                  * $(A).after(B), in that instead of inserting B after A, you're inserting\r
2124                  * A after B.\r
2125                  *\r
2126                  * @example $("p").insertAfter("#foo");\r
2127                  * @before <p>I would like to say: </p><div id="foo">Hello</div>\r
2128                  * @result <div id="foo">Hello</div><p>I would like to say: </p>\r
2129                  *\r
2130                  * @name insertAfter\r
2131                  * @type jQuery\r
2132                  * @param String expr A jQuery expression of elements to match.\r
2133                  * @cat DOM/Manipulation\r
2134                  */\r
2135                 insertAfter: "after"\r
2136         },\r
2137 \r
2138         /**\r
2139          * Get the current CSS width of the first matched element.\r
2140          *\r
2141          * @example $("p").width();\r
2142          * @before <p>This is just a test.</p>\r
2143          * @result "300px"\r
2144          *\r
2145          * @name width\r
2146          * @type String\r
2147          * @cat CSS\r
2148          */\r
2149 \r
2150         /**\r
2151          * Set the CSS width of every matched element. Be sure to include\r
2152          * the "px" (or other unit of measurement) after the number that you\r
2153          * specify, otherwise you might get strange results.\r
2154          *\r
2155          * @example $("p").width("20px");\r
2156          * @before <p>This is just a test.</p>\r
2157          * @result <p style="width:20px;">This is just a test.</p>\r
2158          *\r
2159          * @name width\r
2160          * @type jQuery\r
2161          * @param String val Set the CSS property to the specified value.\r
2162          * @cat CSS\r
2163          */\r
2164 \r
2165         /**\r
2166          * Get the current CSS height of the first matched element.\r
2167          *\r
2168          * @example $("p").height();\r
2169          * @before <p>This is just a test.</p>\r
2170          * @result "14px"\r
2171          *\r
2172          * @name height\r
2173          * @type String\r
2174          * @cat CSS\r
2175          */\r
2176 \r
2177         /**\r
2178          * Set the CSS height of every matched element. Be sure to include\r
2179          * the "px" (or other unit of measurement) after the number that you\r
2180          * specify, otherwise you might get strange results.\r
2181          *\r
2182          * @example $("p").height("20px");\r
2183          * @before <p>This is just a test.</p>\r
2184          * @result <p style="height:20px;">This is just a test.</p>\r
2185          *\r
2186          * @name height\r
2187          * @type jQuery\r
2188          * @param String val Set the CSS property to the specified value.\r
2189          * @cat CSS\r
2190          */\r
2191 \r
2192         /**\r
2193          * Get the current CSS top of the first matched element.\r
2194          *\r
2195          * @example $("p").top();\r
2196          * @before <p>This is just a test.</p>\r
2197          * @result "0px"\r
2198          *\r
2199          * @name top\r
2200          * @type String\r
2201          * @cat CSS\r
2202          */\r
2203 \r
2204         /**\r
2205          * Set the CSS top of every matched element. Be sure to include\r
2206          * the "px" (or other unit of measurement) after the number that you\r
2207          * specify, otherwise you might get strange results.\r
2208          *\r
2209          * @example $("p").top("20px");\r
2210          * @before <p>This is just a test.</p>\r
2211          * @result <p style="top:20px;">This is just a test.</p>\r
2212          *\r
2213          * @name top\r
2214          * @type jQuery\r
2215          * @param String val Set the CSS property to the specified value.\r
2216          * @cat CSS\r
2217          */\r
2218 \r
2219         /**\r
2220          * Get the current CSS left of the first matched element.\r
2221          *\r
2222          * @example $("p").left();\r
2223          * @before <p>This is just a test.</p>\r
2224          * @result "0px"\r
2225          *\r
2226          * @name left\r
2227          * @type String\r
2228          * @cat CSS\r
2229          */\r
2230 \r
2231         /**\r
2232          * Set the CSS left of every matched element. Be sure to include\r
2233          * the "px" (or other unit of measurement) after the number that you\r
2234          * specify, otherwise you might get strange results.\r
2235          *\r
2236          * @example $("p").left("20px");\r
2237          * @before <p>This is just a test.</p>\r
2238          * @result <p style="left:20px;">This is just a test.</p>\r
2239          *\r
2240          * @name left\r
2241          * @type jQuery\r
2242          * @param String val Set the CSS property to the specified value.\r
2243          * @cat CSS\r
2244          */\r
2245 \r
2246         /**\r
2247          * Get the current CSS position of the first matched element.\r
2248          *\r
2249          * @example $("p").position();\r
2250          * @before <p>This is just a test.</p>\r
2251          * @result "static"\r
2252          *\r
2253          * @name position\r
2254          * @type String\r
2255          * @cat CSS\r
2256          */\r
2257 \r
2258         /**\r
2259          * Set the CSS position of every matched element.\r
2260          *\r
2261          * @example $("p").position("relative");\r
2262          * @before <p>This is just a test.</p>\r
2263          * @result <p style="position:relative;">This is just a test.</p>\r
2264          *\r
2265          * @name position\r
2266          * @type jQuery\r
2267          * @param String val Set the CSS property to the specified value.\r
2268          * @cat CSS\r
2269          */\r
2270 \r
2271         /**\r
2272          * Get the current CSS float of the first matched element.\r
2273          *\r
2274          * @example $("p").float();\r
2275          * @before <p>This is just a test.</p>\r
2276          * @result "none"\r
2277          *\r
2278          * @name float\r
2279          * @type String\r
2280          * @cat CSS\r
2281          */\r
2282 \r
2283         /**\r
2284          * Set the CSS float of every matched element.\r
2285          *\r
2286          * @example $("p").float("left");\r
2287          * @before <p>This is just a test.</p>\r
2288          * @result <p style="float:left;">This is just a test.</p>\r
2289          *\r
2290          * @name float\r
2291          * @type jQuery\r
2292          * @param String val Set the CSS property to the specified value.\r
2293          * @cat CSS\r
2294          */\r
2295 \r
2296         /**\r
2297          * Get the current CSS overflow of the first matched element.\r
2298          *\r
2299          * @example $("p").overflow();\r
2300          * @before <p>This is just a test.</p>\r
2301          * @result "none"\r
2302          *\r
2303          * @name overflow\r
2304          * @type String\r
2305          * @cat CSS\r
2306          */\r
2307 \r
2308         /**\r
2309          * Set the CSS overflow of every matched element.\r
2310          *\r
2311          * @example $("p").overflow("auto");\r
2312          * @before <p>This is just a test.</p>\r
2313          * @result <p style="overflow:auto;">This is just a test.</p>\r
2314          *\r
2315          * @name overflow\r
2316          * @type jQuery\r
2317          * @param String val Set the CSS property to the specified value.\r
2318          * @cat CSS\r
2319          */\r
2320 \r
2321         /**\r
2322          * Get the current CSS color of the first matched element.\r
2323          *\r
2324          * @example $("p").color();\r
2325          * @before <p>This is just a test.</p>\r
2326          * @result "black"\r
2327          *\r
2328          * @name color\r
2329          * @type String\r
2330          * @cat CSS\r
2331          */\r
2332 \r
2333         /**\r
2334          * Set the CSS color of every matched element.\r
2335          *\r
2336          * @example $("p").color("blue");\r
2337          * @before <p>This is just a test.</p>\r
2338          * @result <p style="color:blue;">This is just a test.</p>\r
2339          *\r
2340          * @name color\r
2341          * @type jQuery\r
2342          * @param String val Set the CSS property to the specified value.\r
2343          * @cat CSS\r
2344          */\r
2345 \r
2346         /**\r
2347          * Get the current CSS background of the first matched element.\r
2348          *\r
2349          * @example $("p").background();\r
2350          * @before <p style="background:blue;">This is just a test.</p>\r
2351          * @result "blue"\r
2352          *\r
2353          * @name background\r
2354          * @type String\r
2355          * @cat CSS\r
2356          */\r
2357 \r
2358         /**\r
2359          * Set the CSS background of every matched element.\r
2360          *\r
2361          * @example $("p").background("blue");\r
2362          * @before <p>This is just a test.</p>\r
2363          * @result <p style="background:blue;">This is just a test.</p>\r
2364          *\r
2365          * @name background\r
2366          * @type jQuery\r
2367          * @param String val Set the CSS property to the specified value.\r
2368          * @cat CSS\r
2369          */\r
2370 \r
2371         css: "width,height,top,left,position,float,overflow,color,background".split(","),\r
2372 \r
2373         /**\r
2374          * Reduce the set of matched elements to a single element.\r
2375          * The position of the element in the set of matched elements\r
2376          * starts at 0 and goes to length - 1.\r
2377          *\r
2378          * @example $("p").eq(1)\r
2379          * @before <p>This is just a test.</p><p>So is this</p>\r
2380          * @result [ <p>So is this</p> ]\r
2381          *\r
2382          * @name eq\r
2383          * @type jQuery\r
2384          * @param Number pos The index of the element that you wish to limit to.\r
2385          * @cat Core\r
2386          */\r
2387 \r
2388         /**\r
2389          * Reduce the set of matched elements to all elements before a given position.\r
2390          * The position of the element in the set of matched elements\r
2391          * starts at 0 and goes to length - 1.\r
2392          *\r
2393          * @example $("p").lt(1)\r
2394          * @before <p>This is just a test.</p><p>So is this</p>\r
2395          * @result [ <p>This is just a test.</p> ]\r
2396          *\r
2397          * @name lt\r
2398          * @type jQuery\r
2399          * @param Number pos Reduce the set to all elements below this position.\r
2400          * @cat Core\r
2401          */\r
2402 \r
2403         /**\r
2404          * Reduce the set of matched elements to all elements after a given position.\r
2405          * The position of the element in the set of matched elements\r
2406          * starts at 0 and goes to length - 1.\r
2407          *\r
2408          * @example $("p").gt(0)\r
2409          * @before <p>This is just a test.</p><p>So is this</p>\r
2410          * @result [ <p>So is this</p> ]\r
2411          *\r
2412          * @name gt\r
2413          * @type jQuery\r
2414          * @param Number pos Reduce the set to all elements after this position.\r
2415          * @cat Core\r
2416          */\r
2417 \r
2418         /**\r
2419          * Filter the set of elements to those that contain the specified text.\r
2420          *\r
2421          * @example $("p").contains("test")\r
2422          * @before <p>This is just a test.</p><p>So is this</p>\r
2423          * @result [ <p>This is just a test.</p> ]\r
2424          *\r
2425          * @name contains\r
2426          * @type jQuery\r
2427          * @param String str The string that will be contained within the text of an element.\r
2428          * @cat DOM/Traversing\r
2429          */\r
2430 \r
2431         filter: [ "eq", "lt", "gt", "contains" ],\r
2432 \r
2433         attr: {\r
2434                 /**\r
2435                  * Get the current value of the first matched element.\r
2436                  *\r
2437                  * @example $("input").val();\r
2438                  * @before <input type="text" value="some text"/>\r
2439                  * @result "some text"\r
2440                  *\r
2441                  * @name val\r
2442                  * @type String\r
2443                  * @cat DOM/Attributes\r
2444                  */\r
2445 \r
2446                 /**\r
2447                  * Set the value of every matched element.\r
2448                  *\r
2449                  * @example $("input").val("test");\r
2450                  * @before <input type="text" value="some text"/>\r
2451                  * @result <input type="text" value="test"/>\r
2452                  *\r
2453                  * @name val\r
2454                  * @type jQuery\r
2455                  * @param String val Set the property to the specified value.\r
2456                  * @cat DOM/Attributes\r
2457                  */\r
2458                 val: "value",\r
2459 \r
2460                 /**\r
2461                  * Get the html contents of the first matched element.\r
2462                  *\r
2463                  * @example $("div").html();\r
2464                  * @before <div><input/></div>\r
2465                  * @result <input/>\r
2466                  *\r
2467                  * @name html\r
2468                  * @type String\r
2469                  * @cat DOM/Attributes\r
2470                  */\r
2471 \r
2472                 /**\r
2473                  * Set the html contents of every matched element.\r
2474                  *\r
2475                  * @example $("div").html("<b>new stuff</b>");\r
2476                  * @before <div><input/></div>\r
2477                  * @result <div><b>new stuff</b></div>\r
2478                  *\r
2479                  * @name html\r
2480                  * @type jQuery\r
2481                  * @param String val Set the html contents to the specified value.\r
2482                  * @cat DOM/Attributes\r
2483                  */\r
2484                 html: "innerHTML",\r
2485 \r
2486                 /**\r
2487                  * Get the current id of the first matched element.\r
2488                  *\r
2489                  * @example $("input").id();\r
2490                  * @before <input type="text" id="test" value="some text"/>\r
2491                  * @result "test"\r
2492                  *\r
2493                  * @name id\r
2494                  * @type String\r
2495                  * @cat DOM/Attributes\r
2496                  */\r
2497 \r
2498                 /**\r
2499                  * Set the id of every matched element.\r
2500                  *\r
2501                  * @example $("input").id("newid");\r
2502                  * @before <input type="text" id="test" value="some text"/>\r
2503                  * @result <input type="text" id="newid" value="some text"/>\r
2504                  *\r
2505                  * @name id\r
2506                  * @type jQuery\r
2507                  * @param String val Set the property to the specified value.\r
2508                  * @cat DOM/Attributes\r
2509                  */\r
2510                 id: null,\r
2511 \r
2512                 /**\r
2513                  * Get the current title of the first matched element.\r
2514                  *\r
2515                  * @example $("img").title();\r
2516                  * @before <img src="test.jpg" title="my image"/>\r
2517                  * @result "my image"\r
2518                  *\r
2519                  * @name title\r
2520                  * @type String\r
2521                  * @cat DOM/Attributes\r
2522                  */\r
2523 \r
2524                 /**\r
2525                  * Set the title of every matched element.\r
2526                  *\r
2527                  * @example $("img").title("new title");\r
2528                  * @before <img src="test.jpg" title="my image"/>\r
2529                  * @result <img src="test.jpg" title="new image"/>\r
2530                  *\r
2531                  * @name title\r
2532                  * @type jQuery\r
2533                  * @param String val Set the property to the specified value.\r
2534                  * @cat DOM/Attributes\r
2535                  */\r
2536                 title: null,\r
2537 \r
2538                 /**\r
2539                  * Get the current name of the first matched element.\r
2540                  *\r
2541                  * @example $("input").name();\r
2542                  * @before <input type="text" name="username"/>\r
2543                  * @result "username"\r
2544                  *\r
2545                  * @name name\r
2546                  * @type String\r
2547                  * @cat DOM/Attributes\r
2548                  */\r
2549 \r
2550                 /**\r
2551                  * Set the name of every matched element.\r
2552                  *\r
2553                  * @example $("input").name("user");\r
2554                  * @before <input type="text" name="username"/>\r
2555                  * @result <input type="text" name="user"/>\r
2556                  *\r
2557                  * @name name\r
2558                  * @type jQuery\r
2559                  * @param String val Set the property to the specified value.\r
2560                  * @cat DOM/Attributes\r
2561                  */\r
2562                 name: null,\r
2563 \r
2564                 /**\r
2565                  * Get the current href of the first matched element.\r
2566                  *\r
2567                  * @example $("a").href();\r
2568                  * @before <a href="test.html">my link</a>\r
2569                  * @result "test.html"\r
2570                  *\r
2571                  * @name href\r
2572                  * @type String\r
2573                  * @cat DOM/Attributes\r
2574                  */\r
2575 \r
2576                 /**\r
2577                  * Set the href of every matched element.\r
2578                  *\r
2579                  * @example $("a").href("test2.html");\r
2580                  * @before <a href="test.html">my link</a>\r
2581                  * @result <a href="test2.html">my link</a>\r
2582                  *\r
2583                  * @name href\r
2584                  * @type jQuery\r
2585                  * @param String val Set the property to the specified value.\r
2586                  * @cat DOM/Attributes\r
2587                  */\r
2588                 href: null,\r
2589 \r
2590                 /**\r
2591                  * Get the current src of the first matched element.\r
2592                  *\r
2593                  * @example $("img").src();\r
2594                  * @before <img src="test.jpg" title="my image"/>\r
2595                  * @result "test.jpg"\r
2596                  *\r
2597                  * @name src\r
2598                  * @type String\r
2599                  * @cat DOM/Attributes\r
2600                  */\r
2601 \r
2602                 /**\r
2603                  * Set the src of every matched element.\r
2604                  *\r
2605                  * @example $("img").src("test2.jpg");\r
2606                  * @before <img src="test.jpg" title="my image"/>\r
2607                  * @result <img src="test2.jpg" title="my image"/>\r
2608                  *\r
2609                  * @name src\r
2610                  * @type jQuery\r
2611                  * @param String val Set the property to the specified value.\r
2612                  * @cat DOM/Attributes\r
2613                  */\r
2614                 src: null,\r
2615 \r
2616                 /**\r
2617                  * Get the current rel of the first matched element.\r
2618                  *\r
2619                  * @example $("a").rel();\r
2620                  * @before <a href="test.html" rel="nofollow">my link</a>\r
2621                  * @result "nofollow"\r
2622                  *\r
2623                  * @name rel\r
2624                  * @type String\r
2625                  * @cat DOM/Attributes\r
2626                  */\r
2627 \r
2628                 /**\r
2629                  * Set the rel of every matched element.\r
2630                  *\r
2631                  * @example $("a").rel("nofollow");\r
2632                  * @before <a href="test.html">my link</a>\r
2633                  * @result <a href="test.html" rel="nofollow">my link</a>\r
2634                  *\r
2635                  * @name rel\r
2636                  * @type jQuery\r
2637                  * @param String val Set the property to the specified value.\r
2638                  * @cat DOM/Attributes\r
2639                  */\r
2640                 rel: null\r
2641         },\r
2642 \r
2643         axis: {\r
2644                 /**\r
2645                  * Get a set of elements containing the unique parents of the matched\r
2646                  * set of elements.\r
2647                  *\r
2648                  * @example $("p").parent()\r
2649                  * @before <div><p>Hello</p><p>Hello</p></div>\r
2650                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]\r
2651                  *\r
2652                  * @name parent\r
2653                  * @type jQuery\r
2654                  * @cat DOM/Traversing\r
2655                  */\r
2656 \r
2657                 /**\r
2658                  * Get a set of elements containing the unique parents of the matched\r
2659                  * set of elements, and filtered by an expression.\r
2660                  *\r
2661                  * @example $("p").parent(".selected")\r
2662                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>\r
2663                  * @result [ <div class="selected"><p>Hello Again</p></div> ]\r
2664                  *\r
2665                  * @name parent\r
2666                  * @type jQuery\r
2667                  * @param String expr An expression to filter the parents with\r
2668                  * @cat DOM/Traversing\r
2669                  */\r
2670                 parent: "a.parentNode",\r
2671 \r
2672                 /**\r
2673                  * Get a set of elements containing the unique ancestors of the matched\r
2674                  * set of elements (except for the root element).\r
2675                  *\r
2676                  * @example $("span").ancestors()\r
2677                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>\r
2678                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]\r
2679                  *\r
2680                  * @name ancestors\r
2681                  * @type jQuery\r
2682                  * @cat DOM/Traversing\r
2683                  */\r
2684 \r
2685                 /**\r
2686                  * Get a set of elements containing the unique ancestors of the matched\r
2687                  * set of elements, and filtered by an expression.\r
2688                  *\r
2689                  * @example $("span").ancestors("p")\r
2690                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>\r
2691                  * @result [ <p><span>Hello</span></p> ]\r
2692                  *\r
2693                  * @name ancestors\r
2694                  * @type jQuery\r
2695                  * @param String expr An expression to filter the ancestors with\r
2696                  * @cat DOM/Traversing\r
2697                  */\r
2698                 ancestors: jQuery.parents,\r
2699 \r
2700                 /**\r
2701                  * Get a set of elements containing the unique ancestors of the matched\r
2702                  * set of elements (except for the root element).\r
2703                  *\r
2704                  * @example $("span").ancestors()\r
2705                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>\r
2706                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]\r
2707                  *\r
2708                  * @name parents\r
2709                  * @type jQuery\r
2710                  * @cat DOM/Traversing\r
2711                  */\r
2712 \r
2713                 /**\r
2714                  * Get a set of elements containing the unique ancestors of the matched\r
2715                  * set of elements, and filtered by an expression.\r
2716                  *\r
2717                  * @example $("span").ancestors("p")\r
2718                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>\r
2719                  * @result [ <p><span>Hello</span></p> ]\r
2720                  *\r
2721                  * @name parents\r
2722                  * @type jQuery\r
2723                  * @param String expr An expression to filter the ancestors with\r
2724                  * @cat DOM/Traversing\r
2725                  */\r
2726                 parents: jQuery.parents,\r
2727 \r
2728                 /**\r
2729                  * Get a set of elements containing the unique next siblings of each of the\r
2730                  * matched set of elements.\r
2731                  *\r
2732                  * It only returns the very next sibling, not all next siblings.\r
2733                  *\r
2734                  * @example $("p").next()\r
2735                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>\r
2736                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]\r
2737                  *\r
2738                  * @name next\r
2739                  * @type jQuery\r
2740                  * @cat DOM/Traversing\r
2741                  */\r
2742 \r
2743                 /**\r
2744                  * Get a set of elements containing the unique next siblings of each of the\r
2745                  * matched set of elements, and filtered by an expression.\r
2746                  *\r
2747                  * It only returns the very next sibling, not all next siblings.\r
2748                  *\r
2749                  * @example $("p").next(".selected")\r
2750                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>\r
2751                  * @result [ <p class="selected">Hello Again</p> ]\r
2752                  *\r
2753                  * @name next\r
2754                  * @type jQuery\r
2755                  * @param String expr An expression to filter the next Elements with\r
2756                  * @cat DOM/Traversing\r
2757                  */\r
2758                 next: "jQuery.sibling(a).next",\r
2759 \r
2760                 /**\r
2761                  * Get a set of elements containing the unique previous siblings of each of the\r
2762                  * matched set of elements.\r
2763                  *\r
2764                  * It only returns the immediately previous sibling, not all previous siblings.\r
2765                  *\r
2766                  * @example $("p").prev()\r
2767                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>\r
2768                  * @result [ <div><span>Hello Again</span></div> ]\r
2769                  *\r
2770                  * @name prev\r
2771                  * @type jQuery\r
2772                  * @cat DOM/Traversing\r
2773                  */\r
2774 \r
2775                 /**\r
2776                  * Get a set of elements containing the unique previous siblings of each of the\r
2777                  * matched set of elements, and filtered by an expression.\r
2778                  *\r
2779                  * It only returns the immediately previous sibling, not all previous siblings.\r
2780                  *\r
2781                  * @example $("p").prev(".selected")\r
2782                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>\r
2783                  * @result [ <div><span>Hello</span></div> ]\r
2784                  *\r
2785                  * @name prev\r
2786                  * @type jQuery\r
2787                  * @param String expr An expression to filter the previous Elements with\r
2788                  * @cat DOM/Traversing\r
2789                  */\r
2790                 prev: "jQuery.sibling(a).prev",\r
2791 \r
2792                 /**\r
2793                  * Get a set of elements containing all of the unique siblings of each of the\r
2794                  * matched set of elements.\r
2795                  *\r
2796                  * @example $("div").siblings()\r
2797                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>\r
2798                  * @result [ <p>Hello</p>, <p>And Again</p> ]\r
2799                  *\r
2800                  * @name siblings\r
2801                  * @type jQuery\r
2802                  * @cat DOM/Traversing\r
2803                  */\r
2804 \r
2805                 /**\r
2806                  * Get a set of elements containing all of the unique siblings of each of the\r
2807                  * matched set of elements, and filtered by an expression.\r
2808                  *\r
2809                  * @example $("div").siblings(".selected")\r
2810                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>\r
2811                  * @result [ <p class="selected">Hello Again</p> ]\r
2812                  *\r
2813                  * @name siblings\r
2814                  * @type jQuery\r
2815                  * @param String expr An expression to filter the sibling Elements with\r
2816                  * @cat DOM/Traversing\r
2817                  */\r
2818                 siblings: "jQuery.sibling(a, null, true)",\r
2819 \r
2820 \r
2821                 /**\r
2822                  * Get a set of elements containing all of the unique children of each of the\r
2823                  * matched set of elements.\r
2824                  *\r
2825                  * @example $("div").children()\r
2826                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>\r
2827                  * @result [ <span>Hello Again</span> ]\r
2828                  *\r
2829                  * @name children\r
2830                  * @type jQuery\r
2831                  * @cat DOM/Traversing\r
2832                  */\r
2833 \r
2834                 /**\r
2835                  * Get a set of elements containing all of the unique children of each of the\r
2836                  * matched set of elements, and filtered by an expression.\r
2837                  *\r
2838                  * @example $("div").children(".selected")\r
2839                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>\r
2840                  * @result [ <p class="selected">Hello Again</p> ]\r
2841                  *\r
2842                  * @name children\r
2843                  * @type jQuery\r
2844                  * @param String expr An expression to filter the child Elements with\r
2845                  * @cat DOM/Traversing\r
2846                  */\r
2847                 children: "jQuery.sibling(a.firstChild)"\r
2848         },\r
2849 \r
2850         each: {\r
2851 \r
2852                 /**\r
2853                  * Remove an attribute from each of the matched elements.\r
2854                  *\r
2855                  * @example $("input").removeAttr("disabled")\r
2856                  * @before <input disabled="disabled"/>\r
2857                  * @result <input/>\r
2858                  *\r
2859                  * @name removeAttr\r
2860                  * @type jQuery\r
2861                  * @param String name The name of the attribute to remove.\r
2862                  * @cat DOM\r
2863                  */\r
2864                 removeAttr: function( key ) {\r
2865                         jQuery.attr( this, key, "" );\r
2866                         this.removeAttribute( key );\r
2867                 },\r
2868 \r
2869                 /**\r
2870                  * Displays each of the set of matched elements if they are hidden.\r
2871                  *\r
2872                  * @example $("p").show()\r
2873                  * @before <p style="display: none">Hello</p>\r
2874                  * @result [ <p style="display: block">Hello</p> ]\r
2875                  *\r
2876                  * @name show\r
2877                  * @type jQuery\r
2878                  * @cat Effects\r
2879                  */\r
2880                 show: function(){\r
2881                         this.style.display = this.oldblock ? this.oldblock : "";\r
2882                         if ( jQuery.css(this,"display") == "none" )\r
2883                                 this.style.display = "block";\r
2884                 },\r
2885 \r
2886                 /**\r
2887                  * Hides each of the set of matched elements if they are shown.\r
2888                  *\r
2889                  * @example $("p").hide()\r
2890                  * @before <p>Hello</p>\r
2891                  * @result [ <p style="display: none">Hello</p> ]\r
2892                  *\r
2893                  * var pass = true, div = $("div");\r
2894                  * div.hide().each(function(){\r
2895                  *   if ( this.style.display != "none" ) pass = false;\r
2896                  * });\r
2897                  * ok( pass, "Hide" );\r
2898                  *\r
2899                  * @name hide\r
2900                  * @type jQuery\r
2901                  * @cat Effects\r
2902                  */\r
2903                 hide: function(){\r
2904                         this.oldblock = this.oldblock || jQuery.css(this,"display");\r
2905                         if ( this.oldblock == "none" )\r
2906                                 this.oldblock = "block";\r
2907                         this.style.display = "none";\r
2908                 },\r
2909 \r
2910                 /**\r
2911                  * Toggles each of the set of matched elements. If they are shown,\r
2912                  * toggle makes them hidden. If they are hidden, toggle\r
2913                  * makes them shown.\r
2914                  *\r
2915                  * @example $("p").toggle()\r
2916                  * @before <p>Hello</p><p style="display: none">Hello Again</p>\r
2917                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]\r
2918                  *\r
2919                  * @name toggle\r
2920                  * @type jQuery\r
2921                  * @cat Effects\r
2922                  */\r
2923                 toggle: function(){\r
2924                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );\r
2925                 },\r
2926 \r
2927                 /**\r
2928                  * Adds the specified class to each of the set of matched elements.\r
2929                  *\r
2930                  * @example $("p").addClass("selected")\r
2931                  * @before <p>Hello</p>\r
2932                  * @result [ <p class="selected">Hello</p> ]\r
2933                  *\r
2934                  * @name addClass\r
2935                  * @type jQuery\r
2936                  * @param String class A CSS class to add to the elements\r
2937                  * @cat DOM\r
2938                  */\r
2939                 addClass: function(c){\r
2940                         jQuery.className.add(this,c);\r
2941                 },\r
2942 \r
2943                 /**\r
2944                  * Removes the specified class from the set of matched elements.\r
2945                  *\r
2946                  * @example $("p").removeClass("selected")\r
2947                  * @before <p class="selected">Hello</p>\r
2948                  * @result [ <p>Hello</p> ]\r
2949                  *\r
2950                  * @name removeClass\r
2951                  * @type jQuery\r
2952                  * @param String class A CSS class to remove from the elements\r
2953                  * @cat DOM\r
2954                  */\r
2955                 removeClass: function(c){\r
2956                         jQuery.className.remove(this,c);\r
2957                 },\r
2958 \r
2959                 /**\r
2960                  * Adds the specified class if it is not present, removes it if it is\r
2961                  * present.\r
2962                  *\r
2963                  * @example $("p").toggleClass("selected")\r
2964                  * @before <p>Hello</p><p class="selected">Hello Again</p>\r
2965                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]\r
2966                  *\r
2967                  * @name toggleClass\r
2968                  * @type jQuery\r
2969                  * @param String class A CSS class with which to toggle the elements\r
2970                  * @cat DOM\r
2971                  */\r
2972                 toggleClass: function( c ){\r
2973                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);\r
2974                 },\r
2975 \r
2976                 /**\r
2977                  * Removes all matched elements from the DOM. This does NOT remove them from the\r
2978                  * jQuery object, allowing you to use the matched elements further.\r
2979                  *\r
2980                  * @example $("p").remove();\r
2981                  * @before <p>Hello</p> how are <p>you?</p>\r
2982                  * @result how are\r
2983                  *\r
2984                  * @name remove\r
2985                  * @type jQuery\r
2986                  * @cat DOM/Manipulation\r
2987                  */\r
2988 \r
2989                 /**\r
2990                  * Removes only elements (out of the list of matched elements) that match\r
2991                  * the specified jQuery expression. This does NOT remove them from the\r
2992                  * jQuery object, allowing you to use the matched elements further.\r
2993                  *\r
2994                  * @example $("p").remove(".hello");\r
2995                  * @before <p class="hello">Hello</p> how are <p>you?</p>\r
2996                  * @result how are <p>you?</p>\r
2997                  *\r
2998                  * @name remove\r
2999                  * @type jQuery\r
3000                  * @param String expr A jQuery expression to filter elements by.\r
3001                  * @cat DOM/Manipulation\r
3002                  */\r
3003                 remove: function(a){\r
3004                         if ( !a || jQuery.filter( a, [this] ).r )\r
3005                                 this.parentNode.removeChild( this );\r
3006                 },\r
3007 \r
3008                 /**\r
3009                  * Removes all child nodes from the set of matched elements.\r
3010                  *\r
3011                  * @example $("p").empty()\r
3012                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>\r
3013                  * @result [ <p></p> ]\r
3014                  *\r
3015                  * @name empty\r
3016                  * @type jQuery\r
3017                  * @cat DOM/Manipulation\r
3018                  */\r
3019                 empty: function(){\r
3020                         while ( this.firstChild )\r
3021                                 this.removeChild( this.firstChild );\r
3022                 },\r
3023 \r
3024                 /**\r
3025                  * Binds a handler to a particular event (like click) for each matched element.\r
3026                  * The event handler is passed an event object that you can use to prevent\r
3027                  * default behaviour. To stop both default action and event bubbling, your handler\r
3028                  * has to return false.\r
3029                  *\r
3030                  * @example $("p").bind( "click", function() {\r
3031                  *   alert( $(this).text() );\r
3032                  * } )\r
3033                  * @before <p>Hello</p>\r
3034                  * @result alert("Hello")\r
3035                  *\r
3036                  * @example $("form").bind( "submit", function() { return false; } )\r
3037                  * @desc Cancel a default action and prevent it from bubbling by returning false\r
3038                  * from your function.\r
3039                  *\r
3040                  * @example $("form").bind( "submit", function(event) {\r
3041                  *   event.preventDefault();\r
3042                  * } );\r
3043                  * @desc Cancel only the default action by using the preventDefault method.\r
3044                  *\r
3045                  *\r
3046                  * @example $("form").bind( "submit", function(event) {\r
3047                  *   event.stopPropagation();\r
3048                  * } )\r
3049                  * @desc Stop only an event from bubbling by using the stopPropagation method.\r
3050                  *\r
3051                  * @name bind\r
3052                  * @type jQuery\r
3053                  * @param String type An event type\r
3054                  * @param Function fn A function to bind to the event on each of the set of matched elements\r
3055                  * @cat Events\r
3056                  */\r
3057                 bind: function( type, fn ) {\r
3058                         jQuery.event.add( this, type, fn );\r
3059                 },\r
3060 \r
3061                 /**\r
3062                  * The opposite of bind, removes a bound event from each of the matched\r
3063                  * elements. You must pass the identical function that was used in the original\r
3064                  * bind method.\r
3065                  *\r
3066                  * @example $("p").unbind( "click", function() { alert("Hello"); } )\r
3067                  * @before <p onclick="alert('Hello');">Hello</p>\r
3068                  * @result [ <p>Hello</p> ]\r
3069                  *\r
3070                  * @name unbind\r
3071                  * @type jQuery\r
3072                  * @param String type An event type\r
3073                  * @param Function fn A function to unbind from the event on each of the set of matched elements\r
3074                  * @cat Events\r
3075                  */\r
3076 \r
3077                 /**\r
3078                  * Removes all bound events of a particular type from each of the matched\r
3079                  * elements.\r
3080                  *\r
3081                  * @example $("p").unbind( "click" )\r
3082                  * @before <p onclick="alert('Hello');">Hello</p>\r
3083                  * @result [ <p>Hello</p> ]\r
3084                  *\r
3085                  * @name unbind\r
3086                  * @type jQuery\r
3087                  * @param String type An event type\r
3088                  * @cat Events\r
3089                  */\r
3090 \r
3091                 /**\r
3092                  * Removes all bound events from each of the matched elements.\r
3093                  *\r
3094                  * @example $("p").unbind()\r
3095                  * @before <p onclick="alert('Hello');">Hello</p>\r
3096                  * @result [ <p>Hello</p> ]\r
3097                  *\r
3098                  * @name unbind\r
3099                  * @type jQuery\r
3100                  * @cat Events\r
3101                  */\r
3102                 unbind: function( type, fn ) {\r
3103                         jQuery.event.remove( this, type, fn );\r
3104                 },\r
3105 \r
3106                 /**\r
3107                  * Trigger a type of event on every matched element.\r
3108                  *\r
3109                  * @example $("p").trigger("click")\r
3110                  * @before <p click="alert('hello')">Hello</p>\r
3111                  * @result alert('hello')\r
3112                  *\r
3113                  * @name trigger\r
3114                  * @type jQuery\r
3115                  * @param String type An event type to trigger.\r
3116                  * @cat Events\r
3117                  */\r
3118                 trigger: function( type, data ) {\r
3119                         jQuery.event.trigger( type, data, this );\r
3120                 }\r
3121         }\r
3122 };\r
3123 \r
3124 jQuery.init();\r