// If the context is global, return a new object
if ( window == this )
return new jQuery(a,c);
-
- // Make sure that a selection was provided
- a = a || document;
-
- // HANDLE: $(function)
- // Shortcut for document ready
- if ( jQuery.isFunction(a) )
- return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
- // Handle HTML strings
- if ( typeof a == "string" ) {
- // HANDLE: $(html) -> $(array)
- var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
- if ( m )
- a = jQuery.clean( [ m[1] ] );
-
- // HANDLE: $(expr)
- else
- return new jQuery( c ).find( a );
- }
-
- return this.setArray(
- // HANDLE: $(array)
- a.constructor == Array && a ||
-
- // HANDLE: $(arraylike)
- // Watch for when an array-like object is passed as the selector
- (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
-
- // HANDLE: $(*)
- [ a ] );
+ return this.init(a,c);
};
// Map over the $ in case of overwrite
jQuery.fn = jQuery.prototype = {
/**
+ * Initialize a new jQuery object
+ *
+ * @private
+ * @name init
+ * @param String|Function|Element|Array<Element>|jQuery a selector
+ * @param jQuery|Element|Array<Element> c context
+ * @cat Core
+ */
+ init: function(a,c) {
+ // Make sure that a selection was provided
+ a = a || document;
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ if ( jQuery.isFunction(a) )
+ return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
+
+ // Handle HTML strings
+ if ( typeof a == "string" ) {
+ // HANDLE: $(html) -> $(array)
+ var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
+ if ( m )
+ a = jQuery.clean( [ m[1] ] );
+
+ // HANDLE: $(expr)
+ else
+ return new jQuery( c ).find( a );
+ }
+
+ return this.setArray(
+ // HANDLE: $(array)
+ a.constructor == Array && a ||
+
+ // HANDLE: $(arraylike)
+ // Watch for when an array-like object is passed as the selector
+ (a.jquery || a.length && a != window && (!a.nodeType || (jQuery.browser.msie && a.elements)) && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
+
+ // HANDLE: $(*)
+ [ a ] );
+ },
+
+ /**
* The current version of jQuery.
*
* @private
*/
clone: function(deep) {
return this.pushStack( jQuery.map( this, function(a){
- var a = a.cloneNode( deep != undefined ? deep : true );
+ a = a.cloneNode( deep != undefined ? deep : true );
a.$events = null; // drop $events expando to avoid firing incorrect events
return a;
}) );
*/
jQuery.extend = jQuery.fn.extend = function() {
// copy reference to target object
- var target = arguments[0],
- a = 1;
+ var target = arguments[0], a = 1;
// extend jQuery itself if only one argument is passed
if ( arguments.length == 1 ) {
a = 0;
}
var prop;
- while (prop = arguments[a++])
+ while ( (prop = arguments[a++]) != null )
// Extend the base object
for ( var i in prop ) target[i] = prop[i];
// internal only, use removeClass("class")
remove: function( elem, c ){
- elem.className = c ?
+ elem.className = c != undefined ?
jQuery.grep( elem.className.split(/\s+/), function(cur){
return !jQuery.className.has( c, cur );
}).join(" ") : "";
});
jQuery.swap( e, old, function() {
- if (jQuery.css(e,"display") != "none") {
+ if ( jQuery(e).is(':visible') ) {
oHeight = e.offsetHeight;
oWidth = e.offsetWidth;
} else {
visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
}).appendTo(e.parentNode)[0];
- var parPos = jQuery.css(e.parentNode,"position");
- if ( parPos == "" || parPos == "static" )
+ var parPos = jQuery.css(e.parentNode,"position") || "static";
+ if ( parPos == "static" )
e.parentNode.style.position = "relative";
oHeight = e.clientHeight;
oWidth = e.clientWidth;
- if ( parPos == "" || parPos == "static" )
+ if ( parPos == "static" )
e.parentNode.style.position = "static";
e.parentNode.removeChild(e);
// Convert html string into DOM nodes
if ( typeof arg == "string" ) {
// Trim whitespace, otherwise indexOf won't work as expected
- var s = jQuery.trim(arg), div = doc.createElement("div"), tb = [];
+ var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];
var wrap =
// option or optgroup
!s.indexOf("<opt") &&
[1, "<select>", "</select>"] ||
- (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
+ !s.indexOf("<leg") &&
+ [1, "<fieldset>", "</fieldset>"] ||
+
+ (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot") || !s.indexOf("<colg")) &&
[1, "<table>", "</table>"] ||
!s.indexOf("<tr") &&
(!s.indexOf("<td") || !s.indexOf("<th")) &&
[3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
+ !s.indexOf("<col") &&
+ [2, "<table><colgroup>", "</colgroup></table>"] ||
+
[0,"",""];
// Go to html and back, then peel off extra wrappers
arg = jQuery.makeArray( div.childNodes );
}
- if ( arg.length === 0 && !jQuery.nodeName(arg, "form") )
+ if ( 0 === arg.length && !jQuery(arg).is("form, select") )
return;
-
- if ( arg[0] == undefined || jQuery.nodeName(arg, "form") )
+
+ if ( arg[0] == undefined || jQuery.nodeName(arg, "form") || arg.options )
r.push( arg );
else
r = jQuery.merge( r, arg );
disabled: "disabled",
checked: "checked",
readonly: "readOnly",
- selected: "selected"
+ selected: "selected",
+ maxlength: "maxLength"
};
// IE actually uses filters for opacity ... elem is actually elem.style
* @cat JavaScript
*/
merge: function(first, second) {
- for ( var i = 0, sl = second.length; i < sl; i++ )
+ // We have to loop this way because IE & Opera overwrite the length
+ // expando of getElementsByTagName
+ for ( var i = 0; second[i]; i++ )
first.push(second[i]);
-
return first;
},
var r = [], num = jQuery.mergeNum++;
for ( var i = 0, fl = first.length; i < fl; i++ )
- if ( first[i].mergeNum != num ) {
+ if ( num != first[i].mergeNum ) {
first[i].mergeNum = num;
r.push(first[i]);
}
// Figure out what browser is being used
jQuery.browser = {
+ version: b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1],
safari: /webkit/.test(b),
opera: /opera/.test(b),
msie: /msie/.test(b) && !/opera/.test(b),