formtastic-jquery_inputmask 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.bowerrc +3 -0
  3. data/bower.json +19 -0
  4. data/lib/formtastic/jquery_inputmask/engine.rb +1 -1
  5. data/lib/formtastic/jquery_inputmask/version.rb +1 -1
  6. data/vendor/inputmask/.bower.json +59 -0
  7. data/vendor/inputmask/bower.json +40 -0
  8. data/vendor/inputmask/dist/inputmask/bindings/inputmask.binding.js +21 -0
  9. data/vendor/inputmask/dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js +62 -0
  10. data/vendor/inputmask/dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js +13 -0
  11. data/vendor/inputmask/dist/inputmask/dependencyLibs/inputmask.dependencyLib.js +133 -0
  12. data/vendor/inputmask/dist/inputmask/global/document.js +11 -0
  13. data/vendor/inputmask/dist/inputmask/global/window.js +11 -0
  14. data/vendor/inputmask/dist/inputmask/inputmask.date.extensions.js +490 -0
  15. data/vendor/inputmask/dist/inputmask/inputmask.extensions.js +97 -0
  16. data/vendor/inputmask/dist/inputmask/inputmask.js +1643 -0
  17. data/vendor/inputmask/dist/inputmask/inputmask.numeric.extensions.js +347 -0
  18. data/vendor/inputmask/dist/inputmask/inputmask.phone.extensions.js +61 -0
  19. data/vendor/inputmask/dist/inputmask/inputmask.regex.extensions.js +115 -0
  20. data/vendor/inputmask/dist/inputmask/jquery.inputmask.js +62 -0
  21. data/vendor/inputmask/dist/inputmask/phone-codes/phone-be.js +244 -0
  22. data/vendor/inputmask/dist/inputmask/phone-codes/phone-nl.js +924 -0
  23. data/vendor/inputmask/dist/inputmask/phone-codes/phone-ru.js +19240 -0
  24. data/vendor/inputmask/dist/inputmask/phone-codes/phone-uk.js +1009 -0
  25. data/vendor/inputmask/dist/inputmask/phone-codes/phone.js +2111 -0
  26. data/vendor/inputmask/dist/jquery.inputmask.bundle.js +3085 -0
  27. data/vendor/inputmask/dist/min/inputmask/inputmask.date.extensions.min.js +9 -0
  28. data/vendor/inputmask/dist/min/inputmask/inputmask.extensions.min.js +9 -0
  29. data/vendor/inputmask/dist/min/inputmask/inputmask.min.js +10 -0
  30. data/vendor/inputmask/dist/min/inputmask/inputmask.numeric.extensions.min.js +9 -0
  31. data/vendor/inputmask/dist/min/inputmask/inputmask.phone.extensions.min.js +9 -0
  32. data/vendor/inputmask/dist/min/inputmask/inputmask.regex.extensions.min.js +9 -0
  33. data/vendor/inputmask/dist/min/inputmask/jquery.inputmask.min.js +9 -0
  34. data/vendor/inputmask/dist/min/jquery.inputmask.bundle.min.js +11 -0
  35. data/vendor/jquery/.bower.json +25 -0
  36. data/vendor/jquery/AUTHORS.txt +301 -0
  37. data/vendor/jquery/LICENSE.txt +36 -0
  38. data/vendor/jquery/README.md +67 -0
  39. data/vendor/jquery/bower.json +14 -0
  40. data/vendor/jquery/dist/core.js +476 -0
  41. data/vendor/jquery/dist/jquery.js +10253 -0
  42. data/vendor/jquery/dist/jquery.min.js +4 -0
  43. data/vendor/jquery/dist/jquery.min.map +1 -0
  44. data/vendor/jquery/dist/jquery.slim.js +8160 -0
  45. data/vendor/jquery/dist/jquery.slim.min.js +4 -0
  46. data/vendor/jquery/dist/jquery.slim.min.map +1 -0
  47. data/vendor/jquery/external/sizzle/LICENSE.txt +36 -0
  48. data/vendor/jquery/external/sizzle/dist/sizzle.js +2272 -0
  49. data/vendor/jquery/external/sizzle/dist/sizzle.min.js +3 -0
  50. data/vendor/jquery/external/sizzle/dist/sizzle.min.map +1 -0
  51. data/vendor/jquery/src/.eslintrc.json +5 -0
  52. data/vendor/jquery/src/ajax.js +855 -0
  53. data/vendor/jquery/src/ajax/jsonp.js +102 -0
  54. data/vendor/jquery/src/ajax/load.js +76 -0
  55. data/vendor/jquery/src/ajax/parseXML.js +30 -0
  56. data/vendor/jquery/src/ajax/script.js +77 -0
  57. data/vendor/jquery/src/ajax/var/location.js +5 -0
  58. data/vendor/jquery/src/ajax/var/nonce.js +7 -0
  59. data/vendor/jquery/src/ajax/var/rquery.js +5 -0
  60. data/vendor/jquery/src/ajax/xhr.js +169 -0
  61. data/vendor/jquery/src/attributes.js +13 -0
  62. data/vendor/jquery/src/attributes/attr.js +141 -0
  63. data/vendor/jquery/src/attributes/classes.js +174 -0
  64. data/vendor/jquery/src/attributes/prop.js +143 -0
  65. data/vendor/jquery/src/attributes/support.js +33 -0
  66. data/vendor/jquery/src/attributes/val.js +190 -0
  67. data/vendor/jquery/src/callbacks.js +234 -0
  68. data/vendor/jquery/src/core.js +476 -0
  69. data/vendor/jquery/src/core/DOMEval.js +16 -0
  70. data/vendor/jquery/src/core/access.js +70 -0
  71. data/vendor/jquery/src/core/init.js +128 -0
  72. data/vendor/jquery/src/core/nodeName.js +13 -0
  73. data/vendor/jquery/src/core/parseHTML.js +65 -0
  74. data/vendor/jquery/src/core/ready-no-deferred.js +96 -0
  75. data/vendor/jquery/src/core/ready.js +86 -0
  76. data/vendor/jquery/src/core/readyException.js +13 -0
  77. data/vendor/jquery/src/core/stripAndCollapse.js +14 -0
  78. data/vendor/jquery/src/core/support.js +20 -0
  79. data/vendor/jquery/src/core/var/rsingleTag.js +6 -0
  80. data/vendor/jquery/src/css.js +438 -0
  81. data/vendor/jquery/src/css/addGetHookIf.js +26 -0
  82. data/vendor/jquery/src/css/adjustCSS.js +71 -0
  83. data/vendor/jquery/src/css/curCSS.js +65 -0
  84. data/vendor/jquery/src/css/hiddenVisibleSelectors.js +15 -0
  85. data/vendor/jquery/src/css/showHide.js +105 -0
  86. data/vendor/jquery/src/css/support.js +89 -0
  87. data/vendor/jquery/src/css/var/cssExpand.js +5 -0
  88. data/vendor/jquery/src/css/var/getStyles.js +17 -0
  89. data/vendor/jquery/src/css/var/isHiddenWithinTree.js +34 -0
  90. data/vendor/jquery/src/css/var/rmargin.js +5 -0
  91. data/vendor/jquery/src/css/var/rnumnonpx.js +7 -0
  92. data/vendor/jquery/src/css/var/swap.js +26 -0
  93. data/vendor/jquery/src/data.js +179 -0
  94. data/vendor/jquery/src/data/Data.js +161 -0
  95. data/vendor/jquery/src/data/var/acceptData.js +19 -0
  96. data/vendor/jquery/src/data/var/dataPriv.js +7 -0
  97. data/vendor/jquery/src/data/var/dataUser.js +7 -0
  98. data/vendor/jquery/src/deferred.js +391 -0
  99. data/vendor/jquery/src/deferred/exceptionHook.js +21 -0
  100. data/vendor/jquery/src/deprecated.js +40 -0
  101. data/vendor/jquery/src/dimensions.js +56 -0
  102. data/vendor/jquery/src/effects.js +699 -0
  103. data/vendor/jquery/src/effects/Tween.js +123 -0
  104. data/vendor/jquery/src/effects/animatedSelector.js +15 -0
  105. data/vendor/jquery/src/event.js +746 -0
  106. data/vendor/jquery/src/event/ajax.js +22 -0
  107. data/vendor/jquery/src/event/alias.js +29 -0
  108. data/vendor/jquery/src/event/focusin.js +55 -0
  109. data/vendor/jquery/src/event/support.js +11 -0
  110. data/vendor/jquery/src/event/trigger.js +185 -0
  111. data/vendor/jquery/src/exports/amd.js +26 -0
  112. data/vendor/jquery/src/exports/global.js +34 -0
  113. data/vendor/jquery/src/jquery.js +41 -0
  114. data/vendor/jquery/src/manipulation.js +488 -0
  115. data/vendor/jquery/src/manipulation/_evalUrl.js +23 -0
  116. data/vendor/jquery/src/manipulation/buildFragment.js +104 -0
  117. data/vendor/jquery/src/manipulation/getAll.js +32 -0
  118. data/vendor/jquery/src/manipulation/setGlobalEval.js +22 -0
  119. data/vendor/jquery/src/manipulation/support.js +35 -0
  120. data/vendor/jquery/src/manipulation/var/rcheckableType.js +5 -0
  121. data/vendor/jquery/src/manipulation/var/rscriptType.js +5 -0
  122. data/vendor/jquery/src/manipulation/var/rtagName.js +5 -0
  123. data/vendor/jquery/src/manipulation/wrapMap.js +29 -0
  124. data/vendor/jquery/src/offset.js +229 -0
  125. data/vendor/jquery/src/queue.js +145 -0
  126. data/vendor/jquery/src/queue/delay.js +24 -0
  127. data/vendor/jquery/src/selector-native.js +237 -0
  128. data/vendor/jquery/src/selector-sizzle.js +19 -0
  129. data/vendor/jquery/src/selector.js +3 -0
  130. data/vendor/jquery/src/serialize.js +130 -0
  131. data/vendor/jquery/src/traversing.js +191 -0
  132. data/vendor/jquery/src/traversing/findFilter.js +106 -0
  133. data/vendor/jquery/src/traversing/var/dir.js +22 -0
  134. data/vendor/jquery/src/traversing/var/rneedsContext.js +8 -0
  135. data/vendor/jquery/src/traversing/var/siblings.js +17 -0
  136. data/vendor/jquery/src/var/ObjectFunctionString.js +7 -0
  137. data/vendor/jquery/src/var/arr.js +5 -0
  138. data/vendor/jquery/src/var/class2type.js +6 -0
  139. data/vendor/jquery/src/var/concat.js +7 -0
  140. data/vendor/jquery/src/var/document.js +5 -0
  141. data/vendor/jquery/src/var/documentElement.js +7 -0
  142. data/vendor/jquery/src/var/fnToString.js +7 -0
  143. data/vendor/jquery/src/var/getProto.js +5 -0
  144. data/vendor/jquery/src/var/hasOwn.js +7 -0
  145. data/vendor/jquery/src/var/indexOf.js +7 -0
  146. data/vendor/jquery/src/var/pnum.js +5 -0
  147. data/vendor/jquery/src/var/push.js +7 -0
  148. data/vendor/jquery/src/var/rcssNum.js +9 -0
  149. data/vendor/jquery/src/var/rnothtmlwhite.js +8 -0
  150. data/vendor/jquery/src/var/slice.js +7 -0
  151. data/vendor/jquery/src/var/support.js +6 -0
  152. data/vendor/jquery/src/var/toString.js +7 -0
  153. data/vendor/jquery/src/wrap.js +77 -0
  154. metadata +152 -3
  155. data/.gitmodules +0 -3
