html5-starter 0.1.4b → 0.1.8b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/README.md +11 -113
  2. data/stylesheets/html5-boilerplate/_fonts.scss +4 -4
  3. data/stylesheets/html5-boilerplate/_handheld.scss +3 -3
  4. data/stylesheets/html5-boilerplate/_helpers.scss +14 -7
  5. data/stylesheets/html5-boilerplate/_print.scss +2 -2
  6. data/stylesheets/html5-boilerplate/_reset.scss +8 -8
  7. data/stylesheets/html5-boilerplate/_styles.scss +16 -31
  8. data/templates/project/files/404.html +37 -21
  9. data/templates/project/files/apple-touch-icon-114x114-precomposed.png +0 -0
  10. data/templates/project/files/apple-touch-icon-57x57-precomposed.png +0 -0
  11. data/templates/project/files/apple-touch-icon-72x72-precomposed.png +0 -0
  12. data/templates/project/files/apple-touch-icon-precomposed.png +0 -0
  13. data/templates/project/files/apple-touch-icon.png +0 -0
  14. data/templates/project/files/build/build.xml +813 -628
  15. data/templates/project/files/build/config/buildinfo.properties +5 -0
  16. data/templates/project/files/build/config/default.properties +22 -21
  17. data/templates/project/files/build/config/project.properties +9 -8
  18. data/templates/project/files/build/createproject.sh +29 -52
  19. data/templates/project/files/build/runbuildscript.bat +5 -0
  20. data/templates/project/files/build/tools/htmlcompressor-1.1.jar +0 -0
  21. data/templates/project/files/build/tools/{yuicompressor-2.4.2.jar → yuicompressor-2.4.5.jar} +0 -0
  22. data/templates/project/files/gitignore.txt +6 -0
  23. data/templates/project/files/htaccess +71 -8
  24. data/templates/project/index.html +30 -31
  25. data/templates/project/javascripts/libs/dd_belatedpng.js +1 -1
  26. data/templates/project/javascripts/libs/{jquery-1.5.0.js → jquery-1.5.1.js} +549 -409
  27. data/templates/project/javascripts/libs/jquery-1.5.1.min.js +16 -0
  28. data/templates/project/javascripts/libs/modernizr-1.7.min.js +2 -0
  29. data/templates/project/javascripts/plugins.js +3 -1
  30. data/templates/project/manifest.rb +22 -59
  31. data/templates/project/style.scss +17 -0
  32. metadata +15 -44
  33. data/templates/project/files/build/config/build.properties +0 -3
  34. data/templates/project/files/build/tools/css-compressor/CSSCompression.php +0 -465
  35. data/templates/project/files/build/tools/css-compressor/changelog.txt +0 -22
  36. data/templates/project/files/build/tools/css-compressor/cli.php +0 -101
  37. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-colors.json +0 -39
  38. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-safe.json +0 -16
  39. data/templates/project/files/build/tools/css-compressor/helpers/long2hex-colors.json +0 -127
  40. data/templates/project/files/build/tools/css-compressor/lib/Cleanup.php +0 -218
  41. data/templates/project/files/build/tools/css-compressor/lib/Color.php +0 -199
  42. data/templates/project/files/build/tools/css-compressor/lib/Combine/Aural.php +0 -109
  43. data/templates/project/files/build/tools/css-compressor/lib/Combine/Background.php +0 -107
  44. data/templates/project/files/build/tools/css-compressor/lib/Combine/Border.php +0 -98
  45. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderOutline.php +0 -109
  46. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderRadius.php +0 -262
  47. data/templates/project/files/build/tools/css-compressor/lib/Combine/Font.php +0 -125
  48. data/templates/project/files/build/tools/css-compressor/lib/Combine/List.php +0 -104
  49. data/templates/project/files/build/tools/css-compressor/lib/Combine/MarginPadding.php +0 -190
  50. data/templates/project/files/build/tools/css-compressor/lib/Combine.php +0 -191
  51. data/templates/project/files/build/tools/css-compressor/lib/Compress.php +0 -212
  52. data/templates/project/files/build/tools/css-compressor/lib/Control.php +0 -236
  53. data/templates/project/files/build/tools/css-compressor/lib/Exception.php +0 -32
  54. data/templates/project/files/build/tools/css-compressor/lib/Format.php +0 -187
  55. data/templates/project/files/build/tools/css-compressor/lib/Individuals.php +0 -307
  56. data/templates/project/files/build/tools/css-compressor/lib/Numeric.php +0 -103
  57. data/templates/project/files/build/tools/css-compressor/lib/Option.php +0 -133
  58. data/templates/project/files/build/tools/css-compressor/lib/Organize.php +0 -149
  59. data/templates/project/files/build/tools/css-compressor/lib/Selectors.php +0 -245
  60. data/templates/project/files/build/tools/css-compressor/lib/Setup.php +0 -292
  61. data/templates/project/files/build/tools/css-compressor/lib/Trim.php +0 -213
  62. data/templates/project/files/build/tools/css-compressor/license.txt +0 -21
  63. data/templates/project/files/build/tools/htmlcompressor-0.9.8.jar +0 -0
  64. data/templates/project/files/google.yml +0 -22
  65. data/templates/project/files/lighttpd.conf +0 -149
  66. data/templates/project/files/mime.types +0 -80
  67. data/templates/project/files/nginx.conf +0 -108
  68. data/templates/project/files/web.config +0 -207
  69. data/templates/project/javascripts/libs/jquery-1.5.0.min.js +0 -16
  70. data/templates/project/javascripts/libs/modernizr-1.6.min.js +0 -30
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery JavaScript Library v1.5
2
+ * jQuery JavaScript Library v1.5.1
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: Wed Feb 23 13:55:29 2011 -0500
15
15
  */
