govuk_publishing_components 18.1.1 → 18.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +11 -5
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +10 -7
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/jquery/AUTHORS.txt +266 -0
- data/node_modules/jquery/LICENSE.txt +36 -0
- data/node_modules/jquery/README.md +65 -0
- data/node_modules/jquery/bower.json +14 -0
- data/node_modules/jquery/dist/jquery.js +11008 -0
- data/node_modules/jquery/dist/jquery.min.js +5 -0
- data/node_modules/jquery/dist/jquery.min.map +1 -0
- data/node_modules/jquery/external/sizzle/LICENSE.txt +36 -0
- data/node_modules/jquery/external/sizzle/dist/sizzle.js +2143 -0
- data/node_modules/jquery/external/sizzle/dist/sizzle.min.js +3 -0
- data/node_modules/jquery/external/sizzle/dist/sizzle.min.map +1 -0
- data/node_modules/jquery/package.json +157 -0
- data/node_modules/jquery/src/ajax.js +842 -0
- data/node_modules/jquery/src/ajax/jsonp.js +100 -0
- data/node_modules/jquery/src/ajax/load.js +83 -0
- data/node_modules/jquery/src/ajax/parseJSON.js +53 -0
- data/node_modules/jquery/src/ajax/parseXML.js +31 -0
- data/node_modules/jquery/src/ajax/script.js +95 -0
- data/node_modules/jquery/src/ajax/var/location.js +3 -0
- data/node_modules/jquery/src/ajax/var/nonce.js +5 -0
- data/node_modules/jquery/src/ajax/var/rquery.js +3 -0
- data/node_modules/jquery/src/ajax/xhr.js +229 -0
- data/node_modules/jquery/src/attributes.js +11 -0
- data/node_modules/jquery/src/attributes/attr.js +281 -0
- data/node_modules/jquery/src/attributes/classes.js +174 -0
- data/node_modules/jquery/src/attributes/prop.js +156 -0
- data/node_modules/jquery/src/attributes/support.js +70 -0
- data/node_modules/jquery/src/attributes/val.js +191 -0
- data/node_modules/jquery/src/callbacks.js +232 -0
- data/node_modules/jquery/src/core.js +529 -0
- data/node_modules/jquery/src/core/access.js +65 -0
- data/node_modules/jquery/src/core/init.js +140 -0
- data/node_modules/jquery/src/core/parseHTML.js +41 -0
- data/node_modules/jquery/src/core/ready.js +163 -0
- data/node_modules/jquery/src/core/var/rsingleTag.js +5 -0
- data/node_modules/jquery/src/css.js +563 -0
- data/node_modules/jquery/src/css/addGetHookIf.js +24 -0
- data/node_modules/jquery/src/css/adjustCSS.js +65 -0
- data/node_modules/jquery/src/css/curCSS.js +137 -0
- data/node_modules/jquery/src/css/defaultDisplay.js +72 -0
- data/node_modules/jquery/src/css/hiddenVisibleSelectors.js +42 -0
- data/node_modules/jquery/src/css/showHide.js +45 -0
- data/node_modules/jquery/src/css/support.js +184 -0
- data/node_modules/jquery/src/css/var/cssExpand.js +3 -0
- data/node_modules/jquery/src/css/var/isHidden.js +16 -0
- data/node_modules/jquery/src/css/var/rmargin.js +3 -0
- data/node_modules/jquery/src/css/var/rnumnonpx.js +5 -0
- data/node_modules/jquery/src/css/var/swap.js +24 -0
- data/node_modules/jquery/src/data.js +342 -0
- data/node_modules/jquery/src/data/support.js +23 -0
- data/node_modules/jquery/src/data/var/acceptData.js +20 -0
- data/node_modules/jquery/src/deferred.js +159 -0
- data/node_modules/jquery/src/deprecated.js +34 -0
- data/node_modules/jquery/src/dimensions.js +56 -0
- data/node_modules/jquery/src/effects.js +640 -0
- data/node_modules/jquery/src/effects/Tween.js +121 -0
- data/node_modules/jquery/src/effects/animatedSelector.js +13 -0
- data/node_modules/jquery/src/effects/support.js +58 -0
- data/node_modules/jquery/src/event.js +1134 -0
- data/node_modules/jquery/src/event/ajax.js +20 -0
- data/node_modules/jquery/src/event/alias.js +25 -0
- data/node_modules/jquery/src/event/support.js +28 -0
- data/node_modules/jquery/src/exports/amd.js +24 -0
- data/node_modules/jquery/src/exports/global.js +26 -0
- data/node_modules/jquery/src/intro.js +44 -0
- data/node_modules/jquery/src/jquery.js +37 -0
- data/node_modules/jquery/src/manipulation.js +585 -0
- data/node_modules/jquery/src/manipulation/_evalUrl.js +21 -0
- data/node_modules/jquery/src/manipulation/buildFragment.js +157 -0
- data/node_modules/jquery/src/manipulation/createSafeFragment.js +20 -0
- data/node_modules/jquery/src/manipulation/getAll.js +33 -0
- data/node_modules/jquery/src/manipulation/setGlobalEval.js +19 -0
- data/node_modules/jquery/src/manipulation/support.js +72 -0
- data/node_modules/jquery/src/manipulation/var/nodeNames.js +5 -0
- data/node_modules/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/node_modules/jquery/src/manipulation/var/rleadingWhitespace.js +3 -0
- data/node_modules/jquery/src/manipulation/var/rscriptType.js +3 -0
- data/node_modules/jquery/src/manipulation/var/rtagName.js +3 -0
- data/node_modules/jquery/src/manipulation/wrapMap.js +30 -0
- data/node_modules/jquery/src/offset.js +219 -0
- data/node_modules/jquery/src/outro.js +2 -0
- data/node_modules/jquery/src/queue.js +144 -0
- data/node_modules/jquery/src/queue/delay.js +22 -0
- data/node_modules/jquery/src/selector-sizzle.js +14 -0
- data/node_modules/jquery/src/selector.js +1 -0
- data/node_modules/jquery/src/serialize.js +125 -0
- data/node_modules/jquery/src/support.js +63 -0
- data/node_modules/jquery/src/traversing.js +179 -0
- data/node_modules/jquery/src/traversing/findFilter.js +100 -0
- data/node_modules/jquery/src/traversing/var/dir.js +20 -0
- data/node_modules/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/node_modules/jquery/src/traversing/var/siblings.js +15 -0
- data/node_modules/jquery/src/var/class2type.js +5 -0
- data/node_modules/jquery/src/var/concat.js +5 -0
- data/node_modules/jquery/src/var/deletedIds.js +3 -0
- data/node_modules/jquery/src/var/document.js +3 -0
- data/node_modules/jquery/src/var/documentElement.js +5 -0
- data/node_modules/jquery/src/var/hasOwn.js +5 -0
- data/node_modules/jquery/src/var/indexOf.js +5 -0
- data/node_modules/jquery/src/var/pnum.js +3 -0
- data/node_modules/jquery/src/var/push.js +5 -0
- data/node_modules/jquery/src/var/rcssNum.js +7 -0
- data/node_modules/jquery/src/var/rnotwhite.js +3 -0
- data/node_modules/jquery/src/var/slice.js +5 -0
- data/node_modules/jquery/src/var/support.js +5 -0
- data/node_modules/jquery/src/var/toString.js +5 -0
- data/node_modules/jquery/src/wrap.js +77 -0
- metadata +109 -2
@@ -0,0 +1,100 @@
|
|
1
|
+
define( [
|
2
|
+
"../core",
|
3
|
+
"./var/nonce",
|
4
|
+
"./var/rquery",
|
5
|
+
"../ajax"
|
6
|
+
], function( jQuery, nonce, rquery ) {
|
7
|
+
|
8
|
+
var oldCallbacks = [],
|
9
|
+
rjsonp = /(=)\?(?=&|$)|\?\?/;
|
10
|
+
|
11
|
+
// Default jsonp settings
|
12
|
+
jQuery.ajaxSetup( {
|
13
|
+
jsonp: "callback",
|
14
|
+
jsonpCallback: function() {
|
15
|
+
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
|
16
|
+
this[ callback ] = true;
|
17
|
+
return callback;
|
18
|
+
}
|
19
|
+
} );
|
20
|
+
|
21
|
+
// Detect, normalize options and install callbacks for jsonp requests
|
22
|
+
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
23
|
+
|
24
|
+
var callbackName, overwritten, responseContainer,
|
25
|
+
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
26
|
+
"url" :
|
27
|
+
typeof s.data === "string" &&
|
28
|
+
( s.contentType || "" )
|
29
|
+
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
|
30
|
+
rjsonp.test( s.data ) && "data"
|
31
|
+
);
|
32
|
+
|
33
|
+
// Handle iff the expected data type is "jsonp" or we have a parameter to set
|
34
|
+
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
|
35
|
+
|
36
|
+
// Get callback name, remembering preexisting value associated with it
|
37
|
+
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
|
38
|
+
s.jsonpCallback() :
|
39
|
+
s.jsonpCallback;
|
40
|
+
|
41
|
+
// Insert callback into url or form data
|
42
|
+
if ( jsonProp ) {
|
43
|
+
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
|
44
|
+
} else if ( s.jsonp !== false ) {
|
45
|
+
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
46
|
+
}
|
47
|
+
|
48
|
+
// Use data converter to retrieve json after script execution
|
49
|
+
s.converters[ "script json" ] = function() {
|
50
|
+
if ( !responseContainer ) {
|
51
|
+
jQuery.error( callbackName + " was not called" );
|
52
|
+
}
|
53
|
+
return responseContainer[ 0 ];
|
54
|
+
};
|
55
|
+
|
56
|
+
// force json dataType
|
57
|
+
s.dataTypes[ 0 ] = "json";
|
58
|
+
|
59
|
+
// Install callback
|
60
|
+
overwritten = window[ callbackName ];
|
61
|
+
window[ callbackName ] = function() {
|
62
|
+
responseContainer = arguments;
|
63
|
+
};
|
64
|
+
|
65
|
+
// Clean-up function (fires after converters)
|
66
|
+
jqXHR.always( function() {
|
67
|
+
|
68
|
+
// If previous value didn't exist - remove it
|
69
|
+
if ( overwritten === undefined ) {
|
70
|
+
jQuery( window ).removeProp( callbackName );
|
71
|
+
|
72
|
+
// Otherwise restore preexisting value
|
73
|
+
} else {
|
74
|
+
window[ callbackName ] = overwritten;
|
75
|
+
}
|
76
|
+
|
77
|
+
// Save back as free
|
78
|
+
if ( s[ callbackName ] ) {
|
79
|
+
|
80
|
+
// make sure that re-using the options doesn't screw things around
|
81
|
+
s.jsonpCallback = originalSettings.jsonpCallback;
|
82
|
+
|
83
|
+
// save the callback name for future use
|
84
|
+
oldCallbacks.push( callbackName );
|
85
|
+
}
|
86
|
+
|
87
|
+
// Call if it was a function and we have a response
|
88
|
+
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
|
89
|
+
overwritten( responseContainer[ 0 ] );
|
90
|
+
}
|
91
|
+
|
92
|
+
responseContainer = overwritten = undefined;
|
93
|
+
} );
|
94
|
+
|
95
|
+
// Delegate to script
|
96
|
+
return "script";
|
97
|
+
}
|
98
|
+
} );
|
99
|
+
|
100
|
+
} );
|
@@ -0,0 +1,83 @@
|
|
1
|
+
define( [
|
2
|
+
"../core",
|
3
|
+
"../core/parseHTML",
|
4
|
+
"../ajax",
|
5
|
+
"../traversing",
|
6
|
+
"../manipulation",
|
7
|
+
"../selector",
|
8
|
+
|
9
|
+
// Optional event/alias dependency
|
10
|
+
"../event/alias"
|
11
|
+
], function( jQuery ) {
|
12
|
+
|
13
|
+
// Keep a copy of the old load method
|
14
|
+
var _load = jQuery.fn.load;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Load a url into a page
|
18
|
+
*/
|
19
|
+
jQuery.fn.load = function( url, params, callback ) {
|
20
|
+
if ( typeof url !== "string" && _load ) {
|
21
|
+
return _load.apply( this, arguments );
|
22
|
+
}
|
23
|
+
|
24
|
+
var selector, type, response,
|
25
|
+
self = this,
|
26
|
+
off = url.indexOf( " " );
|
27
|
+
|
28
|
+
if ( off > -1 ) {
|
29
|
+
selector = jQuery.trim( url.slice( off, url.length ) );
|
30
|
+
url = url.slice( 0, off );
|
31
|
+
}
|
32
|
+
|
33
|
+
// If it's a function
|
34
|
+
if ( jQuery.isFunction( params ) ) {
|
35
|
+
|
36
|
+
// We assume that it's the callback
|
37
|
+
callback = params;
|
38
|
+
params = undefined;
|
39
|
+
|
40
|
+
// Otherwise, build a param string
|
41
|
+
} else if ( params && typeof params === "object" ) {
|
42
|
+
type = "POST";
|
43
|
+
}
|
44
|
+
|
45
|
+
// If we have elements to modify, make the request
|
46
|
+
if ( self.length > 0 ) {
|
47
|
+
jQuery.ajax( {
|
48
|
+
url: url,
|
49
|
+
|
50
|
+
// If "type" variable is undefined, then "GET" method will be used.
|
51
|
+
// Make value of this field explicit since
|
52
|
+
// user can override it through ajaxSetup method
|
53
|
+
type: type || "GET",
|
54
|
+
dataType: "html",
|
55
|
+
data: params
|
56
|
+
} ).done( function( responseText ) {
|
57
|
+
|
58
|
+
// Save response for use in complete callback
|
59
|
+
response = arguments;
|
60
|
+
|
61
|
+
self.html( selector ?
|
62
|
+
|
63
|
+
// If a selector was specified, locate the right elements in a dummy div
|
64
|
+
// Exclude scripts to avoid IE 'Permission Denied' errors
|
65
|
+
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
66
|
+
|
67
|
+
// Otherwise use the full result
|
68
|
+
responseText );
|
69
|
+
|
70
|
+
// If the request succeeds, this function gets "data", "status", "jqXHR"
|
71
|
+
// but they are ignored because response was set above.
|
72
|
+
// If it fails, this function gets "jqXHR", "status", "error"
|
73
|
+
} ).always( callback && function( jqXHR, status ) {
|
74
|
+
self.each( function() {
|
75
|
+
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
|
76
|
+
} );
|
77
|
+
} );
|
78
|
+
}
|
79
|
+
|
80
|
+
return this;
|
81
|
+
};
|
82
|
+
|
83
|
+
} );
|
@@ -0,0 +1,53 @@
|
|
1
|
+
define( [
|
2
|
+
"../core"
|
3
|
+
], function( jQuery ) {
|
4
|
+
|
5
|
+
var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
|
6
|
+
|
7
|
+
jQuery.parseJSON = function( data ) {
|
8
|
+
|
9
|
+
// Attempt to parse using the native JSON parser first
|
10
|
+
if ( window.JSON && window.JSON.parse ) {
|
11
|
+
|
12
|
+
// Support: Android 2.3
|
13
|
+
// Workaround failure to string-cast null input
|
14
|
+
return window.JSON.parse( data + "" );
|
15
|
+
}
|
16
|
+
|
17
|
+
var requireNonComma,
|
18
|
+
depth = null,
|
19
|
+
str = jQuery.trim( data + "" );
|
20
|
+
|
21
|
+
// Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
|
22
|
+
// after removing valid tokens
|
23
|
+
return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
|
24
|
+
|
25
|
+
// Force termination if we see a misplaced comma
|
26
|
+
if ( requireNonComma && comma ) {
|
27
|
+
depth = 0;
|
28
|
+
}
|
29
|
+
|
30
|
+
// Perform no more replacements after returning to outermost depth
|
31
|
+
if ( depth === 0 ) {
|
32
|
+
return token;
|
33
|
+
}
|
34
|
+
|
35
|
+
// Commas must not follow "[", "{", or ","
|
36
|
+
requireNonComma = open || comma;
|
37
|
+
|
38
|
+
// Determine new depth
|
39
|
+
// array/object open ("[" or "{"): depth += true - false (increment)
|
40
|
+
// array/object close ("]" or "}"): depth += false - true (decrement)
|
41
|
+
// other cases ("," or primitive): depth += true - true (numeric cast)
|
42
|
+
depth += !close - !open;
|
43
|
+
|
44
|
+
// Remove this token
|
45
|
+
return "";
|
46
|
+
} ) ) ?
|
47
|
+
( Function( "return " + str ) )() :
|
48
|
+
jQuery.error( "Invalid JSON: " + data );
|
49
|
+
};
|
50
|
+
|
51
|
+
return jQuery.parseJSON;
|
52
|
+
|
53
|
+
} );
|
@@ -0,0 +1,31 @@
|
|
1
|
+
define( [
|
2
|
+
"../core"
|
3
|
+
], function( jQuery ) {
|
4
|
+
|
5
|
+
// Cross-browser xml parsing
|
6
|
+
jQuery.parseXML = function( data ) {
|
7
|
+
var xml, tmp;
|
8
|
+
if ( !data || typeof data !== "string" ) {
|
9
|
+
return null;
|
10
|
+
}
|
11
|
+
try {
|
12
|
+
if ( window.DOMParser ) { // Standard
|
13
|
+
tmp = new window.DOMParser();
|
14
|
+
xml = tmp.parseFromString( data, "text/xml" );
|
15
|
+
} else { // IE
|
16
|
+
xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
|
17
|
+
xml.async = "false";
|
18
|
+
xml.loadXML( data );
|
19
|
+
}
|
20
|
+
} catch ( e ) {
|
21
|
+
xml = undefined;
|
22
|
+
}
|
23
|
+
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
|
24
|
+
jQuery.error( "Invalid XML: " + data );
|
25
|
+
}
|
26
|
+
return xml;
|
27
|
+
};
|
28
|
+
|
29
|
+
return jQuery.parseXML;
|
30
|
+
|
31
|
+
} );
|
@@ -0,0 +1,95 @@
|
|
1
|
+
define( [
|
2
|
+
"../core",
|
3
|
+
"../var/document",
|
4
|
+
"../ajax"
|
5
|
+
], function( jQuery, document ) {
|
6
|
+
|
7
|
+
// Install script dataType
|
8
|
+
jQuery.ajaxSetup( {
|
9
|
+
accepts: {
|
10
|
+
script: "text/javascript, application/javascript, " +
|
11
|
+
"application/ecmascript, application/x-ecmascript"
|
12
|
+
},
|
13
|
+
contents: {
|
14
|
+
script: /\b(?:java|ecma)script\b/
|
15
|
+
},
|
16
|
+
converters: {
|
17
|
+
"text script": function( text ) {
|
18
|
+
jQuery.globalEval( text );
|
19
|
+
return text;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
} );
|
23
|
+
|
24
|
+
// Handle cache's special case and global
|
25
|
+
jQuery.ajaxPrefilter( "script", function( s ) {
|
26
|
+
if ( s.cache === undefined ) {
|
27
|
+
s.cache = false;
|
28
|
+
}
|
29
|
+
if ( s.crossDomain ) {
|
30
|
+
s.type = "GET";
|
31
|
+
s.global = false;
|
32
|
+
}
|
33
|
+
} );
|
34
|
+
|
35
|
+
// Bind script tag hack transport
|
36
|
+
jQuery.ajaxTransport( "script", function( s ) {
|
37
|
+
|
38
|
+
// This transport only deals with cross domain requests
|
39
|
+
if ( s.crossDomain ) {
|
40
|
+
|
41
|
+
var script,
|
42
|
+
head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
|
43
|
+
|
44
|
+
return {
|
45
|
+
|
46
|
+
send: function( _, callback ) {
|
47
|
+
|
48
|
+
script = document.createElement( "script" );
|
49
|
+
|
50
|
+
script.async = true;
|
51
|
+
|
52
|
+
if ( s.scriptCharset ) {
|
53
|
+
script.charset = s.scriptCharset;
|
54
|
+
}
|
55
|
+
|
56
|
+
script.src = s.url;
|
57
|
+
|
58
|
+
// Attach handlers for all browsers
|
59
|
+
script.onload = script.onreadystatechange = function( _, isAbort ) {
|
60
|
+
|
61
|
+
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
62
|
+
|
63
|
+
// Handle memory leak in IE
|
64
|
+
script.onload = script.onreadystatechange = null;
|
65
|
+
|
66
|
+
// Remove the script
|
67
|
+
if ( script.parentNode ) {
|
68
|
+
script.parentNode.removeChild( script );
|
69
|
+
}
|
70
|
+
|
71
|
+
// Dereference the script
|
72
|
+
script = null;
|
73
|
+
|
74
|
+
// Callback if not abort
|
75
|
+
if ( !isAbort ) {
|
76
|
+
callback( 200, "success" );
|
77
|
+
}
|
78
|
+
}
|
79
|
+
};
|
80
|
+
|
81
|
+
// Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
|
82
|
+
// Use native DOM manipulation to avoid our domManip AJAX trickery
|
83
|
+
head.insertBefore( script, head.firstChild );
|
84
|
+
},
|
85
|
+
|
86
|
+
abort: function() {
|
87
|
+
if ( script ) {
|
88
|
+
script.onload( undefined, true );
|
89
|
+
}
|
90
|
+
}
|
91
|
+
};
|
92
|
+
}
|
93
|
+
} );
|
94
|
+
|
95
|
+
} );
|
@@ -0,0 +1,229 @@
|
|
1
|
+
define( [
|
2
|
+
"../core",
|
3
|
+
"../var/document",
|
4
|
+
"../var/support",
|
5
|
+
"../ajax"
|
6
|
+
], function( jQuery, document, support ) {
|
7
|
+
|
8
|
+
// Create the request object
|
9
|
+
// (This is still attached to ajaxSettings for backward compatibility)
|
10
|
+
jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
|
11
|
+
|
12
|
+
// Support: IE6-IE8
|
13
|
+
function() {
|
14
|
+
|
15
|
+
// XHR cannot access local files, always use ActiveX for that case
|
16
|
+
if ( this.isLocal ) {
|
17
|
+
return createActiveXHR();
|
18
|
+
}
|
19
|
+
|
20
|
+
// Support: IE 9-11
|
21
|
+
// IE seems to error on cross-domain PATCH requests when ActiveX XHR
|
22
|
+
// is used. In IE 9+ always use the native XHR.
|
23
|
+
// Note: this condition won't catch Edge as it doesn't define
|
24
|
+
// document.documentMode but it also doesn't support ActiveX so it won't
|
25
|
+
// reach this code.
|
26
|
+
if ( document.documentMode > 8 ) {
|
27
|
+
return createStandardXHR();
|
28
|
+
}
|
29
|
+
|
30
|
+
// Support: IE<9
|
31
|
+
// oldIE XHR does not support non-RFC2616 methods (#13240)
|
32
|
+
// See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
|
33
|
+
// and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
|
34
|
+
// Although this check for six methods instead of eight
|
35
|
+
// since IE also does not support "trace" and "connect"
|
36
|
+
return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
|
37
|
+
createStandardXHR() || createActiveXHR();
|
38
|
+
} :
|
39
|
+
|
40
|
+
// For all other browsers, use the standard XMLHttpRequest object
|
41
|
+
createStandardXHR;
|
42
|
+
|
43
|
+
var xhrId = 0,
|
44
|
+
xhrCallbacks = {},
|
45
|
+
xhrSupported = jQuery.ajaxSettings.xhr();
|
46
|
+
|
47
|
+
// Support: IE<10
|
48
|
+
// Open requests must be manually aborted on unload (#5280)
|
49
|
+
// See https://support.microsoft.com/kb/2856746 for more info
|
50
|
+
if ( window.attachEvent ) {
|
51
|
+
window.attachEvent( "onunload", function() {
|
52
|
+
for ( var key in xhrCallbacks ) {
|
53
|
+
xhrCallbacks[ key ]( undefined, true );
|
54
|
+
}
|
55
|
+
} );
|
56
|
+
}
|
57
|
+
|
58
|
+
// Determine support properties
|
59
|
+
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
|
60
|
+
xhrSupported = support.ajax = !!xhrSupported;
|
61
|
+
|
62
|
+
// Create transport if the browser can provide an xhr
|
63
|
+
if ( xhrSupported ) {
|
64
|
+
|
65
|
+
jQuery.ajaxTransport( function( options ) {
|
66
|
+
|
67
|
+
// Cross domain only allowed if supported through XMLHttpRequest
|
68
|
+
if ( !options.crossDomain || support.cors ) {
|
69
|
+
|
70
|
+
var callback;
|
71
|
+
|
72
|
+
return {
|
73
|
+
send: function( headers, complete ) {
|
74
|
+
var i,
|
75
|
+
xhr = options.xhr(),
|
76
|
+
id = ++xhrId;
|
77
|
+
|
78
|
+
// Open the socket
|
79
|
+
xhr.open(
|
80
|
+
options.type,
|
81
|
+
options.url,
|
82
|
+
options.async,
|
83
|
+
options.username,
|
84
|
+
options.password
|
85
|
+
);
|
86
|
+
|
87
|
+
// Apply custom fields if provided
|
88
|
+
if ( options.xhrFields ) {
|
89
|
+
for ( i in options.xhrFields ) {
|
90
|
+
xhr[ i ] = options.xhrFields[ i ];
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
// Override mime type if needed
|
95
|
+
if ( options.mimeType && xhr.overrideMimeType ) {
|
96
|
+
xhr.overrideMimeType( options.mimeType );
|
97
|
+
}
|
98
|
+
|
99
|
+
// X-Requested-With header
|
100
|
+
// For cross-domain requests, seeing as conditions for a preflight are
|
101
|
+
// akin to a jigsaw puzzle, we simply never set it to be sure.
|
102
|
+
// (it can always be set on a per-request basis or even using ajaxSetup)
|
103
|
+
// For same-domain requests, won't change header if already provided.
|
104
|
+
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
|
105
|
+
headers[ "X-Requested-With" ] = "XMLHttpRequest";
|
106
|
+
}
|
107
|
+
|
108
|
+
// Set headers
|
109
|
+
for ( i in headers ) {
|
110
|
+
|
111
|
+
// Support: IE<9
|
112
|
+
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
|
113
|
+
// request header to a null-value.
|
114
|
+
//
|
115
|
+
// To keep consistent with other XHR implementations, cast the value
|
116
|
+
// to string and ignore `undefined`.
|
117
|
+
if ( headers[ i ] !== undefined ) {
|
118
|
+
xhr.setRequestHeader( i, headers[ i ] + "" );
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
// Do send the request
|
123
|
+
// This may raise an exception which is actually
|
124
|
+
// handled in jQuery.ajax (so no try/catch here)
|
125
|
+
xhr.send( ( options.hasContent && options.data ) || null );
|
126
|
+
|
127
|
+
// Listener
|
128
|
+
callback = function( _, isAbort ) {
|
129
|
+
var status, statusText, responses;
|
130
|
+
|
131
|
+
// Was never called and is aborted or complete
|
132
|
+
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
133
|
+
|
134
|
+
// Clean up
|
135
|
+
delete xhrCallbacks[ id ];
|
136
|
+
callback = undefined;
|
137
|
+
xhr.onreadystatechange = jQuery.noop;
|
138
|
+
|
139
|
+
// Abort manually if needed
|
140
|
+
if ( isAbort ) {
|
141
|
+
if ( xhr.readyState !== 4 ) {
|
142
|
+
xhr.abort();
|
143
|
+
}
|
144
|
+
} else {
|
145
|
+
responses = {};
|
146
|
+
status = xhr.status;
|
147
|
+
|
148
|
+
// Support: IE<10
|
149
|
+
// Accessing binary-data responseText throws an exception
|
150
|
+
// (#11426)
|
151
|
+
if ( typeof xhr.responseText === "string" ) {
|
152
|
+
responses.text = xhr.responseText;
|
153
|
+
}
|
154
|
+
|
155
|
+
// Firefox throws an exception when accessing
|
156
|
+
// statusText for faulty cross-domain requests
|
157
|
+
try {
|
158
|
+
statusText = xhr.statusText;
|
159
|
+
} catch ( e ) {
|
160
|
+
|
161
|
+
// We normalize with Webkit giving an empty statusText
|
162
|
+
statusText = "";
|
163
|
+
}
|
164
|
+
|
165
|
+
// Filter status for non standard behaviors
|
166
|
+
|
167
|
+
// If the request is local and we have data: assume a success
|
168
|
+
// (success with no data won't get notified, that's the best we
|
169
|
+
// can do given current implementations)
|
170
|
+
if ( !status && options.isLocal && !options.crossDomain ) {
|
171
|
+
status = responses.text ? 200 : 404;
|
172
|
+
|
173
|
+
// IE - #1450: sometimes returns 1223 when it should be 204
|
174
|
+
} else if ( status === 1223 ) {
|
175
|
+
status = 204;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
// Call complete if needed
|
181
|
+
if ( responses ) {
|
182
|
+
complete( status, statusText, responses, xhr.getAllResponseHeaders() );
|
183
|
+
}
|
184
|
+
};
|
185
|
+
|
186
|
+
// Do send the request
|
187
|
+
// `xhr.send` may raise an exception, but it will be
|
188
|
+
// handled in jQuery.ajax (so no try/catch here)
|
189
|
+
if ( !options.async ) {
|
190
|
+
|
191
|
+
// If we're in sync mode we fire the callback
|
192
|
+
callback();
|
193
|
+
} else if ( xhr.readyState === 4 ) {
|
194
|
+
|
195
|
+
// (IE6 & IE7) if it's in cache and has been
|
196
|
+
// retrieved directly we need to fire the callback
|
197
|
+
window.setTimeout( callback );
|
198
|
+
} else {
|
199
|
+
|
200
|
+
// Register the callback, but delay it in case `xhr.send` throws
|
201
|
+
// Add to the list of active xhr callbacks
|
202
|
+
xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
|
203
|
+
}
|
204
|
+
},
|
205
|
+
|
206
|
+
abort: function() {
|
207
|
+
if ( callback ) {
|
208
|
+
callback( undefined, true );
|
209
|
+
}
|
210
|
+
}
|
211
|
+
};
|
212
|
+
}
|
213
|
+
} );
|
214
|
+
}
|
215
|
+
|
216
|
+
// Functions to create xhrs
|
217
|
+
function createStandardXHR() {
|
218
|
+
try {
|
219
|
+
return new window.XMLHttpRequest();
|
220
|
+
} catch ( e ) {}
|
221
|
+
}
|
222
|
+
|
223
|
+
function createActiveXHR() {
|
224
|
+
try {
|
225
|
+
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
|
226
|
+
} catch ( e ) {}
|
227
|
+
}
|
228
|
+
|
229
|
+
} );
|