aboutsummaryrefslogtreecommitdiffstats
path: root/themes/default/js/jquery.js
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/js/jquery.js')
-rw-r--r--themes/default/js/jquery.js958
1 files changed, 549 insertions, 409 deletions
diff --git a/themes/default/js/jquery.js b/themes/default/js/jquery.js
index 5c99a8d4a..78fcfa469 100644
--- a/themes/default/js/jquery.js
+++ b/themes/default/js/jquery.js
@@ -1,5 +1,5 @@
/*!
- * jQuery JavaScript Library v1.5
+ * jQuery JavaScript Library v1.5.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 Jan 31 08:31:29 2011 -0500
+ * Date: Wed Feb 23 13:55:29 2011 -0500
*/
(function( window, undefined ) {
@@ -202,7 +202,7 @@ jQuery.fn = jQuery.prototype = {
selector: "",
// The current version of jQuery being used
- jquery: "1.5",
+ jquery: "1.5.1",
// The default length of a jQuery object is 0
length: 0,
@@ -313,7 +313,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
+ var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
@@ -585,10 +585,8 @@ jQuery.extend({
if ( data && rnotwhite.test(data) ) {
// Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
- var head = document.getElementsByTagName("head")[0] || document.documentElement,
- script = document.createElement("script");
-
- script.type = "text/javascript";
+ var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
+ script = document.createElement( "script" );
if ( jQuery.support.scriptEval() ) {
script.appendChild( document.createTextNode( data ) );
@@ -864,6 +862,12 @@ jQuery.extend({
callbacks.shift().apply( context, args );
}
}
+ // We have to add a catch block for
+ // IE prior to 8 or else the finally
+ // block will never get executed
+ catch (e) {
+ throw e;
+ }
finally {
fired = [ context, args ];
firing = 0;
@@ -911,22 +915,22 @@ jQuery.extend({
isRejected: failDeferred.isResolved,
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
- promise: function( obj , i /* internal */ ) {
+ promise: function( obj ) {
if ( obj == null ) {
if ( promise ) {
return promise;
}
promise = obj = {};
}
- i = promiseMethods.length;
+ var i = promiseMethods.length;
while( i-- ) {
- obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
+ obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
}
return obj;
}
} );
// Make sure only one callback list will be used
- deferred.then( failDeferred.cancel, deferred.cancel );
+ deferred.done( failDeferred.cancel ).fail( deferred.cancel );
// Unexpose cancel
delete deferred.cancel;
// Call given func if any
@@ -938,24 +942,34 @@ jQuery.extend({
// Deferred helper
when: function( object ) {
- var args = arguments,
- length = args.length,
- deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ?
+ var lastIndex = arguments.length,
+ deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
object :
jQuery.Deferred(),
- promise = deferred.promise(),
- resolveArray;
-
- if ( length > 1 ) {
- resolveArray = new Array( length );
- jQuery.each( args, function( index, element ) {
- jQuery.when( element ).then( function( value ) {
- resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
- if( ! --length ) {
- deferred.resolveWith( promise, resolveArray );
- }
- }, deferred.reject );
- } );
+ promise = deferred.promise();
+
+ if ( lastIndex > 1 ) {
+ var array = slice.call( arguments, 0 ),
+ count = lastIndex,
+ iCallback = function( index ) {
+ return function( value ) {
+ array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
+ if ( !( --count ) ) {
+ deferred.resolveWith( promise, array );
+ }
+ };
+ };
+ while( ( lastIndex-- ) ) {
+ object = array[ lastIndex ];
+ if ( object && jQuery.isFunction( object.promise ) ) {
+ object.promise().then( iCallback(lastIndex), deferred.reject );
+ } else {
+ --count;
+ }
+ }
+ if ( !count ) {
+ deferred.resolveWith( promise, array );
+ }
} else if ( deferred !== object ) {
deferred.resolve( object );
}
@@ -1071,7 +1085,7 @@ function doScrollCheck() {
}
// Expose jQuery to the global object
-return (window.jQuery = window.$ = jQuery);
+return jQuery;
})();
@@ -1088,7 +1102,8 @@ return (window.jQuery = window.$ = jQuery);
var all = div.getElementsByTagName("*"),
a = div.getElementsByTagName("a")[0],
select = document.createElement("select"),
- opt = select.appendChild( document.createElement("option") );
+ opt = select.appendChild( document.createElement("option") ),
+ input = div.getElementsByTagName("input")[0];
// Can't get basic test support
if ( !all || !all.length || !a ) {
@@ -1127,7 +1142,7 @@ return (window.jQuery = window.$ = jQuery);
// Make sure that if no value is specified for a checkbox
// that it defaults to "on".
// (WebKit defaults to "" instead)
- checkOn: div.getElementsByTagName("input")[0].value === "on",
+ checkOn: input.value === "on",
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
@@ -1137,26 +1152,29 @@ return (window.jQuery = window.$ = jQuery);
deleteExpando: true,
optDisabled: false,
checkClone: false,
- _scriptEval: null,
noCloneEvent: true,
+ noCloneChecked: true,
boxModel: null,
inlineBlockNeedsLayout: false,
shrinkWrapBlocks: false,
reliableHiddenOffsets: true
};
+ input.checked = true;
+ jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
+
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as diabled)
select.disabled = true;
jQuery.support.optDisabled = !opt.disabled;
+ var _scriptEval = null;
jQuery.support.scriptEval = function() {
- if ( jQuery.support._scriptEval === null ) {
+ if ( _scriptEval === null ) {
var root = document.documentElement,
script = document.createElement("script"),
id = "script" + jQuery.now();
- script.type = "text/javascript";
try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
} catch(e) {}
@@ -1167,10 +1185,10 @@ return (window.jQuery = window.$ = jQuery);
// tag with appendChild/createTextNode
// (IE doesn't support this, fails, and uses .text instead)
if ( window[ id ] ) {
- jQuery.support._scriptEval = true;
+ _scriptEval = true;
delete window[ id ];
} else {
- jQuery.support._scriptEval = false;
+ _scriptEval = false;
}
root.removeChild( script );
@@ -1178,7 +1196,7 @@ return (window.jQuery = window.$ = jQuery);
root = script = id = null;
}
- return jQuery.support._scriptEval;
+ return _scriptEval;
};
// Test to see if it's possible to delete an expando from an element
@@ -1190,7 +1208,7 @@ return (window.jQuery = window.$ = jQuery);
jQuery.support.deleteExpando = false;
}
- if ( div.attachEvent && div.fireEvent ) {
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
div.attachEvent("onclick", function click() {
// Cloning a node shouldn't copy over any
// bound event handlers (IE does this)
@@ -1321,7 +1339,7 @@ jQuery.extend({
hasData: function( elem ) {
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
- return !!elem && !jQuery.isEmptyObject(elem);
+ return !!elem && !isEmptyDataObject( elem );
},
data: function( elem, name, data, pvt /* Internal Use Only */ ) {
@@ -1361,11 +1379,18 @@ jQuery.extend({
if ( !cache[ id ] ) {
cache[ id ] = {};
+
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
+ // metadata on plain JS objects when the object is serialized using
+ // JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
}
// An object can be passed to jQuery.data instead of a key/value pair; this gets
// shallow copied over onto the existing cache
- if ( typeof name === "object" ) {
+ if ( typeof name === "object" || typeof name === "function" ) {
if ( pvt ) {
cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
} else {
@@ -1427,7 +1452,7 @@ jQuery.extend({
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
- if ( !jQuery.isEmptyObject(thisCache) ) {
+ if ( !isEmptyDataObject(thisCache) ) {
return;
}
}
@@ -1439,7 +1464,7 @@ jQuery.extend({
// Don't destroy the parent cache unless the internal data object
// had been the only thing left in it
- if ( !jQuery.isEmptyObject(cache[ id ]) ) {
+ if ( !isEmptyDataObject(cache[ id ]) ) {
return;
}
}
@@ -1460,6 +1485,13 @@ jQuery.extend({
// data if it existed
if ( internalCache ) {
cache[ id ] = {};
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
+ // metadata on plain JS objects when the object is serialized using
+ // JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
+
cache[ id ][ internalKey ] = internalCache;
// Otherwise, we need to eliminate the expando on the node to avoid
@@ -1588,6 +1620,19 @@ function dataAttr( elem, key, data ) {
return data;
}
+// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
+// property to be considered empty objects; this property always exists in
+// order to make sure JSON.stringify does not expose internal metadata
+function isEmptyDataObject( obj ) {
+ for ( var name in obj ) {
+ if ( name !== "toJSON" ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
@@ -1888,6 +1933,11 @@ jQuery.fn.extend({
}
}
+ // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
+ if ( one && !values.length && options.length ) {
+ return jQuery( options[ index ] ).val();
+ }
+
return values;
}
@@ -2081,8 +2131,7 @@ var rnamespaces = /\.(.*)$/,
rescape = /[^\w\s.|`]/g,
fcleanup = function( nm ) {
return nm.replace(rescape, "\\$&");
- },
- eventKey = "events";
+ };
/*
* A number of helper functions used for managing events.
@@ -2098,17 +2147,22 @@ jQuery.event = {
return;
}
- // For whatever reason, IE has trouble passing the window object
- // around, causing it to be cloned in the process
- if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
- elem = window;
+ // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
+ // Minor release fix for bug #8018
+ try {
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
}
+ catch ( e ) {}
if ( handler === false ) {
handler = returnFalse;
} else if ( !handler ) {
// Fixes bug #7229. Fix recommended by jdalton
- return;
+ return;
}
var handleObjIn, handleObj;
@@ -2132,23 +2186,10 @@ jQuery.event = {
return;
}
- var events = elemData[ eventKey ],
+ var events = elemData.events,
eventHandle = elemData.handle;
- if ( typeof events === "function" ) {
- // On plain objects events is a fn that holds the the data
- // which prevents this data from being JSON serialized
- // the function does not need to be called, it just contains the data
- eventHandle = events.handle;
- events = events.events;
-
- } else if ( !events ) {
- if ( !elem.nodeType ) {
- // On plain objects, create a fn that acts as the holder
- // of the values to avoid JSON serialization of event data
- elemData[ eventKey ] = elemData = function(){};
- }
-
+ if ( !events ) {
elemData.events = events = {};
}
@@ -2249,17 +2290,12 @@ jQuery.event = {
var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
- events = elemData && elemData[ eventKey ];
+ events = elemData && elemData.events;
if ( !elemData || !events ) {
return;
}
- if ( typeof events === "function" ) {
- elemData = events;
- events = events.events;
- }
-
// types is actually an event object here
if ( types && types.type ) {
handler = types.handler;
@@ -2359,10 +2395,7 @@ jQuery.event = {
delete elemData.events;
delete elemData.handle;
- if ( typeof elemData === "function" ) {
- jQuery.removeData( elem, eventKey, true );
-
- } else if ( jQuery.isEmptyObject( elemData ) ) {
+ if ( jQuery.isEmptyObject( elemData ) ) {
jQuery.removeData( elem, undefined, true );
}
}
@@ -2403,7 +2436,7 @@ jQuery.event = {
// points to jQuery.expando
var internalKey = jQuery.expando,
internalCache = this[ internalKey ];
- if ( internalCache && internalCache.events && internalCache.events[type] ) {
+ if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
jQuery.event.trigger( event, data, internalCache.handle.elem );
}
});
@@ -2429,9 +2462,7 @@ jQuery.event = {
event.currentTarget = elem;
// Trigger the event, it is assumed that "handle" is a function
- var handle = elem.nodeType ?
- jQuery._data( elem, "handle" ) :
- (jQuery._data( elem, eventKey ) || {}).handle;
+ var handle = jQuery._data( elem, "handle" );
if ( handle ) {
handle.apply( elem, data );
@@ -2509,11 +2540,7 @@ jQuery.event = {
event.namespace = event.namespace || namespace_sort.join(".");
- events = jQuery._data(this, eventKey);
-
- if ( typeof events === "function" ) {
- events = events.events;
- }
+ events = jQuery._data(this, "events");
handlers = (events || {})[ event.type ];
@@ -2680,7 +2707,7 @@ jQuery.Event = function( src ) {
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
+ this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
// Event type
@@ -2755,6 +2782,12 @@ var withinElement = function( event ) {
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
+
+ // Chrome does something similar, the parentNode property
+ // can be accessed but is null.
+ if ( parent !== document && !parent.parentNode ) {
+ return;
+ }
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
@@ -2805,8 +2838,7 @@ if ( !jQuery.support.submitBubbles ) {
type = elem.type;
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
+ trigger( "submit", this, arguments );
}
});
@@ -2815,8 +2847,7 @@ if ( !jQuery.support.submitBubbles ) {
type = elem.type;
if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
+ trigger( "submit", this, arguments );
}
});
@@ -2879,7 +2910,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( data != null || val ) {
e.type = "change";
e.liveFired = undefined;
- return jQuery.event.trigger( e, arguments[1], elem );
+ jQuery.event.trigger( e, arguments[1], elem );
}
};
@@ -2893,7 +2924,7 @@ if ( !jQuery.support.changeBubbles ) {
var elem = e.target, type = elem.type;
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
- return testChange.call( this, e );
+ testChange.call( this, e );
}
},
@@ -2905,7 +2936,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
type === "select-multiple" ) {
- return testChange.call( this, e );
+ testChange.call( this, e );
}
},
@@ -2944,8 +2975,18 @@ if ( !jQuery.support.changeBubbles ) {
}
function trigger( type, elem, args ) {
- args[0].type = type;
- return jQuery.event.handle.apply( elem, args );
+ // Piggyback on a donor event to simulate a different one.
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
+ // simulated event prevents default then we do the same on the donor.
+ // Don't pass args or remember liveFired; they apply to the donor event.
+ var event = jQuery.extend( {}, args[ 0 ] );
+ event.type = type;
+ event.originalEvent = {};
+ event.liveFired = undefined;
+ jQuery.event.handle.call( elem, event );
+ if ( event.isDefaultPrevented() ) {
+ args[ 0 ].preventDefault();
+ }
}
// Create "bubbling" focus and blur events
@@ -2954,8 +2995,8 @@ if ( document.addEventListener ) {
jQuery.event.special[ fix ] = {
setup: function() {
this.addEventListener( orig, handler, true );
- },
- teardown: function() {
+ },
+ teardown: function() {
this.removeEventListener( orig, handler, true );
}
};
@@ -3148,11 +3189,7 @@ function liveHandler( event ) {
var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
elems = [],
selectors = [],
- events = jQuery._data( this, eventKey );
-
- if ( typeof events === "function" ) {
- events = events.events;
- }
+ events = jQuery._data( this, "events" );
// Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
@@ -3186,7 +3223,7 @@ function liveHandler( event ) {
for ( j = 0; j < live.length; j++ ) {
handleObj = live[j];
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
+ if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
elem = close.elem;
related = null;
@@ -3269,7 +3306,9 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[
done = 0,
toString = Object.prototype.toString,
hasDuplicate = false,
- baseHasDuplicate = true;
+ baseHasDuplicate = true,
+ rBackslash = /\\/g,
+ rNonWord = /\W/;
// Here we check if the JavaScript engine is using some sort of
// optimization where it does not always call our comparision
@@ -3468,7 +3507,7 @@ Sizzle.find = function( expr, context, isXML ) {
match.splice( 1, 1 );
if ( left.substr( left.length - 1 ) !== "\\" ) {
- match[1] = (match[1] || "").replace(/\\/g, "");
+ match[1] = (match[1] || "").replace( rBackslash, "" );
set = Expr.find[ type ]( match, context, isXML );
if ( set != null ) {
@@ -3607,13 +3646,16 @@ var Expr = Sizzle.selectors = {
attrHandle: {
href: function( elem ) {
return elem.getAttribute( "href" );
+ },
+ type: function( elem ) {
+ return elem.getAttribute( "type" );
}
},
relative: {
"+": function(checkSet, part){
var isPartStr = typeof part === "string",
- isTag = isPartStr && !/\W/.test( part ),
+ isTag = isPartStr && !rNonWord.test( part ),
isPartStrNotTag = isPartStr && !isTag;
if ( isTag ) {
@@ -3641,7 +3683,7 @@ var Expr = Sizzle.selectors = {
i = 0,
l = checkSet.length;
- if ( isPartStr && !/\W/.test( part ) ) {
+ if ( isPartStr && !rNonWord.test( part ) ) {
part = part.toLowerCase();
for ( ; i < l; i++ ) {
@@ -3675,7 +3717,7 @@ var Expr = Sizzle.selectors = {
doneName = done++,
checkFn = dirCheck;
- if ( typeof part === "string" && !/\W/.test(part) ) {
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
@@ -3689,7 +3731,7 @@ var Expr = Sizzle.selectors = {
doneName = done++,
checkFn = dirCheck;
- if ( typeof part === "string" && !/\W/.test( part ) ) {
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
@@ -3732,7 +3774,7 @@ var Expr = Sizzle.selectors = {
},
preFilter: {
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
- match = " " + match[1].replace(/\\/g, "") + " ";
+ match = " " + match[1].replace( rBackslash, "" ) + " ";
if ( isXML ) {
return match;
@@ -3755,11 +3797,11 @@ var Expr = Sizzle.selectors = {
},
ID: function( match ) {
- return match[1].replace(/\\/g, "");
+ return match[1].replace( rBackslash, "" );
},
TAG: function( match, curLoop ) {
- return match[1].toLowerCase();
+ return match[1].replace( rBackslash, "" ).toLowerCase();
},
CHILD: function( match ) {
@@ -3790,14 +3832,14 @@ var Expr = Sizzle.selectors = {
},
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
- var name = match[1] = match[1].replace(/\\/g, "");
+ var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
// Handle if an un-quoted value was used
- match[4] = ( match[4] || match[5] || "" ).replace(/\\/g, "");
+ match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
if ( match[2] === "~=" ) {
match[4] = " " + match[4] + " ";
@@ -3852,7 +3894,9 @@ var Expr = Sizzle.selectors = {
selected: function( elem ) {
// Accessing this property makes selected-by-default
// options in Safari work properly
- elem.parentNode.selectedIndex;
+ if ( elem.parentNode ) {
+ elem.parentNode.selectedIndex;
+ }
return elem.selected === true;
},
@@ -3874,7 +3918,9 @@ var Expr = Sizzle.selectors = {
},
text: function( elem ) {
- return "text" === elem.type;
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // use getAttribute instead to test this case
+ return "text" === elem.getAttribute( 'type' );
},
radio: function( elem ) {
return "radio" === elem.type;
@@ -4407,7 +4453,8 @@ if ( document.querySelectorAll ) {
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var old = context.getAttribute( "id" ),
+ var oldContext = context,
+ old = context.getAttribute( "id" ),
nid = old || id,
hasParent = context.parentNode,
relativeHierarchySelector = /^\s*[+~]/.test( query );
@@ -4429,7 +4476,7 @@ if ( document.querySelectorAll ) {
} catch(pseudoError) {
} finally {
if ( !old ) {
- context.removeAttribute( "id" );
+ oldContext.removeAttribute( "id" );
}
}
}
@@ -4845,11 +4892,11 @@ jQuery.each({
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {
var ret = jQuery.map( this, fn, until ),
- // The variable 'args' was introduced in
- // https://github.com/jquery/jquery/commit/52a0238
- // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
- // http://code.google.com/p/v8/issues/detail?id=1050
- args = slice.call(arguments);
+ // The variable 'args' was introduced in
+ // https://github.com/jquery/jquery/commit/52a0238
+ // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
+ // http://code.google.com/p/v8/issues/detail?id=1050
+ args = slice.call(arguments);
if ( !runtil.test( name ) ) {
selector = until;
@@ -4959,7 +5006,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/,
rnocache = /<(?:script|object|embed|option|style)/i,
- // checked="checked" or checked (html5)
+ // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
@@ -5111,7 +5158,7 @@ jQuery.fn.extend({
}
if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
+ elem.parentNode.removeChild( elem );
}
}
}
@@ -5136,7 +5183,7 @@ jQuery.fn.extend({
},
clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? true : dataAndEvents;
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map( function () {
@@ -5305,8 +5352,8 @@ function cloneCopyEvent( src, dest ) {
}
var internalKey = jQuery.expando,
- oldData = jQuery.data( src ),
- curData = jQuery.data( dest, oldData );
+ oldData = jQuery.data( src ),
+ curData = jQuery.data( dest, oldData );
// Switch to use the internal data object, if it exists, for the next
// stage of data copying
@@ -5320,7 +5367,7 @@ function cloneCopyEvent( src, dest ) {
for ( var type in events ) {
for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data );
+ jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
}
}
}
@@ -5441,6 +5488,18 @@ jQuery.each({
};
});
+function getAll( elem ) {
+ if ( "getElementsByTagName" in elem ) {
+ return elem.getElementsByTagName( "*" );
+
+ } else if ( "querySelectorAll" in elem ) {
+ return elem.querySelectorAll( "*" );
+
+ } else {
+ return [];
+ }
+}
+
jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true),
@@ -5448,17 +5507,20 @@ jQuery.extend({
destElements,
i;
- if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// IE copies events bound via attachEvent when using cloneNode.
// Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some
// proprietary methods to clear the events. Thanks to MooTools
// guys for this hotness.
+ cloneFixAttributes( elem, clone );
+
// Using Sizzle here is crazy slow, so we use getElementsByTagName
// instead
- srcElements = elem.getElementsByTagName("*");
- destElements = clone.getElementsByTagName("*");
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
// Weird iteration because IE will replace the length property
// with an element if you are cloning the body and one of the
@@ -5466,30 +5528,25 @@ jQuery.extend({
for ( i = 0; srcElements[i]; ++i ) {
cloneFixAttributes( srcElements[i], destElements[i] );
}
-
- cloneFixAttributes( elem, clone );
}
// Copy the events from the original to the clone
if ( dataAndEvents ) {
-
cloneCopyEvent( elem, clone );
- if ( deepDataAndEvents && "getElementsByTagName" in elem ) {
+ if ( deepDataAndEvents ) {
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
- srcElements = elem.getElementsByTagName("*");
- destElements = clone.getElementsByTagName("*");
-
- if ( srcElements.length ) {
- for ( i = 0; srcElements[i]; ++i ) {
- cloneCopyEvent( srcElements[i], destElements[i] );
- }
+ for ( i = 0; srcElements[i]; ++i ) {
+ cloneCopyEvent( srcElements[i], destElements[i] );
}
}
}
+
// Return the cloned set
return clone;
- },
+},
clean: function( elems, context, fragment, scripts ) {
context = context || document;
@@ -5910,7 +5967,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
if ( document.documentElement.currentStyle ) {
currentStyle = function( elem, name ) {
- var left,
+ var left,
ret = elem.currentStyle && elem.currentStyle[ name ],
rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
style = elem.style;
@@ -5988,8 +6045,10 @@ var r20 = /%20/g,
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rhash = /#.*$/,
- rheaders = /^(.*?):\s*(.*?)\r?$/mg, // IE leaves an \r character at EOL
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /(?:^file|^widget|\-extension):$/,
rnoContent = /^(?:GET|HEAD)$/,
rprotocol = /^\/\//,
rquery = /\?/,
@@ -5997,7 +6056,11 @@ var r20 = /%20/g,
rselectTextarea = /^(?:select|textarea)/i,
rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/,
- rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/,
+ rucHeaders = /(^|\-)([a-z])/g,
+ rucHeadersFunc = function( _, $1, $2 ) {
+ return $1 + $2.toUpperCase();
+ },
+ rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
// Keep a copy of the old load method
_load = jQuery.fn.load,
@@ -6018,7 +6081,28 @@ var r20 = /%20/g,
* 2) the catchall symbol "*" can be used
* 3) selection will start with transport dataType and THEN go to "*" if needed
*/
- transports = {};
+ transports = {},
+
+ // Document location
+ ajaxLocation,
+
+ // Document location segments
+ ajaxLocParts;
+
+// #8138, IE may throw an exception when accessing
+// a field from document.location if document.domain has been set
+try {
+ ajaxLocation = document.location.href;
+} catch( e ) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement( "a" );
+ ajaxLocation.href = "";
+ ajaxLocation = ajaxLocation.href;
+}
+
+// Segment location into parts
+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {
@@ -6057,7 +6141,7 @@ function addToPrefiltersOrTransports( structure ) {
}
//Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jXHR,
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
dataType /* internal */, inspected /* internal */ ) {
dataType = dataType || options.dataTypes[ 0 ];
@@ -6072,16 +6156,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
selection;
for(; i < length && ( executeOnly || !selection ); i++ ) {
- selection = list[ i ]( options, originalOptions, jXHR );
+ selection = list[ i ]( options, originalOptions, jqXHR );
// If we got redirected to another dataType
- // we try there if not done already
+ // we try there if executing only and not done already
if ( typeof selection === "string" ) {
- if ( inspected[ selection ] ) {
+ if ( !executeOnly || inspected[ selection ] ) {
selection = undefined;
} else {
options.dataTypes.unshift( selection );
selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jXHR, selection, inspected );
+ structure, options, originalOptions, jqXHR, selection, inspected );
}
}
}
@@ -6089,7 +6173,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
// we try the catchall dataType if not done already
if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jXHR, "*", inspected );
+ structure, options, originalOptions, jqXHR, "*", inspected );
}
// unnecessary when only executing (prefilters)
// but it'll be ignored by the caller in that case
@@ -6121,7 +6205,7 @@ jQuery.fn.extend({
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
- params = null;
+ params = undefined;
// Otherwise, build a param string
} else if ( typeof params === "object" ) {
@@ -6139,14 +6223,14 @@ jQuery.fn.extend({
dataType: "html",
data: params,
// Complete callback (responseText is used internally)
- complete: function( jXHR, status, responseText ) {
- // Store the response as specified by the jXHR object
- responseText = jXHR.responseText;
+ complete: function( jqXHR, status, responseText ) {
+ // Store the response as specified by the jqXHR object
+ responseText = jqXHR.responseText;
// If successful, inject the HTML into all the matched elements
- if ( jXHR.isResolved() ) {
+ if ( jqXHR.isResolved() ) {
// #4825: Get the actual response in case
// a dataFilter is present in ajaxSettings
- jXHR.done(function( r ) {
+ jqXHR.done(function( r ) {
responseText = r;
});
// See if a selector was specified
@@ -6165,7 +6249,7 @@ jQuery.fn.extend({
}
if ( callback ) {
- self.each( callback, [ responseText, status, jXHR ] );
+ self.each( callback, [ responseText, status, jqXHR ] );
}
}
});
@@ -6213,7 +6297,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
if ( jQuery.isFunction( data ) ) {
type = type || callback;
callback = data;
- data = null;
+ data = undefined;
}
return jQuery.ajax({
@@ -6229,22 +6313,39 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery.extend({
getScript: function( url, callback ) {
- return jQuery.get( url, null, callback, "script" );
+ return jQuery.get( url, undefined, callback, "script" );
},
getJSON: function( url, data, callback ) {
return jQuery.get( url, data, callback, "json" );
},
- ajaxSetup: function( settings ) {
- jQuery.extend( true, jQuery.ajaxSettings, settings );
- if ( settings.context ) {
- jQuery.ajaxSettings.context = settings.context;
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function ( target, settings ) {
+ if ( !settings ) {
+ // Only one parameter, we extend ajaxSettings
+ settings = target;
+ target = jQuery.extend( true, jQuery.ajaxSettings, settings );
+ } else {
+ // target was provided, we extend into it
+ jQuery.extend( true, target, jQuery.ajaxSettings, settings );
}
+ // Flatten fields we don't want deep extended
+ for( var field in { context: 1, url: 1 } ) {
+ if ( field in settings ) {
+ target[ field ] = settings[ field ];
+ } else if( field in jQuery.ajaxSettings ) {
+ target[ field ] = jQuery.ajaxSettings[ field ];
+ }
+ }
+ return target;
},
ajaxSettings: {
- url: location.href,
+ url: ajaxLocation,
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded",
@@ -6306,9 +6407,8 @@ jQuery.extend({
// Main method
ajax: function( url, options ) {
- // If options is not an object,
- // we simulate pre-1.5 signature
- if ( typeof options !== "object" ) {
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
options = url;
url = undefined;
}
@@ -6317,19 +6417,22 @@ jQuery.extend({
options = options || {};
var // Create the final options object
- s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ),
- // Callbacks contexts
- // We force the original context if it exists
- // or take it from jQuery.ajaxSettings otherwise
- // (plain objects used as context get extended)
- callbackContext =
- ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s,
- globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ),
+ s = jQuery.ajaxSetup( {}, options ),
+ // Callbacks context
+ callbackContext = s.context || s,
+ // Context for global events
+ // It's the callbackContext if one was provided in the options
+ // and if it's a DOM node or a jQuery collection
+ globalEventContext = callbackContext !== s &&
+ ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
+ jQuery( callbackContext ) : jQuery.event,
// Deferreds
deferred = jQuery.Deferred(),
completeDeferred = jQuery._Deferred(),
// Status-dependent callbacks
statusCode = s.statusCode || {},
+ // ifModified key
+ ifModifiedKey,
// Headers (they are sent all at once)
requestHeaders = {},
// Response headers
@@ -6340,22 +6443,22 @@ jQuery.extend({
// timeout handle
timeoutTimer,
// Cross-domain detection vars
- loc = document.location,
- protocol = loc.protocol || "http:",
parts,
- // The jXHR state
+ // The jqXHR state
state = 0,
+ // To know if global events are to be dispatched
+ fireGlobals,
// Loop variable
i,
// Fake xhr
- jXHR = {
+ jqXHR = {
readyState: 0,
// Caches the header
setRequestHeader: function( name, value ) {
- if ( state === 0 ) {
- requestHeaders[ name.toLowerCase() ] = value;
+ if ( !state ) {
+ requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
}
return this;
},
@@ -6377,7 +6480,15 @@ jQuery.extend({
}
match = responseHeaders[ key.toLowerCase() ];
}
- return match || null;
+ return match === undefined ? null : match;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( !state ) {
+ s.mimeType = type;
+ }
+ return this;
},
// Cancel the request
@@ -6394,7 +6505,7 @@ jQuery.extend({
// Callback for when everything is done
// It is defined here because jslint complains if it is declared
// at the end of the function (which would be more logical and readable)
- function done( status, statusText, responses, headers) {
+ function done( status, statusText, responses, headers ) {
// Called once
if ( state === 2 ) {
@@ -6410,19 +6521,19 @@ jQuery.extend({
}
// Dereference transport for early garbage collection
- // (no matter how long the jXHR object will be used)
+ // (no matter how long the jqXHR object will be used)
transport = undefined;
// Cache response headers
responseHeadersString = headers || "";
// Set readyState
- jXHR.readyState = status ? 4 : 0;
+ jqXHR.readyState = status ? 4 : 0;
var isSuccess,
success,
error,
- response = responses ? ajaxHandleResponses( s, jXHR, responses ) : undefined,
+ response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
lastModified,
etag;
@@ -6432,11 +6543,11 @@ jQuery.extend({
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
- if ( ( lastModified = jXHR.getResponseHeader( "Last-Modified" ) ) ) {
- jQuery.lastModified[ s.url ] = lastModified;
+ if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
+ jQuery.lastModified[ ifModifiedKey ] = lastModified;
}
- if ( ( etag = jXHR.getResponseHeader( "Etag" ) ) ) {
- jQuery.etag[ s.url ] = etag;
+ if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
+ jQuery.etag[ ifModifiedKey ] = etag;
}
}
@@ -6463,7 +6574,7 @@ jQuery.extend({
// We extract error from statusText
// then normalize statusText and status for non-aborts
error = statusText;
- if( status ) {
+ if( !statusText || status ) {
statusText = "error";
if ( status < 0 ) {
status = 0;
@@ -6472,30 +6583,30 @@ jQuery.extend({
}
// Set data for the fake xhr object
- jXHR.status = status;
- jXHR.statusText = statusText;
+ jqXHR.status = status;
+ jqXHR.statusText = statusText;
// Success/Error
if ( isSuccess ) {
- deferred.resolveWith( callbackContext, [ success, statusText, jXHR ] );
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
} else {
- deferred.rejectWith( callbackContext, [ jXHR, statusText, error ] );
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
}
// Status-dependent callbacks
- jXHR.statusCode( statusCode );
+ jqXHR.statusCode( statusCode );
statusCode = undefined;
- if ( s.global ) {
+ if ( fireGlobals ) {
globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
- [ jXHR, s, isSuccess ? success : error ] );
+ [ jqXHR, s, isSuccess ? success : error ] );
}
// Complete
- completeDeferred.resolveWith( callbackContext, [ jXHR, statusText ] );
+ completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
- if ( s.global ) {
- globalEventContext.trigger( "ajaxComplete", [ jXHR, s] );
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
// Handle the global AJAX counter
if ( !( --jQuery.active ) ) {
jQuery.event.trigger( "ajaxStop" );
@@ -6504,13 +6615,13 @@ jQuery.extend({
}
// Attach deferreds
- deferred.promise( jXHR );
- jXHR.success = jXHR.done;
- jXHR.error = jXHR.fail;
- jXHR.complete = completeDeferred.done;
+ deferred.promise( jqXHR );
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+ jqXHR.complete = completeDeferred.done;
// Status-dependent callbacks
- jXHR.statusCode = function( map ) {
+ jqXHR.statusCode = function( map ) {
if ( map ) {
var tmp;
if ( state < 2 ) {
@@ -6518,8 +6629,8 @@ jQuery.extend({
statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
}
} else {
- tmp = map[ jXHR.status ];
- jXHR.then( tmp, tmp );
+ tmp = map[ jqXHR.status ];
+ jqXHR.then( tmp, tmp );
}
}
return this;
@@ -6528,7 +6639,7 @@ jQuery.extend({
// Remove hash character (#7531: and string promotion)
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
// We also use the url parameter if available
- s.url = ( "" + ( url || s.url ) ).replace( rhash, "" ).replace( rprotocol, protocol + "//" );
+ s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
@@ -6537,9 +6648,9 @@ jQuery.extend({
if ( !s.crossDomain ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&
- ( parts[ 1 ] != protocol || parts[ 2 ] != loc.hostname ||
+ ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
- ( loc.port || ( protocol === "http:" ? 80 : 443 ) ) )
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
);
}
@@ -6549,7 +6660,15 @@ jQuery.extend({
}
// Apply prefilters
- inspectPrefiltersOrTransports( prefilters, s, options, jXHR );
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefiler, stop there
+ if ( state === 2 ) {
+ return false;
+ }
+
+ // We can fire global events as of now if asked to
+ fireGlobals = s.global;
// Uppercase the type
s.type = s.type.toUpperCase();
@@ -6558,7 +6677,7 @@ jQuery.extend({
s.hasContent = !rnoContent.test( s.type );
// Watch for a new set of requests
- if ( s.global && jQuery.active++ === 0 ) {
+ if ( fireGlobals && jQuery.active++ === 0 ) {
jQuery.event.trigger( "ajaxStart" );
}
@@ -6570,6 +6689,9 @@ jQuery.extend({
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
}
+ // Get ifModifiedKey before adding the anti-cache parameter
+ ifModifiedKey = s.url;
+
// Add anti-cache in url if needed
if ( s.cache === false ) {
@@ -6584,77 +6706,77 @@ jQuery.extend({
// Set the correct header, if data is being sent
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
- requestHeaders[ "content-type" ] = s.contentType;
+ requestHeaders[ "Content-Type" ] = s.contentType;
}
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
- if ( jQuery.lastModified[ s.url ] ) {
- requestHeaders[ "if-modified-since" ] = jQuery.lastModified[ s.url ];
+ ifModifiedKey = ifModifiedKey || s.url;
+ if ( jQuery.lastModified[ ifModifiedKey ] ) {
+ requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
}
- if ( jQuery.etag[ s.url ] ) {
- requestHeaders[ "if-none-match" ] = jQuery.etag[ s.url ];
+ if ( jQuery.etag[ ifModifiedKey ] ) {
+ requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
}
}
// Set the Accepts header for the server, depending on the dataType
- requestHeaders.accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
+ requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
s.accepts[ "*" ];
// Check for headers option
for ( i in s.headers ) {
- requestHeaders[ i.toLowerCase() ] = s.headers[ i ];
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
}
// Allow custom headers/mimetypes and early abort
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jXHR, s ) === false || state === 2 ) ) {
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
// Abort if not done already
- done( 0, "abort" );
- // Return false
- jXHR = false;
+ jqXHR.abort();
+ return false;
- } else {
+ }
- // Install callbacks on deferreds
- for ( i in { success: 1, error: 1, complete: 1 } ) {
- jXHR[ i ]( s[ i ] );
- }
+ // Install callbacks on deferreds
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
+ jqXHR[ i ]( s[ i ] );
+ }
- // Get transport
- transport = inspectPrefiltersOrTransports( transports, s, options, jXHR );
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
- // If no transport, we auto-abort
- if ( !transport ) {
- done( -1, "No Transport" );
- } else {
- // Set state as sending
- state = jXHR.readyState = 1;
- // Send global event
- if ( s.global ) {
- globalEventContext.trigger( "ajaxSend", [ jXHR, s ] );
- }
- // Timeout
- if ( s.async && s.timeout > 0 ) {
- timeoutTimer = setTimeout( function(){
- jXHR.abort( "timeout" );
- }, s.timeout );
- }
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = setTimeout( function(){
+ jqXHR.abort( "timeout" );
+ }, s.timeout );
+ }
- try {
- transport.send( requestHeaders, done );
- } catch (e) {
- // Propagate exception as error if not done
- if ( status < 2 ) {
- done( -1, e );
- // Simply rethrow otherwise
- } else {
- jQuery.error( e );
- }
+ try {
+ state = 1;
+ transport.send( requestHeaders, done );
+ } catch (e) {
+ // Propagate exception as error if not done
+ if ( status < 2 ) {
+ done( -1, e );
+ // Simply rethrow otherwise
+ } else {
+ jQuery.error( e );
}
}
}
- return jXHR;
+
+ return jqXHR;
},
// Serialize an array of form elements or a set of
@@ -6673,7 +6795,7 @@ jQuery.extend({
}
// If an array was passed in, assume that it is an array of form elements.
- if ( jQuery.isArray( a ) || a.jquery ) {
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
@@ -6720,9 +6842,9 @@ function buildParams( prefix, obj, traditional, add ) {
// Serialize object item.
} else {
- jQuery.each( obj, function( k, v ) {
- buildParams( prefix + "[" + k + "]", v, traditional, add );
- });
+ for ( var name in obj ) {
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+ }
}
} else {
@@ -6749,7 +6871,7 @@ jQuery.extend({
* - finds the right dataType (mediates between content-type and expected dataType)
* - returns the corresponding response
*/
-function ajaxHandleResponses( s, jXHR, responses ) {
+function ajaxHandleResponses( s, jqXHR, responses ) {
var contents = s.contents,
dataTypes = s.dataTypes,
@@ -6762,7 +6884,7 @@ function ajaxHandleResponses( s, jXHR, responses ) {
// Fill responseXXX fields
for( type in responseFields ) {
if ( type in responses ) {
- jXHR[ responseFields[type] ] = responses[ type ];
+ jqXHR[ responseFields[type] ] = responses[ type ];
}
}
@@ -6770,7 +6892,7 @@ function ajaxHandleResponses( s, jXHR, responses ) {
while( dataTypes[ 0 ] === "*" ) {
dataTypes.shift();
if ( ct === undefined ) {
- ct = jXHR.getResponseHeader( "content-type" );
+ ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
}
}
@@ -6822,8 +6944,9 @@ function ajaxConvert( s, response ) {
}
var dataTypes = s.dataTypes,
- converters = s.converters,
+ converters = {},
i,
+ key,
length = dataTypes.length,
tmp,
// Current and previous dataTypes
@@ -6840,6 +6963,16 @@ function ajaxConvert( s, response ) {
// For each dataType in the chain
for( i = 1; i < length; i++ ) {
+ // Create converters map
+ // with lowercased keys
+ if ( i === 1 ) {
+ for( key in s.converters ) {
+ if( typeof key === "string" ) {
+ converters[ key.toLowerCase() ] = s.converters[ key ];
+ }
+ }
+ }
+
// Get the dataTypes
prev = current;
current = dataTypes[ i ];
@@ -6902,9 +7035,9 @@ jQuery.ajaxSetup({
});
// Detect, normalize options and install callbacks for jsonp requests
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */ ) {
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
- dataIsString = ( typeof s.data === "string" );
+ var dataIsString = ( typeof s.data === "string" );
if ( s.dataTypes[ 0 ] === "jsonp" ||
originalSettings.jsonpCallback ||
@@ -6918,7 +7051,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
previous = window[ jsonpCallback ],
url = s.url,
data = s.data,
- replace = "$1" + jsonpCallback + "$2";
+ replace = "$1" + jsonpCallback + "$2",
+ cleanUp = function() {
+ // Set callback back to previous value
+ window[ jsonpCallback ] = previous;
+ // Call if it was a function and we have a response
+ if ( responseContainer && jQuery.isFunction( previous ) ) {
+ window[ jsonpCallback ]( responseContainer[ 0 ] );
+ }
+ };
if ( s.jsonp !== false ) {
url = url.replace( jsre, replace );
@@ -6936,32 +7077,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
s.url = url;
s.data = data;
+ // Install callback
window[ jsonpCallback ] = function( response ) {
responseContainer = [ response ];
};
- s.complete = [ function() {
-
- // Set callback back to previous value
- window[ jsonpCallback ] = previous;
-
- // Call if it was a function and we have a response
- if ( previous) {
- if ( responseContainer && jQuery.isFunction( previous ) ) {
- window[ jsonpCallback ] ( responseContainer[ 0 ] );
- }
- } else {
- // else, more memory leak avoidance
- try{
- delete window[ jsonpCallback ];
- } catch( e ) {}
- }
-
- }, s.complete ];
+ // Install cleanUp function
+ jqXHR.then( cleanUp, cleanUp );
// Use data converter to retrieve json after script execution
s.converters["script json"] = function() {
- if ( ! responseContainer ) {
+ if ( !responseContainer ) {
jQuery.error( jsonpCallback + " was not called" );
}
return responseContainer[ 0 ];
@@ -6981,10 +7107,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
// Install script dataType
jQuery.ajaxSetup({
accepts: {
- script: "text/javascript, application/javascript"
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
},
contents: {
- script: /javascript/
+ script: /javascript|ecmascript/
},
converters: {
"text script": function( text ) {
@@ -7012,7 +7138,7 @@ jQuery.ajaxTransport( "script", function(s) {
if ( s.crossDomain ) {
var script,
- head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement;
+ head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
return {
@@ -7067,18 +7193,36 @@ jQuery.ajaxTransport( "script", function(s) {
-var // Next active xhr id
+var // #5280: next active xhr id and list of active xhrs' callbacks
xhrId = jQuery.now(),
-
- // active xhrs
- xhrs = {},
-
- // #5280: see below
- xhrUnloadAbortInstalled,
+ xhrCallbacks,
// XHR used to determine supports properties
testXHR;
+// #5280: Internet Explorer will keep connections alive if we don't abort on unload
+function xhrOnUnloadAbort() {
+ jQuery( window ).unload(function() {
+ // Abort all pending requests
+ for ( var key in xhrCallbacks ) {
+ xhrCallbacks[ key ]( 0, 1 );
+ }
+ });
+}
+
+// Functions to create xhrs
+function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch( e ) {}
+}
+
+function createActiveXHR() {
+ try {
+ return new window.ActiveXObject( "Microsoft.XMLHTTP" );
+ } catch( e ) {}
+}
+
// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
@@ -7089,27 +7233,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
* we need a fallback.
*/
function() {
- if ( window.location.protocol !== "file:" ) {
- try {
- return new window.XMLHttpRequest();
- } catch( xhrError ) {}
- }
-
- try {
- return new window.ActiveXObject("Microsoft.XMLHTTP");
- } catch( activeError ) {}
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
} :
// For all other browsers, use the standard XMLHttpRequest object
- function() {
- return new window.XMLHttpRequest();
- };
+ createStandardXHR;
// Test if we can create an xhr object
-try {
- testXHR = jQuery.ajaxSettings.xhr();
-} catch( xhrCreationException ) {}
-
-//Does this browser support XHR requests?
+testXHR = jQuery.ajaxSettings.xhr();
jQuery.support.ajax = !!testXHR;
// Does this browser support crossDomain XHR requests
@@ -7130,26 +7260,10 @@ if ( jQuery.support.ajax ) {
return {
send: function( headers, complete ) {
- // #5280: we need to abort on unload or IE will keep connections alive
- if ( !xhrUnloadAbortInstalled ) {
-
- xhrUnloadAbortInstalled = 1;
-
- jQuery(window).bind( "unload", function() {
-
- // Abort all pending requests
- jQuery.each( xhrs, function( _, xhr ) {
- if ( xhr.onreadystatechange ) {
- xhr.onreadystatechange( 1 );
- }
- } );
-
- } );
- }
-
// Get a new xhr
var xhr = s.xhr(),
- handle;
+ handle,
+ i;
// Open the socket
// Passing null username, generates a login popup on Opera (#2865)
@@ -7159,19 +7273,31 @@ if ( jQuery.support.ajax ) {
xhr.open( s.type, s.url, s.async );
}
+ // Apply custom fields if provided
+ if ( s.xhrFields ) {
+ for ( i in s.xhrFields ) {
+ xhr[ i ] = s.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( s.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( s.mimeType );
+ }
+
// Requested-With header
// Not set for crossDomain requests with no content
// (see why at http://trac.dojotoolkit.org/ticket/9486)
// Won't change header if already provided
- if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) {
- headers[ "x-requested-with" ] = "XMLHttpRequest";
+ if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
}
// Need an extra try/catch for cross domain requests in Firefox 3
try {
- jQuery.each( headers, function( key, value ) {
- xhr.setRequestHeader( key, value );
- } );
+ for ( i in headers ) {
+ xhr.setRequestHeader( i, headers[ i ] );
+ }
} catch( _ ) {}
// Do send the request
@@ -7182,75 +7308,79 @@ if ( jQuery.support.ajax ) {
// Listener
callback = function( _, isAbort ) {
- // Was never called and is aborted or complete
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+ var status,
+ statusText,
+ responseHeaders,
+ responses,
+ xml;
- // Only called once
- callback = 0;
+ // Firefox throws exceptions when accessing properties
+ // of an xhr when a network error occured
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
+ try {
- // Do not keep as active anymore
- if ( handle ) {
- xhr.onreadystatechange = jQuery.noop;
- delete xhrs[ handle ];
- }
+ // Was never called and is aborted or complete
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
- // If it's an abort
- if ( isAbort ) {
- // Abort it manually if needed
- if ( xhr.readyState !== 4 ) {
- xhr.abort();
+ // Only called once
+ callback = undefined;
+
+ // Do not keep as active anymore
+ if ( handle ) {
+ xhr.onreadystatechange = jQuery.noop;
+ delete xhrCallbacks[ handle ];
}
- } else {
- // Get info
- var status = xhr.status,
- statusText,
- responseHeaders = xhr.getAllResponseHeaders(),
- responses = {},
+
+ // If it's an abort
+ if ( isAbort ) {
+ // Abort it manually if needed
+ if ( xhr.readyState !== 4 ) {
+ xhr.abort();
+ }
+ } else {
+ status = xhr.status;
+ responseHeaders = xhr.getAllResponseHeaders();
+ responses = {};
xml = xhr.responseXML;
- // Construct response list
- if ( xml && xml.documentElement /* #4958 */ ) {
- responses.xml = xml;
- }
- responses.text = xhr.responseText;
-
- // Firefox throws an exception when accessing
- // statusText for faulty cross-domain requests
- try {
- statusText = xhr.statusText;
- } catch( e ) {
- // We normalize with Webkit giving an empty statusText
- statusText = "";
+ // Construct response list
+ if ( xml && xml.documentElement /* #4958 */ ) {
+ responses.xml = xml;
+ }
+ responses.text = xhr.responseText;
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch( e ) {
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if ( !status && s.isLocal && !s.crossDomain ) {
+ status = responses.text ? 200 : 404;
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if ( status === 1223 ) {
+ status = 204;
+ }
}
-
- // Filter status for non standard behaviours
- status =
- // Opera returns 0 when it should be 304
- // Webkit returns 0 for failing cross-domain no matter the real status
- status === 0 ?
- (
- // Webkit, Firefox: filter out faulty cross-domain requests
- !s.crossDomain || statusText ?
- (
- // Opera: filter out real aborts #6060
- responseHeaders ?
- 304 :
- 0
- ) :
- // We assume 302 but could be anything cross-domain related
- 302
- ) :
- (
- // IE sometimes returns 1223 when it should be 204 (see #1450)
- status == 1223 ?
- 204 :
- status
- );
-
- // Call complete
- complete( status, statusText, responses, responseHeaders );
+ }
+ } catch( firefoxAccessException ) {
+ if ( !isAbort ) {
+ complete( -1, firefoxAccessException );
}
}
+
+ // Call complete if needed
+ if ( responses ) {
+ complete( status, statusText, responses, responseHeaders );
+ }
};
// if we're in sync mode or it's in cache
@@ -7259,10 +7389,15 @@ if ( jQuery.support.ajax ) {
if ( !s.async || xhr.readyState === 4 ) {
callback();
} else {
- // Add to list of active xhrs
+ // Create the active xhrs callbacks list if needed
+ // and attach the unload handler
+ if ( !xhrCallbacks ) {
+ xhrCallbacks = {};
+ xhrOnUnloadAbort();
+ }
+ // Add to list of active xhrs callbacks
handle = xhrId++;
- xhrs[ handle ] = xhr;
- xhr.onreadystatechange = callback;
+ xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
}
},
@@ -7464,11 +7599,11 @@ jQuery.fn.extend({
} else {
var parts = rfxnum.exec(val),
- start = e.cur() || 0;
+ start = e.cur();
if ( parts ) {
var end = parseFloat( parts[2] ),
- unit = parts[3] || "px";
+ unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
// We need to compute starting value
if ( unit !== "px" ) {
@@ -7615,8 +7750,12 @@ jQuery.fx.prototype = {
return this.elem[ this.prop ];
}
- var r = parseFloat( jQuery.css( this.elem, this.prop ) );
- return r || 0;
+ var parsed,
+ r = jQuery.css( this.elem, this.prop );
+ // Empty strings, null, undefined and "auto" are converted to 0,
+ // complex values such as "rotate(1rad)" are returned as is,
+ // simple values such as "10px" are parsed to Float.
+ return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
},
// Start an animation from one number to another
@@ -7627,7 +7766,7 @@ jQuery.fx.prototype = {
this.startTime = jQuery.now();
this.start = from;
this.end = to;
- this.unit = unit || this.unit || "px";
+ this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
this.now = this.start;
this.pos = this.state = 0;
@@ -8078,7 +8217,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
if ( win ) {
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
- i ? val : jQuery(win).scrollTop()
+ i ? val : jQuery(win).scrollTop()
);
} else {
@@ -8173,4 +8312,5 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
});
+window.jQuery = window.$ = jQuery;
})(window);