seaweed 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery JavaScript Library v1.5
2
+ * jQuery JavaScript Library v1.5.2
3
3
  * http://jquery.com/
4
4
  *
5
5
  * Copyright 2011, John Resig
@@ -11,7 +11,7 @@
11
11
  * Copyright 2011, The Dojo Foundation
12
12
  * Released under the MIT, BSD, and GPL Licenses.
13
13
  *
14
- * Date: Mon Jan 31 08:31:29 2011 -0500
14
+ * Date: Thu Mar 31 15:28:23 2011 -0400
15
15
  */
16
16
  (function( window, undefined ) {
17
17
 
@@ -69,15 +69,9 @@ var jQuery = function( selector, context ) {
69
69
  // For matching the engine and version of the browser
70
70
  browserMatch,
71
71
 
72
- // Has the ready events already been bound?
73
- readyBound = false,
74
-
75
72
  // The deferred used on DOM ready
76
73
  readyList,
77
74
 
78
- // Promise methods
79
- promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
80
-
81
75
  // The ready event handler
82
76
  DOMContentLoaded,
83
77
 
@@ -202,7 +196,7 @@ jQuery.fn = jQuery.prototype = {
202
196
  selector: "",
203
197
 
204
198
  // The current version of jQuery being used
205
- jquery: "1.5",
199
+ jquery: "1.5.2",
206
200
 
207
201
  // The default length of a jQuery object is 0
208
202
  length: 0,
@@ -313,7 +307,7 @@ jQuery.fn = jQuery.prototype = {
313
307
  jQuery.fn.init.prototype = jQuery.fn;
314
308
 
315
309
  jQuery.extend = jQuery.fn.extend = function() {
316
- var options, name, src, copy, copyIsArray, clone,
310
+ var options, name, src, copy, copyIsArray, clone,
317
311
  target = arguments[0] || {},
318
312
  i = 1,
319
313
  length = arguments.length,
@@ -427,11 +421,11 @@ jQuery.extend({
427
421
  },
428
422
 
429
423
  bindReady: function() {
430
- if ( readyBound ) {
424
+ if ( readyList ) {
431
425
  return;
432
426
  }
433
427
 
434
- readyBound = true;
428
+ readyList = jQuery._Deferred();
435
429
 
436
430
  // Catch cases where $(document).ready() is called after the
437
431
  // browser event has already occurred.
@@ -585,10 +579,8 @@ jQuery.extend({
585
579
  if ( data && rnotwhite.test(data) ) {
586
580
  // Inspired by code by Andrea Giammarchi
587
581
  // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
588
- var head = document.getElementsByTagName("head")[0] || document.documentElement,
589
- script = document.createElement("script");
590
-
591
- script.type = "text/javascript";
582
+ var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
583
+ script = document.createElement( "script" );
592
584
 
593
585
  if ( jQuery.support.scriptEval() ) {
594
586
  script.appendChild( document.createTextNode( data ) );
@@ -813,6 +805,123 @@ jQuery.extend({
813
805
  return (new Date()).getTime();
814
806
  },
815
807
 
808
+ // Use of jQuery.browser is frowned upon.
809
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
810
+ uaMatch: function( ua ) {
811
+ ua = ua.toLowerCase();
812
+
813
+ var match = rwebkit.exec( ua ) ||
814
+ ropera.exec( ua ) ||
815
+ rmsie.exec( ua ) ||
816
+ ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
817
+ [];
818
+
819
+ return { browser: match[1] || "", version: match[2] || "0" };
820
+ },
821
+
822
+ sub: function() {
823
+ function jQuerySubclass( selector, context ) {
824
+ return new jQuerySubclass.fn.init( selector, context );
825
+ }
826
+ jQuery.extend( true, jQuerySubclass, this );
827
+ jQuerySubclass.superclass = this;
828
+ jQuerySubclass.fn = jQuerySubclass.prototype = this();
829
+ jQuerySubclass.fn.constructor = jQuerySubclass;
830
+ jQuerySubclass.subclass = this.subclass;
831
+ jQuerySubclass.fn.init = function init( selector, context ) {
832
+ if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
833
+ context = jQuerySubclass(context);
834
+ }
835
+
836
+ return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
837
+ };
838
+ jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
839
+ var rootjQuerySubclass = jQuerySubclass(document);
840
+ return jQuerySubclass;
841
+ },
842
+
843
+ browser: {}
844
+ });
845
+
846
+ // Populate the class2type map
847
+ jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
848
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
849
+ });
850
+
851
+ browserMatch = jQuery.uaMatch( userAgent );
852
+ if ( browserMatch.browser ) {
853
+ jQuery.browser[ browserMatch.browser ] = true;
854
+ jQuery.browser.version = browserMatch.version;
855
+ }
856
+
857
+ // Deprecated, use jQuery.browser.webkit instead
858
+ if ( jQuery.browser.webkit ) {
859
+ jQuery.browser.safari = true;
860
+ }
861
+
862
+ if ( indexOf ) {
863
+ jQuery.inArray = function( elem, array ) {
864
+ return indexOf.call( array, elem );
865
+ };
866
+ }
867
+
868
+ // IE doesn't match non-breaking spaces with \s
869
+ if ( rnotwhite.test( "\xA0" ) ) {
870
+ trimLeft = /^[\s\xA0]+/;
871
+ trimRight = /[\s\xA0]+$/;
872
+ }
873
+
874
+ // All jQuery objects should point back to these
875
+ rootjQuery = jQuery(document);
876
+
877
+ // Cleanup functions for the document ready method
878
+ if ( document.addEventListener ) {
879
+ DOMContentLoaded = function() {
880
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
881
+ jQuery.ready();
882
+ };
883
+
884
+ } else if ( document.attachEvent ) {
885
+ DOMContentLoaded = function() {
886
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
887
+ if ( document.readyState === "complete" ) {
888
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
889
+ jQuery.ready();
890
+ }
891
+ };
892
+ }
893
+
894
+ // The DOM ready check for Internet Explorer
895
+ function doScrollCheck() {
896
+ if ( jQuery.isReady ) {
897
+ return;
898
+ }
899
+
900
+ try {
901
+ // If IE is used, use the trick by Diego Perini
902
+ // http://javascript.nwbox.com/IEContentLoaded/
903
+ document.documentElement.doScroll("left");
904
+ } catch(e) {
905
+ setTimeout( doScrollCheck, 1 );
906
+ return;
907
+ }
908
+
909
+ // and execute any waiting functions
910
+ jQuery.ready();
911
+ }
912
+
913
+ // Expose jQuery to the global object
914
+ return jQuery;
915
+
916
+ })();
917
+
918
+
919
+ var // Promise methods
920
+ promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
921
+ // Static reference to slice
922
+ sliceDeferred = [].slice;
923
+
924
+ jQuery.extend({
816
925
  // Create a simple deferred (one callbacks list)
817
926
  _Deferred: function() {
818
927
  var // callbacks list
@@ -858,6 +967,8 @@ jQuery.extend({
858
967
  // resolve with given context and args
859
968
  resolveWith: function( context, args ) {
860
969
  if ( !cancelled && !fired && !firing ) {
970
+ // make sure args are available (#8421)
971
+ args = args || [];
861
972
  firing = 1;
862
973
  try {
863
974
  while( callbacks[ 0 ] ) {
@@ -874,7 +985,7 @@ jQuery.extend({
874
985
 
875
986
  // resolve with this as context and given arguments
876
987
  resolve: function() {
877
- deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
988
+ deferred.resolveWith( this, arguments );
878
989
  return this;
879
990
  },
880
991
 
@@ -911,22 +1022,22 @@ jQuery.extend({
911
1022
  isRejected: failDeferred.isResolved,
912
1023
  // Get a promise for this deferred
913
1024
  // If obj is provided, the promise aspect is added to the object
914
- promise: function( obj , i /* internal */ ) {
1025
+ promise: function( obj ) {
915
1026
  if ( obj == null ) {
916
1027
  if ( promise ) {
917
1028
  return promise;
918
1029
  }
919
1030
  promise = obj = {};
920
1031
  }
921
- i = promiseMethods.length;
1032
+ var i = promiseMethods.length;
922
1033
  while( i-- ) {
923
- obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
1034
+ obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
924
1035
  }
925
1036
  return obj;
926
1037
  }
927
1038
  } );
928
1039
  // Make sure only one callback list will be used
929
- deferred.then( failDeferred.cancel, deferred.cancel );
1040
+ deferred.done( failDeferred.cancel ).fail( deferred.cancel );
930
1041
  // Unexpose cancel
931
1042
  delete deferred.cancel;
932
1043
  // Call given func if any
@@ -937,143 +1048,44 @@ jQuery.extend({
937
1048
  },
938
1049
 
939
1050
  // Deferred helper
940
- when: function( object ) {
1051
+ when: function( firstParam ) {
941
1052
  var args = arguments,
1053
+ i = 0,
942
1054
  length = args.length,
943
- deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ?
944
- object :
945
- jQuery.Deferred(),
946
- promise = deferred.promise(),
947
- resolveArray;
948
-
949
- if ( length > 1 ) {
950
- resolveArray = new Array( length );
951
- jQuery.each( args, function( index, element ) {
952
- jQuery.when( element ).then( function( value ) {
953
- resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
954
- if( ! --length ) {
955
- deferred.resolveWith( promise, resolveArray );
956
- }
957
- }, deferred.reject );
958
- } );
959
- } else if ( deferred !== object ) {
960
- deferred.resolve( object );
961
- }
962
- return promise;
963
- },
964
-
965
- // Use of jQuery.browser is frowned upon.
966
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
967
- uaMatch: function( ua ) {
968
- ua = ua.toLowerCase();
969
-
970
- var match = rwebkit.exec( ua ) ||
971
- ropera.exec( ua ) ||
972
- rmsie.exec( ua ) ||
973
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
974
- [];
975
-
976
- return { browser: match[1] || "", version: match[2] || "0" };
977
- },
978
-
979
- sub: function() {
980
- function jQuerySubclass( selector, context ) {
981
- return new jQuerySubclass.fn.init( selector, context );
1055
+ count = length,
1056
+ deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1057
+ firstParam :
1058
+ jQuery.Deferred();
1059
+ function resolveFunc( i ) {
1060
+ return function( value ) {
1061
+ args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1062
+ if ( !( --count ) ) {
1063
+ // Strange bug in FF4:
1064
+ // Values changed onto the arguments object sometimes end up as undefined values
1065
+ // outside the $.when method. Cloning the object into a fresh array solves the issue
1066
+ deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1067
+ }
1068
+ };
982
1069
  }
983
- jQuery.extend( true, jQuerySubclass, this );
984
- jQuerySubclass.superclass = this;
985
- jQuerySubclass.fn = jQuerySubclass.prototype = this();
986
- jQuerySubclass.fn.constructor = jQuerySubclass;
987
- jQuerySubclass.subclass = this.subclass;
988
- jQuerySubclass.fn.init = function init( selector, context ) {
989
- if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
990
- context = jQuerySubclass(context);
1070
+ if ( length > 1 ) {
1071
+ for( ; i < length; i++ ) {
1072
+ if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1073
+ args[ i ].promise().then( resolveFunc(i), deferred.reject );
1074
+ } else {
1075
+ --count;
1076
+ }
991
1077
  }
992
-
993
- return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
994
- };
995
- jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
996
- var rootjQuerySubclass = jQuerySubclass(document);
997
- return jQuerySubclass;
998
- },
999
-
1000
- browser: {}
1001
- });
1002
-
1003
- // Create readyList deferred
1004
- readyList = jQuery._Deferred();
1005
-
1006
- // Populate the class2type map
1007
- jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
1008
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
1009
- });
1010
-
1011
- browserMatch = jQuery.uaMatch( userAgent );
1012
- if ( browserMatch.browser ) {
1013
- jQuery.browser[ browserMatch.browser ] = true;
1014
- jQuery.browser.version = browserMatch.version;
1015
- }
1016
-
1017
- // Deprecated, use jQuery.browser.webkit instead
1018
- if ( jQuery.browser.webkit ) {
1019
- jQuery.browser.safari = true;
1020
- }
1021
-
1022
- if ( indexOf ) {
1023
- jQuery.inArray = function( elem, array ) {
1024
- return indexOf.call( array, elem );
1025
- };
1026
- }
1027
-
1028
- // IE doesn't match non-breaking spaces with \s
1029
- if ( rnotwhite.test( "\xA0" ) ) {
1030
- trimLeft = /^[\s\xA0]+/;
1031
- trimRight = /[\s\xA0]+$/;
1032
- }
1033
-
1034
- // All jQuery objects should point back to these
1035
- rootjQuery = jQuery(document);
1036
-
1037
- // Cleanup functions for the document ready method
1038
- if ( document.addEventListener ) {
1039
- DOMContentLoaded = function() {
1040
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
1041
- jQuery.ready();
1042
- };
1043
-
1044
- } else if ( document.attachEvent ) {
1045
- DOMContentLoaded = function() {
1046
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
1047
- if ( document.readyState === "complete" ) {
1048
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
1049
- jQuery.ready();
1078
+ if ( !count ) {
1079
+ deferred.resolveWith( deferred, args );
1080
+ }
1081
+ } else if ( deferred !== firstParam ) {
1082
+ deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1050
1083
  }
1051
- };
1052
- }
1053
-
1054
- // The DOM ready check for Internet Explorer
1055
- function doScrollCheck() {
1056
- if ( jQuery.isReady ) {
1057
- return;
1058
- }
1059
-
1060
- try {
1061
- // If IE is used, use the trick by Diego Perini
1062
- // http://javascript.nwbox.com/IEContentLoaded/
1063
- document.documentElement.doScroll("left");
1064
- } catch(e) {
1065
- setTimeout( doScrollCheck, 1 );
1066
- return;
1084
+ return deferred.promise();
1067
1085
  }
1086
+ });
1068
1087
 
1069
- // and execute any waiting functions
1070
- jQuery.ready();
1071
- }
1072
1088
 
1073
- // Expose jQuery to the global object
1074
- return (window.jQuery = window.$ = jQuery);
1075
-
1076
- })();
1077
1089
 
1078
1090
 
1079
1091
  (function() {
@@ -1088,7 +1100,8 @@ return (window.jQuery = window.$ = jQuery);
1088
1100
  var all = div.getElementsByTagName("*"),
1089
1101
  a = div.getElementsByTagName("a")[0],
1090
1102
  select = document.createElement("select"),
1091
- opt = select.appendChild( document.createElement("option") );
1103
+ opt = select.appendChild( document.createElement("option") ),
1104
+ input = div.getElementsByTagName("input")[0];
1092
1105
 
1093
1106
  // Can't get basic test support
1094
1107
  if ( !all || !all.length || !a ) {
@@ -1127,7 +1140,7 @@ return (window.jQuery = window.$ = jQuery);
1127
1140
  // Make sure that if no value is specified for a checkbox
1128
1141
  // that it defaults to "on".
1129
1142
  // (WebKit defaults to "" instead)
1130
- checkOn: div.getElementsByTagName("input")[0].value === "on",
1143
+ checkOn: input.value === "on",
1131
1144
 
1132
1145
  // Make sure that a selected-by-default option has a working selected property.
1133
1146
  // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
@@ -1137,48 +1150,50 @@ return (window.jQuery = window.$ = jQuery);
1137
1150
  deleteExpando: true,
1138
1151
  optDisabled: false,
1139
1152
  checkClone: false,
1140
- _scriptEval: null,
1141
1153
  noCloneEvent: true,
1154
+ noCloneChecked: true,
1142
1155
  boxModel: null,
1143
1156
  inlineBlockNeedsLayout: false,
1144
1157
  shrinkWrapBlocks: false,
1145
- reliableHiddenOffsets: true
1158
+ reliableHiddenOffsets: true,
1159
+ reliableMarginRight: true
1146
1160
  };
1147
1161
 
1162
+ input.checked = true;
1163
+ jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
1164
+
1148
1165
  // Make sure that the options inside disabled selects aren't marked as disabled
1149
1166
  // (WebKit marks them as diabled)
1150
1167
  select.disabled = true;
1151
1168
  jQuery.support.optDisabled = !opt.disabled;
1152
1169
 
1170
+ var _scriptEval = null;
1153
1171
  jQuery.support.scriptEval = function() {
1154
- if ( jQuery.support._scriptEval === null ) {
1172
+ if ( _scriptEval === null ) {
1155
1173
  var root = document.documentElement,
1156
1174
  script = document.createElement("script"),
1157
1175
  id = "script" + jQuery.now();
1158
1176
 
1159
- script.type = "text/javascript";
1177
+ // Make sure that the execution of code works by injecting a script
1178
+ // tag with appendChild/createTextNode
1179
+ // (IE doesn't support this, fails, and uses .text instead)
1160
1180
  try {
1161
1181
  script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
1162
1182
  } catch(e) {}
1163
1183
 
1164
1184
  root.insertBefore( script, root.firstChild );
1165
1185
 
1166
- // Make sure that the execution of code works by injecting a script
1167
- // tag with appendChild/createTextNode
1168
- // (IE doesn't support this, fails, and uses .text instead)
1169
1186
  if ( window[ id ] ) {
1170
- jQuery.support._scriptEval = true;
1187
+ _scriptEval = true;
1171
1188
  delete window[ id ];
1172
1189
  } else {
1173
- jQuery.support._scriptEval = false;
1190
+ _scriptEval = false;
1174
1191
  }
1175
1192
 
1176
1193
  root.removeChild( script );
1177
- // release memory in IE
1178
- root = script = id = null;
1179
1194
  }
1180
1195
 
1181
- return jQuery.support._scriptEval;
1196
+ return _scriptEval;
1182
1197
  };
1183
1198
 
1184
1199
  // Test to see if it's possible to delete an expando from an element
@@ -1190,7 +1205,7 @@ return (window.jQuery = window.$ = jQuery);
1190
1205
  jQuery.support.deleteExpando = false;
1191
1206
  }
1192
1207
 
1193
- if ( div.attachEvent && div.fireEvent ) {
1208
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1194
1209
  div.attachEvent("onclick", function click() {
1195
1210
  // Cloning a node shouldn't copy over any
1196
1211
  // bound event handlers (IE does this)
@@ -1260,6 +1275,17 @@ return (window.jQuery = window.$ = jQuery);
1260
1275
  jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
1261
1276
  div.innerHTML = "";
1262
1277
 
1278
+ // Check if div with explicit width and no margin-right incorrectly
1279
+ // gets computed margin-right based on width of container. For more
1280
+ // info see bug #3333
1281
+ // Fails in WebKit before Feb 2011 nightlies
1282
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1283
+ if ( document.defaultView && document.defaultView.getComputedStyle ) {
1284
+ div.style.width = "1px";
1285
+ div.style.marginRight = "0";
1286
+ jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div, null).marginRight, 10) || 0 ) === 0;
1287
+ }
1288
+
1263
1289
  body.removeChild( div ).style.display = "none";
1264
1290
  div = tds = null;
1265
1291
  });
@@ -1283,8 +1309,6 @@ return (window.jQuery = window.$ = jQuery);
1283
1309
  el.setAttribute(eventName, "return;");
1284
1310
  isSupported = typeof el[eventName] === "function";
1285
1311
  }
1286
- el = null;
1287
-
1288
1312
  return isSupported;
1289
1313
  };
1290
1314
 
@@ -1321,7 +1345,7 @@ jQuery.extend({
1321
1345
  hasData: function( elem ) {
1322
1346
  elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1323
1347
 
1324
- return !!elem && !jQuery.isEmptyObject(elem);
1348
+ return !!elem && !isEmptyDataObject( elem );
1325
1349
  },
1326
1350
 
1327
1351
  data: function( elem, name, data, pvt /* Internal Use Only */ ) {
@@ -1361,11 +1385,18 @@ jQuery.extend({
1361
1385
 
1362
1386
  if ( !cache[ id ] ) {
1363
1387
  cache[ id ] = {};
1388
+
1389
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1390
+ // metadata on plain JS objects when the object is serialized using
1391
+ // JSON.stringify
1392
+ if ( !isNode ) {
1393
+ cache[ id ].toJSON = jQuery.noop;
1394
+ }
1364
1395
  }
1365
1396
 
1366
1397
  // An object can be passed to jQuery.data instead of a key/value pair; this gets
1367
1398
  // shallow copied over onto the existing cache
1368
- if ( typeof name === "object" ) {
1399
+ if ( typeof name === "object" || typeof name === "function" ) {
1369
1400
  if ( pvt ) {
1370
1401
  cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1371
1402
  } else {
@@ -1427,7 +1458,7 @@ jQuery.extend({
1427
1458
 
1428
1459
  // If there is no data left in the cache, we want to continue
1429
1460
  // and let the cache object itself get destroyed
1430
- if ( !jQuery.isEmptyObject(thisCache) ) {
1461
+ if ( !isEmptyDataObject(thisCache) ) {
1431
1462
  return;
1432
1463
  }
1433
1464
  }
@@ -1439,7 +1470,7 @@ jQuery.extend({
1439
1470
 
1440
1471
  // Don't destroy the parent cache unless the internal data object
1441
1472
  // had been the only thing left in it
1442
- if ( !jQuery.isEmptyObject(cache[ id ]) ) {
1473
+ if ( !isEmptyDataObject(cache[ id ]) ) {
1443
1474
  return;
1444
1475
  }
1445
1476
  }
@@ -1460,6 +1491,13 @@ jQuery.extend({
1460
1491
  // data if it existed
1461
1492
  if ( internalCache ) {
1462
1493
  cache[ id ] = {};
1494
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1495
+ // metadata on plain JS objects when the object is serialized using
1496
+ // JSON.stringify
1497
+ if ( !isNode ) {
1498
+ cache[ id ].toJSON = jQuery.noop;
1499
+ }
1500
+
1463
1501
  cache[ id ][ internalKey ] = internalCache;
1464
1502
 
1465
1503
  // Otherwise, we need to eliminate the expando on the node to avoid
@@ -1588,6 +1626,19 @@ function dataAttr( elem, key, data ) {
1588
1626
  return data;
1589
1627
  }
1590
1628
 
1629
+ // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1630
+ // property to be considered empty objects; this property always exists in
1631
+ // order to make sure JSON.stringify does not expose internal metadata
1632
+ function isEmptyDataObject( obj ) {
1633
+ for ( var name in obj ) {
1634
+ if ( name !== "toJSON" ) {
1635
+ return false;
1636
+ }
1637
+ }
1638
+
1639
+ return true;
1640
+ }
1641
+
1591
1642
 
1592
1643
 
1593
1644
 
@@ -1888,6 +1939,11 @@ jQuery.fn.extend({
1888
1939
  }
1889
1940
  }
1890
1941
 
1942
+ // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
1943
+ if ( one && !values.length && options.length ) {
1944
+ return jQuery( options[ index ] ).val();
1945
+ }
1946
+
1891
1947
  return values;
1892
1948
  }
1893
1949
 
@@ -2081,8 +2137,7 @@ var rnamespaces = /\.(.*)$/,
2081
2137
  rescape = /[^\w\s.|`]/g,
2082
2138
  fcleanup = function( nm ) {
2083
2139
  return nm.replace(rescape, "\\$&");
2084
- },
2085
- eventKey = "events";
2140
+ };
2086
2141
 
2087
2142
  /*
2088
2143
  * A number of helper functions used for managing events.
@@ -2098,17 +2153,22 @@ jQuery.event = {
2098
2153
  return;
2099
2154
  }
2100
2155
 
2101
- // For whatever reason, IE has trouble passing the window object
2102
- // around, causing it to be cloned in the process
2103
- if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
2104
- elem = window;
2156
+ // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
2157
+ // Minor release fix for bug #8018
2158
+ try {
2159
+ // For whatever reason, IE has trouble passing the window object
2160
+ // around, causing it to be cloned in the process
2161
+ if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
2162
+ elem = window;
2163
+ }
2105
2164
  }
2165
+ catch ( e ) {}
2106
2166
 
2107
2167
  if ( handler === false ) {
2108
2168
  handler = returnFalse;
2109
2169
  } else if ( !handler ) {
2110
2170
  // Fixes bug #7229. Fix recommended by jdalton
2111
- return;
2171
+ return;
2112
2172
  }
2113
2173
 
2114
2174
  var handleObjIn, handleObj;
@@ -2132,31 +2192,18 @@ jQuery.event = {
2132
2192
  return;
2133
2193
  }
2134
2194
 
2135
- var events = elemData[ eventKey ],
2195
+ var events = elemData.events,
2136
2196
  eventHandle = elemData.handle;
2137
2197
 
2138
- if ( typeof events === "function" ) {
2139
- // On plain objects events is a fn that holds the the data
2140
- // which prevents this data from being JSON serialized
2141
- // the function does not need to be called, it just contains the data
2142
- eventHandle = events.handle;
2143
- events = events.events;
2144
-
2145
- } else if ( !events ) {
2146
- if ( !elem.nodeType ) {
2147
- // On plain objects, create a fn that acts as the holder
2148
- // of the values to avoid JSON serialization of event data
2149
- elemData[ eventKey ] = elemData = function(){};
2150
- }
2151
-
2198
+ if ( !events ) {
2152
2199
  elemData.events = events = {};
2153
2200
  }
2154
2201
 
2155
2202
  if ( !eventHandle ) {
2156
- elemData.handle = eventHandle = function() {
2203
+ elemData.handle = eventHandle = function( e ) {
2157
2204
  // Handle the second event of a trigger and when
2158
2205
  // an event is called after a page has unloaded
2159
- return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
2206
+ return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
2160
2207
  jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2161
2208
  undefined;
2162
2209
  };
@@ -2249,17 +2296,12 @@ jQuery.event = {
2249
2296
 
2250
2297
  var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2251
2298
  elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2252
- events = elemData && elemData[ eventKey ];
2299
+ events = elemData && elemData.events;
2253
2300
 
2254
2301
  if ( !elemData || !events ) {
2255
2302
  return;
2256
2303
  }
2257
2304
 
2258
- if ( typeof events === "function" ) {
2259
- elemData = events;
2260
- events = events.events;
2261
- }
2262
-
2263
2305
  // types is actually an event object here
2264
2306
  if ( types && types.type ) {
2265
2307
  handler = types.handler;
@@ -2306,7 +2348,7 @@ jQuery.event = {
2306
2348
  for ( j = 0; j < eventType.length; j++ ) {
2307
2349
  handleObj = eventType[ j ];
2308
2350
 
2309
- if ( handleObj && (all || namespace.test( handleObj.namespace )) ) {
2351
+ if ( all || namespace.test( handleObj.namespace ) ) {
2310
2352
  jQuery.event.remove( elem, origType, handleObj.handler, j );
2311
2353
  eventType.splice( j--, 1 );
2312
2354
  }
@@ -2359,10 +2401,7 @@ jQuery.event = {
2359
2401
  delete elemData.events;
2360
2402
  delete elemData.handle;
2361
2403
 
2362
- if ( typeof elemData === "function" ) {
2363
- jQuery.removeData( elem, eventKey, true );
2364
-
2365
- } else if ( jQuery.isEmptyObject( elemData ) ) {
2404
+ if ( jQuery.isEmptyObject( elemData ) ) {
2366
2405
  jQuery.removeData( elem, undefined, true );
2367
2406
  }
2368
2407
  }
@@ -2403,7 +2442,7 @@ jQuery.event = {
2403
2442
  // points to jQuery.expando
2404
2443
  var internalKey = jQuery.expando,
2405
2444
  internalCache = this[ internalKey ];
2406
- if ( internalCache && internalCache.events && internalCache.events[type] ) {
2445
+ if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
2407
2446
  jQuery.event.trigger( event, data, internalCache.handle.elem );
2408
2447
  }
2409
2448
  });
@@ -2429,9 +2468,7 @@ jQuery.event = {
2429
2468
  event.currentTarget = elem;
2430
2469
 
2431
2470
  // Trigger the event, it is assumed that "handle" is a function
2432
- var handle = elem.nodeType ?
2433
- jQuery._data( elem, "handle" ) :
2434
- (jQuery._data( elem, eventKey ) || {}).handle;
2471
+ var handle = jQuery._data( elem, "handle" );
2435
2472
 
2436
2473
  if ( handle ) {
2437
2474
  handle.apply( elem, data );
@@ -2473,7 +2510,7 @@ jQuery.event = {
2473
2510
  target[ "on" + targetType ] = null;
2474
2511
  }
2475
2512
 
2476
- jQuery.event.triggered = true;
2513
+ jQuery.event.triggered = event.type;
2477
2514
  target[ targetType ]();
2478
2515
  }
2479
2516
 
@@ -2484,7 +2521,7 @@ jQuery.event = {
2484
2521
  target[ "on" + targetType ] = old;
2485
2522
  }
2486
2523
 
2487
- jQuery.event.triggered = false;
2524
+ jQuery.event.triggered = undefined;
2488
2525
  }
2489
2526
  }
2490
2527
  },
@@ -2509,11 +2546,7 @@ jQuery.event = {
2509
2546
 
2510
2547
  event.namespace = event.namespace || namespace_sort.join(".");
2511
2548
 
2512
- events = jQuery._data(this, eventKey);
2513
-
2514
- if ( typeof events === "function" ) {
2515
- events = events.events;
2516
- }
2549
+ events = jQuery._data(this, "events");
2517
2550
 
2518
2551
  handlers = (events || {})[ event.type ];
2519
2552
 
@@ -2680,7 +2713,7 @@ jQuery.Event = function( src ) {
2680
2713
 
2681
2714
  // Events bubbling up the document may have been marked as prevented
2682
2715
  // by a handler lower down the tree; reflect the correct value.
2683
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
2716
+ this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
2684
2717
  src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
2685
2718
 
2686
2719
  // Event type
@@ -2755,6 +2788,12 @@ var withinElement = function( event ) {
2755
2788
  // Firefox sometimes assigns relatedTarget a XUL element
2756
2789
  // which we cannot access the parentNode property of
2757
2790
  try {
2791
+
2792
+ // Chrome does something similar, the parentNode property
2793
+ // can be accessed but is null.
2794
+ if ( parent && parent !== document && !parent.parentNode ) {
2795
+ return;
2796
+ }
2758
2797
  // Traverse up the tree
2759
2798
  while ( parent && parent !== this ) {
2760
2799
  parent = parent.parentNode;
@@ -2805,8 +2844,7 @@ if ( !jQuery.support.submitBubbles ) {
2805
2844
  type = elem.type;
2806
2845
 
2807
2846
  if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
2808
- e.liveFired = undefined;
2809
- return trigger( "submit", this, arguments );
2847
+ trigger( "submit", this, arguments );
2810
2848
  }
2811
2849
  });
2812
2850
 
@@ -2815,8 +2853,7 @@ if ( !jQuery.support.submitBubbles ) {
2815
2853
  type = elem.type;
2816
2854
 
2817
2855
  if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
2818
- e.liveFired = undefined;
2819
- return trigger( "submit", this, arguments );
2856
+ trigger( "submit", this, arguments );
2820
2857
  }
2821
2858
  });
2822
2859
 
@@ -2879,7 +2916,7 @@ if ( !jQuery.support.changeBubbles ) {
2879
2916
  if ( data != null || val ) {
2880
2917
  e.type = "change";
2881
2918
  e.liveFired = undefined;
2882
- return jQuery.event.trigger( e, arguments[1], elem );
2919
+ jQuery.event.trigger( e, arguments[1], elem );
2883
2920
  }
2884
2921
  };
2885
2922
 
@@ -2893,7 +2930,7 @@ if ( !jQuery.support.changeBubbles ) {
2893
2930
  var elem = e.target, type = elem.type;
2894
2931
 
2895
2932
  if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
2896
- return testChange.call( this, e );
2933
+ testChange.call( this, e );
2897
2934
  }
2898
2935
  },
2899
2936
 
@@ -2905,7 +2942,7 @@ if ( !jQuery.support.changeBubbles ) {
2905
2942
  if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
2906
2943
  (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
2907
2944
  type === "select-multiple" ) {
2908
- return testChange.call( this, e );
2945
+ testChange.call( this, e );
2909
2946
  }
2910
2947
  },
2911
2948
 
@@ -2944,26 +2981,50 @@ if ( !jQuery.support.changeBubbles ) {
2944
2981
  }
2945
2982
 
2946
2983
  function trigger( type, elem, args ) {
2947
- args[0].type = type;
2948
- return jQuery.event.handle.apply( elem, args );
2984
+ // Piggyback on a donor event to simulate a different one.
2985
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
2986
+ // simulated event prevents default then we do the same on the donor.
2987
+ // Don't pass args or remember liveFired; they apply to the donor event.
2988
+ var event = jQuery.extend( {}, args[ 0 ] );
2989
+ event.type = type;
2990
+ event.originalEvent = {};
2991
+ event.liveFired = undefined;
2992
+ jQuery.event.handle.call( elem, event );
2993
+ if ( event.isDefaultPrevented() ) {
2994
+ args[ 0 ].preventDefault();
2995
+ }
2949
2996
  }
2950
2997
 
2951
2998
  // Create "bubbling" focus and blur events
2952
2999
  if ( document.addEventListener ) {
2953
3000
  jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3001
+
3002
+ // Attach a single capturing handler while someone wants focusin/focusout
3003
+ var attaches = 0;
3004
+
2954
3005
  jQuery.event.special[ fix ] = {
2955
3006
  setup: function() {
2956
- this.addEventListener( orig, handler, true );
2957
- },
2958
- teardown: function() {
2959
- this.removeEventListener( orig, handler, true );
3007
+ if ( attaches++ === 0 ) {
3008
+ document.addEventListener( orig, handler, true );
3009
+ }
3010
+ },
3011
+ teardown: function() {
3012
+ if ( --attaches === 0 ) {
3013
+ document.removeEventListener( orig, handler, true );
3014
+ }
2960
3015
  }
2961
3016
  };
2962
3017
 
2963
- function handler( e ) {
2964
- e = jQuery.event.fix( e );
3018
+ function handler( donor ) {
3019
+ // Donor event is always a native one; fix it and switch its type.
3020
+ // Let focusin/out handler cancel the donor focus/blur event.
3021
+ var e = jQuery.event.fix( donor );
2965
3022
  e.type = fix;
2966
- return jQuery.event.handle.call( this, e );
3023
+ e.originalEvent = {};
3024
+ jQuery.event.trigger( e, null, e.target );
3025
+ if ( e.isDefaultPrevented() ) {
3026
+ donor.preventDefault();
3027
+ }
2967
3028
  }
2968
3029
  });
2969
3030
  }
@@ -3148,11 +3209,7 @@ function liveHandler( event ) {
3148
3209
  var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
3149
3210
  elems = [],
3150
3211
  selectors = [],
3151
- events = jQuery._data( this, eventKey );
3152
-
3153
- if ( typeof events === "function" ) {
3154
- events = events.events;
3155
- }
3212
+ events = jQuery._data( this, "events" );
3156
3213
 
3157
3214
  // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
3158
3215
  if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
@@ -3186,7 +3243,7 @@ function liveHandler( event ) {
3186
3243
  for ( j = 0; j < live.length; j++ ) {
3187
3244
  handleObj = live[j];
3188
3245
 
3189
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
3246
+ if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
3190
3247
  elem = close.elem;
3191
3248
  related = null;
3192
3249
 
@@ -3269,7 +3326,9 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[
3269
3326
  done = 0,
3270
3327
  toString = Object.prototype.toString,
3271
3328
  hasDuplicate = false,
3272
- baseHasDuplicate = true;
3329
+ baseHasDuplicate = true,
3330
+ rBackslash = /\\/g,
3331
+ rNonWord = /\W/;
3273
3332
 
3274
3333
  // Here we check if the JavaScript engine is using some sort of
3275
3334
  // optimization where it does not always call our comparision
@@ -3468,7 +3527,7 @@ Sizzle.find = function( expr, context, isXML ) {
3468
3527
  match.splice( 1, 1 );
3469
3528
 
3470
3529
  if ( left.substr( left.length - 1 ) !== "\\" ) {
3471
- match[1] = (match[1] || "").replace(/\\/g, "");
3530
+ match[1] = (match[1] || "").replace( rBackslash, "" );
3472
3531
  set = Expr.find[ type ]( match, context, isXML );
3473
3532
 
3474
3533
  if ( set != null ) {
@@ -3607,13 +3666,16 @@ var Expr = Sizzle.selectors = {
3607
3666
  attrHandle: {
3608
3667
  href: function( elem ) {
3609
3668
  return elem.getAttribute( "href" );
3669
+ },
3670
+ type: function( elem ) {
3671
+ return elem.getAttribute( "type" );
3610
3672
  }
3611
3673
  },
3612
3674
 
3613
3675
  relative: {
3614
3676
  "+": function(checkSet, part){
3615
3677
  var isPartStr = typeof part === "string",
3616
- isTag = isPartStr && !/\W/.test( part ),
3678
+ isTag = isPartStr && !rNonWord.test( part ),
3617
3679
  isPartStrNotTag = isPartStr && !isTag;
3618
3680
 
3619
3681
  if ( isTag ) {
@@ -3641,7 +3703,7 @@ var Expr = Sizzle.selectors = {
3641
3703
  i = 0,
3642
3704
  l = checkSet.length;
3643
3705
 
3644
- if ( isPartStr && !/\W/.test( part ) ) {
3706
+ if ( isPartStr && !rNonWord.test( part ) ) {
3645
3707
  part = part.toLowerCase();
3646
3708
 
3647
3709
  for ( ; i < l; i++ ) {
@@ -3675,7 +3737,7 @@ var Expr = Sizzle.selectors = {
3675
3737
  doneName = done++,
3676
3738
  checkFn = dirCheck;
3677
3739
 
3678
- if ( typeof part === "string" && !/\W/.test(part) ) {
3740
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
3679
3741
  part = part.toLowerCase();
3680
3742
  nodeCheck = part;
3681
3743
  checkFn = dirNodeCheck;
@@ -3689,7 +3751,7 @@ var Expr = Sizzle.selectors = {
3689
3751
  doneName = done++,
3690
3752
  checkFn = dirCheck;
3691
3753
 
3692
- if ( typeof part === "string" && !/\W/.test( part ) ) {
3754
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
3693
3755
  part = part.toLowerCase();
3694
3756
  nodeCheck = part;
3695
3757
  checkFn = dirNodeCheck;
@@ -3732,7 +3794,7 @@ var Expr = Sizzle.selectors = {
3732
3794
  },
3733
3795
  preFilter: {
3734
3796
  CLASS: function( match, curLoop, inplace, result, not, isXML ) {
3735
- match = " " + match[1].replace(/\\/g, "") + " ";
3797
+ match = " " + match[1].replace( rBackslash, "" ) + " ";
3736
3798
 
3737
3799
  if ( isXML ) {
3738
3800
  return match;
@@ -3755,11 +3817,11 @@ var Expr = Sizzle.selectors = {
3755
3817
  },
3756
3818
 
3757
3819
  ID: function( match ) {
3758
- return match[1].replace(/\\/g, "");
3820
+ return match[1].replace( rBackslash, "" );
3759
3821
  },
3760
3822
 
3761
3823
  TAG: function( match, curLoop ) {
3762
- return match[1].toLowerCase();
3824
+ return match[1].replace( rBackslash, "" ).toLowerCase();
3763
3825
  },
3764
3826
 
3765
3827
  CHILD: function( match ) {
@@ -3790,14 +3852,14 @@ var Expr = Sizzle.selectors = {
3790
3852
  },
3791
3853
 
3792
3854
  ATTR: function( match, curLoop, inplace, result, not, isXML ) {
3793
- var name = match[1] = match[1].replace(/\\/g, "");
3855
+ var name = match[1] = match[1].replace( rBackslash, "" );
3794
3856
 
3795
3857
  if ( !isXML && Expr.attrMap[name] ) {
3796
3858
  match[1] = Expr.attrMap[name];
3797
3859
  }
3798
3860
 
3799
3861
  // Handle if an un-quoted value was used
3800
- match[4] = ( match[4] || match[5] || "" ).replace(/\\/g, "");
3862
+ match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
3801
3863
 
3802
3864
  if ( match[2] === "~=" ) {
3803
3865
  match[4] = " " + match[4] + " ";
@@ -3852,7 +3914,9 @@ var Expr = Sizzle.selectors = {
3852
3914
  selected: function( elem ) {
3853
3915
  // Accessing this property makes selected-by-default
3854
3916
  // options in Safari work properly
3855
- elem.parentNode.selectedIndex;
3917
+ if ( elem.parentNode ) {
3918
+ elem.parentNode.selectedIndex;
3919
+ }
3856
3920
 
3857
3921
  return elem.selected === true;
3858
3922
  },
@@ -3874,8 +3938,12 @@ var Expr = Sizzle.selectors = {
3874
3938
  },
3875
3939
 
3876
3940
  text: function( elem ) {
3877
- return "text" === elem.type;
3941
+ var attr = elem.getAttribute( "type" ), type = elem.type;
3942
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
3943
+ // use getAttribute instead to test this case
3944
+ return "text" === type && ( attr === type || attr === null );
3878
3945
  },
3946
+
3879
3947
  radio: function( elem ) {
3880
3948
  return "radio" === elem.type;
3881
3949
  },
@@ -4407,7 +4475,8 @@ if ( document.querySelectorAll ) {
4407
4475
  // and working up from there (Thanks to Andrew Dupont for the technique)
4408
4476
  // IE 8 doesn't work on object elements
4409
4477
  } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
4410
- var old = context.getAttribute( "id" ),
4478
+ var oldContext = context,
4479
+ old = context.getAttribute( "id" ),
4411
4480
  nid = old || id,
4412
4481
  hasParent = context.parentNode,
4413
4482
  relativeHierarchySelector = /^\s*[+~]/.test( query );
@@ -4429,7 +4498,7 @@ if ( document.querySelectorAll ) {
4429
4498
  } catch(pseudoError) {
4430
4499
  } finally {
4431
4500
  if ( !old ) {
4432
- context.removeAttribute( "id" );
4501
+ oldContext.removeAttribute( "id" );
4433
4502
  }
4434
4503
  }
4435
4504
  }
@@ -4449,19 +4518,23 @@ if ( document.querySelectorAll ) {
4449
4518
 
4450
4519
  (function(){
4451
4520
  var html = document.documentElement,
4452
- matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
4453
- pseudoWorks = false;
4521
+ matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
4454
4522
 
4455
- try {
4456
- // This should fail with an exception
4457
- // Gecko does not error, returns false instead
4458
- matches.call( document.documentElement, "[test!='']:sizzle" );
4523
+ if ( matches ) {
4524
+ // Check to see if it's possible to do matchesSelector
4525
+ // on a disconnected node (IE 9 fails this)
4526
+ var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
4527
+ pseudoWorks = false;
4528
+
4529
+ try {
4530
+ // This should fail with an exception
4531
+ // Gecko does not error, returns false instead
4532
+ matches.call( document.documentElement, "[test!='']:sizzle" );
4459
4533
 
4460
- } catch( pseudoError ) {
4461
- pseudoWorks = true;
4462
- }
4534
+ } catch( pseudoError ) {
4535
+ pseudoWorks = true;
4536
+ }
4463
4537
 
4464
- if ( matches ) {
4465
4538
  Sizzle.matchesSelector = function( node, expr ) {
4466
4539
  // Make sure that attribute selectors are quoted
4467
4540
  expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
@@ -4469,7 +4542,15 @@ if ( document.querySelectorAll ) {
4469
4542
  if ( !Sizzle.isXML( node ) ) {
4470
4543
  try {
4471
4544
  if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
4472
- return matches.call( node, expr );
4545
+ var ret = matches.call( node, expr );
4546
+
4547
+ // IE 9's matchesSelector returns false on disconnected nodes
4548
+ if ( ret || !disconnectedMatch ||
4549
+ // As well, disconnected nodes are said to be in a document
4550
+ // fragment in IE 9, so check for that
4551
+ node.document && node.document.nodeType !== 11 ) {
4552
+ return ret;
4553
+ }
4473
4554
  }
4474
4555
  } catch(e) {}
4475
4556
  }
@@ -4845,11 +4926,11 @@ jQuery.each({
4845
4926
  }, function( name, fn ) {
4846
4927
  jQuery.fn[ name ] = function( until, selector ) {
4847
4928
  var ret = jQuery.map( this, fn, until ),
4848
- // The variable 'args' was introduced in
4849
- // https://github.com/jquery/jquery/commit/52a0238
4850
- // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
4851
- // http://code.google.com/p/v8/issues/detail?id=1050
4852
- args = slice.call(arguments);
4929
+ // The variable 'args' was introduced in
4930
+ // https://github.com/jquery/jquery/commit/52a0238
4931
+ // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
4932
+ // http://code.google.com/p/v8/issues/detail?id=1050
4933
+ args = slice.call(arguments);
4853
4934
 
4854
4935
  if ( !runtil.test( name ) ) {
4855
4936
  selector = until;
@@ -4959,7 +5040,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
4959
5040
  rtbody = /<tbody/i,
4960
5041
  rhtml = /<|&#?\w+;/,
4961
5042
  rnocache = /<(?:script|object|embed|option|style)/i,
4962
- // checked="checked" or checked (html5)
5043
+ // checked="checked" or checked
4963
5044
  rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
4964
5045
  wrapMap = {
4965
5046
  option: [ 1, "<select multiple='multiple'>", "</select>" ],
@@ -5111,7 +5192,7 @@ jQuery.fn.extend({
5111
5192
  }
5112
5193
 
5113
5194
  if ( elem.parentNode ) {
5114
- elem.parentNode.removeChild( elem );
5195
+ elem.parentNode.removeChild( elem );
5115
5196
  }
5116
5197
  }
5117
5198
  }
@@ -5136,7 +5217,7 @@ jQuery.fn.extend({
5136
5217
  },
5137
5218
 
5138
5219
  clone: function( dataAndEvents, deepDataAndEvents ) {
5139
- dataAndEvents = dataAndEvents == null ? true : dataAndEvents;
5220
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5140
5221
  deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5141
5222
 
5142
5223
  return this.map( function () {
@@ -5213,7 +5294,9 @@ jQuery.fn.extend({
5213
5294
  }
5214
5295
  });
5215
5296
  } else {
5216
- return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
5297
+ return this.length ?
5298
+ this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5299
+ this;
5217
5300
  }
5218
5301
  },
5219
5302
 
@@ -5305,8 +5388,8 @@ function cloneCopyEvent( src, dest ) {
5305
5388
  }
5306
5389
 
5307
5390
  var internalKey = jQuery.expando,
5308
- oldData = jQuery.data( src ),
5309
- curData = jQuery.data( dest, oldData );
5391
+ oldData = jQuery.data( src ),
5392
+ curData = jQuery.data( dest, oldData );
5310
5393
 
5311
5394
  // Switch to use the internal data object, if it exists, for the next
5312
5395
  // stage of data copying
@@ -5320,7 +5403,7 @@ function cloneCopyEvent( src, dest ) {
5320
5403
 
5321
5404
  for ( var type in events ) {
5322
5405
  for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
5323
- jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data );
5406
+ jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5324
5407
  }
5325
5408
  }
5326
5409
  }
@@ -5441,6 +5524,18 @@ jQuery.each({
5441
5524
  };
5442
5525
  });
5443
5526
 
5527
+ function getAll( elem ) {
5528
+ if ( "getElementsByTagName" in elem ) {
5529
+ return elem.getElementsByTagName( "*" );
5530
+
5531
+ } else if ( "querySelectorAll" in elem ) {
5532
+ return elem.querySelectorAll( "*" );
5533
+
5534
+ } else {
5535
+ return [];
5536
+ }
5537
+ }
5538
+
5444
5539
  jQuery.extend({
5445
5540
  clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5446
5541
  var clone = elem.cloneNode(true),
@@ -5448,17 +5543,20 @@ jQuery.extend({
5448
5543
  destElements,
5449
5544
  i;
5450
5545
 
5451
- if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
5546
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
5547
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
5452
5548
  // IE copies events bound via attachEvent when using cloneNode.
5453
5549
  // Calling detachEvent on the clone will also remove the events
5454
5550
  // from the original. In order to get around this, we use some
5455
5551
  // proprietary methods to clear the events. Thanks to MooTools
5456
5552
  // guys for this hotness.
5457
5553
 
5554
+ cloneFixAttributes( elem, clone );
5555
+
5458
5556
  // Using Sizzle here is crazy slow, so we use getElementsByTagName
5459
5557
  // instead
5460
- srcElements = elem.getElementsByTagName("*");
5461
- destElements = clone.getElementsByTagName("*");
5558
+ srcElements = getAll( elem );
5559
+ destElements = getAll( clone );
5462
5560
 
5463
5561
  // Weird iteration because IE will replace the length property
5464
5562
  // with an element if you are cloning the body and one of the
@@ -5466,30 +5564,25 @@ jQuery.extend({
5466
5564
  for ( i = 0; srcElements[i]; ++i ) {
5467
5565
  cloneFixAttributes( srcElements[i], destElements[i] );
5468
5566
  }
5469
-
5470
- cloneFixAttributes( elem, clone );
5471
5567
  }
5472
5568
 
5473
5569
  // Copy the events from the original to the clone
5474
5570
  if ( dataAndEvents ) {
5475
-
5476
5571
  cloneCopyEvent( elem, clone );
5477
5572
 
5478
- if ( deepDataAndEvents && "getElementsByTagName" in elem ) {
5573
+ if ( deepDataAndEvents ) {
5574
+ srcElements = getAll( elem );
5575
+ destElements = getAll( clone );
5479
5576
 
5480
- srcElements = elem.getElementsByTagName("*");
5481
- destElements = clone.getElementsByTagName("*");
5482
-
5483
- if ( srcElements.length ) {
5484
- for ( i = 0; srcElements[i]; ++i ) {
5485
- cloneCopyEvent( srcElements[i], destElements[i] );
5486
- }
5577
+ for ( i = 0; srcElements[i]; ++i ) {
5578
+ cloneCopyEvent( srcElements[i], destElements[i] );
5487
5579
  }
5488
5580
  }
5489
5581
  }
5582
+
5490
5583
  // Return the cloned set
5491
5584
  return clone;
5492
- },
5585
+ },
5493
5586
  clean: function( elems, context, fragment, scripts ) {
5494
5587
  context = context || document;
5495
5588
 
@@ -5650,7 +5743,8 @@ function evalScript( i, elem ) {
5650
5743
  var ralpha = /alpha\([^)]*\)/i,
5651
5744
  ropacity = /opacity=([^)]*)/,
5652
5745
  rdashAlpha = /-([a-z])/ig,
5653
- rupper = /([A-Z])/g,
5746
+ // fixed for IE9, see #8346
5747
+ rupper = /([A-Z]|^ms)/g,
5654
5748
  rnumpx = /^-?\d+(?:px)?$/i,
5655
5749
  rnum = /^-?\d/,
5656
5750
 
@@ -5887,6 +5981,28 @@ if ( !jQuery.support.opacity ) {
5887
5981
  };
5888
5982
  }
5889
5983
 
5984
+ jQuery(function() {
5985
+ // This hook cannot be added until DOM ready because the support test
5986
+ // for it is not run until after DOM ready
5987
+ if ( !jQuery.support.reliableMarginRight ) {
5988
+ jQuery.cssHooks.marginRight = {
5989
+ get: function( elem, computed ) {
5990
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
5991
+ // Work around by temporarily setting element display to inline-block
5992
+ var ret;
5993
+ jQuery.swap( elem, { "display": "inline-block" }, function() {
5994
+ if ( computed ) {
5995
+ ret = curCSS( elem, "margin-right", "marginRight" );
5996
+ } else {
5997
+ ret = elem.style.marginRight;
5998
+ }
5999
+ });
6000
+ return ret;
6001
+ }
6002
+ };
6003
+ }
6004
+ });
6005
+
5890
6006
  if ( document.defaultView && document.defaultView.getComputedStyle ) {
5891
6007
  getComputedStyle = function( elem, newName, name ) {
5892
6008
  var ret, defaultView, computedStyle;
@@ -5910,7 +6026,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
5910
6026
 
5911
6027
  if ( document.documentElement.currentStyle ) {
5912
6028
  currentStyle = function( elem, name ) {
5913
- var left,
6029
+ var left,
5914
6030
  ret = elem.currentStyle && elem.currentStyle[ name ],
5915
6031
  rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
5916
6032
  style = elem.style;
@@ -5988,8 +6104,10 @@ var r20 = /%20/g,
5988
6104
  rbracket = /\[\]$/,
5989
6105
  rCRLF = /\r?\n/g,
5990
6106
  rhash = /#.*$/,
5991
- rheaders = /^(.*?):\s*(.*?)\r?$/mg, // IE leaves an \r character at EOL
6107
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
5992
6108
  rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6109
+ // #7653, #8125, #8152: local protocol detection
6110
+ rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
5993
6111
  rnoContent = /^(?:GET|HEAD)$/,
5994
6112
  rprotocol = /^\/\//,
5995
6113
  rquery = /\?/,
@@ -5997,7 +6115,11 @@ var r20 = /%20/g,
5997
6115
  rselectTextarea = /^(?:select|textarea)/i,
5998
6116
  rspacesAjax = /\s+/,
5999
6117
  rts = /([?&])_=[^&]*/,
6000
- rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/,
6118
+ rucHeaders = /(^|\-)([a-z])/g,
6119
+ rucHeadersFunc = function( _, $1, $2 ) {
6120
+ return $1 + $2.toUpperCase();
6121
+ },
6122
+ rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6001
6123
 
6002
6124
  // Keep a copy of the old load method
6003
6125
  _load = jQuery.fn.load,
@@ -6018,7 +6140,28 @@ var r20 = /%20/g,
6018
6140
  * 2) the catchall symbol "*" can be used
6019
6141
  * 3) selection will start with transport dataType and THEN go to "*" if needed
6020
6142
  */
6021
- transports = {};
6143
+ transports = {},
6144
+
6145
+ // Document location
6146
+ ajaxLocation,
6147
+
6148
+ // Document location segments
6149
+ ajaxLocParts;
6150
+
6151
+ // #8138, IE may throw an exception when accessing
6152
+ // a field from document.location if document.domain has been set
6153
+ try {
6154
+ ajaxLocation = document.location.href;
6155
+ } catch( e ) {
6156
+ // Use the href attribute of an A element
6157
+ // since IE will modify it given document.location
6158
+ ajaxLocation = document.createElement( "a" );
6159
+ ajaxLocation.href = "";
6160
+ ajaxLocation = ajaxLocation.href;
6161
+ }
6162
+
6163
+ // Segment location into parts
6164
+ ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
6022
6165
 
6023
6166
  // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6024
6167
  function addToPrefiltersOrTransports( structure ) {
@@ -6057,7 +6200,7 @@ function addToPrefiltersOrTransports( structure ) {
6057
6200
  }
6058
6201
 
6059
6202
  //Base inspection function for prefilters and transports
6060
- function inspectPrefiltersOrTransports( structure, options, originalOptions, jXHR,
6203
+ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6061
6204
  dataType /* internal */, inspected /* internal */ ) {
6062
6205
 
6063
6206
  dataType = dataType || options.dataTypes[ 0 ];
@@ -6072,16 +6215,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
6072
6215
  selection;
6073
6216
 
6074
6217
  for(; i < length && ( executeOnly || !selection ); i++ ) {
6075
- selection = list[ i ]( options, originalOptions, jXHR );
6218
+ selection = list[ i ]( options, originalOptions, jqXHR );
6076
6219
  // If we got redirected to another dataType
6077
- // we try there if not done already
6220
+ // we try there if executing only and not done already
6078
6221
  if ( typeof selection === "string" ) {
6079
- if ( inspected[ selection ] ) {
6222
+ if ( !executeOnly || inspected[ selection ] ) {
6080
6223
  selection = undefined;
6081
6224
  } else {
6082
6225
  options.dataTypes.unshift( selection );
6083
6226
  selection = inspectPrefiltersOrTransports(
6084
- structure, options, originalOptions, jXHR, selection, inspected );
6227
+ structure, options, originalOptions, jqXHR, selection, inspected );
6085
6228
  }
6086
6229
  }
6087
6230
  }
@@ -6089,7 +6232,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
6089
6232
  // we try the catchall dataType if not done already
6090
6233
  if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6091
6234
  selection = inspectPrefiltersOrTransports(
6092
- structure, options, originalOptions, jXHR, "*", inspected );
6235
+ structure, options, originalOptions, jqXHR, "*", inspected );
6093
6236
  }
6094
6237
  // unnecessary when only executing (prefilters)
6095
6238
  // but it'll be ignored by the caller in that case
@@ -6121,7 +6264,7 @@ jQuery.fn.extend({
6121
6264
  if ( jQuery.isFunction( params ) ) {
6122
6265
  // We assume that it's the callback
6123
6266
  callback = params;
6124
- params = null;
6267
+ params = undefined;
6125
6268
 
6126
6269
  // Otherwise, build a param string
6127
6270
  } else if ( typeof params === "object" ) {
@@ -6139,14 +6282,14 @@ jQuery.fn.extend({
6139
6282
  dataType: "html",
6140
6283
  data: params,
6141
6284
  // Complete callback (responseText is used internally)
6142
- complete: function( jXHR, status, responseText ) {
6143
- // Store the response as specified by the jXHR object
6144
- responseText = jXHR.responseText;
6285
+ complete: function( jqXHR, status, responseText ) {
6286
+ // Store the response as specified by the jqXHR object
6287
+ responseText = jqXHR.responseText;
6145
6288
  // If successful, inject the HTML into all the matched elements
6146
- if ( jXHR.isResolved() ) {
6289
+ if ( jqXHR.isResolved() ) {
6147
6290
  // #4825: Get the actual response in case
6148
6291
  // a dataFilter is present in ajaxSettings
6149
- jXHR.done(function( r ) {
6292
+ jqXHR.done(function( r ) {
6150
6293
  responseText = r;
6151
6294
  });
6152
6295
  // See if a selector was specified
@@ -6165,7 +6308,7 @@ jQuery.fn.extend({
6165
6308
  }
6166
6309
 
6167
6310
  if ( callback ) {
6168
- self.each( callback, [ responseText, status, jXHR ] );
6311
+ self.each( callback, [ responseText, status, jqXHR ] );
6169
6312
  }
6170
6313
  }
6171
6314
  });
@@ -6213,7 +6356,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
6213
6356
  if ( jQuery.isFunction( data ) ) {
6214
6357
  type = type || callback;
6215
6358
  callback = data;
6216
- data = null;
6359
+ data = undefined;
6217
6360
  }
6218
6361
 
6219
6362
  return jQuery.ajax({
@@ -6229,22 +6372,39 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
6229
6372
  jQuery.extend({
6230
6373
 
6231
6374
  getScript: function( url, callback ) {
6232
- return jQuery.get( url, null, callback, "script" );
6375
+ return jQuery.get( url, undefined, callback, "script" );
6233
6376
  },
6234
6377
 
6235
6378
  getJSON: function( url, data, callback ) {
6236
6379
  return jQuery.get( url, data, callback, "json" );
6237
6380
  },
6238
6381
 
6239
- ajaxSetup: function( settings ) {
6240
- jQuery.extend( true, jQuery.ajaxSettings, settings );
6241
- if ( settings.context ) {
6242
- jQuery.ajaxSettings.context = settings.context;
6382
+ // Creates a full fledged settings object into target
6383
+ // with both ajaxSettings and settings fields.
6384
+ // If target is omitted, writes into ajaxSettings.
6385
+ ajaxSetup: function ( target, settings ) {
6386
+ if ( !settings ) {
6387
+ // Only one parameter, we extend ajaxSettings
6388
+ settings = target;
6389
+ target = jQuery.extend( true, jQuery.ajaxSettings, settings );
6390
+ } else {
6391
+ // target was provided, we extend into it
6392
+ jQuery.extend( true, target, jQuery.ajaxSettings, settings );
6243
6393
  }
6394
+ // Flatten fields we don't want deep extended
6395
+ for( var field in { context: 1, url: 1 } ) {
6396
+ if ( field in settings ) {
6397
+ target[ field ] = settings[ field ];
6398
+ } else if( field in jQuery.ajaxSettings ) {
6399
+ target[ field ] = jQuery.ajaxSettings[ field ];
6400
+ }
6401
+ }
6402
+ return target;
6244
6403
  },
6245
6404
 
6246
6405
  ajaxSettings: {
6247
- url: location.href,
6406
+ url: ajaxLocation,
6407
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
6248
6408
  global: true,
6249
6409
  type: "GET",
6250
6410
  contentType: "application/x-www-form-urlencoded",
@@ -6259,7 +6419,6 @@ jQuery.extend({
6259
6419
  cache: null,
6260
6420
  traditional: false,
6261
6421
  headers: {},
6262
- crossDomain: null,
6263
6422
  */
6264
6423
 
6265
6424
  accepts: {
@@ -6306,9 +6465,8 @@ jQuery.extend({
6306
6465
  // Main method
6307
6466
  ajax: function( url, options ) {
6308
6467
 
6309
- // If options is not an object,
6310
- // we simulate pre-1.5 signature
6311
- if ( typeof options !== "object" ) {
6468
+ // If url is an object, simulate pre-1.5 signature
6469
+ if ( typeof url === "object" ) {
6312
6470
  options = url;
6313
6471
  url = undefined;
6314
6472
  }
@@ -6317,19 +6475,22 @@ jQuery.extend({
6317
6475
  options = options || {};
6318
6476
 
6319
6477
  var // Create the final options object
6320
- s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ),
6321
- // Callbacks contexts
6322
- // We force the original context if it exists
6323
- // or take it from jQuery.ajaxSettings otherwise
6324
- // (plain objects used as context get extended)
6325
- callbackContext =
6326
- ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s,
6327
- globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ),
6478
+ s = jQuery.ajaxSetup( {}, options ),
6479
+ // Callbacks context
6480
+ callbackContext = s.context || s,
6481
+ // Context for global events
6482
+ // It's the callbackContext if one was provided in the options
6483
+ // and if it's a DOM node or a jQuery collection
6484
+ globalEventContext = callbackContext !== s &&
6485
+ ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
6486
+ jQuery( callbackContext ) : jQuery.event,
6328
6487
  // Deferreds
6329
6488
  deferred = jQuery.Deferred(),
6330
6489
  completeDeferred = jQuery._Deferred(),
6331
6490
  // Status-dependent callbacks
6332
6491
  statusCode = s.statusCode || {},
6492
+ // ifModified key
6493
+ ifModifiedKey,
6333
6494
  // Headers (they are sent all at once)
6334
6495
  requestHeaders = {},
6335
6496
  // Response headers
@@ -6340,22 +6501,22 @@ jQuery.extend({
6340
6501
  // timeout handle
6341
6502
  timeoutTimer,
6342
6503
  // Cross-domain detection vars
6343
- loc = document.location,
6344
- protocol = loc.protocol || "http:",
6345
6504
  parts,
6346
- // The jXHR state
6505
+ // The jqXHR state
6347
6506
  state = 0,
6507
+ // To know if global events are to be dispatched
6508
+ fireGlobals,
6348
6509
  // Loop variable
6349
6510
  i,
6350
6511
  // Fake xhr
6351
- jXHR = {
6512
+ jqXHR = {
6352
6513
 
6353
6514
  readyState: 0,
6354
6515
 
6355
6516
  // Caches the header
6356
6517
  setRequestHeader: function( name, value ) {
6357
- if ( state === 0 ) {
6358
- requestHeaders[ name.toLowerCase() ] = value;
6518
+ if ( !state ) {
6519
+ requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
6359
6520
  }
6360
6521
  return this;
6361
6522
  },
@@ -6377,7 +6538,15 @@ jQuery.extend({
6377
6538
  }
6378
6539
  match = responseHeaders[ key.toLowerCase() ];
6379
6540
  }
6380
- return match || null;
6541
+ return match === undefined ? null : match;
6542
+ },
6543
+
6544
+ // Overrides response content-type header
6545
+ overrideMimeType: function( type ) {
6546
+ if ( !state ) {
6547
+ s.mimeType = type;
6548
+ }
6549
+ return this;
6381
6550
  },
6382
6551
 
6383
6552
  // Cancel the request
@@ -6394,7 +6563,7 @@ jQuery.extend({
6394
6563
  // Callback for when everything is done
6395
6564
  // It is defined here because jslint complains if it is declared
6396
6565
  // at the end of the function (which would be more logical and readable)
6397
- function done( status, statusText, responses, headers) {
6566
+ function done( status, statusText, responses, headers ) {
6398
6567
 
6399
6568
  // Called once
6400
6569
  if ( state === 2 ) {
@@ -6410,19 +6579,19 @@ jQuery.extend({
6410
6579
  }
6411
6580
 
6412
6581
  // Dereference transport for early garbage collection
6413
- // (no matter how long the jXHR object will be used)
6582
+ // (no matter how long the jqXHR object will be used)
6414
6583
  transport = undefined;
6415
6584
 
6416
6585
  // Cache response headers
6417
6586
  responseHeadersString = headers || "";
6418
6587
 
6419
6588
  // Set readyState
6420
- jXHR.readyState = status ? 4 : 0;
6589
+ jqXHR.readyState = status ? 4 : 0;
6421
6590
 
6422
6591
  var isSuccess,
6423
6592
  success,
6424
6593
  error,
6425
- response = responses ? ajaxHandleResponses( s, jXHR, responses ) : undefined,
6594
+ response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
6426
6595
  lastModified,
6427
6596
  etag;
6428
6597
 
@@ -6432,11 +6601,11 @@ jQuery.extend({
6432
6601
  // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6433
6602
  if ( s.ifModified ) {
6434
6603
 
6435
- if ( ( lastModified = jXHR.getResponseHeader( "Last-Modified" ) ) ) {
6436
- jQuery.lastModified[ s.url ] = lastModified;
6604
+ if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
6605
+ jQuery.lastModified[ ifModifiedKey ] = lastModified;
6437
6606
  }
6438
- if ( ( etag = jXHR.getResponseHeader( "Etag" ) ) ) {
6439
- jQuery.etag[ s.url ] = etag;
6607
+ if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
6608
+ jQuery.etag[ ifModifiedKey ] = etag;
6440
6609
  }
6441
6610
  }
6442
6611
 
@@ -6463,7 +6632,7 @@ jQuery.extend({
6463
6632
  // We extract error from statusText
6464
6633
  // then normalize statusText and status for non-aborts
6465
6634
  error = statusText;
6466
- if( status ) {
6635
+ if( !statusText || status ) {
6467
6636
  statusText = "error";
6468
6637
  if ( status < 0 ) {
6469
6638
  status = 0;
@@ -6472,30 +6641,30 @@ jQuery.extend({
6472
6641
  }
6473
6642
 
6474
6643
  // Set data for the fake xhr object
6475
- jXHR.status = status;
6476
- jXHR.statusText = statusText;
6644
+ jqXHR.status = status;
6645
+ jqXHR.statusText = statusText;
6477
6646
 
6478
6647
  // Success/Error
6479
6648
  if ( isSuccess ) {
6480
- deferred.resolveWith( callbackContext, [ success, statusText, jXHR ] );
6649
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
6481
6650
  } else {
6482
- deferred.rejectWith( callbackContext, [ jXHR, statusText, error ] );
6651
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
6483
6652
  }
6484
6653
 
6485
6654
  // Status-dependent callbacks
6486
- jXHR.statusCode( statusCode );
6655
+ jqXHR.statusCode( statusCode );
6487
6656
  statusCode = undefined;
6488
6657
 
6489
- if ( s.global ) {
6658
+ if ( fireGlobals ) {
6490
6659
  globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
6491
- [ jXHR, s, isSuccess ? success : error ] );
6660
+ [ jqXHR, s, isSuccess ? success : error ] );
6492
6661
  }
6493
6662
 
6494
6663
  // Complete
6495
- completeDeferred.resolveWith( callbackContext, [ jXHR, statusText ] );
6664
+ completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
6496
6665
 
6497
- if ( s.global ) {
6498
- globalEventContext.trigger( "ajaxComplete", [ jXHR, s] );
6666
+ if ( fireGlobals ) {
6667
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
6499
6668
  // Handle the global AJAX counter
6500
6669
  if ( !( --jQuery.active ) ) {
6501
6670
  jQuery.event.trigger( "ajaxStop" );
@@ -6504,13 +6673,13 @@ jQuery.extend({
6504
6673
  }
6505
6674
 
6506
6675
  // Attach deferreds
6507
- deferred.promise( jXHR );
6508
- jXHR.success = jXHR.done;
6509
- jXHR.error = jXHR.fail;
6510
- jXHR.complete = completeDeferred.done;
6676
+ deferred.promise( jqXHR );
6677
+ jqXHR.success = jqXHR.done;
6678
+ jqXHR.error = jqXHR.fail;
6679
+ jqXHR.complete = completeDeferred.done;
6511
6680
 
6512
6681
  // Status-dependent callbacks
6513
- jXHR.statusCode = function( map ) {
6682
+ jqXHR.statusCode = function( map ) {
6514
6683
  if ( map ) {
6515
6684
  var tmp;
6516
6685
  if ( state < 2 ) {
@@ -6518,8 +6687,8 @@ jQuery.extend({
6518
6687
  statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
6519
6688
  }
6520
6689
  } else {
6521
- tmp = map[ jXHR.status ];
6522
- jXHR.then( tmp, tmp );
6690
+ tmp = map[ jqXHR.status ];
6691
+ jqXHR.then( tmp, tmp );
6523
6692
  }
6524
6693
  }
6525
6694
  return this;
@@ -6528,18 +6697,18 @@ jQuery.extend({
6528
6697
  // Remove hash character (#7531: and string promotion)
6529
6698
  // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
6530
6699
  // We also use the url parameter if available
6531
- s.url = ( "" + ( url || s.url ) ).replace( rhash, "" ).replace( rprotocol, protocol + "//" );
6700
+ s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
6532
6701
 
6533
6702
  // Extract dataTypes list
6534
6703
  s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
6535
6704
 
6536
6705
  // Determine if a cross-domain request is in order
6537
- if ( !s.crossDomain ) {
6706
+ if ( s.crossDomain == null ) {
6538
6707
  parts = rurl.exec( s.url.toLowerCase() );
6539
6708
  s.crossDomain = !!( parts &&
6540
- ( parts[ 1 ] != protocol || parts[ 2 ] != loc.hostname ||
6709
+ ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
6541
6710
  ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
6542
- ( loc.port || ( protocol === "http:" ? 80 : 443 ) ) )
6711
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
6543
6712
  );
6544
6713
  }
6545
6714
 
@@ -6549,7 +6718,15 @@ jQuery.extend({
6549
6718
  }
6550
6719
 
6551
6720
  // Apply prefilters
6552
- inspectPrefiltersOrTransports( prefilters, s, options, jXHR );
6721
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
6722
+
6723
+ // If request was aborted inside a prefiler, stop there
6724
+ if ( state === 2 ) {
6725
+ return false;
6726
+ }
6727
+
6728
+ // We can fire global events as of now if asked to
6729
+ fireGlobals = s.global;
6553
6730
 
6554
6731
  // Uppercase the type
6555
6732
  s.type = s.type.toUpperCase();
@@ -6558,7 +6735,7 @@ jQuery.extend({
6558
6735
  s.hasContent = !rnoContent.test( s.type );
6559
6736
 
6560
6737
  // Watch for a new set of requests
6561
- if ( s.global && jQuery.active++ === 0 ) {
6738
+ if ( fireGlobals && jQuery.active++ === 0 ) {
6562
6739
  jQuery.event.trigger( "ajaxStart" );
6563
6740
  }
6564
6741
 
@@ -6570,6 +6747,9 @@ jQuery.extend({
6570
6747
  s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
6571
6748
  }
6572
6749
 
6750
+ // Get ifModifiedKey before adding the anti-cache parameter
6751
+ ifModifiedKey = s.url;
6752
+
6573
6753
  // Add anti-cache in url if needed
6574
6754
  if ( s.cache === false ) {
6575
6755
 
@@ -6584,77 +6764,77 @@ jQuery.extend({
6584
6764
 
6585
6765
  // Set the correct header, if data is being sent
6586
6766
  if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
6587
- requestHeaders[ "content-type" ] = s.contentType;
6767
+ requestHeaders[ "Content-Type" ] = s.contentType;
6588
6768
  }
6589
6769
 
6590
6770
  // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6591
6771
  if ( s.ifModified ) {
6592
- if ( jQuery.lastModified[ s.url ] ) {
6593
- requestHeaders[ "if-modified-since" ] = jQuery.lastModified[ s.url ];
6772
+ ifModifiedKey = ifModifiedKey || s.url;
6773
+ if ( jQuery.lastModified[ ifModifiedKey ] ) {
6774
+ requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
6594
6775
  }
6595
- if ( jQuery.etag[ s.url ] ) {
6596
- requestHeaders[ "if-none-match" ] = jQuery.etag[ s.url ];
6776
+ if ( jQuery.etag[ ifModifiedKey ] ) {
6777
+ requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
6597
6778
  }
6598
6779
  }
6599
6780
 
6600
6781
  // Set the Accepts header for the server, depending on the dataType
6601
- requestHeaders.accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
6782
+ requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
6602
6783
  s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
6603
6784
  s.accepts[ "*" ];
6604
6785
 
6605
6786
  // Check for headers option
6606
6787
  for ( i in s.headers ) {
6607
- requestHeaders[ i.toLowerCase() ] = s.headers[ i ];
6788
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
6608
6789
  }
6609
6790
 
6610
6791
  // Allow custom headers/mimetypes and early abort
6611
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jXHR, s ) === false || state === 2 ) ) {
6792
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
6612
6793
  // Abort if not done already
6613
- done( 0, "abort" );
6614
- // Return false
6615
- jXHR = false;
6794
+ jqXHR.abort();
6795
+ return false;
6616
6796
 
6617
- } else {
6797
+ }
6618
6798
 
6619
- // Install callbacks on deferreds
6620
- for ( i in { success: 1, error: 1, complete: 1 } ) {
6621
- jXHR[ i ]( s[ i ] );
6622
- }
6799
+ // Install callbacks on deferreds
6800
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
6801
+ jqXHR[ i ]( s[ i ] );
6802
+ }
6623
6803
 
6624
- // Get transport
6625
- transport = inspectPrefiltersOrTransports( transports, s, options, jXHR );
6804
+ // Get transport
6805
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
6626
6806
 
6627
- // If no transport, we auto-abort
6628
- if ( !transport ) {
6629
- done( -1, "No Transport" );
6630
- } else {
6631
- // Set state as sending
6632
- state = jXHR.readyState = 1;
6633
- // Send global event
6634
- if ( s.global ) {
6635
- globalEventContext.trigger( "ajaxSend", [ jXHR, s ] );
6636
- }
6637
- // Timeout
6638
- if ( s.async && s.timeout > 0 ) {
6639
- timeoutTimer = setTimeout( function(){
6640
- jXHR.abort( "timeout" );
6641
- }, s.timeout );
6642
- }
6807
+ // If no transport, we auto-abort
6808
+ if ( !transport ) {
6809
+ done( -1, "No Transport" );
6810
+ } else {
6811
+ jqXHR.readyState = 1;
6812
+ // Send global event
6813
+ if ( fireGlobals ) {
6814
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
6815
+ }
6816
+ // Timeout
6817
+ if ( s.async && s.timeout > 0 ) {
6818
+ timeoutTimer = setTimeout( function(){
6819
+ jqXHR.abort( "timeout" );
6820
+ }, s.timeout );
6821
+ }
6643
6822
 
6644
- try {
6645
- transport.send( requestHeaders, done );
6646
- } catch (e) {
6647
- // Propagate exception as error if not done
6648
- if ( status < 2 ) {
6649
- done( -1, e );
6650
- // Simply rethrow otherwise
6651
- } else {
6652
- jQuery.error( e );
6653
- }
6823
+ try {
6824
+ state = 1;
6825
+ transport.send( requestHeaders, done );
6826
+ } catch (e) {
6827
+ // Propagate exception as error if not done
6828
+ if ( status < 2 ) {
6829
+ done( -1, e );
6830
+ // Simply rethrow otherwise
6831
+ } else {
6832
+ jQuery.error( e );
6654
6833
  }
6655
6834
  }
6656
6835
  }
6657
- return jXHR;
6836
+
6837
+ return jqXHR;
6658
6838
  },
6659
6839
 
6660
6840
  // Serialize an array of form elements or a set of
@@ -6673,7 +6853,7 @@ jQuery.extend({
6673
6853
  }
6674
6854
 
6675
6855
  // If an array was passed in, assume that it is an array of form elements.
6676
- if ( jQuery.isArray( a ) || a.jquery ) {
6856
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
6677
6857
  // Serialize the form elements
6678
6858
  jQuery.each( a, function() {
6679
6859
  add( this.name, this.value );
@@ -6720,9 +6900,9 @@ function buildParams( prefix, obj, traditional, add ) {
6720
6900
 
6721
6901
  // Serialize object item.
6722
6902
  } else {
6723
- jQuery.each( obj, function( k, v ) {
6724
- buildParams( prefix + "[" + k + "]", v, traditional, add );
6725
- });
6903
+ for ( var name in obj ) {
6904
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
6905
+ }
6726
6906
  }
6727
6907
 
6728
6908
  } else {
@@ -6749,7 +6929,7 @@ jQuery.extend({
6749
6929
  * - finds the right dataType (mediates between content-type and expected dataType)
6750
6930
  * - returns the corresponding response
6751
6931
  */
6752
- function ajaxHandleResponses( s, jXHR, responses ) {
6932
+ function ajaxHandleResponses( s, jqXHR, responses ) {
6753
6933
 
6754
6934
  var contents = s.contents,
6755
6935
  dataTypes = s.dataTypes,
@@ -6762,7 +6942,7 @@ function ajaxHandleResponses( s, jXHR, responses ) {
6762
6942
  // Fill responseXXX fields
6763
6943
  for( type in responseFields ) {
6764
6944
  if ( type in responses ) {
6765
- jXHR[ responseFields[type] ] = responses[ type ];
6945
+ jqXHR[ responseFields[type] ] = responses[ type ];
6766
6946
  }
6767
6947
  }
6768
6948
 
@@ -6770,7 +6950,7 @@ function ajaxHandleResponses( s, jXHR, responses ) {
6770
6950
  while( dataTypes[ 0 ] === "*" ) {
6771
6951
  dataTypes.shift();
6772
6952
  if ( ct === undefined ) {
6773
- ct = jXHR.getResponseHeader( "content-type" );
6953
+ ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
6774
6954
  }
6775
6955
  }
6776
6956
 
@@ -6822,8 +7002,9 @@ function ajaxConvert( s, response ) {
6822
7002
  }
6823
7003
 
6824
7004
  var dataTypes = s.dataTypes,
6825
- converters = s.converters,
7005
+ converters = {},
6826
7006
  i,
7007
+ key,
6827
7008
  length = dataTypes.length,
6828
7009
  tmp,
6829
7010
  // Current and previous dataTypes
@@ -6840,6 +7021,16 @@ function ajaxConvert( s, response ) {
6840
7021
  // For each dataType in the chain
6841
7022
  for( i = 1; i < length; i++ ) {
6842
7023
 
7024
+ // Create converters map
7025
+ // with lowercased keys
7026
+ if ( i === 1 ) {
7027
+ for( key in s.converters ) {
7028
+ if( typeof key === "string" ) {
7029
+ converters[ key.toLowerCase() ] = s.converters[ key ];
7030
+ }
7031
+ }
7032
+ }
7033
+
6843
7034
  // Get the dataTypes
6844
7035
  prev = current;
6845
7036
  current = dataTypes[ i ];
@@ -6891,7 +7082,7 @@ function ajaxConvert( s, response ) {
6891
7082
 
6892
7083
 
6893
7084
  var jsc = jQuery.now(),
6894
- jsre = /(\=)\?(&|$)|()\?\?()/i;
7085
+ jsre = /(\=)\?(&|$)|\?\?/i;
6895
7086
 
6896
7087
  // Default jsonp settings
6897
7088
  jQuery.ajaxSetup({
@@ -6902,9 +7093,9 @@ jQuery.ajaxSetup({
6902
7093
  });
6903
7094
 
6904
7095
  // Detect, normalize options and install callbacks for jsonp requests
6905
- jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */ ) {
7096
+ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
6906
7097
 
6907
- dataIsString = ( typeof s.data === "string" );
7098
+ var dataIsString = ( typeof s.data === "string" );
6908
7099
 
6909
7100
  if ( s.dataTypes[ 0 ] === "jsonp" ||
6910
7101
  originalSettings.jsonpCallback ||
@@ -6918,7 +7109,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
6918
7109
  previous = window[ jsonpCallback ],
6919
7110
  url = s.url,
6920
7111
  data = s.data,
6921
- replace = "$1" + jsonpCallback + "$2";
7112
+ replace = "$1" + jsonpCallback + "$2",
7113
+ cleanUp = function() {
7114
+ // Set callback back to previous value
7115
+ window[ jsonpCallback ] = previous;
7116
+ // Call if it was a function and we have a response
7117
+ if ( responseContainer && jQuery.isFunction( previous ) ) {
7118
+ window[ jsonpCallback ]( responseContainer[ 0 ] );
7119
+ }
7120
+ };
6922
7121
 
6923
7122
  if ( s.jsonp !== false ) {
6924
7123
  url = url.replace( jsre, replace );
@@ -6936,32 +7135,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
6936
7135
  s.url = url;
6937
7136
  s.data = data;
6938
7137
 
7138
+ // Install callback
6939
7139
  window[ jsonpCallback ] = function( response ) {
6940
7140
  responseContainer = [ response ];
6941
7141
  };
6942
7142
 
6943
- s.complete = [ function() {
6944
-
6945
- // Set callback back to previous value
6946
- window[ jsonpCallback ] = previous;
6947
-
6948
- // Call if it was a function and we have a response
6949
- if ( previous) {
6950
- if ( responseContainer && jQuery.isFunction( previous ) ) {
6951
- window[ jsonpCallback ] ( responseContainer[ 0 ] );
6952
- }
6953
- } else {
6954
- // else, more memory leak avoidance
6955
- try{
6956
- delete window[ jsonpCallback ];
6957
- } catch( e ) {}
6958
- }
6959
-
6960
- }, s.complete ];
7143
+ // Install cleanUp function
7144
+ jqXHR.then( cleanUp, cleanUp );
6961
7145
 
6962
7146
  // Use data converter to retrieve json after script execution
6963
7147
  s.converters["script json"] = function() {
6964
- if ( ! responseContainer ) {
7148
+ if ( !responseContainer ) {
6965
7149
  jQuery.error( jsonpCallback + " was not called" );
6966
7150
  }
6967
7151
  return responseContainer[ 0 ];
@@ -6981,10 +7165,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
6981
7165
  // Install script dataType
6982
7166
  jQuery.ajaxSetup({
6983
7167
  accepts: {
6984
- script: "text/javascript, application/javascript"
7168
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
6985
7169
  },
6986
7170
  contents: {
6987
- script: /javascript/
7171
+ script: /javascript|ecmascript/
6988
7172
  },
6989
7173
  converters: {
6990
7174
  "text script": function( text ) {
@@ -7012,7 +7196,7 @@ jQuery.ajaxTransport( "script", function(s) {
7012
7196
  if ( s.crossDomain ) {
7013
7197
 
7014
7198
  var script,
7015
- head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement;
7199
+ head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7016
7200
 
7017
7201
  return {
7018
7202
 
@@ -7067,18 +7251,36 @@ jQuery.ajaxTransport( "script", function(s) {
7067
7251
 
7068
7252
 
7069
7253
 
7070
- var // Next active xhr id
7254
+ var // #5280: next active xhr id and list of active xhrs' callbacks
7071
7255
  xhrId = jQuery.now(),
7072
-
7073
- // active xhrs
7074
- xhrs = {},
7075
-
7076
- // #5280: see below
7077
- xhrUnloadAbortInstalled,
7256
+ xhrCallbacks,
7078
7257
 
7079
7258
  // XHR used to determine supports properties
7080
7259
  testXHR;
7081
7260
 
7261
+ // #5280: Internet Explorer will keep connections alive if we don't abort on unload
7262
+ function xhrOnUnloadAbort() {
7263
+ jQuery( window ).unload(function() {
7264
+ // Abort all pending requests
7265
+ for ( var key in xhrCallbacks ) {
7266
+ xhrCallbacks[ key ]( 0, 1 );
7267
+ }
7268
+ });
7269
+ }
7270
+
7271
+ // Functions to create xhrs
7272
+ function createStandardXHR() {
7273
+ try {
7274
+ return new window.XMLHttpRequest();
7275
+ } catch( e ) {}
7276
+ }
7277
+
7278
+ function createActiveXHR() {
7279
+ try {
7280
+ return new window.ActiveXObject( "Microsoft.XMLHTTP" );
7281
+ } catch( e ) {}
7282
+ }
7283
+
7082
7284
  // Create the request object
7083
7285
  // (This is still attached to ajaxSettings for backward compatibility)
7084
7286
  jQuery.ajaxSettings.xhr = window.ActiveXObject ?
@@ -7089,27 +7291,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
7089
7291
  * we need a fallback.
7090
7292
  */
7091
7293
  function() {
7092
- if ( window.location.protocol !== "file:" ) {
7093
- try {
7094
- return new window.XMLHttpRequest();
7095
- } catch( xhrError ) {}
7096
- }
7097
-
7098
- try {
7099
- return new window.ActiveXObject("Microsoft.XMLHTTP");
7100
- } catch( activeError ) {}
7294
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
7101
7295
  } :
7102
7296
  // For all other browsers, use the standard XMLHttpRequest object
7103
- function() {
7104
- return new window.XMLHttpRequest();
7105
- };
7297
+ createStandardXHR;
7106
7298
 
7107
7299
  // Test if we can create an xhr object
7108
- try {
7109
- testXHR = jQuery.ajaxSettings.xhr();
7110
- } catch( xhrCreationException ) {}
7111
-
7112
- //Does this browser support XHR requests?
7300
+ testXHR = jQuery.ajaxSettings.xhr();
7113
7301
  jQuery.support.ajax = !!testXHR;
7114
7302
 
7115
7303
  // Does this browser support crossDomain XHR requests
@@ -7130,26 +7318,10 @@ if ( jQuery.support.ajax ) {
7130
7318
  return {
7131
7319
  send: function( headers, complete ) {
7132
7320
 
7133
- // #5280: we need to abort on unload or IE will keep connections alive
7134
- if ( !xhrUnloadAbortInstalled ) {
7135
-
7136
- xhrUnloadAbortInstalled = 1;
7137
-
7138
- jQuery(window).bind( "unload", function() {
7139
-
7140
- // Abort all pending requests
7141
- jQuery.each( xhrs, function( _, xhr ) {
7142
- if ( xhr.onreadystatechange ) {
7143
- xhr.onreadystatechange( 1 );
7144
- }
7145
- } );
7146
-
7147
- } );
7148
- }
7149
-
7150
7321
  // Get a new xhr
7151
7322
  var xhr = s.xhr(),
7152
- handle;
7323
+ handle,
7324
+ i;
7153
7325
 
7154
7326
  // Open the socket
7155
7327
  // Passing null username, generates a login popup on Opera (#2865)
@@ -7159,19 +7331,32 @@ if ( jQuery.support.ajax ) {
7159
7331
  xhr.open( s.type, s.url, s.async );
7160
7332
  }
7161
7333
 
7162
- // Requested-With header
7163
- // Not set for crossDomain requests with no content
7164
- // (see why at http://trac.dojotoolkit.org/ticket/9486)
7165
- // Won't change header if already provided
7166
- if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) {
7167
- headers[ "x-requested-with" ] = "XMLHttpRequest";
7334
+ // Apply custom fields if provided
7335
+ if ( s.xhrFields ) {
7336
+ for ( i in s.xhrFields ) {
7337
+ xhr[ i ] = s.xhrFields[ i ];
7338
+ }
7339
+ }
7340
+
7341
+ // Override mime type if needed
7342
+ if ( s.mimeType && xhr.overrideMimeType ) {
7343
+ xhr.overrideMimeType( s.mimeType );
7344
+ }
7345
+
7346
+ // X-Requested-With header
7347
+ // For cross-domain requests, seeing as conditions for a preflight are
7348
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
7349
+ // (it can always be set on a per-request basis or even using ajaxSetup)
7350
+ // For same-domain requests, won't change header if already provided.
7351
+ if ( !s.crossDomain && !headers["X-Requested-With"] ) {
7352
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
7168
7353
  }
7169
7354
 
7170
7355
  // Need an extra try/catch for cross domain requests in Firefox 3
7171
7356
  try {
7172
- jQuery.each( headers, function( key, value ) {
7173
- xhr.setRequestHeader( key, value );
7174
- } );
7357
+ for ( i in headers ) {
7358
+ xhr.setRequestHeader( i, headers[ i ] );
7359
+ }
7175
7360
  } catch( _ ) {}
7176
7361
 
7177
7362
  // Do send the request
@@ -7182,75 +7367,79 @@ if ( jQuery.support.ajax ) {
7182
7367
  // Listener
7183
7368
  callback = function( _, isAbort ) {
7184
7369
 
7185
- // Was never called and is aborted or complete
7186
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7370
+ var status,
7371
+ statusText,
7372
+ responseHeaders,
7373
+ responses,
7374
+ xml;
7375
+
7376
+ // Firefox throws exceptions when accessing properties
7377
+ // of an xhr when a network error occured
7378
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
7379
+ try {
7187
7380
 
7188
- // Only called once
7189
- callback = 0;
7381
+ // Was never called and is aborted or complete
7382
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7190
7383
 
7191
- // Do not keep as active anymore
7192
- if ( handle ) {
7193
- xhr.onreadystatechange = jQuery.noop;
7194
- delete xhrs[ handle ];
7195
- }
7384
+ // Only called once
7385
+ callback = undefined;
7196
7386
 
7197
- // If it's an abort
7198
- if ( isAbort ) {
7199
- // Abort it manually if needed
7200
- if ( xhr.readyState !== 4 ) {
7201
- xhr.abort();
7387
+ // Do not keep as active anymore
7388
+ if ( handle ) {
7389
+ xhr.onreadystatechange = jQuery.noop;
7390
+ delete xhrCallbacks[ handle ];
7202
7391
  }
7203
- } else {
7204
- // Get info
7205
- var status = xhr.status,
7206
- statusText,
7207
- responseHeaders = xhr.getAllResponseHeaders(),
7208
- responses = {},
7392
+
7393
+ // If it's an abort
7394
+ if ( isAbort ) {
7395
+ // Abort it manually if needed
7396
+ if ( xhr.readyState !== 4 ) {
7397
+ xhr.abort();
7398
+ }
7399
+ } else {
7400
+ status = xhr.status;
7401
+ responseHeaders = xhr.getAllResponseHeaders();
7402
+ responses = {};
7209
7403
  xml = xhr.responseXML;
7210
7404
 
7211
- // Construct response list
7212
- if ( xml && xml.documentElement /* #4958 */ ) {
7213
- responses.xml = xml;
7405
+ // Construct response list
7406
+ if ( xml && xml.documentElement /* #4958 */ ) {
7407
+ responses.xml = xml;
7408
+ }
7409
+ responses.text = xhr.responseText;
7410
+
7411
+ // Firefox throws an exception when accessing
7412
+ // statusText for faulty cross-domain requests
7413
+ try {
7414
+ statusText = xhr.statusText;
7415
+ } catch( e ) {
7416
+ // We normalize with Webkit giving an empty statusText
7417
+ statusText = "";
7418
+ }
7419
+
7420
+ // Filter status for non standard behaviors
7421
+
7422
+ // If the request is local and we have data: assume a success
7423
+ // (success with no data won't get notified, that's the best we
7424
+ // can do given current implementations)
7425
+ if ( !status && s.isLocal && !s.crossDomain ) {
7426
+ status = responses.text ? 200 : 404;
7427
+ // IE - #1450: sometimes returns 1223 when it should be 204
7428
+ } else if ( status === 1223 ) {
7429
+ status = 204;
7430
+ }
7214
7431
  }
7215
- responses.text = xhr.responseText;
7216
-
7217
- // Firefox throws an exception when accessing
7218
- // statusText for faulty cross-domain requests
7219
- try {
7220
- statusText = xhr.statusText;
7221
- } catch( e ) {
7222
- // We normalize with Webkit giving an empty statusText
7223
- statusText = "";
7224
- }
7225
-
7226
- // Filter status for non standard behaviours
7227
- status =
7228
- // Opera returns 0 when it should be 304
7229
- // Webkit returns 0 for failing cross-domain no matter the real status
7230
- status === 0 ?
7231
- (
7232
- // Webkit, Firefox: filter out faulty cross-domain requests
7233
- !s.crossDomain || statusText ?
7234
- (
7235
- // Opera: filter out real aborts #6060
7236
- responseHeaders ?
7237
- 304 :
7238
- 0
7239
- ) :
7240
- // We assume 302 but could be anything cross-domain related
7241
- 302
7242
- ) :
7243
- (
7244
- // IE sometimes returns 1223 when it should be 204 (see #1450)
7245
- status == 1223 ?
7246
- 204 :
7247
- status
7248
- );
7249
-
7250
- // Call complete
7251
- complete( status, statusText, responses, responseHeaders );
7432
+ }
7433
+ } catch( firefoxAccessException ) {
7434
+ if ( !isAbort ) {
7435
+ complete( -1, firefoxAccessException );
7252
7436
  }
7253
7437
  }
7438
+
7439
+ // Call complete if needed
7440
+ if ( responses ) {
7441
+ complete( status, statusText, responses, responseHeaders );
7442
+ }
7254
7443
  };
7255
7444
 
7256
7445
  // if we're in sync mode or it's in cache
@@ -7259,10 +7448,15 @@ if ( jQuery.support.ajax ) {
7259
7448
  if ( !s.async || xhr.readyState === 4 ) {
7260
7449
  callback();
7261
7450
  } else {
7262
- // Add to list of active xhrs
7451
+ // Create the active xhrs callbacks list if needed
7452
+ // and attach the unload handler
7453
+ if ( !xhrCallbacks ) {
7454
+ xhrCallbacks = {};
7455
+ xhrOnUnloadAbort();
7456
+ }
7457
+ // Add to list of active xhrs callbacks
7263
7458
  handle = xhrId++;
7264
- xhrs[ handle ] = xhr;
7265
- xhr.onreadystatechange = callback;
7459
+ xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
7266
7460
  }
7267
7461
  },
7268
7462
 
@@ -7464,11 +7658,11 @@ jQuery.fn.extend({
7464
7658
 
7465
7659
  } else {
7466
7660
  var parts = rfxnum.exec(val),
7467
- start = e.cur() || 0;
7661
+ start = e.cur();
7468
7662
 
7469
7663
  if ( parts ) {
7470
7664
  var end = parseFloat( parts[2] ),
7471
- unit = parts[3] || "px";
7665
+ unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
7472
7666
 
7473
7667
  // We need to compute starting value
7474
7668
  if ( unit !== "px" ) {
@@ -7615,8 +7809,12 @@ jQuery.fx.prototype = {
7615
7809
  return this.elem[ this.prop ];
7616
7810
  }
7617
7811
 
7618
- var r = parseFloat( jQuery.css( this.elem, this.prop ) );
7619
- return r || 0;
7812
+ var parsed,
7813
+ r = jQuery.css( this.elem, this.prop );
7814
+ // Empty strings, null, undefined and "auto" are converted to 0,
7815
+ // complex values such as "rotate(1rad)" are returned as is,
7816
+ // simple values such as "10px" are parsed to Float.
7817
+ return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
7620
7818
  },
7621
7819
 
7622
7820
  // Start an animation from one number to another
@@ -7627,7 +7825,7 @@ jQuery.fx.prototype = {
7627
7825
  this.startTime = jQuery.now();
7628
7826
  this.start = from;
7629
7827
  this.end = to;
7630
- this.unit = unit || this.unit || "px";
7828
+ this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
7631
7829
  this.now = this.start;
7632
7830
  this.pos = this.state = 0;
7633
7831
 
@@ -7840,8 +8038,8 @@ if ( "getBoundingClientRect" in document.documentElement ) {
7840
8038
  win = getWindow(doc),
7841
8039
  clientTop = docElem.clientTop || body.clientTop || 0,
7842
8040
  clientLeft = docElem.clientLeft || body.clientLeft || 0,
7843
- scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
7844
- scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
8041
+ scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
8042
+ scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
7845
8043
  top = box.top + scrollTop - clientTop,
7846
8044
  left = box.left + scrollLeft - clientLeft;
7847
8045
 
@@ -7954,7 +8152,6 @@ jQuery.offset = {
7954
8152
  this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
7955
8153
 
7956
8154
  body.removeChild( container );
7957
- body = container = innerDiv = checkDiv = table = td = null;
7958
8155
  jQuery.offset.initialize = jQuery.noop;
7959
8156
  },
7960
8157
 
@@ -7984,10 +8181,10 @@ jQuery.offset = {
7984
8181
  curOffset = curElem.offset(),
7985
8182
  curCSSTop = jQuery.css( elem, "top" ),
7986
8183
  curCSSLeft = jQuery.css( elem, "left" ),
7987
- calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
8184
+ calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1,
7988
8185
  props = {}, curPosition = {}, curTop, curLeft;
7989
8186
 
7990
- // need to be able to calculate position if either top or left is auto and position is absolute
8187
+ // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
7991
8188
  if ( calculatePosition ) {
7992
8189
  curPosition = curElem.position();
7993
8190
  }
@@ -8078,7 +8275,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
8078
8275
  if ( win ) {
8079
8276
  win.scrollTo(
8080
8277
  !i ? val : jQuery(win).scrollLeft(),
8081
- i ? val : jQuery(win).scrollTop()
8278
+ i ? val : jQuery(win).scrollTop()
8082
8279
  );
8083
8280
 
8084
8281
  } else {
@@ -8173,4 +8370,5 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
8173
8370
  });
8174
8371
 
8175
8372
 
8373
+ window.jQuery = window.$ = jQuery;
8176
8374
  })(window);