Upgrade to jQuery 1.6.1 to pick up :checked fixes.

This commit is contained in:
Kin Blas 2011-05-13 15:27:09 -07:00
parent 0d7754fe4c
commit 7df38d9abf

291
js/jquery.js vendored
View file

@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v1.6
* jQuery JavaScript Library v1.6.1
* http://jquery.com/
*
* Copyright 2011, John Resig
@ -11,7 +11,7 @@
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Mon May 2 13:50:00 2011 -0400
* Date: Thu May 12 15:04:36 2011 -0400
*/
(function( window, undefined ) {
@ -204,7 +204,7 @@ jQuery.fn = jQuery.prototype = {
selector: "",
// The current version of jQuery being used
jquery: "1.6",
jquery: "1.6.1",
// The default length of a jQuery object is 0
length: 0,
@ -1055,7 +1055,7 @@ jQuery.extend({
if ( jQuery.isFunction( fn ) ) {
deferred[ handler ](function() {
returned = fn.apply( this, arguments );
if ( jQuery.isFunction( returned.promise ) ) {
if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise().then( newDefer.resolve, newDefer.reject );
} else {
newDefer[ action ]( returned );
@ -1137,6 +1137,7 @@ jQuery.extend({
jQuery.support = (function() {
var div = document.createElement( "div" ),
documentElement = document.documentElement,
all,
a,
select,
@ -1284,7 +1285,7 @@ jQuery.support = (function() {
body.style[ i ] = bodyStyle[ i ];
}
body.appendChild( div );
document.documentElement.appendChild( body );
documentElement.insertBefore( body, documentElement.firstChild );
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
@ -1339,12 +1340,12 @@ jQuery.support = (function() {
marginDiv.style.marginRight = "0";
div.appendChild( marginDiv );
support.reliableMarginRight =
( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
}
// Remove the body element we added
body.innerHTML = "";
document.documentElement.removeChild( body );
documentElement.removeChild( body );
// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
@ -1475,7 +1476,7 @@ jQuery.extend({
}
if ( data !== undefined ) {
thisCache[ name ] = data;
thisCache[ jQuery.camelCase( name ) ] = data;
}
// TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
@ -1485,7 +1486,7 @@ jQuery.extend({
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
}
return getByName ? thisCache[ name ] : thisCache;
return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
},
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
@ -1661,7 +1662,7 @@ function dataAttr( elem, key, data ) {
// If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) {
name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
data = elem.getAttribute( name );
@ -1850,7 +1851,8 @@ jQuery.fn.extend({
count = 1,
deferDataKey = type + "defer",
queueDataKey = type + "queue",
markDataKey = type + "mark";
markDataKey = type + "mark",
tmp;
function resolve() {
if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] );
@ -1879,9 +1881,9 @@ var rclass = /[\n\t\r]/g,
rtype = /^(?:button|input)$/i,
rfocusable = /^(?:button|input|object|select|textarea)$/i,
rclickable = /^a(?:rea)?$/i,
rspecial = /^(?:data-|aria-)/,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
rinvalidChar = /\:/,
formHook;
formHook, boolHook;
jQuery.fn.extend({
attr: function( name, value ) {
@ -1899,6 +1901,7 @@ jQuery.fn.extend({
},
removeProp: function( name ) {
name = jQuery.propFix[ name ] || name;
return this.each(function() {
// try/catch handles cases where IE balks (such as removing a property on window)
try {
@ -2072,7 +2075,7 @@ jQuery.fn.extend({
hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
// If set returns undefined, fall back to normal setting
if ( !hooks || ("set" in hooks && hooks.set( this, val, "value" ) === undefined) ) {
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
});
@ -2091,7 +2094,8 @@ jQuery.extend({
},
select: {
get: function( elem ) {
var index = elem.selectedIndex,
var value,
index = elem.selectedIndex,
values = [],
options = elem.options,
one = elem.type === "select-one";
@ -2158,8 +2162,7 @@ jQuery.extend({
attrFix: {
// Always normalize to ensure hook usage
tabindex: "tabIndex",
readonly: "readOnly"
tabindex: "tabIndex"
},
attr: function( elem, name, value, pass ) {
@ -2173,23 +2176,36 @@ jQuery.extend({
if ( pass && name in jQuery.attrFn ) {
return jQuery( elem )[ name ]( value );
}
// Fallback to prop when attributes are not supported
if ( !("getAttribute" in elem) ) {
return jQuery.prop( elem, name, value );
}
var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Normalize the name if needed
name = notxml && jQuery.attrFix[ name ] || name;
// Get the appropriate hook, or the formHook
// if getSetAttribute is not supported and we have form objects in IE6/7
hooks = jQuery.attrHooks[ name ] ||
( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ?
formHook :
undefined );
hooks = jQuery.attrHooks[ name ];
if ( !hooks ) {
// Use boolHook for boolean attributes
if ( rboolean.test( name ) &&
(typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase()) ) {
hooks = boolHook;
// Use formHook for forms and if the name contains certain characters
} else if ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
hooks = formHook;
}
}
if ( value !== undefined ) {
if ( value === null || (value === false && !rspecial.test( name )) ) {
if ( value === null ) {
jQuery.removeAttr( elem, name );
return undefined;
@ -2197,34 +2213,26 @@ jQuery.extend({
return ret;
} else {
// Set boolean attributes to the same name
if ( value === true && !rspecial.test( name ) ) {
value = name;
}
elem.setAttribute( name, "" + value );
return value;
}
} else if ( hooks && "get" in hooks && notxml ) {
return hooks.get( elem, name );
} else {
if ( hooks && "get" in hooks && notxml ) {
return hooks.get( elem, name );
ret = elem.getAttribute( name );
} else {
ret = elem.getAttribute( name );
// Non-existent attributes return null, we normalize to undefined
return ret === null ?
undefined :
ret;
}
// Non-existent attributes return null, we normalize to undefined
return ret === null ?
undefined :
ret;
}
},
removeAttr: function( elem, name ) {
var propName;
if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name;
@ -2235,6 +2243,11 @@ jQuery.extend({
jQuery.attr( elem, name, "" );
elem.removeAttributeNode( elem.getAttributeNode( name ) );
}
// Set corresponding property to false for boolean attributes
if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
elem[ propName ] = false;
}
}
},
@ -2248,7 +2261,7 @@ jQuery.extend({
// Setting the type on a radio button after the value resets the value in IE6-9
// Reset value to it's default in case type is set after value
// This is for element creation
var val = elem.getAttribute("value");
var val = elem.value;
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
@ -2271,37 +2284,50 @@ jQuery.extend({
}
}
},
propFix: {},
propFix: {
tabindex: "tabIndex",
readonly: "readOnly",
"for": "htmlFor",
"class": "className",
maxlength: "maxLength",
cellspacing: "cellSpacing",
cellpadding: "cellPadding",
rowspan: "rowSpan",
colspan: "colSpan",
usemap: "useMap",
frameborder: "frameBorder",
contenteditable: "contentEditable"
},
prop: function( elem, name, value ) {
var nType = elem.nodeType;
// don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined;
}
var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Try to normalize/fix the name
name = notxml && jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
if ( value !== undefined ) {
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret;
} else {
return (elem[ name ] = value);
}
} else {
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) {
return ret;
} else {
return elem[ name ];
}
@ -2311,30 +2337,65 @@ jQuery.extend({
propHooks: {}
});
// Hook for boolean attributes
boolHook = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
return elem[ jQuery.propFix[ name ] || name ] ?
name.toLowerCase() :
undefined;
},
set: function( elem, value, name ) {
var propName;
if ( value === false ) {
// Remove boolean attributes when set to false
jQuery.removeAttr( elem, name );
} else {
// value is true since we know at this point it's type boolean and not false
// Set boolean attributes to the same name and set the DOM property
propName = jQuery.propFix[ name ] || name;
if ( propName in elem ) {
// Only set the IDL specifically if it already exists on the element
elem[ propName ] = value;
}
elem.setAttribute( name, name.toLowerCase() );
}
return name;
}
};
// Use the value property for back compat
// Use the formHook for button elements in IE6/7 (#1954)
jQuery.attrHooks.value = {
get: function( elem, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.get( elem, name );
}
return elem.value;
},
set: function( elem, value, name ) {
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
return formHook.set( elem, value, name );
}
// Does not return so that setAttribute is also used
elem.value = value;
}
};
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !jQuery.support.getSetAttribute ) {
jQuery.attrFix = jQuery.extend( jQuery.attrFix, {
"for": "htmlFor",
"class": "className",
maxlength: "maxLength",
cellspacing: "cellSpacing",
cellpadding: "cellPadding",
rowspan: "rowSpan",
colspan: "colSpan",
usemap: "useMap",
frameborder: "frameBorder"
});
// propFix is more comprehensive and contains all fixes
jQuery.attrFix = jQuery.propFix;
// Use this for any attribute on a form in IE6/7
formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = {
formHook = jQuery.attrHooks.name = jQuery.valHooks.button = {
get: function( elem, name ) {
var ret;
if ( name === "value" && !jQuery.nodeName( elem, "button" ) ) {
return elem.getAttribute( name );
}
ret = elem.getAttributeNode( name );
// Return undefined if not specified instead of empty string
return ret && ret.specified ?
// Return undefined if nodeValue is empty string
return ret && ret.nodeValue !== "" ?
ret.nodeValue :
undefined;
},
@ -3086,6 +3147,9 @@ var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
// set the correct event type
event.type = event.data;
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
@ -3095,15 +3159,13 @@ var withinElement = function( event ) {
if ( parent && parent !== document && !parent.parentNode ) {
return;
}
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
}
if ( parent !== this ) {
// set the correct event type
event.type = event.data;
// handle event if we actually just moused on to a non sub-element
jQuery.event.handle.apply( this, arguments );
}
@ -4291,7 +4353,8 @@ var Expr = Sizzle.selectors = {
},
reset: function( elem ) {
return elem.nodeName.toLowerCase() === "input" && "reset" === elem.type;
var name = elem.nodeName.toLowerCase();
return (name === "input" || name === "button") && "reset" === elem.type;
},
button: function( elem ) {
@ -4557,6 +4620,16 @@ if ( document.documentElement.compareDocumentPosition ) {
} else {
sortOrder = function( a, b ) {
// The nodes are identical, we can exit early
if ( a === b ) {
hasDuplicate = true;
return 0;
// Fallback to using sourceIndex (in IE) if it's available on both nodes
} else if ( a.sourceIndex && b.sourceIndex ) {
return a.sourceIndex - b.sourceIndex;
}
var al, bl,
ap = [],
bp = [],
@ -4564,13 +4637,8 @@ if ( document.documentElement.compareDocumentPosition ) {
bup = b.parentNode,
cur = aup;
// The nodes are identical, we can exit early
if ( a === b ) {
hasDuplicate = true;
return 0;
// If the nodes are siblings (or identical) we can do a quick check
} else if ( aup === bup ) {
if ( aup === bup ) {
return siblingCheck( a, b );
// If no parents were found then the nodes are disconnected
@ -5394,6 +5462,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /\/(java|ecma)script/i,
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ],
@ -5414,6 +5483,7 @@ if ( !jQuery.support.htmlSerialize ) {
wrapMap._default = [ 1, "div<div>", "</div>" ];
}
jQuery.fn.extend({
text: function( text ) {
if ( jQuery.isFunction(text) ) {
@ -5884,7 +5954,7 @@ jQuery.each({
function getAll( elem ) {
if ( "getElementsByTagName" in elem ) {
return elem.getElementsByTagName( "*" );
} else if ( "querySelectorAll" in elem ) {
return elem.querySelectorAll( "*" );
@ -5966,7 +6036,7 @@ jQuery.extend({
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
}
var ret = [];
var ret = [], j;
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
if ( typeof elem === "number" ) {
@ -6012,7 +6082,7 @@ jQuery.extend({
div.childNodes :
[];
for ( var j = tbody.length - 1; j >= 0 ; --j ) {
for ( j = tbody.length - 1; j >= 0 ; --j ) {
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
tbody[ j ].parentNode.removeChild( tbody[ j ] );
}
@ -6033,8 +6103,8 @@ jQuery.extend({
var len;
if ( !jQuery.support.appendChecked ) {
if ( elem[0] && typeof (len = elem.length) === "number" ) {
for ( i = 0; i < len; i++ ) {
findInputs( elem[i] );
for ( j = 0; j < len; j++ ) {
findInputs( elem[j] );
}
} else {
findInputs( elem );
@ -6122,7 +6192,7 @@ function evalScript( i, elem ) {
dataType: "script"
});
} else {
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
}
if ( elem.parentNode ) {
@ -7999,6 +8069,9 @@ jQuery.fn.extend({
return this.each( optall.complete, [ false ] );
}
// Do not change referenced properties as per-property easing will be lost
prop = jQuery.extend( {}, prop );
return this[ optall.queue === false ? "each" : "queue" ](function() {
// XXX 'this' does not always have a nodeName when running the
// test suite
@ -8007,7 +8080,7 @@ jQuery.fn.extend({
jQuery._mark( this );
}
var opt = jQuery.extend({}, optall),
var opt = jQuery.extend( {}, optall ),
isElement = this.nodeType === 1,
hidden = isElement && jQuery(this).is(":hidden"),
name, val, p,
@ -8026,10 +8099,18 @@ jQuery.fn.extend({
delete prop[ p ];
}
val = prop[name];
val = prop[ name ];
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
if ( jQuery.isArray( val ) ) {
opt.animatedProperties[ name ] = val[ 1 ];
val = prop[ name ] = val[ 0 ];
} else {
opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
}
if ( val === "hide" && hidden || val === "show" && !hidden ) {
return opt.complete.call(this);
return opt.complete.call( this );
}
if ( isElement && ( name === "height" || name === "width" ) ) {
@ -8048,7 +8129,7 @@ jQuery.fn.extend({
this.style.display = "inline-block";
} else {
display = defaultDisplay(this.nodeName);
display = defaultDisplay( this.nodeName );
// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
@ -8062,11 +8143,6 @@ jQuery.fn.extend({
}
}
}
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
opt.animatedProperties[name] = jQuery.isArray( val ) ?
val[1]:
opt.specialEasing && opt.specialEasing[name] || opt.easing || 'swing';
}
if ( opt.overflow != null ) {
@ -8075,19 +8151,18 @@ jQuery.fn.extend({
for ( p in prop ) {
e = new jQuery.fx( this, opt, p );
val = prop[p];
val = prop[ p ];
if ( rfxtypes.test(val) ) {
e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
} else {
parts = rfxnum.exec(val);
parts = rfxnum.exec( val );
start = e.cur();
if ( parts ) {
end = parseFloat( parts[2] );
unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
// We need to compute starting value
if ( unit !== "px" ) {
@ -8098,7 +8173,7 @@ jQuery.fn.extend({
// If a +=/-= token was provided, we're doing a relative animation
if ( parts[1] ) {
end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
}
e.custom( start, end, unit );
@ -8126,7 +8201,6 @@ jQuery.fn.extend({
if ( !gotoEnd ) {
jQuery._unmark( true, this );
}
// go in reverse order so anything added to the queue during the loop is ignored
while ( i-- ) {
if ( timers[i].elem === this ) {
if (gotoEnd) {
@ -8374,10 +8448,10 @@ jQuery.fx.prototype = {
this.now = t;
} else {
n = t - this.startTime;
this.state = n / options.duration;
// Perform the easing function, defaults to swing
this.pos = jQuery.easing[options.animatedProperties[this.prop]](this.state, n, 0, 1, options.duration);
this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
this.now = this.start + ((this.end - this.start) * this.pos);
}
// Perform the next step of the animation
@ -8390,11 +8464,9 @@ jQuery.fx.prototype = {
jQuery.extend( jQuery.fx, {
tick: function() {
var timers = jQuery.timers,
i = timers.length;
while ( i-- ) {
for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
if ( !timers[i]() ) {
timers.splice(i, 1);
timers.splice(i--, 1);
}
}
@ -8862,4 +8934,5 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
window.jQuery = window.$ = jQuery;
})(window);
})(window);