16
16
  (function( window, undefined ) {
17
17
 
@@ -202,7 +202,7 @@ jQuery.fn = jQuery.prototype = {
202
202
  selector: "",
203
203
 
204
204
  // The current version of jQuery being used
205
- jquery: "1.5",
205
+ jquery: "1.5.1",
206
206
 
207
207
  // The default length of a jQuery object is 0
208
208
  length: 0,
@@ -313,7 +313,7 @@ jQuery.fn = jQuery.prototype = {
313
313
  jQuery.fn.init.prototype = jQuery.fn;
314
314
 
315
315
  jQuery.extend = jQuery.fn.extend = function() {
316
- var options, name, src, copy, copyIsArray, clone,
316
+ var options, name, src, copy, copyIsArray, clone,
317
317
  target = arguments[0] || {},
318
318
  i = 1,
319
319
  length = arguments.length,
@@ -585,10 +585,8 @@ jQuery.extend({
585
585
  if ( data && rnotwhite.test(data) ) {
586
586
  // Inspired by code by Andrea Giammarchi
587
587
  // 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";
588
+ var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
589
+ script = document.createElement( "script" );
592
590
 
593
591
  if ( jQuery.support.scriptEval() ) {
594
592
  script.appendChild( document.createTextNode( data ) );
@@ -864,6 +862,12 @@ jQuery.extend({
864
862
  callbacks.shift().apply( context, args );
865
863
  }
866
864
  }
865
+ // We have to add a catch block for
866
+ // IE prior to 8 or else the finally
867
+ // block will never get executed
868
+ catch (e) {
869
+ throw e;
870
+ }
867
871
  finally {
868
872
  fired = [ context, args ];
869
873
  firing = 0;
@@ -911,22 +915,22 @@ jQuery.extend({
911
915
  isRejected: failDeferred.isResolved,
912
916
  // Get a promise for this deferred
913
917
  // If obj is provided, the promise aspect is added to the object
914
- promise: function( obj , i /* internal */ ) {
918
+ promise: function( obj ) {
915
919
  if ( obj == null ) {
916
920
  if ( promise ) {
917
921
  return promise;
918
922
  }
919
923
  promise = obj = {};
920
924
  }
921
- i = promiseMethods.length;
925
+ var i = promiseMethods.length;
922
926
  while( i-- ) {
923
- obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
927
+ obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
924
928
  }
925
929
  return obj;
926
930
  }
927
931
  } );
928
932
  // Make sure only one callback list will be used
929
- deferred.then( failDeferred.cancel, deferred.cancel );
933
+ deferred.done( failDeferred.cancel ).fail( deferred.cancel );
930
934
  // Unexpose cancel
931
935
  delete deferred.cancel;
932
936
  // Call given func if any
@@ -938,24 +942,34 @@ jQuery.extend({
938
942
 
939
943
  // Deferred helper
940
944
  when: function( object ) {
941
- var args = arguments,
942
- length = args.length,
943
- deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ?
945
+ var lastIndex = arguments.length,
946
+ deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
944
947
  object :
945
948
  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
- } );
949
+ promise = deferred.promise();
950
+
951
+ if ( lastIndex > 1 ) {
952
+ var array = slice.call( arguments, 0 ),
953
+ count = lastIndex,
954
+ iCallback = function( index ) {
955
+ return function( value ) {
956
+ array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
957
+ if ( !( --count ) ) {
958
+ deferred.resolveWith( promise, array );
959
+ }
960
+ };
961
+ };
962
+ while( ( lastIndex-- ) ) {
963
+ object = array[ lastIndex ];
964
+ if ( object && jQuery.isFunction( object.promise ) ) {
965
+ object.promise().then( iCallback(lastIndex), deferred.reject );
966
+ } else {
967
+ --count;
968
+ }
969
+ }
970
+ if ( !count ) {
971
+ deferred.resolveWith( promise, array );
972
+ }
959
973
  } else if ( deferred !== object ) {
960
974
  deferred.resolve( object );
961
975
  }
@@ -1071,7 +1085,7 @@ function doScrollCheck() {
1071
1085
  }
1072
1086
 
1073
1087
  // Expose jQuery to the global object
1074
- return (window.jQuery = window.$ = jQuery);
1088
+ return jQuery;
1075
1089
 
1076
1090
  })();
1077
1091
 
@@ -1088,7 +1102,8 @@ return (window.jQuery = window.$ = jQuery);
1088
1102
  var all = div.getElementsByTagName("*"),
1089
1103
  a = div.getElementsByTagName("a")[0],
1090
1104
  select = document.createElement("select"),
1091
- opt = select.appendChild( document.createElement("option") );
1105
+ opt = select.appendChild( document.createElement("option") ),
1106
+ input = div.getElementsByTagName("input")[0];
1092
1107
 
1093
1108
  // Can't get basic test support
1094
1109
  if ( !all || !all.length || !a ) {
@@ -1127,7 +1142,7 @@ return (window.jQuery = window.$ = jQuery);
1127
1142
  // Make sure that if no value is specified for a checkbox
1128
1143
  // that it defaults to "on".
1129
1144
  // (WebKit defaults to "" instead)
1130
- checkOn: div.getElementsByTagName("input")[0].value === "on",
1145
+ checkOn: input.value === "on",
1131
1146
 
1132
1147
  // Make sure that a selected-by-default option has a working selected property.
1133
1148
  // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
@@ -1137,26 +1152,29 @@ return (window.jQuery = window.$ = jQuery);
1137
1152
  deleteExpando: true,
1138
1153
  optDisabled: false,
1139
1154
  checkClone: false,
1140
- _scriptEval: null,
1141
1155
  noCloneEvent: true,
1156
+ noCloneChecked: true,
1142
1157
  boxModel: null,
1143
1158
  inlineBlockNeedsLayout: false,
1144
1159
  shrinkWrapBlocks: false,
1145
1160
  reliableHiddenOffsets: true
1146
1161
  };
1147
1162
 
1163
+ input.checked = true;
1164
+ jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
1165
+
1148
1166
  // Make sure that the options inside disabled selects aren't marked as disabled
1149
1167
  // (WebKit marks them as diabled)
1150
1168
  select.disabled = true;
1151
1169
  jQuery.support.optDisabled = !opt.disabled;
1152
1170
 
1171
+ var _scriptEval = null;
1153
1172
  jQuery.support.scriptEval = function() {
1154
- if ( jQuery.support._scriptEval === null ) {
1173
+ if ( _scriptEval === null ) {
1155
1174
  var root = document.documentElement,
1156
1175
  script = document.createElement("script"),
1157
1176
  id = "script" + jQuery.now();
1158
1177
 
1159
- script.type = "text/javascript";
1160
1178
  try {
1161
1179
  script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
1162
1180
  } catch(e) {}
@@ -1167,10 +1185,10 @@ return (window.jQuery = window.$ = jQuery);
1167
1185
  // tag with appendChild/createTextNode
1168
1186
  // (IE doesn't support this, fails, and uses .text instead)
1169
1187
  if ( window[ id ] ) {
1170
- jQuery.support._scriptEval = true;
1188
+ _scriptEval = true;
1171
1189
  delete window[ id ];
1172
1190
  } else {
1173
- jQuery.support._scriptEval = false;
1191
+ _scriptEval = false;
1174
1192
  }
1175
1193
 
1176
1194
  root.removeChild( script );
@@ -1178,7 +1196,7 @@ return (window.jQuery = window.$ = jQuery);
1178
1196
  root = script = id = null;
1179
1197
  }
1180
1198
 
1181
- return jQuery.support._scriptEval;
1199
+ return _scriptEval;
1182
1200
  };
1183
1201
 
1184
1202
  // Test to see if it's possible to delete an expando from an element
@@ -1190,7 +1208,7 @@ return (window.jQuery = window.$ = jQuery);
1190
1208
  jQuery.support.deleteExpando = false;
1191
1209
  }
1192
1210
 
1193
- if ( div.attachEvent && div.fireEvent ) {
1211
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1194
1212
  div.attachEvent("onclick", function click() {
1195
1213
  // Cloning a node shouldn't copy over any
1196
1214
  // bound event handlers (IE does this)
@@ -1321,7 +1339,7 @@ jQuery.extend({
1321
1339
  hasData: function( elem ) {
1322
1340
  elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1323
1341
 
1324
- return !!elem && !jQuery.isEmptyObject(elem);
1342
+ return !!elem && !isEmptyDataObject( elem );
1325
1343
  },
1326
1344
 
1327
1345
  data: function( elem, name, data, pvt /* Internal Use Only */ ) {
@@ -1361,11 +1379,18 @@ jQuery.extend({
1361
1379
 
1362
1380
  if ( !cache[ id ] ) {
1363
1381
  cache[ id ] = {};
1382
+
1383
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1384
+ // metadata on plain JS objects when the object is serialized using
1385
+ // JSON.stringify
1386
+ if ( !isNode ) {
1387
+ cache[ id ].toJSON = jQuery.noop;
1388
+ }
1364
1389
  }
1365
1390
 
1366
1391
  // An object can be passed to jQuery.data instead of a key/value pair; this gets
1367
1392
  // shallow copied over onto the existing cache
1368
- if ( typeof name === "object" ) {
1393
+ if ( typeof name === "object" || typeof name === "function" ) {
1369
1394
  if ( pvt ) {
1370
1395
  cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1371
1396
  } else {
@@ -1427,7 +1452,7 @@ jQuery.extend({
1427
1452
 
1428
1453
  // If there is no data left in the cache, we want to continue
1429
1454
  // and let the cache object itself get destroyed
1430
- if ( !jQuery.isEmptyObject(thisCache) ) {
1455
+ if ( !isEmptyDataObject(thisCache) ) {
1431
1456
  return;
1432
1457
  }
1433
1458
  }
@@ -1439,7 +1464,7 @@ jQuery.extend({
1439
1464
 
1440
1465
  // Don't destroy the parent cache unless the internal data object
1441
1466
  // had been the only thing left in it
1442
- if ( !jQuery.isEmptyObject(cache[ id ]) ) {
1467
+ if ( !isEmptyDataObject(cache[ id ]) ) {
1443
1468
  return;
1444
1469
  }
1445
1470
  }
@@ -1460,6 +1485,13 @@ jQuery.extend({
1460
1485
  // data if it existed
1461
1486
  if ( internalCache ) {
1462
1487
  cache[ id ] = {};
1488
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1489
+ // metadata on plain JS objects when the object is serialized using
1490
+ // JSON.stringify
1491
+ if ( !isNode ) {
1492
+ cache[ id ].toJSON = jQuery.noop;
1493
+ }
1494
+
1463
1495
  cache[ id ][ internalKey ] = internalCache;
1464
1496
 
1465
1497
  // Otherwise, we need to eliminate the expando on the node to avoid
@@ -1588,6 +1620,19 @@ function dataAttr( elem, key, data ) {
1588
1620
  return data;
1589
1621
  }
1590
1622
 
1623
+ // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1624
+ // property to be considered empty objects; this property always exists in
1625
+ // order to make sure JSON.stringify does not expose internal metadata
1626
+ function isEmptyDataObject( obj ) {
1627
+ for ( var name in obj ) {
1628
+ if ( name !== "toJSON" ) {
1629
+ return false;
1630
+ }
1631
+ }
1632
+
1633
+ return true;
1634
+ }
1635
+
1591
1636
 
1592
1637
 
1593
1638
 
@@ -1888,6 +1933,11 @@ jQuery.fn.extend({
1888
1933
  }
1889
1934
  }
1890
1935
 
1936
+ // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
1937
+ if ( one && !values.length && options.length ) {
1938
+ return jQuery( options[ index ] ).val();
1939
+ }
1940
+
1891
1941
  return values;
1892
1942
  }
1893
1943
 
@@ -2081,8 +2131,7 @@ var rnamespaces = /\.(.*)$/,
2081
2131
  rescape = /[^\w\s.|`]/g,
2082
2132
  fcleanup = function( nm ) {
2083
2133
  return nm.replace(rescape, "\\$&");
2084
- },
2085
- eventKey = "events";
2134
+ };
2086
2135
 
2087
2136
  /*
2088
2137
  * A number of helper functions used for managing events.
@@ -2098,17 +2147,22 @@ jQuery.event = {
2098
2147
  return;
2099
2148
  }
2100
2149
 
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;
2150
+ // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
2151
+ // Minor release fix for bug #8018
2152
+ try {
2153
+ // For whatever reason, IE has trouble passing the window object
2154
+ // around, causing it to be cloned in the process
2155
+ if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
2156
+ elem = window;
2157
+ }
2105
2158
  }
2159
+ catch ( e ) {}
2106
2160
 
2107
2161
  if ( handler === false ) {
2108
2162
  handler = returnFalse;
2109
2163
  } else if ( !handler ) {
2110
2164
  // Fixes bug #7229. Fix recommended by jdalton
2111
- return;
2165
+ return;
2112
2166
  }
2113
2167
 
2114
2168
  var handleObjIn, handleObj;
@@ -2132,23 +2186,10 @@ jQuery.event = {
2132
2186
  return;
2133
2187
  }
2134
2188
 
2135
- var events = elemData[ eventKey ],
2189
+ var events = elemData.events,
2136
2190
  eventHandle = elemData.handle;
2137
2191
 
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
-
2192
+ if ( !events ) {
2152
2193
  elemData.events = events = {};
2153
2194
  }
2154
2195
 
@@ -2249,17 +2290,12 @@ jQuery.event = {
2249
2290
 
2250
2291
  var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2251
2292
  elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2252
- events = elemData && elemData[ eventKey ];
2293
+ events = elemData && elemData.events;
2253
2294
 
2254
2295
  if ( !elemData || !events ) {
2255
2296
  return;
2256
2297
  }
2257
2298
 
2258
- if ( typeof events === "function" ) {
2259
- elemData = events;
2260
- events = events.events;
2261
- }
2262
-
2263
2299
  // types is actually an event object here
2264
2300
  if ( types && types.type ) {
2265
2301
  handler = types.handler;
@@ -2359,10 +2395,7 @@ jQuery.event = {
2359
2395
  delete elemData.events;
2360
2396
  delete elemData.handle;
2361
2397
 
2362
- if ( typeof elemData === "function" ) {
2363
- jQuery.removeData( elem, eventKey, true );
2364
-
2365
- } else if ( jQuery.isEmptyObject( elemData ) ) {
2398
+ if ( jQuery.isEmptyObject( elemData ) ) {
2366
2399
  jQuery.removeData( elem, undefined, true );
2367
2400
  }
2368
2401
  }
@@ -2403,7 +2436,7 @@ jQuery.event = {
2403
2436
  // points to jQuery.expando
2404
2437
  var internalKey = jQuery.expando,
2405
2438
  internalCache = this[ internalKey ];
2406
- if ( internalCache && internalCache.events && internalCache.events[type] ) {
2439
+ if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
2407
2440
  jQuery.event.trigger( event, data, internalCache.handle.elem );
2408
2441
  }
2409
2442
  });
@@ -2429,9 +2462,7 @@ jQuery.event = {
2429
2462
  event.currentTarget = elem;
2430
2463
 
2431
2464
  // 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;
2465
+ var handle = jQuery._data( elem, "handle" );
2435
2466
 
2436
2467
  if ( handle ) {
2437
2468
  handle.apply( elem, data );
@@ -2509,11 +2540,7 @@ jQuery.event = {
2509
2540
 
2510
2541
  event.namespace = event.namespace || namespace_sort.join(".");
2511
2542
 
2512
- events = jQuery._data(this, eventKey);
2513
-
2514
- if ( typeof events === "function" ) {
2515
- events = events.events;
2516
- }
2543
+ events = jQuery._data(this, "events");
2517
2544
 
2518
2545
  handlers = (events || {})[ event.type ];
2519
2546
 
@@ -2680,7 +2707,7 @@ jQuery.Event = function( src ) {
2680
2707
 
2681
2708
  // Events bubbling up the document may have been marked as prevented
2682
2709
  // by a handler lower down the tree; reflect the correct value.
2683
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
2710
+ this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
2684
2711
  src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
2685
2712
 
2686
2713
  // Event type
@@ -2755,6 +2782,12 @@ var withinElement = function( event ) {
2755
2782
  // Firefox sometimes assigns relatedTarget a XUL element
2756
2783
  // which we cannot access the parentNode property of
2757
2784
  try {
2785
+
2786
+ // Chrome does something similar, the parentNode property
2787
+ // can be accessed but is null.
2788
+ if ( parent !== document && !parent.parentNode ) {
2789
+ return;
2790
+ }
2758
2791
  // Traverse up the tree
2759
2792
  while ( parent && parent !== this ) {
2760
2793
  parent = parent.parentNode;
@@ -2805,8 +2838,7 @@ if ( !jQuery.support.submitBubbles ) {
2805
2838
  type = elem.type;
2806
2839
 
2807
2840
  if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
2808
- e.liveFired = undefined;
2809
- return trigger( "submit", this, arguments );
2841
+ trigger( "submit", this, arguments );
2810
2842
  }
2811
2843
  });
2812
2844
 
@@ -2815,8 +2847,7 @@ if ( !jQuery.support.submitBubbles ) {
2815
2847
  type = elem.type;
2816
2848
 
2817
2849
  if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
2818
- e.liveFired = undefined;
2819
- return trigger( "submit", this, arguments );
2850
+ trigger( "submit", this, arguments );
2820
2851
  }
2821
2852
  });
2822
2853
 
@@ -2879,7 +2910,7 @@ if ( !jQuery.support.changeBubbles ) {
2879
2910
  if ( data != null || val ) {
2880
2911
  e.type = "change";
2881
2912
  e.liveFired = undefined;
2882
- return jQuery.event.trigger( e, arguments[1], elem );
2913
+ jQuery.event.trigger( e, arguments[1], elem );
2883
2914
  }
2884
2915
  };
2885
2916
 
@@ -2893,7 +2924,7 @@ if ( !jQuery.support.changeBubbles ) {
2893
2924
  var elem = e.target, type = elem.type;
2894
2925
 
2895
2926
  if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
2896
- return testChange.call( this, e );
2927
+ testChange.call( this, e );
2897
2928
  }
2898
2929
  },
2899
2930
 
@@ -2905,7 +2936,7 @@ if ( !jQuery.support.changeBubbles ) {
2905
2936
  if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
2906
2937
  (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
2907
2938
  type === "select-multiple" ) {
2908
- return testChange.call( this, e );
2939
+ testChange.call( this, e );
2909
2940
  }
2910
2941
  },
2911
2942
 
@@ -2944,8 +2975,18 @@ if ( !jQuery.support.changeBubbles ) {
2944
2975
  }
2945
2976
 
2946
2977
  function trigger( type, elem, args ) {
2947
- args[0].type = type;
2948
- return jQuery.event.handle.apply( elem, args );
2978
+ // Piggyback on a donor event to simulate a different one.
2979
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
2980
+ // simulated event prevents default then we do the same on the donor.
2981
+ // Don't pass args or remember liveFired; they apply to the donor event.
2982
+ var event = jQuery.extend( {}, args[ 0 ] );
2983
+ event.type = type;
2984
+ event.originalEvent = {};
2985
+ event.liveFired = undefined;
2986
+ jQuery.event.handle.call( elem, event );
2987
+ if ( event.isDefaultPrevented() ) {
2988
+ args[ 0 ].preventDefault();
2989
+ }
2949
2990
  }
2950
2991
 
2951
2992
  // Create "bubbling" focus and blur events
@@ -2954,8 +2995,8 @@ if ( document.addEventListener ) {
2954
2995
  jQuery.event.special[ fix ] = {
2955
2996
  setup: function() {
2956
2997
  this.addEventListener( orig, handler, true );
2957
- },
2958
- teardown: function() {
2998
+ },
2999
+ teardown: function() {
2959
3000
  this.removeEventListener( orig, handler, true );
2960
3001
  }
2961
3002
  };
@@ -3148,11 +3189,7 @@ function liveHandler( event ) {
3148
3189
  var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
3149
3190
  elems = [],
3150
3191
  selectors = [],
3151
- events = jQuery._data( this, eventKey );
3152
-
3153
- if ( typeof events === "function" ) {
3154
- events = events.events;
3155
- }
3192
+ events = jQuery._data( this, "events" );
3156
3193
 
3157
3194
  // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
3158
3195
  if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
@@ -3186,7 +3223,7 @@ function liveHandler( event ) {
3186
3223
  for ( j = 0; j < live.length; j++ ) {
3187
3224
  handleObj = live[j];
3188
3225
 
3189
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
3226
+ if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
3190
3227
  elem = close.elem;
3191
3228
  related = null;
3192
3229
 
@@ -3269,7 +3306,9 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[
3269
3306
  done = 0,
3270
3307
  toString = Object.prototype.toString,
3271
3308
  hasDuplicate = false,
3272
- baseHasDuplicate = true;
3309
+ baseHasDuplicate = true,
3310
+ rBackslash = /\\/g,
3311
+ rNonWord = /\W/;
3273
3312
 
3274
3313
  // Here we check if the JavaScript engine is using some sort of
3275
3314
  // optimization where it does not always call our comparision
@@ -3468,7 +3507,7 @@ Sizzle.find = function( expr, context, isXML ) {
3468
3507
  match.splice( 1, 1 );
3469
3508
 
3470
3509
  if ( left.substr( left.length - 1 ) !== "\\" ) {
3471
- match[1] = (match[1] || "").replace(/\\/g, "");
3510
+ match[1] = (match[1] || "").replace( rBackslash, "" );
3472
3511
  set = Expr.find[ type ]( match, context, isXML );
3473
3512
 
3474
3513
  if ( set != null ) {
@@ -3607,13 +3646,16 @@ var Expr = Sizzle.selectors = {
3607
3646
  attrHandle: {
3608
3647
  href: function( elem ) {
3609
3648
  return elem.getAttribute( "href" );
3649
+ },
3650
+ type: function( elem ) {
3651
+ return elem.getAttribute( "type" );
3610
3652
  }
3611
3653
  },
3612
3654
 
3613
3655
  relative: {
3614
3656
  "+": function(checkSet, part){
3615
3657
  var isPartStr = typeof part === "string",
3616
- isTag = isPartStr && !/\W/.test( part ),
3658
+ isTag = isPartStr && !rNonWord.test( part ),
3617
3659
  isPartStrNotTag = isPartStr && !isTag;
3618
3660
 
3619
3661
  if ( isTag ) {
@@ -3641,7 +3683,7 @@ var Expr = Sizzle.selectors = {
3641
3683
  i = 0,
3642
3684
  l = checkSet.length;
3643
3685
 
3644
- if ( isPartStr && !/\W/.test( part ) ) {
3686
+ if ( isPartStr && !rNonWord.test( part ) ) {
3645
3687
  part = part.toLowerCase();
3646
3688
 
3647
3689
  for ( ; i < l; i++ ) {
@@ -3675,7 +3717,7 @@ var Expr = Sizzle.selectors = {
3675
3717
  doneName = done++,
3676
3718
  checkFn = dirCheck;
3677
3719
 
3678
- if ( typeof part === "string" && !/\W/.test(part) ) {
3720
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
3679
3721
  part = part.toLowerCase();
3680
3722
  nodeCheck = part;
3681
3723
  checkFn = dirNodeCheck;
@@ -3689,7 +3731,7 @@ var Expr = Sizzle.selectors = {
3689
3731
  doneName = done++,
3690
3732
  checkFn = dirCheck;
3691
3733
 
3692
- if ( typeof part === "string" && !/\W/.test( part ) ) {
3734
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
3693
3735
  part = part.toLowerCase();
3694
3736
  nodeCheck = part;
3695
3737
  checkFn = dirNodeCheck;
@@ -3732,7 +3774,7 @@ var Expr = Sizzle.selectors = {
3732
3774
  },
3733
3775
  preFilter: {
3734
3776
  CLASS: function( match, curLoop, inplace, result, not, isXML ) {
3735
- match = " " + match[1].replace(/\\/g, "") + " ";
3777
+ match = " " + match[1].replace( rBackslash, "" ) + " ";
3736
3778
 
3737
3779
  if ( isXML ) {
3738
3780
  return match;
@@ -3755,11 +3797,11 @@ var Expr = Sizzle.selectors = {
3755
3797
  },
3756
3798
 
3757
3799
  ID: function( match ) {
3758
- return match[1].replace(/\\/g, "");
3800
+ return match[1].replace( rBackslash, "" );
3759
3801
  },
3760
3802
 
3761
3803
  TAG: function( match, curLoop ) {
3762
- return match[1].toLowerCase();
3804
+ return match[1].replace( rBackslash, "" ).toLowerCase();
3763
3805
  },
3764
3806
 
3765
3807
  CHILD: function( match ) {
@@ -3790,14 +3832,14 @@ var Expr = Sizzle.selectors = {
3790
3832
  },
3791
3833
 
3792
3834
  ATTR: function( match, curLoop, inplace, result, not, isXML ) {
3793
- var name = match[1] = match[1].replace(/\\/g, "");
3835
+ var name = match[1] = match[1].replace( rBackslash, "" );
3794
3836
 
3795
3837
  if ( !isXML && Expr.attrMap[name] ) {
3796
3838
  match[1] = Expr.attrMap[name];
3797
3839
  }
3798
3840
 
3799
3841
  // Handle if an un-quoted value was used
3800
- match[4] = ( match[4] || match[5] || "" ).replace(/\\/g, "");
3842
+ match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
3801
3843
 
3802
3844
  if ( match[2] === "~=" ) {
3803
3845
  match[4] = " " + match[4] + " ";
@@ -3852,7 +3894,9 @@ var Expr = Sizzle.selectors = {
3852
3894
  selected: function( elem ) {
3853
3895
  // Accessing this property makes selected-by-default
3854
3896
  // options in Safari work properly
3855
- elem.parentNode.selectedIndex;
3897
+ if ( elem.parentNode ) {
3898
+ elem.parentNode.selectedIndex;
3899
+ }
3856
3900
 
3857
3901
  return elem.selected === true;
3858
3902
  },
@@ -3874,7 +3918,9 @@ var Expr = Sizzle.selectors = {
3874
3918
  },
3875
3919
 
3876
3920
  text: function( elem ) {
3877
- return "text" === elem.type;
3921
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
3922
+ // use getAttribute instead to test this case
3923
+ return "text" === elem.getAttribute( 'type' );
3878
3924
  },
3879
3925
  radio: function( elem ) {
3880
3926
  return "radio" === elem.type;
@@ -4407,7 +4453,8 @@ if ( document.querySelectorAll ) {
4407
4453
  // and working up from there (Thanks to Andrew Dupont for the technique)
4408
4454
  // IE 8 doesn't work on object elements
4409
4455
  } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
4410
- var old = context.getAttribute( "id" ),
4456
+ var oldContext = context,
4457
+ old = context.getAttribute( "id" ),
4411
4458
  nid = old || id,
4412
4459
  hasParent = context.parentNode,
4413
4460
  relativeHierarchySelector = /^\s*[+~]/.test( query );
@@ -4429,7 +4476,7 @@ if ( document.querySelectorAll ) {
4429
4476
  } catch(pseudoError) {
4430
4477
  } finally {
4431
4478
  if ( !old ) {
4432
- context.removeAttribute( "id" );
4479
+ oldContext.removeAttribute( "id" );
4433
4480
  }
4434
4481
  }
4435
4482
  }
@@ -4845,11 +4892,11 @@ jQuery.each({
4845
4892
  }, function( name, fn ) {
4846
4893
  jQuery.fn[ name ] = function( until, selector ) {
4847
4894
  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);
4895
+ // The variable 'args' was introduced in
4896
+ // https://github.com/jquery/jquery/commit/52a0238
4897
+ // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
4898
+ // http://code.google.com/p/v8/issues/detail?id=1050
4899
+ args = slice.call(arguments);
4853
4900
 
4854
4901
  if ( !runtil.test( name ) ) {
4855
4902
  selector = until;
@@ -4959,7 +5006,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
4959
5006
  rtbody = /<tbody/i,
4960
5007
  rhtml = /<|&#?\w+;/,
4961
5008
  rnocache = /<(?:script|object|embed|option|style)/i,
4962
- // checked="checked" or checked (html5)
5009
+ // checked="checked" or checked
4963
5010
  rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
4964
5011
  wrapMap = {
4965
5012
  option: [ 1, "<select multiple='multiple'>", "</select>" ],
@@ -5111,7 +5158,7 @@ jQuery.fn.extend({
5111
5158
  }
5112
5159
 
5113
5160
  if ( elem.parentNode ) {
5114
- elem.parentNode.removeChild( elem );
5161
+ elem.parentNode.removeChild( elem );
5115
5162
  }
5116
5163
  }
5117
5164
  }
@@ -5136,7 +5183,7 @@ jQuery.fn.extend({
5136
5183
  },
5137
5184
 
5138
5185
  clone: function( dataAndEvents, deepDataAndEvents ) {
5139
- dataAndEvents = dataAndEvents == null ? true : dataAndEvents;
5186
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5140
5187
  deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5141
5188
 
5142
5189
  return this.map( function () {
@@ -5305,8 +5352,8 @@ function cloneCopyEvent( src, dest ) {
5305
5352
  }
5306
5353
 
5307
5354
  var internalKey = jQuery.expando,
5308
- oldData = jQuery.data( src ),
5309
- curData = jQuery.data( dest, oldData );
5355
+ oldData = jQuery.data( src ),
5356
+ curData = jQuery.data( dest, oldData );
5310
5357
 
5311
5358
  // Switch to use the internal data object, if it exists, for the next
5312
5359
  // stage of data copying
@@ -5320,7 +5367,7 @@ function cloneCopyEvent( src, dest ) {
5320
5367
 
5321
5368
  for ( var type in events ) {
5322
5369
  for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
5323
- jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data );
5370
+ jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5324
5371
  }
5325
5372
  }
5326
5373
  }
@@ -5441,6 +5488,18 @@ jQuery.each({
5441
5488
  };
5442
5489
  });
5443
5490
 
5491
+ function getAll( elem ) {
5492
+ if ( "getElementsByTagName" in elem ) {
5493
+ return elem.getElementsByTagName( "*" );
5494
+
5495
+ } else if ( "querySelectorAll" in elem ) {
5496
+ return elem.querySelectorAll( "*" );
5497
+
5498
+ } else {
5499
+ return [];
5500
+ }
5501
+ }
5502
+
5444
5503
  jQuery.extend({
5445
5504
  clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5446
5505
  var clone = elem.cloneNode(true),
@@ -5448,17 +5507,20 @@ jQuery.extend({
5448
5507
  destElements,
5449
5508
  i;
5450
5509
 
5451
- if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
5510
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
5511
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
5452
5512
  // IE copies events bound via attachEvent when using cloneNode.
5453
5513
  // Calling detachEvent on the clone will also remove the events
5454
5514
  // from the original. In order to get around this, we use some
5455
5515
  // proprietary methods to clear the events. Thanks to MooTools
5456
5516
  // guys for this hotness.
5457
5517
 
5518
+ cloneFixAttributes( elem, clone );
5519
+
5458
5520
  // Using Sizzle here is crazy slow, so we use getElementsByTagName
5459
5521
  // instead
5460
- srcElements = elem.getElementsByTagName("*");
5461
- destElements = clone.getElementsByTagName("*");
5522
+ srcElements = getAll( elem );
5523
+ destElements = getAll( clone );
5462
5524
 
5463
5525
  // Weird iteration because IE will replace the length property
5464
5526
  // with an element if you are cloning the body and one of the
@@ -5466,30 +5528,25 @@ jQuery.extend({
5466
5528
  for ( i = 0; srcElements[i]; ++i ) {
5467
5529
  cloneFixAttributes( srcElements[i], destElements[i] );
5468
5530
  }
5469
-
5470
- cloneFixAttributes( elem, clone );
5471
5531
  }
5472
5532
 
5473
5533
  // Copy the events from the original to the clone
5474
5534
  if ( dataAndEvents ) {
5475
-
5476
5535
  cloneCopyEvent( elem, clone );
5477
5536
 
5478
- if ( deepDataAndEvents && "getElementsByTagName" in elem ) {
5537
+ if ( deepDataAndEvents ) {
5538
+ srcElements = getAll( elem );
5539
+ destElements = getAll( clone );
5479
5540
 
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
- }
5541
+ for ( i = 0; srcElements[i]; ++i ) {
5542
+ cloneCopyEvent( srcElements[i], destElements[i] );
5487
5543
  }
5488
5544
  }
5489
5545
  }
5546
+
5490
5547
  // Return the cloned set
5491
5548
  return clone;
5492
- },
5549
+ },
5493
5550
  clean: function( elems, context, fragment, scripts ) {
5494
5551
  context = context || document;
5495
5552
 
@@ -5910,7 +5967,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
5910
5967
 
5911
5968
  if ( document.documentElement.currentStyle ) {
5912
5969
  currentStyle = function( elem, name ) {
5913
- var left,
5970
+ var left,
5914
5971
  ret = elem.currentStyle && elem.currentStyle[ name ],
5915
5972
  rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
5916
5973
  style = elem.style;
@@ -5988,8 +6045,10 @@ var r20 = /%20/g,
5988
6045
  rbracket = /\[\]$/,
5989
6046
  rCRLF = /\r?\n/g,
5990
6047
  rhash = /#.*$/,
5991
- rheaders = /^(.*?):\s*(.*?)\r?$/mg, // IE leaves an \r character at EOL
6048
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
5992
6049
  rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6050
+ // #7653, #8125, #8152: local protocol detection
6051
+ rlocalProtocol = /(?:^file|^widget|\-extension):$/,
5993
6052
  rnoContent = /^(?:GET|HEAD)$/,
5994
6053
  rprotocol = /^\/\//,
5995
6054
  rquery = /\?/,
@@ -5997,7 +6056,11 @@ var r20 = /%20/g,
5997
6056
  rselectTextarea = /^(?:select|textarea)/i,
5998
6057
  rspacesAjax = /\s+/,
5999
6058
  rts = /([?&])_=[^&]*/,
6000
- rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/,
6059
+ rucHeaders = /(^|\-)([a-z])/g,
6060
+ rucHeadersFunc = function( _, $1, $2 ) {
6061
+ return $1 + $2.toUpperCase();
6062
+ },
6063
+ rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
6001
6064
 
6002
6065
  // Keep a copy of the old load method
6003
6066
  _load = jQuery.fn.load,
@@ -6018,7 +6081,28 @@ var r20 = /%20/g,
6018
6081
  * 2) the catchall symbol "*" can be used
6019
6082
  * 3) selection will start with transport dataType and THEN go to "*" if needed
6020
6083
  */
6021
- transports = {};
6084
+ transports = {},
6085
+
6086
+ // Document location
6087
+ ajaxLocation,
6088
+
6089
+ // Document location segments
6090
+ ajaxLocParts;
6091
+
6092
+ // #8138, IE may throw an exception when accessing
6093
+ // a field from document.location if document.domain has been set
6094
+ try {
6095
+ ajaxLocation = document.location.href;
6096
+ } catch( e ) {
6097
+ // Use the href attribute of an A element
6098
+ // since IE will modify it given document.location
6099
+ ajaxLocation = document.createElement( "a" );
6100
+ ajaxLocation.href = "";
6101
+ ajaxLocation = ajaxLocation.href;
6102
+ }
6103
+
6104
+ // Segment location into parts
6105
+ ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
6022
6106
 
6023
6107
  // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6024
6108
  function addToPrefiltersOrTransports( structure ) {
@@ -6057,7 +6141,7 @@ function addToPrefiltersOrTransports( structure ) {
6057
6141
  }
6058
6142
 
6059
6143
  //Base inspection function for prefilters and transports
6060
- function inspectPrefiltersOrTransports( structure, options, originalOptions, jXHR,
6144
+ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6061
6145
  dataType /* internal */, inspected /* internal */ ) {
6062
6146
 
6063
6147
  dataType = dataType || options.dataTypes[ 0 ];
@@ -6072,16 +6156,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
6072
6156
  selection;
6073
6157
 
6074
6158
  for(; i < length && ( executeOnly || !selection ); i++ ) {
6075
- selection = list[ i ]( options, originalOptions, jXHR );
6159
+ selection = list[ i ]( options, originalOptions, jqXHR );
6076
6160
  // If we got redirected to another dataType
6077
- // we try there if not done already
6161
+ // we try there if executing only and not done already
6078
6162
  if ( typeof selection === "string" ) {
6079
- if ( inspected[ selection ] ) {
6163
+ if ( !executeOnly || inspected[ selection ] ) {
6080
6164
  selection = undefined;
6081
6165
  } else {
6082
6166
  options.dataTypes.unshift( selection );
6083
6167
  selection = inspectPrefiltersOrTransports(
6084
- structure, options, originalOptions, jXHR, selection, inspected );
6168
+ structure, options, originalOptions, jqXHR, selection, inspected );
6085
6169
  }
6086
6170
  }
6087
6171
  }
@@ -6089,7 +6173,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
6089
6173
  // we try the catchall dataType if not done already
6090
6174
  if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6091
6175
  selection = inspectPrefiltersOrTransports(
6092
- structure, options, originalOptions, jXHR, "*", inspected );
6176
+ structure, options, originalOptions, jqXHR, "*", inspected );
6093
6177
  }
6094
6178
  // unnecessary when only executing (prefilters)
6095
6179
  // but it'll be ignored by the caller in that case
@@ -6121,7 +6205,7 @@ jQuery.fn.extend({
6121
6205
  if ( jQuery.isFunction( params ) ) {
6122
6206
  // We assume that it's the callback
6123
6207
  callback = params;
6124
- params = null;
6208
+ params = undefined;
6125
6209
 
6126
6210
  // Otherwise, build a param string
6127
6211
  } else if ( typeof params === "object" ) {
@@ -6139,14 +6223,14 @@ jQuery.fn.extend({
6139
6223
  dataType: "html",
6140
6224
  data: params,
6141
6225
  // 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;
6226
+ complete: function( jqXHR, status, responseText ) {
6227
+ // Store the response as specified by the jqXHR object
6228
+ responseText = jqXHR.responseText;
6145
6229
  // If successful, inject the HTML into all the matched elements
6146
- if ( jXHR.isResolved() ) {
6230
+ if ( jqXHR.isResolved() ) {
6147
6231
  // #4825: Get the actual response in case
6148
6232
  // a dataFilter is present in ajaxSettings
6149
- jXHR.done(function( r ) {
6233
+ jqXHR.done(function( r ) {
6150
6234
  responseText = r;
6151
6235
  });
6152
6236
  // See if a selector was specified
@@ -6165,7 +6249,7 @@ jQuery.fn.extend({
6165
6249
  }
6166
6250
 
6167
6251
  if ( callback ) {
6168
- self.each( callback, [ responseText, status, jXHR ] );
6252
+ self.each( callback, [ responseText, status, jqXHR ] );
6169
6253
  }
6170
6254
  }
6171
6255
  });
@@ -6213,7 +6297,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
6213
6297
  if ( jQuery.isFunction( data ) ) {
6214
6298
  type = type || callback;
6215
6299
  callback = data;
6216
- data = null;
6300
+ data = undefined;
6217
6301
  }
6218
6302
 
6219
6303
  return jQuery.ajax({
@@ -6229,22 +6313,39 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
6229
6313
  jQuery.extend({
6230
6314
 
6231
6315
  getScript: function( url, callback ) {
6232
- return jQuery.get( url, null, callback, "script" );
6316
+ return jQuery.get( url, undefined, callback, "script" );
6233
6317
  },
6234
6318
 
6235
6319
  getJSON: function( url, data, callback ) {
6236
6320
  return jQuery.get( url, data, callback, "json" );
6237
6321
  },
6238
6322
 
6239
- ajaxSetup: function( settings ) {
6240
- jQuery.extend( true, jQuery.ajaxSettings, settings );
6241
- if ( settings.context ) {
6242
- jQuery.ajaxSettings.context = settings.context;
6323
+ // Creates a full fledged settings object into target
6324
+ // with both ajaxSettings and settings fields.
6325
+ // If target is omitted, writes into ajaxSettings.
6326
+ ajaxSetup: function ( target, settings ) {
6327
+ if ( !settings ) {
6328
+ // Only one parameter, we extend ajaxSettings
6329
+ settings = target;
6330
+ target = jQuery.extend( true, jQuery.ajaxSettings, settings );
6331
+ } else {
6332
+ // target was provided, we extend into it
6333
+ jQuery.extend( true, target, jQuery.ajaxSettings, settings );
6243
6334
  }
6335
+ // Flatten fields we don't want deep extended
6336
+ for( var field in { context: 1, url: 1 } ) {
6337
+ if ( field in settings ) {
6338
+ target[ field ] = settings[ field ];
6339
+ } else if( field in jQuery.ajaxSettings ) {
6340
+ target[ field ] = jQuery.ajaxSettings[ field ];
6341
+ }
6342
+ }
6343
+ return target;
6244
6344
  },
6245
6345
 
6246
6346
  ajaxSettings: {
6247
- url: location.href,
6347
+ url: ajaxLocation,
6348
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
6248
6349
  global: true,
6249
6350
  type: "GET",
6250
6351
  contentType: "application/x-www-form-urlencoded",
@@ -6306,9 +6407,8 @@ jQuery.extend({
6306
6407
  // Main method
6307
6408
  ajax: function( url, options ) {
6308
6409
 
6309
- // If options is not an object,
6310
- // we simulate pre-1.5 signature
6311
- if ( typeof options !== "object" ) {
6410
+ // If url is an object, simulate pre-1.5 signature
6411
+ if ( typeof url === "object" ) {
6312
6412
  options = url;
6313
6413
  url = undefined;
6314
6414
  }
@@ -6317,19 +6417,22 @@ jQuery.extend({
6317
6417
  options = options || {};
6318
6418
 
6319
6419
  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 ),
6420
+ s = jQuery.ajaxSetup( {}, options ),
6421
+ // Callbacks context
6422
+ callbackContext = s.context || s,
6423
+ // Context for global events
6424
+ // It's the callbackContext if one was provided in the options
6425
+ // and if it's a DOM node or a jQuery collection
6426
+ globalEventContext = callbackContext !== s &&
6427
+ ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
6428
+ jQuery( callbackContext ) : jQuery.event,
6328
6429
  // Deferreds
6329
6430
  deferred = jQuery.Deferred(),
6330
6431
  completeDeferred = jQuery._Deferred(),
6331
6432
  // Status-dependent callbacks
6332
6433
  statusCode = s.statusCode || {},
6434
+ // ifModified key
6435
+ ifModifiedKey,
6333
6436
  // Headers (they are sent all at once)
6334
6437
  requestHeaders = {},
6335
6438
  // Response headers
@@ -6340,22 +6443,22 @@ jQuery.extend({
6340
6443
  // timeout handle
6341
6444
  timeoutTimer,
6342
6445
  // Cross-domain detection vars
6343
- loc = document.location,
6344
- protocol = loc.protocol || "http:",
6345
6446
  parts,
6346
- // The jXHR state
6447
+ // The jqXHR state
6347
6448
  state = 0,
6449
+ // To know if global events are to be dispatched
6450
+ fireGlobals,
6348
6451
  // Loop variable
6349
6452
  i,
6350
6453
  // Fake xhr
6351
- jXHR = {
6454
+ jqXHR = {
6352
6455
 
6353
6456
  readyState: 0,
6354
6457
 
6355
6458
  // Caches the header
6356
6459
  setRequestHeader: function( name, value ) {
6357
- if ( state === 0 ) {
6358
- requestHeaders[ name.toLowerCase() ] = value;
6460
+ if ( !state ) {
6461
+ requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
6359
6462
  }
6360
6463
  return this;
6361
6464
  },
@@ -6377,7 +6480,15 @@ jQuery.extend({
6377
6480
  }
6378
6481
  match = responseHeaders[ key.toLowerCase() ];
6379
6482
  }
6380
- return match || null;
6483
+ return match === undefined ? null : match;
6484
+ },
6485
+
6486
+ // Overrides response content-type header
6487
+ overrideMimeType: function( type ) {
6488
+ if ( !state ) {
6489
+ s.mimeType = type;
6490
+ }
6491
+ return this;
6381
6492
  },
6382
6493
 
6383
6494
  // Cancel the request
@@ -6394,7 +6505,7 @@ jQuery.extend({
6394
6505
  // Callback for when everything is done
6395
6506
  // It is defined here because jslint complains if it is declared
6396
6507
  // at the end of the function (which would be more logical and readable)
6397
- function done( status, statusText, responses, headers) {
6508
+ function done( status, statusText, responses, headers ) {
6398
6509
 
6399
6510
  // Called once
6400
6511
  if ( state === 2 ) {
@@ -6410,19 +6521,19 @@ jQuery.extend({
6410
6521
  }
6411
6522
 
6412
6523
  // Dereference transport for early garbage collection
6413
- // (no matter how long the jXHR object will be used)
6524
+ // (no matter how long the jqXHR object will be used)
6414
6525
  transport = undefined;
6415
6526
 
6416
6527
  // Cache response headers
6417
6528
  responseHeadersString = headers || "";
6418
6529
 
6419
6530
  // Set readyState
6420
- jXHR.readyState = status ? 4 : 0;
6531
+ jqXHR.readyState = status ? 4 : 0;
6421
6532
 
6422
6533
  var isSuccess,
6423
6534
  success,
6424
6535
  error,
6425
- response = responses ? ajaxHandleResponses( s, jXHR, responses ) : undefined,
6536
+ response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
6426
6537
  lastModified,
6427
6538
  etag;
6428
6539
 
@@ -6432,11 +6543,11 @@ jQuery.extend({
6432
6543
  // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6433
6544
  if ( s.ifModified ) {
6434
6545
 
6435
- if ( ( lastModified = jXHR.getResponseHeader( "Last-Modified" ) ) ) {
6436
- jQuery.lastModified[ s.url ] = lastModified;
6546
+ if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
6547
+ jQuery.lastModified[ ifModifiedKey ] = lastModified;
6437
6548
  }
6438
- if ( ( etag = jXHR.getResponseHeader( "Etag" ) ) ) {
6439
- jQuery.etag[ s.url ] = etag;
6549
+ if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
6550
+ jQuery.etag[ ifModifiedKey ] = etag;
6440
6551
  }
6441
6552
  }
6442
6553
 
@@ -6463,7 +6574,7 @@ jQuery.extend({
6463
6574
  // We extract error from statusText
6464
6575
  // then normalize statusText and status for non-aborts
6465
6576
  error = statusText;
6466
- if( status ) {
6577
+ if( !statusText || status ) {
6467
6578
  statusText = "error";
6468
6579
  if ( status < 0 ) {
6469
6580
  status = 0;
@@ -6472,30 +6583,30 @@ jQuery.extend({
6472
6583
  }
6473
6584
 
6474
6585
  // Set data for the fake xhr object
6475
- jXHR.status = status;
6476
- jXHR.statusText = statusText;
6586
+ jqXHR.status = status;
6587
+ jqXHR.statusText = statusText;
6477
6588
 
6478
6589
  // Success/Error
6479
6590
  if ( isSuccess ) {
6480
- deferred.resolveWith( callbackContext, [ success, statusText, jXHR ] );
6591
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
6481
6592
  } else {
6482
- deferred.rejectWith( callbackContext, [ jXHR, statusText, error ] );
6593
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
6483
6594
  }
6484
6595
 
6485
6596
  // Status-dependent callbacks
6486
- jXHR.statusCode( statusCode );
6597
+ jqXHR.statusCode( statusCode );
6487
6598
  statusCode = undefined;
6488
6599
 
6489
- if ( s.global ) {
6600
+ if ( fireGlobals ) {
6490
6601
  globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
6491
- [ jXHR, s, isSuccess ? success : error ] );
6602
+ [ jqXHR, s, isSuccess ? success : error ] );
6492
6603
  }
6493
6604
 
6494
6605
  // Complete
6495
- completeDeferred.resolveWith( callbackContext, [ jXHR, statusText ] );
6606
+ completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
6496
6607
 
6497
- if ( s.global ) {
6498
- globalEventContext.trigger( "ajaxComplete", [ jXHR, s] );
6608
+ if ( fireGlobals ) {
6609
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
6499
6610
  // Handle the global AJAX counter
6500
6611
  if ( !( --jQuery.active ) ) {
6501
6612
  jQuery.event.trigger( "ajaxStop" );
@@ -6504,13 +6615,13 @@ jQuery.extend({
6504
6615
  }
6505
6616
 
6506
6617
  // Attach deferreds
6507
- deferred.promise( jXHR );
6508
- jXHR.success = jXHR.done;
6509
- jXHR.error = jXHR.fail;
6510
- jXHR.complete = completeDeferred.done;
6618
+ deferred.promise( jqXHR );
6619
+ jqXHR.success = jqXHR.done;
6620
+ jqXHR.error = jqXHR.fail;
6621
+ jqXHR.complete = completeDeferred.done;
6511
6622
 
6512
6623
  // Status-dependent callbacks
6513
- jXHR.statusCode = function( map ) {
6624
+ jqXHR.statusCode = function( map ) {
6514
6625
  if ( map ) {
6515
6626
  var tmp;
6516
6627
  if ( state < 2 ) {
@@ -6518,8 +6629,8 @@ jQuery.extend({
6518
6629
  statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
6519
6630
  }
6520
6631
  } else {
6521
- tmp = map[ jXHR.status ];
6522
- jXHR.then( tmp, tmp );
6632
+ tmp = map[ jqXHR.status ];
6633
+ jqXHR.then( tmp, tmp );
6523
6634
  }
6524
6635
  }
6525
6636
  return this;
@@ -6528,7 +6639,7 @@ jQuery.extend({
6528
6639
  // Remove hash character (#7531: and string promotion)
6529
6640
  // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
6530
6641
  // We also use the url parameter if available
6531
- s.url = ( "" + ( url || s.url ) ).replace( rhash, "" ).replace( rprotocol, protocol + "//" );
6642
+ s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
6532
6643
 
6533
6644
  // Extract dataTypes list
6534
6645
  s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
@@ -6537,9 +6648,9 @@ jQuery.extend({
6537
6648
  if ( !s.crossDomain ) {
6538
6649
  parts = rurl.exec( s.url.toLowerCase() );
6539
6650
  s.crossDomain = !!( parts &&
6540
- ( parts[ 1 ] != protocol || parts[ 2 ] != loc.hostname ||
6651
+ ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
6541
6652
  ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
6542
- ( loc.port || ( protocol === "http:" ? 80 : 443 ) ) )
6653
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
6543
6654
  );
6544
6655
  }
6545
6656
 
@@ -6549,7 +6660,15 @@ jQuery.extend({
6549
6660
  }
6550
6661
 
6551
6662
  // Apply prefilters
6552
- inspectPrefiltersOrTransports( prefilters, s, options, jXHR );
6663
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
6664
+
6665
+ // If request was aborted inside a prefiler, stop there
6666
+ if ( state === 2 ) {
6667
+ return false;
6668
+ }
6669
+
6670
+ // We can fire global events as of now if asked to
6671
+ fireGlobals = s.global;
6553
6672
 
6554
6673
  // Uppercase the type
6555
6674
  s.type = s.type.toUpperCase();
@@ -6558,7 +6677,7 @@ jQuery.extend({
6558
6677
  s.hasContent = !rnoContent.test( s.type );
6559
6678
 
6560
6679
  // Watch for a new set of requests
6561
- if ( s.global && jQuery.active++ === 0 ) {
6680
+ if ( fireGlobals && jQuery.active++ === 0 ) {
6562
6681
  jQuery.event.trigger( "ajaxStart" );
6563
6682
  }
6564
6683
 
@@ -6570,6 +6689,9 @@ jQuery.extend({
6570
6689
  s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
6571
6690
  }
6572
6691
 
6692
+ // Get ifModifiedKey before adding the anti-cache parameter
6693
+ ifModifiedKey = s.url;
6694
+
6573
6695
  // Add anti-cache in url if needed
6574
6696
  if ( s.cache === false ) {
6575
6697
 
@@ -6584,77 +6706,77 @@ jQuery.extend({
6584
6706
 
6585
6707
  // Set the correct header, if data is being sent
6586
6708
  if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
6587
- requestHeaders[ "content-type" ] = s.contentType;
6709
+ requestHeaders[ "Content-Type" ] = s.contentType;
6588
6710
  }
6589
6711
 
6590
6712
  // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6591
6713
  if ( s.ifModified ) {
6592
- if ( jQuery.lastModified[ s.url ] ) {
6593
- requestHeaders[ "if-modified-since" ] = jQuery.lastModified[ s.url ];
6714
+ ifModifiedKey = ifModifiedKey || s.url;
6715
+ if ( jQuery.lastModified[ ifModifiedKey ] ) {
6716
+ requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
6594
6717
  }
6595
- if ( jQuery.etag[ s.url ] ) {
6596
- requestHeaders[ "if-none-match" ] = jQuery.etag[ s.url ];
6718
+ if ( jQuery.etag[ ifModifiedKey ] ) {
6719
+ requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
6597
6720
  }
6598
6721
  }
6599
6722
 
6600
6723
  // Set the Accepts header for the server, depending on the dataType
6601
- requestHeaders.accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
6724
+ requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
6602
6725
  s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
6603
6726
  s.accepts[ "*" ];
6604
6727
 
6605
6728
  // Check for headers option
6606
6729
  for ( i in s.headers ) {
6607
- requestHeaders[ i.toLowerCase() ] = s.headers[ i ];
6730
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
6608
6731
  }
6609
6732
 
6610
6733
  // Allow custom headers/mimetypes and early abort
6611
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jXHR, s ) === false || state === 2 ) ) {
6734
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
6612
6735
  // Abort if not done already
6613
- done( 0, "abort" );
6614
- // Return false
6615
- jXHR = false;
6736
+ jqXHR.abort();
6737
+ return false;
6616
6738
 
6617
- } else {
6739
+ }
6618
6740
 
6619
- // Install callbacks on deferreds
6620
- for ( i in { success: 1, error: 1, complete: 1 } ) {
6621
- jXHR[ i ]( s[ i ] );
6622
- }
6741
+ // Install callbacks on deferreds
6742
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
6743
+ jqXHR[ i ]( s[ i ] );
6744
+ }
6623
6745
 
6624
- // Get transport
6625
- transport = inspectPrefiltersOrTransports( transports, s, options, jXHR );
6746
+ // Get transport
6747
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
6626
6748
 
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
- }
6749
+ // If no transport, we auto-abort
6750
+ if ( !transport ) {
6751
+ done( -1, "No Transport" );
6752
+ } else {
6753
+ jqXHR.readyState = 1;
6754
+ // Send global event
6755
+ if ( fireGlobals ) {
6756
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
6757
+ }
6758
+ // Timeout
6759
+ if ( s.async && s.timeout > 0 ) {
6760
+ timeoutTimer = setTimeout( function(){
6761
+ jqXHR.abort( "timeout" );
6762
+ }, s.timeout );
6763
+ }
6643
6764
 
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
- }
6765
+ try {
6766
+ state = 1;
6767
+ transport.send( requestHeaders, done );
6768
+ } catch (e) {
6769
+ // Propagate exception as error if not done
6770
+ if ( status < 2 ) {
6771
+ done( -1, e );
6772
+ // Simply rethrow otherwise
6773
+ } else {
6774
+ jQuery.error( e );
6654
6775
  }
6655
6776
  }
6656
6777
  }
6657
- return jXHR;
6778
+
6779
+ return jqXHR;
6658
6780
  },
6659
6781
 
6660
6782
  // Serialize an array of form elements or a set of
@@ -6673,7 +6795,7 @@ jQuery.extend({
6673
6795
  }
6674
6796
 
6675
6797
  // If an array was passed in, assume that it is an array of form elements.
6676
- if ( jQuery.isArray( a ) || a.jquery ) {
6798
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
6677
6799
  // Serialize the form elements
6678
6800
  jQuery.each( a, function() {
6679
6801
  add( this.name, this.value );
@@ -6720,9 +6842,9 @@ function buildParams( prefix, obj, traditional, add ) {
6720
6842
 
6721
6843
  // Serialize object item.
6722
6844
  } else {
6723
- jQuery.each( obj, function( k, v ) {
6724
- buildParams( prefix + "[" + k + "]", v, traditional, add );
6725
- });
6845
+ for ( var name in obj ) {
6846
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
6847
+ }
6726
6848
  }
6727
6849
 
6728
6850
  } else {
@@ -6749,7 +6871,7 @@ jQuery.extend({
6749
6871
  * - finds the right dataType (mediates between content-type and expected dataType)
6750
6872
  * - returns the corresponding response
6751
6873
  */
6752
- function ajaxHandleResponses( s, jXHR, responses ) {
6874
+ function ajaxHandleResponses( s, jqXHR, responses ) {
6753
6875
 
6754
6876
  var contents = s.contents,
6755
6877
  dataTypes = s.dataTypes,
@@ -6762,7 +6884,7 @@ function ajaxHandleResponses( s, jXHR, responses ) {
6762
6884
  // Fill responseXXX fields
6763
6885
  for( type in responseFields ) {
6764
6886
  if ( type in responses ) {
6765
- jXHR[ responseFields[type] ] = responses[ type ];
6887
+ jqXHR[ responseFields[type] ] = responses[ type ];
6766
6888
  }
6767
6889
  }
6768
6890
 
@@ -6770,7 +6892,7 @@ function ajaxHandleResponses( s, jXHR, responses ) {
6770
6892
  while( dataTypes[ 0 ] === "*" ) {
6771
6893
  dataTypes.shift();
6772
6894
  if ( ct === undefined ) {
6773
- ct = jXHR.getResponseHeader( "content-type" );
6895
+ ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
6774
6896
  }
6775
6897
  }
6776
6898
 
@@ -6822,8 +6944,9 @@ function ajaxConvert( s, response ) {
6822
6944
  }
6823
6945
 
6824
6946
  var dataTypes = s.dataTypes,
6825
- converters = s.converters,
6947
+ converters = {},
6826
6948
  i,
6949
+ key,
6827
6950
  length = dataTypes.length,
6828
6951
  tmp,
6829
6952
  // Current and previous dataTypes
@@ -6840,6 +6963,16 @@ function ajaxConvert( s, response ) {
6840
6963
  // For each dataType in the chain
6841
6964
  for( i = 1; i < length; i++ ) {
6842
6965
 
6966
+ // Create converters map
6967
+ // with lowercased keys
6968
+ if ( i === 1 ) {
6969
+ for( key in s.converters ) {
6970
+ if( typeof key === "string" ) {
6971
+ converters[ key.toLowerCase() ] = s.converters[ key ];
6972
+ }
6973
+ }
6974
+ }
6975
+
6843
6976
  // Get the dataTypes
6844
6977
  prev = current;
6845
6978
  current = dataTypes[ i ];
@@ -6902,9 +7035,9 @@ jQuery.ajaxSetup({
6902
7035
  });
6903
7036
 
6904
7037
  // Detect, normalize options and install callbacks for jsonp requests
6905
- jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */ ) {
7038
+ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
6906
7039
 
6907
- dataIsString = ( typeof s.data === "string" );
7040
+ var dataIsString = ( typeof s.data === "string" );
6908
7041
 
6909
7042
  if ( s.dataTypes[ 0 ] === "jsonp" ||
6910
7043
  originalSettings.jsonpCallback ||
@@ -6918,7 +7051,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
6918
7051
  previous = window[ jsonpCallback ],
6919
7052
  url = s.url,
6920
7053
  data = s.data,
6921
- replace = "$1" + jsonpCallback + "$2";
7054
+ replace = "$1" + jsonpCallback + "$2",
7055
+ cleanUp = function() {
7056
+ // Set callback back to previous value
7057
+ window[ jsonpCallback ] = previous;
7058
+ // Call if it was a function and we have a response
7059
+ if ( responseContainer && jQuery.isFunction( previous ) ) {
7060
+ window[ jsonpCallback ]( responseContainer[ 0 ] );
7061
+ }
7062
+ };
6922
7063
 
6923
7064
  if ( s.jsonp !== false ) {
6924
7065
  url = url.replace( jsre, replace );
@@ -6936,32 +7077,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
6936
7077
  s.url = url;
6937
7078
  s.data = data;
6938
7079
 
7080
+ // Install callback
6939
7081
  window[ jsonpCallback ] = function( response ) {
6940
7082
  responseContainer = [ response ];
6941
7083
  };
6942
7084
 
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 ];
7085
+ // Install cleanUp function
7086
+ jqXHR.then( cleanUp, cleanUp );
6961
7087
 
6962
7088
  // Use data converter to retrieve json after script execution
6963
7089
  s.converters["script json"] = function() {
6964
- if ( ! responseContainer ) {
7090
+ if ( !responseContainer ) {
6965
7091
  jQuery.error( jsonpCallback + " was not called" );
6966
7092
  }
6967
7093
  return responseContainer[ 0 ];
@@ -6981,10 +7107,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
6981
7107
  // Install script dataType
6982
7108
  jQuery.ajaxSetup({
6983
7109
  accepts: {
6984
- script: "text/javascript, application/javascript"
7110
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
6985
7111
  },
6986
7112
  contents: {
6987
- script: /javascript/
7113
+ script: /javascript|ecmascript/
6988
7114
  },
6989
7115
  converters: {
6990
7116
  "text script": function( text ) {
@@ -7012,7 +7138,7 @@ jQuery.ajaxTransport( "script", function(s) {
7012
7138
  if ( s.crossDomain ) {
7013
7139
 
7014
7140
  var script,
7015
- head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement;
7141
+ head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7016
7142
 
7017
7143
  return {
7018
7144
 
@@ -7067,18 +7193,36 @@ jQuery.ajaxTransport( "script", function(s) {
7067
7193
 
7068
7194
 
7069
7195
 
7070
- var // Next active xhr id
7196
+ var // #5280: next active xhr id and list of active xhrs' callbacks
7071
7197
  xhrId = jQuery.now(),
7072
-
7073
- // active xhrs
7074
- xhrs = {},
7075
-
7076
- // #5280: see below
7077
- xhrUnloadAbortInstalled,
7198
+ xhrCallbacks,
7078
7199
 
7079
7200
  // XHR used to determine supports properties
7080
7201
  testXHR;
7081
7202
 
7203
+ // #5280: Internet Explorer will keep connections alive if we don't abort on unload
7204
+ function xhrOnUnloadAbort() {
7205
+ jQuery( window ).unload(function() {
7206
+ // Abort all pending requests
7207
+ for ( var key in xhrCallbacks ) {
7208
+ xhrCallbacks[ key ]( 0, 1 );
7209
+ }
7210
+ });
7211
+ }
7212
+
7213
+ // Functions to create xhrs
7214
+ function createStandardXHR() {
7215
+ try {
7216
+ return new window.XMLHttpRequest();
7217
+ } catch( e ) {}
7218
+ }
7219
+
7220
+ function createActiveXHR() {
7221
+ try {
7222
+ return new window.ActiveXObject( "Microsoft.XMLHTTP" );
7223
+ } catch( e ) {}
7224
+ }
7225
+
7082
7226
  // Create the request object
7083
7227
  // (This is still attached to ajaxSettings for backward compatibility)
7084
7228
  jQuery.ajaxSettings.xhr = window.ActiveXObject ?
@@ -7089,27 +7233,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
7089
7233
  * we need a fallback.
7090
7234
  */
7091
7235
  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 ) {}
7236
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
7101
7237
  } :
7102
7238
  // For all other browsers, use the standard XMLHttpRequest object
7103
- function() {
7104
- return new window.XMLHttpRequest();
7105
- };
7239
+ createStandardXHR;
7106
7240
 
7107
7241
  // 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?
7242
+ testXHR = jQuery.ajaxSettings.xhr();
7113
7243
  jQuery.support.ajax = !!testXHR;
7114
7244
 
7115
7245
  // Does this browser support crossDomain XHR requests
@@ -7130,26 +7260,10 @@ if ( jQuery.support.ajax ) {
7130
7260
  return {
7131
7261
  send: function( headers, complete ) {
7132
7262
 
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
7263
  // Get a new xhr
7151
7264
  var xhr = s.xhr(),
7152
- handle;
7265
+ handle,
7266
+ i;
7153
7267
 
7154
7268
  // Open the socket
7155
7269
  // Passing null username, generates a login popup on Opera (#2865)
@@ -7159,19 +7273,31 @@ if ( jQuery.support.ajax ) {
7159
7273
  xhr.open( s.type, s.url, s.async );
7160
7274
  }
7161
7275
 
7276
+ // Apply custom fields if provided
7277
+ if ( s.xhrFields ) {
7278
+ for ( i in s.xhrFields ) {
7279
+ xhr[ i ] = s.xhrFields[ i ];
7280
+ }
7281
+ }
7282
+
7283
+ // Override mime type if needed
7284
+ if ( s.mimeType && xhr.overrideMimeType ) {
7285
+ xhr.overrideMimeType( s.mimeType );
7286
+ }
7287
+
7162
7288
  // Requested-With header
7163
7289
  // Not set for crossDomain requests with no content
7164
7290
  // (see why at http://trac.dojotoolkit.org/ticket/9486)
7165
7291
  // Won't change header if already provided
7166
- if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) {
7167
- headers[ "x-requested-with" ] = "XMLHttpRequest";
7292
+ if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
7293
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
7168
7294
  }
7169
7295
 
7170
7296
  // Need an extra try/catch for cross domain requests in Firefox 3
7171
7297
  try {
7172
- jQuery.each( headers, function( key, value ) {
7173
- xhr.setRequestHeader( key, value );
7174
- } );
7298
+ for ( i in headers ) {
7299
+ xhr.setRequestHeader( i, headers[ i ] );
7300
+ }
7175
7301
  } catch( _ ) {}
7176
7302
 
7177
7303
  // Do send the request
@@ -7182,75 +7308,79 @@ if ( jQuery.support.ajax ) {
7182
7308
  // Listener
7183
7309
  callback = function( _, isAbort ) {
7184
7310
 
7185
- // Was never called and is aborted or complete
7186
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7311
+ var status,
7312
+ statusText,
7313
+ responseHeaders,
7314
+ responses,
7315
+ xml;
7187
7316
 
7188
- // Only called once
7189
- callback = 0;
7317
+ // Firefox throws exceptions when accessing properties
7318
+ // of an xhr when a network error occured
7319
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
7320
+ try {
7190
7321
 
7191
- // Do not keep as active anymore
7192
- if ( handle ) {
7193
- xhr.onreadystatechange = jQuery.noop;
7194
- delete xhrs[ handle ];
7195
- }
7322
+ // Was never called and is aborted or complete
7323
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7196
7324
 
7197
- // If it's an abort
7198
- if ( isAbort ) {
7199
- // Abort it manually if needed
7200
- if ( xhr.readyState !== 4 ) {
7201
- xhr.abort();
7325
+ // Only called once
7326
+ callback = undefined;
7327
+
7328
+ // Do not keep as active anymore
7329
+ if ( handle ) {
7330
+ xhr.onreadystatechange = jQuery.noop;
7331
+ delete xhrCallbacks[ handle ];
7202
7332
  }
7203
- } else {
7204
- // Get info
7205
- var status = xhr.status,
7206
- statusText,
7207
- responseHeaders = xhr.getAllResponseHeaders(),
7208
- responses = {},
7333
+
7334
+ // If it's an abort
7335
+ if ( isAbort ) {
7336
+ // Abort it manually if needed
7337
+ if ( xhr.readyState !== 4 ) {
7338
+ xhr.abort();
7339
+ }
7340
+ } else {
7341
+ status = xhr.status;
7342
+ responseHeaders = xhr.getAllResponseHeaders();
7343
+ responses = {};
7209
7344
  xml = xhr.responseXML;
7210
7345
 
7211
- // Construct response list
7212
- if ( xml && xml.documentElement /* #4958 */ ) {
7213
- responses.xml = xml;
7214
- }
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 = "";
7346
+ // Construct response list
7347
+ if ( xml && xml.documentElement /* #4958 */ ) {
7348
+ responses.xml = xml;
7349
+ }
7350
+ responses.text = xhr.responseText;
7351
+
7352
+ // Firefox throws an exception when accessing
7353
+ // statusText for faulty cross-domain requests
7354
+ try {
7355
+ statusText = xhr.statusText;
7356
+ } catch( e ) {
7357
+ // We normalize with Webkit giving an empty statusText
7358
+ statusText = "";
7359
+ }
7360
+
7361
+ // Filter status for non standard behaviors
7362
+
7363
+ // If the request is local and we have data: assume a success
7364
+ // (success with no data won't get notified, that's the best we
7365
+ // can do given current implementations)
7366
+ if ( !status && s.isLocal && !s.crossDomain ) {
7367
+ status = responses.text ? 200 : 404;
7368
+ // IE - #1450: sometimes returns 1223 when it should be 204
7369
+ } else if ( status === 1223 ) {
7370
+ status = 204;
7371
+ }
7224
7372
  }
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 );
7373
+ }
7374
+ } catch( firefoxAccessException ) {
7375
+ if ( !isAbort ) {
7376
+ complete( -1, firefoxAccessException );
7252
7377
  }
7253
7378
  }
7379
+
7380
+ // Call complete if needed
7381
+ if ( responses ) {
7382
+ complete( status, statusText, responses, responseHeaders );
7383
+ }
7254
7384
  };
7255
7385
 
7256
7386
  // if we're in sync mode or it's in cache
@@ -7259,10 +7389,15 @@ if ( jQuery.support.ajax ) {
7259
7389
  if ( !s.async || xhr.readyState === 4 ) {
7260
7390
  callback();
7261
7391
  } else {
7262
- // Add to list of active xhrs
7392
+ // Create the active xhrs callbacks list if needed
7393
+ // and attach the unload handler
7394
+ if ( !xhrCallbacks ) {
7395
+ xhrCallbacks = {};
7396
+ xhrOnUnloadAbort();
7397
+ }
7398
+ // Add to list of active xhrs callbacks
7263
7399
  handle = xhrId++;
7264
- xhrs[ handle ] = xhr;
7265
- xhr.onreadystatechange = callback;
7400
+ xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
7266
7401
  }
7267
7402
  },
7268
7403
 
@@ -7464,11 +7599,11 @@ jQuery.fn.extend({
7464
7599
 
7465
7600
  } else {
7466
7601
  var parts = rfxnum.exec(val),
7467
- start = e.cur() || 0;
7602
+ start = e.cur();
7468
7603
 
7469
7604
  if ( parts ) {
7470
7605
  var end = parseFloat( parts[2] ),
7471
- unit = parts[3] || "px";
7606
+ unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
7472
7607
 
7473
7608
  // We need to compute starting value
7474
7609
  if ( unit !== "px" ) {
@@ -7615,8 +7750,12 @@ jQuery.fx.prototype = {
7615
7750
  return this.elem[ this.prop ];
7616
7751
  }
7617
7752
 
7618
- var r = parseFloat( jQuery.css( this.elem, this.prop ) );
7619
- return r || 0;
7753
+ var parsed,
7754
+ r = jQuery.css( this.elem, this.prop );
7755
+ // Empty strings, null, undefined and "auto" are converted to 0,
7756
+ // complex values such as "rotate(1rad)" are returned as is,
7757
+ // simple values such as "10px" are parsed to Float.
7758
+ return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
7620
7759
  },
7621
7760
 
7622
7761
  // Start an animation from one number to another
@@ -7627,7 +7766,7 @@ jQuery.fx.prototype = {
7627
7766
  this.startTime = jQuery.now();
7628
7767
  this.start = from;
7629
7768
  this.end = to;
7630
- this.unit = unit || this.unit || "px";
7769
+ this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
7631
7770
  this.now = this.start;
7632
7771
  this.pos = this.state = 0;
7633
7772
 
@@ -8078,7 +8217,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
8078
8217
  if ( win ) {
8079
8218
  win.scrollTo(
8080
8219
  !i ? val : jQuery(win).scrollLeft(),
8081
- i ? val : jQuery(win).scrollTop()
8220
+ i ? val : jQuery(win).scrollTop()
8082
8221
  );
8083
8222
 
8084
8223
  } else {
@@ -8173,4 +8312,5 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
8173
8312
  });
8174
8313
 
8175
8314
 
8315
+ window.jQuery = window.$ = jQuery;
8176
8316
  })(window);