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