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