@@ -0,0 +1,102 @@
1
+ define( [
2
+ "../core",
3
+ "./var/nonce",
4
+ "./var/rquery",
5
+ "../ajax"
6
+ ], function( jQuery, nonce, rquery ) {
7
+
8
+ "use strict";
9
+
10
+ var oldCallbacks = [],
11
+ rjsonp = /(=)\?(?=&|$)|\?\?/;
12
+
13
+ // Default jsonp settings
14
+ jQuery.ajaxSetup( {
15
+ jsonp: "callback",
16
+ jsonpCallback: function() {
17
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
18
+ this[ callback ] = true;
19
+ return callback;
20
+ }
21
+ } );
22
+
23
+ // Detect, normalize options and install callbacks for jsonp requests
24
+ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
25
+
26
+ var callbackName, overwritten, responseContainer,
27
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
28
+ "url" :
29
+ typeof s.data === "string" &&
30
+ ( s.contentType || "" )
31
+ .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
32
+ rjsonp.test( s.data ) && "data"
33
+ );
34
+
35
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
36
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
37
+
38
+ // Get callback name, remembering preexisting value associated with it
39
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
40
+ s.jsonpCallback() :
41
+ s.jsonpCallback;
42
+
43
+ // Insert callback into url or form data
44
+ if ( jsonProp ) {
45
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
46
+ } else if ( s.jsonp !== false ) {
47
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
48
+ }
49
+
50
+ // Use data converter to retrieve json after script execution
51
+ s.converters[ "script json" ] = function() {
52
+ if ( !responseContainer ) {
53
+ jQuery.error( callbackName + " was not called" );
54
+ }
55
+ return responseContainer[ 0 ];
56
+ };
57
+
58
+ // Force json dataType
59
+ s.dataTypes[ 0 ] = "json";
60
+
61
+ // Install callback
62
+ overwritten = window[ callbackName ];
63
+ window[ callbackName ] = function() {
64
+ responseContainer = arguments;
65
+ };
66
+
67
+ // Clean-up function (fires after converters)
68
+ jqXHR.always( function() {
69
+
70
+ // If previous value didn't exist - remove it
71
+ if ( overwritten === undefined ) {
72
+ jQuery( window ).removeProp( callbackName );
73
+
74
+ // Otherwise restore preexisting value
75
+ } else {
76
+ window[ callbackName ] = overwritten;
77
+ }
78
+
79
+ // Save back as free
80
+ if ( s[ callbackName ] ) {
81
+
82
+ // Make sure that re-using the options doesn't screw things around
83
+ s.jsonpCallback = originalSettings.jsonpCallback;
84
+
85
+ // Save the callback name for future use
86
+ oldCallbacks.push( callbackName );
87
+ }
88
+
89
+ // Call if it was a function and we have a response
90
+ if ( responseContainer && jQuery.isFunction( overwritten ) ) {
91
+ overwritten( responseContainer[ 0 ] );
92
+ }
93
+
94
+ responseContainer = overwritten = undefined;
95
+ } );
96
+
97
+ // Delegate to script
98
+ return "script";
99
+ }
100
+ } );
101
+
102
+ } );
@@ -0,0 +1,76 @@
1
+ define( [
2
+ "../core",
3
+ "../core/stripAndCollapse",
4
+ "../core/parseHTML",
5
+ "../ajax",
6
+ "../traversing",
7
+ "../manipulation",
8
+ "../selector"
9
+ ], function( jQuery, stripAndCollapse ) {
10
+
11
+ "use strict";
12
+
13
+ /**
14
+ * Load a url into a page
15
+ */
16
+ jQuery.fn.load = function( url, params, callback ) {
17
+ var selector, type, response,
18
+ self = this,
19
+ off = url.indexOf( " " );
20
+
21
+ if ( off > -1 ) {
22
+ selector = stripAndCollapse( url.slice( off ) );
23
+ url = url.slice( 0, off );
24
+ }
25
+
26
+ // If it's a function
27
+ if ( jQuery.isFunction( params ) ) {
28
+
29
+ // We assume that it's the callback
30
+ callback = params;
31
+ params = undefined;
32
+
33
+ // Otherwise, build a param string
34
+ } else if ( params && typeof params === "object" ) {
35
+ type = "POST";
36
+ }
37
+
38
+ // If we have elements to modify, make the request
39
+ if ( self.length > 0 ) {
40
+ jQuery.ajax( {
41
+ url: url,
42
+
43
+ // If "type" variable is undefined, then "GET" method will be used.
44
+ // Make value of this field explicit since
45
+ // user can override it through ajaxSetup method
46
+ type: type || "GET",
47
+ dataType: "html",
48
+ data: params
49
+ } ).done( function( responseText ) {
50
+
51
+ // Save response for use in complete callback
52
+ response = arguments;
53
+
54
+ self.html( selector ?
55
+
56
+ // If a selector was specified, locate the right elements in a dummy div
57
+ // Exclude scripts to avoid IE 'Permission Denied' errors
58
+ jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
59
+
60
+ // Otherwise use the full result
61
+ responseText );
62
+
63
+ // If the request succeeds, this function gets "data", "status", "jqXHR"
64
+ // but they are ignored because response was set above.
65
+ // If it fails, this function gets "jqXHR", "status", "error"
66
+ } ).always( callback && function( jqXHR, status ) {
67
+ self.each( function() {
68
+ callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
69
+ } );
70
+ } );
71
+ }
72
+
73
+ return this;
74
+ };
75
+
76
+ } );
@@ -0,0 +1,30 @@
1
+ define( [
2
+ "../core"
3
+ ], function( jQuery ) {
4
+
5
+ "use strict";
6
+
7
+ // Cross-browser xml parsing
8
+ jQuery.parseXML = function( data ) {
9
+ var xml;
10
+ if ( !data || typeof data !== "string" ) {
11
+ return null;
12
+ }
13
+
14
+ // Support: IE 9 - 11 only
15
+ // IE throws on parseFromString with invalid input.
16
+ try {
17
+ xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
18
+ } catch ( e ) {
19
+ xml = undefined;
20
+ }
21
+
22
+ if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
23
+ jQuery.error( "Invalid XML: " + data );
24
+ }
25
+ return xml;
26
+ };
27
+
28
+ return jQuery.parseXML;
29
+
30
+ } );
@@ -0,0 +1,77 @@
1
+ define( [
2
+ "../core",
3
+ "../var/document",
4
+ "../ajax"
5
+ ], function( jQuery, document ) {
6
+
7
+ "use strict";
8
+
9
+ // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
10
+ jQuery.ajaxPrefilter( function( s ) {
11
+ if ( s.crossDomain ) {
12
+ s.contents.script = false;
13
+ }
14
+ } );
15
+
16
+ // Install script dataType
17
+ jQuery.ajaxSetup( {
18
+ accepts: {
19
+ script: "text/javascript, application/javascript, " +
20
+ "application/ecmascript, application/x-ecmascript"
21
+ },
22
+ contents: {
23
+ script: /\b(?:java|ecma)script\b/
24
+ },
25
+ converters: {
26
+ "text script": function( text ) {
27
+ jQuery.globalEval( text );
28
+ return text;
29
+ }
30
+ }
31
+ } );
32
+
33
+ // Handle cache's special case and crossDomain
34
+ jQuery.ajaxPrefilter( "script", function( s ) {
35
+ if ( s.cache === undefined ) {
36
+ s.cache = false;
37
+ }
38
+ if ( s.crossDomain ) {
39
+ s.type = "GET";
40
+ }
41
+ } );
42
+
43
+ // Bind script tag hack transport
44
+ jQuery.ajaxTransport( "script", function( s ) {
45
+
46
+ // This transport only deals with cross domain requests
47
+ if ( s.crossDomain ) {
48
+ var script, callback;
49
+ return {
50
+ send: function( _, complete ) {
51
+ script = jQuery( "<script>" ).prop( {
52
+ charset: s.scriptCharset,
53
+ src: s.url
54
+ } ).on(
55
+ "load error",
56
+ callback = function( evt ) {
57
+ script.remove();
58
+ callback = null;
59
+ if ( evt ) {
60
+ complete( evt.type === "error" ? 404 : 200, evt.type );
61
+ }
62
+ }
63
+ );
64
+
65
+ // Use native DOM manipulation to avoid our domManip AJAX trickery
66
+ document.head.appendChild( script[ 0 ] );
67
+ },
68
+ abort: function() {
69
+ if ( callback ) {
70
+ callback();
71
+ }
72
+ }
73
+ };
74
+ }
75
+ } );
76
+
77
+ } );
@@ -0,0 +1,5 @@
1
+ define( function() {
2
+ "use strict";
3
+
4
+ return window.location;
5
+ } );
@@ -0,0 +1,7 @@
1
+ define( [
2
+ "../../core"
3
+ ], function( jQuery ) {
4
+ "use strict";
5
+
6
+ return jQuery.now();
7
+ } );
@@ -0,0 +1,5 @@
1
+ define( function() {
2
+ "use strict";
3
+
4
+ return ( /\?/ );
5
+ } );
@@ -0,0 +1,169 @@
1
+ define( [
2
+ "../core",
3
+ "../var/support",
4
+ "../ajax"
5
+ ], function( jQuery, support ) {
6
+
7
+ "use strict";
8
+
9
+ jQuery.ajaxSettings.xhr = function() {
10
+ try {
11
+ return new window.XMLHttpRequest();
12
+ } catch ( e ) {}
13
+ };
14
+
15
+ var xhrSuccessStatus = {
16
+
17
+ // File protocol always yields status code 0, assume 200
18
+ 0: 200,
19
+
20
+ // Support: IE <=9 only
21
+ // #1450: sometimes IE returns 1223 when it should be 204
22
+ 1223: 204
23
+ },
24
+ xhrSupported = jQuery.ajaxSettings.xhr();
25
+
26
+ support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
27
+ support.ajax = xhrSupported = !!xhrSupported;
28
+
29
+ jQuery.ajaxTransport( function( options ) {
30
+ var callback, errorCallback;
31
+
32
+ // Cross domain only allowed if supported through XMLHttpRequest
33
+ if ( support.cors || xhrSupported && !options.crossDomain ) {
34
+ return {
35
+ send: function( headers, complete ) {
36
+ var i,
37
+ xhr = options.xhr();
38
+
39
+ xhr.open(
40
+ options.type,
41
+ options.url,
42
+ options.async,
43
+ options.username,
44
+ options.password
45
+ );
46
+
47
+ // Apply custom fields if provided
48
+ if ( options.xhrFields ) {
49
+ for ( i in options.xhrFields ) {
50
+ xhr[ i ] = options.xhrFields[ i ];
51
+ }
52
+ }
53
+
54
+ // Override mime type if needed
55
+ if ( options.mimeType && xhr.overrideMimeType ) {
56
+ xhr.overrideMimeType( options.mimeType );
57
+ }
58
+
59
+ // X-Requested-With header
60
+ // For cross-domain requests, seeing as conditions for a preflight are
61
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
62
+ // (it can always be set on a per-request basis or even using ajaxSetup)
63
+ // For same-domain requests, won't change header if already provided.
64
+ if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
65
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
66
+ }
67
+
68
+ // Set headers
69
+ for ( i in headers ) {
70
+ xhr.setRequestHeader( i, headers[ i ] );
71
+ }
72
+
73
+ // Callback
74
+ callback = function( type ) {
75
+ return function() {
76
+ if ( callback ) {
77
+ callback = errorCallback = xhr.onload =
78
+ xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
79
+
80
+ if ( type === "abort" ) {
81
+ xhr.abort();
82
+ } else if ( type === "error" ) {
83
+
84
+ // Support: IE <=9 only
85
+ // On a manual native abort, IE9 throws
86
+ // errors on any property access that is not readyState
87
+ if ( typeof xhr.status !== "number" ) {
88
+ complete( 0, "error" );
89
+ } else {
90
+ complete(
91
+
92
+ // File: protocol always yields status 0; see #8605, #14207
93
+ xhr.status,
94
+ xhr.statusText
95
+ );
96
+ }
97
+ } else {
98
+ complete(
99
+ xhrSuccessStatus[ xhr.status ] || xhr.status,
100
+ xhr.statusText,
101
+
102
+ // Support: IE <=9 only
103
+ // IE9 has no XHR2 but throws on binary (trac-11426)
104
+ // For XHR2 non-text, let the caller handle it (gh-2498)
105
+ ( xhr.responseType || "text" ) !== "text" ||
106
+ typeof xhr.responseText !== "string" ?
107
+ { binary: xhr.response } :
108
+ { text: xhr.responseText },
109
+ xhr.getAllResponseHeaders()
110
+ );
111
+ }
112
+ }
113
+ };
114
+ };
115
+
116
+ // Listen to events
117
+ xhr.onload = callback();
118
+ errorCallback = xhr.onerror = callback( "error" );
119
+
120
+ // Support: IE 9 only
121
+ // Use onreadystatechange to replace onabort
122
+ // to handle uncaught aborts
123
+ if ( xhr.onabort !== undefined ) {
124
+ xhr.onabort = errorCallback;
125
+ } else {
126
+ xhr.onreadystatechange = function() {
127
+
128
+ // Check readyState before timeout as it changes
129
+ if ( xhr.readyState === 4 ) {
130
+
131
+ // Allow onerror to be called first,
132
+ // but that will not handle a native abort
133
+ // Also, save errorCallback to a variable
134
+ // as xhr.onerror cannot be accessed
135
+ window.setTimeout( function() {
136
+ if ( callback ) {
137
+ errorCallback();
138
+ }
139
+ } );
140
+ }
141
+ };
142
+ }
143
+
144
+ // Create the abort callback
145
+ callback = callback( "abort" );
146
+
147
+ try {
148
+
149
+ // Do send the request (this may raise an exception)
150
+ xhr.send( options.hasContent && options.data || null );
151
+ } catch ( e ) {
152
+
153
+ // #14683: Only rethrow if this hasn't been notified as an error yet
154
+ if ( callback ) {
155
+ throw e;
156
+ }
157
+ }
158
+ },
159
+
160
+ abort: function() {
161
+ if ( callback ) {
162
+ callback();
163
+ }
164
+ }
165
+ };
166
+ }
167
+ } );
168
+
169
+ } );