/*
* jQuery - New Wave Javascript
*
* Copyright (c) 2006 John Resig (jquery.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* $Date: 2006-09-07 10:12:12 +0200 (Do, 07 Sep 2006) $
* $Rev: 276 $
*/
// Global undefined variable
window.undefined = window.undefined;
/**
* Create a new jQuery Object
*
* @test ok( Array.prototype.push, "Array.push()" );
* @test ok( Function.prototype.apply, "Function.apply()" );
* @test ok( document.getElementById, "getElementById" );
* @test ok( document.getElementsByTagName, "getElementsByTagName" );
* @test ok( RegExp, "RegExp" );
* @test ok( jQuery, "jQuery" );
* @test ok( $, "$()" );
*
* @constructor
* @private
* @name jQuery
* @cat Core
*/
function jQuery(a,c) {
// Shortcut for document ready (because $(document).each() is silly)
if ( a && a.constructor == Function && jQuery.fn.ready )
return jQuery(document).ready(a);
// Make sure that a selection was provided
a = a || jQuery.context || document;
// Watch for when a jQuery object is passed as the selector
if ( a.jquery )
return jQuery( jQuery.merge( a, [] ) );
// Watch for when a jQuery object is passed at the context
if ( c && c.jquery )
return jQuery( c ).find(a);
// If the context is global, return a new object
if ( window == this )
return new jQuery(a,c);
// Handle HTML strings
var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
if ( m ) a = jQuery.clean( [ m[1] ] );
// Watch for when an array is passed in
this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ?
// Assume that it is an array of DOM Elements
jQuery.merge( a, [] ) :
// Find the matching elements and save them for later
jQuery.find( a, c ) );
// See if an extra function was provided
var fn = arguments[ arguments.length - 1 ];
// If so, execute it in context
if ( fn && fn.constructor == Function )
this.each(fn);
}
// Map over the $ in case of overwrite
if ( typeof $ != "undefined" )
jQuery._$ = $;
/**
* This function accepts a string containing a CSS selector,
* basic XPath, or raw HTML, which is then used to match a set of elements.
* The HTML string is different from the traditional selectors in that
* it creates the DOM elements representing that HTML string, on the fly,
* to be (assumedly) inserted into the document later.
*
* The core functionality of jQuery centers around this function.
* Everything in jQuery is based upon this, or uses this in some way.
* The most basic use of this function is to pass in an expression
* (usually consisting of CSS or XPath), which then finds all matching
* elements and remembers them for later use.
*
* By default, $() looks for DOM elements within the context of the
* current HTML document.
*
* @example $("div > p")
* @desc This finds all p elements that are children of a div element.
* @before <p>one</p> <div><p>two</p></div> <p>three</p>
* @result [ <p>two</p> ]
*
* @example $("<div><p>Hello</p></div>").appendTo("#body")
* @desc Creates a div element (and all of its contents) dynamically, and appends it to the element with the ID of body.
*
* @name $
* @param String expr An expression to search with, or a string of HTML to create on the fly.
* @cat Core
* @type jQuery
*/
/**
* This function accepts a string containing a CSS selector, or
* basic XPath, which is then used to match a set of elements with the
* context of the specified DOM element, or document
*
* @example $("div", xml.responseXML)
* @desc This finds all div elements within the specified XML document.
*
* @name $
* @param String expr An expression to search with.
* @param Element context A DOM Element, or Document, representing the base context.
* @cat Core
* @type jQuery
*/
/**
* Wrap jQuery functionality around a specific DOM Element.
* This function also accepts XML Documents and Window objects
* as valid arguments (even though they are not DOM Elements).
*
* @example $(document).find("div > p")
* @before <p>one</p> <div><p>two</p></div> <p>three</p>
* @result [ <p>two</p> ]
*
* @example $(document.body).background( "black" );
* @desc Sets the background color of the page to black.
*
* @name $
* @param Element elem A DOM element to be encapsulated by a jQuery object.
* @cat Core
* @type jQuery
*/
/**
* Wrap jQuery functionality around a set of DOM Elements.
*
* @example $( myForm.elements ).hide()
* @desc Hides all the input elements within a form
*
* @name $
* @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
* @cat Core
* @type jQuery
*/
/**
* A shorthand for $(document).ready(), allowing you to bind a function
* to be executed when the DOM document has finished loading. This function
* behaves just like $(document).ready(), in that it should be used to wrap
* all of the other $() operations on your page. While this function is,
* technically, chainable - there really isn't much use for chaining against it.
*
* @example $(function(){
* // Document is ready
* });
* @desc Executes the function when the DOM is ready to be used.
*
* @name $
* @param Function fn The function to execute when the DOM is ready.
* @cat Core
* @type jQuery
*/
/**
* A means of creating a cloned copy of a jQuery object. This function
* copies the set of matched elements from one jQuery object and creates
* another, new, jQuery object containing the same elements.
*
* @example var div = $("div");
* $( div ).find("p");
* @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).
*
* @name $
* @param jQuery obj The jQuery object to be cloned.
* @cat Core
* @type jQuery
*/
// Map the jQuery namespace to the '$' one
var $ = jQuery;
jQuery.fn = jQuery.prototype = {
/**
* The current SVN version of jQuery.
*
* @private
* @property
* @name jquery
* @type String
* @cat Core
*/
jquery: "$Rev: 276 $",
/**
* The number of elements currently matched.
*
* @example $("img").length;
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result 2
*
* @test cmpOK( $("div").length, "==", 2, "Get Number of Elements Found" );
*
* @property
* @name length
* @type Number
* @cat Core
*/
/**
* The number of elements currently matched.
*
* @example $("img").size();
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result 2
*
* @test cmpOK( $("div").size(), "==", 2, "Get Number of Elements Found" );
*
* @name size
* @type Number
* @cat Core
*/
size: function() {
return this.length;
},
/**
* Access all matched elements. This serves as a backwards-compatible
* way of accessing all matched elements (other than the jQuery object
* itself, which is, in fact, an array of elements).
*
* @example $("img").get();
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
*
* @test isSet( $("div").get(), q("main","foo"), "Get All Elements" );
*
* @name get
* @type Array<Element>
* @cat Core
*/
/**
* Access a single matched element. num is used to access the
* Nth element matched.
*
* @example $("img").get(1);
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result [ <img src="test1.jpg"/> ]
*
* @test cmpOK( $("div").get(0), "==", document.getElementById("main"), "Get A Single Element" );
*
* @name get
* @type Element
* @param Number num Access the element in the Nth position.
* @cat Core
*/
/**
* Set the jQuery object to an array of elements.
*
* @example $("img").get([ document.body ]);
* @result $("img").get() == [ document.body ]
*
* @private
* @name get
* @type jQuery
* @param Elements elems An array of elements
* @cat Core
*/
get: function( num ) {
// Watch for when an array (of elements) is p