webshims-rails 1.12.3 → 1.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/polyfiller.js +75 -31
- data/vendor/assets/javascripts/webshims/shims/color-picker.js +14 -14
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +83 -459
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +92 -69
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +90 -54
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +104 -494
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +66 -228
- data/vendor/assets/javascripts/webshims/shims/combos/14.js +2 -0
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +42 -40
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +105 -494
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +90 -54
- data/vendor/assets/javascripts/webshims/shims/combos/18.js +90 -54
- data/vendor/assets/javascripts/webshims/shims/combos/19.js +123 -471
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +85 -474
- data/vendor/assets/javascripts/webshims/shims/combos/20.js +85 -205
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +103 -45
- data/vendor/assets/javascripts/webshims/shims/combos/22.js +41 -40
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +63 -454
- data/vendor/assets/javascripts/webshims/shims/combos/24.js +52 -36
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +123 -471
- data/vendor/assets/javascripts/webshims/shims/combos/26.js +2 -15
- data/vendor/assets/javascripts/webshims/shims/combos/27.js +38 -266
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +20 -20
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +24 -20
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +24 -20
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +22 -20
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +4 -15
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +90 -54
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +90 -54
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +87 -474
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +87 -474
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +92 -69
- data/vendor/assets/javascripts/webshims/shims/combos/99.js +1724 -0
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +2 -15
- data/vendor/assets/javascripts/webshims/shims/form-core.js +19 -4
- data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +39 -5
- data/vendor/assets/javascripts/webshims/shims/form-message.js +2 -0
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +69 -37
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +18 -20
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +34 -16
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +12 -9
- data/vendor/assets/javascripts/webshims/shims/form-validators.js +21 -5
- data/vendor/assets/javascripts/webshims/shims/forms-picker.js +16 -13
- data/vendor/assets/javascripts/webshims/shims/geolocation.js +3 -3
- data/vendor/assets/javascripts/webshims/shims/jajax.js +1262 -0
- data/vendor/assets/javascripts/webshims/shims/jme/b.js +576 -0
- data/vendor/assets/javascripts/webshims/shims/jme/c.js +1148 -0
- data/vendor/assets/javascripts/webshims/shims/jme/controls.css +373 -0
- data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +711 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.eot +0 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.svg +36 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.ttf +0 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.woff +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +16 -18
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +25 -188
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +58 -2
- data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +130 -66
- data/vendor/assets/javascripts/webshims/shims/range-ui.js +21 -17
- data/vendor/assets/javascripts/webshims/shims/sizzle.js +1634 -1613
- data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +5 -5
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +5 -1
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +13 -9
- data/vendor/assets/javascripts/webshims/shims/swfmini-embed.js +136 -0
- data/vendor/assets/javascripts/webshims/shims/swfmini.js +38 -266
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +1 -3
- data/vendor/assets/javascripts/webshims/shims/track.js +41 -40
- metadata +13 -2
@@ -110,11 +110,9 @@ webshims.register('form-validation', function($, webshims, window, document, und
|
|
110
110
|
){
|
111
111
|
return;
|
112
112
|
}
|
113
|
-
if(webshims.refreshCustomValidityRules){
|
114
|
-
|
115
|
-
|
116
|
-
return;
|
117
|
-
}
|
113
|
+
if(webshims.refreshCustomValidityRules && webshims.refreshCustomValidityRules(elem) == 'async'){
|
114
|
+
$(elem).one('refreshvalidityui', switchValidityClass);
|
115
|
+
return;
|
118
116
|
}
|
119
117
|
|
120
118
|
var validity = $.prop(elem, 'validity');
|
@@ -663,7 +661,7 @@ webshims.register('form-validation', function($, webshims, window, document, und
|
|
663
661
|
check();
|
664
662
|
},
|
665
663
|
hideError: function(elem, reset){
|
666
|
-
var invalid, errorBox;
|
664
|
+
var invalid, errorBox, afterHide;
|
667
665
|
var fieldWrapper = this.getFieldWrapper(elem);
|
668
666
|
|
669
667
|
if(fieldWrapper.hasClass(invalidWrapperClass)){
|
@@ -674,12 +672,17 @@ webshims.register('form-validation', function($, webshims, window, document, und
|
|
674
672
|
errorBox = this.get(elem, fieldWrapper);
|
675
673
|
fieldWrapper.removeClass(invalidWrapperClass);
|
676
674
|
errorBox.message = '';
|
677
|
-
|
675
|
+
afterHide = function(){
|
678
676
|
if(this.id == elem.getAttribute('aria-describedby')){
|
679
677
|
elem.removeAttribute('aria-describedby');
|
680
678
|
}
|
681
679
|
$(this).attr({hidden: 'hidden'});
|
682
|
-
}
|
680
|
+
};
|
681
|
+
if(iVal.fx != 'no'){
|
682
|
+
errorBox[fx[iVal.fx].hide](afterHide);
|
683
|
+
} else {
|
684
|
+
errorBox[fx[iVal.fx].hide]().each(afterHide);
|
685
|
+
}
|
683
686
|
}
|
684
687
|
|
685
688
|
}
|
@@ -779,7 +782,7 @@ webshims.register('form-validation', function($, webshims, window, document, und
|
|
779
782
|
}
|
780
783
|
},
|
781
784
|
submit: function(e){
|
782
|
-
if(iVal.sel && iVal.submitCheck
|
785
|
+
if(iVal.sel && iVal.submitCheck && $(e.target).is(iVal.sel) && $.prop(e.target, 'noValidate') && !$(e.target).checkValidity()){
|
783
786
|
e.stopImmediatePropagation();
|
784
787
|
return false;
|
785
788
|
}
|
@@ -93,6 +93,18 @@ webshims.register('form-validators', function($, webshims, window, document, und
|
|
93
93
|
return message;
|
94
94
|
};
|
95
95
|
var testValidityRules = webshims.refreshCustomValidityRules;
|
96
|
+
|
97
|
+
if(typeof document.activeElement != 'unknown'){
|
98
|
+
$('body').on('click', function(e){
|
99
|
+
if(e.target.type == 'submit'){
|
100
|
+
var activeElement = document.activeElement;
|
101
|
+
|
102
|
+
if(activeElement != e.target && $.data(activeElement, 'webshimsswitchvalidityclass')){
|
103
|
+
$(activeElement).trigger('refreshvalidityui');
|
104
|
+
}
|
105
|
+
}
|
106
|
+
});
|
107
|
+
}
|
96
108
|
|
97
109
|
webshims.ready('forms form-validation', function(){
|
98
110
|
|
@@ -264,12 +276,10 @@ webshims.register('form-validators', function($, webshims, window, document, und
|
|
264
276
|
$(data.masterElement.type === 'radio' && getGroupElements(data.masterElement) || data.masterElement).on('change', depFn);
|
265
277
|
} else {
|
266
278
|
$(data.masterElement).on('change', function(){
|
279
|
+
webshims.refreshCustomValidityRules(elem);
|
267
280
|
$(elem)
|
268
281
|
.getShadowElement()
|
269
282
|
.filter('.user-error, .user-success')
|
270
|
-
.each(function(){
|
271
|
-
webshims.refreshCustomValidityRules(elem);
|
272
|
-
})
|
273
283
|
.trigger('refreshvalidityui')
|
274
284
|
;
|
275
285
|
});
|
@@ -284,8 +294,14 @@ webshims.register('form-validators', function($, webshims, window, document, und
|
|
284
294
|
}
|
285
295
|
|
286
296
|
}, 'The value of this field does not repeat the value of the other field');
|
287
|
-
|
288
|
-
|
297
|
+
|
298
|
+
addCustomValidityRule('valuevalidation', function(elem, val, data){
|
299
|
+
if(val && ('valuevalidation' in data)){
|
300
|
+
//Todo allow markup params
|
301
|
+
return $(elem).triggerHandler('valuevalidation', [{value: val, valueAsDate: $.prop(elem, 'valueAsDate'), isPartial: false}]) || '';
|
302
|
+
}
|
303
|
+
}, 'This value is not allowed here');
|
304
|
+
|
289
305
|
if(window.JSON){
|
290
306
|
addCustomValidityRule('ajaxvalidate', function(elem, val, data){
|
291
307
|
if(!val || !data.ajaxvalidate){return;}
|
@@ -932,6 +932,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
932
932
|
var enabled = 0;
|
933
933
|
var str = '';
|
934
934
|
var rowNum = 0;
|
935
|
+
var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig)));
|
935
936
|
|
936
937
|
if(data.options.useDecadeBase == 'max' && max[0]){
|
937
938
|
xthCorrect = 11 - (max[0] % 12);
|
@@ -956,7 +957,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
956
957
|
for(i = 0; i < 12; i++){
|
957
958
|
val = start + i ;
|
958
959
|
classArray = [];
|
959
|
-
if( !picker.isInRange([val], max, min) ){
|
960
|
+
if( !picker.isInRange([val], max, min) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: val, valueAsDate: null, isPartial: [val]}]))){
|
960
961
|
disabled = ' disabled=""';
|
961
962
|
} else {
|
962
963
|
disabled = '';
|
@@ -1007,6 +1008,9 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1007
1008
|
var enabled = 0;
|
1008
1009
|
var rowNum = 0;
|
1009
1010
|
var str = '';
|
1011
|
+
var action = data.type == 'month' ? 'changeInput' : 'setDayList' ;
|
1012
|
+
var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig)));
|
1013
|
+
var isPartial = action != 'changeInput';
|
1010
1014
|
|
1011
1015
|
value = value[0] - Math.floor((size - 1) / 2);
|
1012
1016
|
for(j = 0; j < size; j++){
|
@@ -1040,7 +1044,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1040
1044
|
val = curCfg.date.monthkeys[i+1];
|
1041
1045
|
name = getMonthNameHTML(i);
|
1042
1046
|
classArray = [];
|
1043
|
-
if(!picker.isInRange([value, val], max, min) ){
|
1047
|
+
if(!picker.isInRange([value, val], max, min) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: value+'-'+val, valueAsDate: data.asDate(value+'-'+val), isPartial: isPartial && [value, val]}]))){
|
1044
1048
|
disabled = ' disabled=""';
|
1045
1049
|
} else {
|
1046
1050
|
disabled = '';
|
@@ -1061,7 +1065,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1061
1065
|
lis.push('</tr><tr class="ws-row-'+ rowNum +'">');
|
1062
1066
|
}
|
1063
1067
|
|
1064
|
-
lis.push('<td class="ws-item-'+ i +'" role="presentation"><button data-id="month-'+ i +'" type="button"'+ disabled + classStr +' data-action="'+
|
1068
|
+
lis.push('<td class="ws-item-'+ i +'" role="presentation"><button data-id="month-'+ i +'" type="button"'+ disabled + classStr +' data-action="'+ action +'" value="'+value+'-'+val+'" tabindex="-1" role="gridcell" aria-label="'+ curCfg.date.monthNames[i] +'">'+name+'</button></td>');
|
1065
1069
|
|
1066
1070
|
}
|
1067
1071
|
|
@@ -1081,9 +1085,9 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1081
1085
|
|
1082
1086
|
picker.getDayList = function(value, data){
|
1083
1087
|
|
1084
|
-
var j, i, k, day, nDay,
|
1088
|
+
var j, i, k, day, nDay, disabled, prevDisabled, nextDisabled, yearNext, yearPrev, addTr, week, rowNum;
|
1085
1089
|
|
1086
|
-
var lastMonth, curMonth, otherMonth, dateArray, monthName, fullMonthName,
|
1090
|
+
var lastMonth, curMonth, otherMonth, dateArray, monthName, fullMonthName, buttonStr, date2, classArray;
|
1087
1091
|
|
1088
1092
|
var o = data.options;
|
1089
1093
|
var size = o.size;
|
@@ -1091,10 +1095,11 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1091
1095
|
var min = o.minS;
|
1092
1096
|
var currentValue = o.value.split('T')[0].split('-');
|
1093
1097
|
var dateCfg = curCfg.date;
|
1094
|
-
var enabled = 0;
|
1095
1098
|
var str = [];
|
1096
1099
|
var date = new Date(value[0], value[1] - 1, 1);
|
1097
1100
|
var action = (data.type == 'datetime-local') ? 'setTimeList' : 'changeInput';
|
1101
|
+
var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig)));
|
1102
|
+
var isPartial = action != 'changeInput';
|
1098
1103
|
|
1099
1104
|
date.setMonth(date.getMonth() - Math.floor((size - 1) / 2));
|
1100
1105
|
|
@@ -1210,7 +1215,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1210
1215
|
buttonStr += ' class="'+ classArray.join(' ') +'"';
|
1211
1216
|
}
|
1212
1217
|
|
1213
|
-
if(!picker.isInRange(dateArray, max, min)){
|
1218
|
+
if(!picker.isInRange(dateArray, max, min) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: dateArray.join('-'), valueAsDate: date, isPartial: isPartial && dateArray}]))){
|
1214
1219
|
buttonStr += ' disabled=""';
|
1215
1220
|
}
|
1216
1221
|
|
@@ -1252,7 +1257,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1252
1257
|
max: $.prop(data.orig, 'max'),
|
1253
1258
|
step: $.prop(data.orig, 'step')
|
1254
1259
|
};
|
1255
|
-
var
|
1260
|
+
var triggerValueValidation = (data.orig && ('valuevalidation' in $.data(data.orig)));
|
1256
1261
|
var gridLabel = '';
|
1257
1262
|
|
1258
1263
|
if(data.type == 'time'){
|
@@ -1285,7 +1290,7 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1285
1290
|
}
|
1286
1291
|
str += '<td role="presentation"><button role="gridcell" data-action="changeInput" value="'+ hVal +'" type="button" tabindex="-1"';
|
1287
1292
|
|
1288
|
-
if(!data.isValid(hVal, attrs)){
|
1293
|
+
if(!data.isValid(hVal, attrs) || (triggerValueValidation && $(data.orig).triggerHandler('valuevalidation', [{value: hVal, valueAsDate: data.asDate(hVal), partial: false}]))){
|
1289
1294
|
str += ' disabled=""';
|
1290
1295
|
}
|
1291
1296
|
if(value == iVal){
|
@@ -1523,15 +1528,13 @@ webshims.register('forms-picker', function($, webshims, window, document, undefi
|
|
1523
1528
|
text = (formcfg[''][[data.type]] || {}).currentText || (curCfg.date || {}).currentText || 'current';
|
1524
1529
|
webshims.warn("could not get currentText from form cfg for "+data.type);
|
1525
1530
|
}
|
1531
|
+
|
1526
1532
|
if(today[data.type] && data.type != 'time'){
|
1527
|
-
$.prop(this, 'disabled', !picker.isInRange(today[data.type].split('-'), o.maxS, o.minS));
|
1533
|
+
$.prop(this, 'disabled', (!picker.isInRange(today[data.type].split('-'), o.maxS, o.minS) || !!$(data.orig).triggerHandler('valuevalidation', [{value: today[data.type], valueAsDate: new Date(), isPartial: false}])));
|
1528
1534
|
}
|
1529
1535
|
}
|
1530
1536
|
if(text){
|
1531
1537
|
$(this).text(text).attr({'aria-label': text});
|
1532
|
-
if(webshims.assumeARIA){
|
1533
|
-
$.attr(this, 'aria-label', text);
|
1534
|
-
}
|
1535
1538
|
}
|
1536
1539
|
|
1537
1540
|
});
|
@@ -128,8 +128,8 @@
|
|
128
128
|
if($.ajax){
|
129
129
|
createAjax();
|
130
130
|
} else {
|
131
|
-
webshims.ready('
|
132
|
-
webshims.loader.loadList(['
|
131
|
+
webshims.ready('jajax', createAjax);
|
132
|
+
webshims.loader.loadList(['jajax']);
|
133
133
|
}
|
134
134
|
clearTimeout(googleTimer);
|
135
135
|
if (!window.google || !window.google.loader) {
|
@@ -174,7 +174,7 @@
|
|
174
174
|
})();
|
175
175
|
|
176
176
|
webshims.ready('WINDOWLOAD', function(){
|
177
|
-
webshims.loader.loadList(['
|
177
|
+
webshims.loader.loadList(['jajax']);
|
178
178
|
});
|
179
179
|
webshims.isReady('geolocation', true);
|
180
180
|
})(webshims.$);
|
@@ -0,0 +1,1262 @@
|
|
1
|
+
(function(){
|
2
|
+
var jQuery = window.webshims && webshims.$ || window.jQuery;
|
3
|
+
|
4
|
+
var rnotwhite = (/\S+/g);
|
5
|
+
var nonce = jQuery.now();
|
6
|
+
var rquery = (/\?/);
|
7
|
+
var init = jQuery.fn.init;
|
8
|
+
|
9
|
+
jQuery.parseJSON = function( data ) {
|
10
|
+
return window.JSON.parse( data + "" );
|
11
|
+
};
|
12
|
+
|
13
|
+
// Cross-browser xml parsing
|
14
|
+
jQuery.parseXML = function( data ) {
|
15
|
+
var xml, tmp;
|
16
|
+
if ( !data || typeof data !== "string" ) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
try {
|
20
|
+
if ( window.DOMParser ) { // Standard
|
21
|
+
tmp = new DOMParser();
|
22
|
+
xml = tmp.parseFromString( data, "text/xml" );
|
23
|
+
} else { // IE
|
24
|
+
xml = new ActiveXObject( "Microsoft.XMLDOM" );
|
25
|
+
xml.async = "false";
|
26
|
+
xml.loadXML( data );
|
27
|
+
}
|
28
|
+
} catch( e ) {
|
29
|
+
xml = undefined;
|
30
|
+
}
|
31
|
+
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
|
32
|
+
jQuery.error( "Invalid XML: " + data );
|
33
|
+
}
|
34
|
+
return xml;
|
35
|
+
};
|
36
|
+
|
37
|
+
(function(){
|
38
|
+
var
|
39
|
+
// Document location
|
40
|
+
ajaxLocParts,
|
41
|
+
ajaxLocation,
|
42
|
+
|
43
|
+
rhash = /#.*$/,
|
44
|
+
rts = /([?&])_=[^&]*/,
|
45
|
+
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
46
|
+
// #7653, #8125, #8152: local protocol detection
|
47
|
+
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
48
|
+
rnoContent = /^(?:GET|HEAD)$/,
|
49
|
+
rprotocol = /^\/\//,
|
50
|
+
rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
|
51
|
+
|
52
|
+
/* Prefilters
|
53
|
+
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
54
|
+
* 2) These are called:
|
55
|
+
* - BEFORE asking for a transport
|
56
|
+
* - AFTER param serialization (s.data is a string if s.processData is true)
|
57
|
+
* 3) key is the dataType
|
58
|
+
* 4) the catchall symbol "*" can be used
|
59
|
+
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
60
|
+
*/
|
61
|
+
prefilters = {},
|
62
|
+
|
63
|
+
/* Transports bindings
|
64
|
+
* 1) key is the dataType
|
65
|
+
* 2) the catchall symbol "*" can be used
|
66
|
+
* 3) selection will start with transport dataType and THEN go to "*" if needed
|
67
|
+
*/
|
68
|
+
transports = {},
|
69
|
+
|
70
|
+
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
|
71
|
+
allTypes = "*/".concat("*");
|
72
|
+
|
73
|
+
// #8138, IE may throw an exception when accessing
|
74
|
+
// a field from window.location if document.domain has been set
|
75
|
+
try {
|
76
|
+
ajaxLocation = location.href;
|
77
|
+
} catch( e ) {
|
78
|
+
// Use the href attribute of an A element
|
79
|
+
// since IE will modify it given document.location
|
80
|
+
ajaxLocation = document.createElement( "a" );
|
81
|
+
ajaxLocation.href = "";
|
82
|
+
ajaxLocation = ajaxLocation.href;
|
83
|
+
}
|
84
|
+
|
85
|
+
// Segment location into parts
|
86
|
+
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
87
|
+
|
88
|
+
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
89
|
+
function addToPrefiltersOrTransports( structure ) {
|
90
|
+
|
91
|
+
// dataTypeExpression is optional and defaults to "*"
|
92
|
+
return function( dataTypeExpression, func ) {
|
93
|
+
|
94
|
+
if ( typeof dataTypeExpression !== "string" ) {
|
95
|
+
func = dataTypeExpression;
|
96
|
+
dataTypeExpression = "*";
|
97
|
+
}
|
98
|
+
|
99
|
+
var dataType,
|
100
|
+
i = 0,
|
101
|
+
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
|
102
|
+
|
103
|
+
if ( jQuery.isFunction( func ) ) {
|
104
|
+
// For each dataType in the dataTypeExpression
|
105
|
+
while ( (dataType = dataTypes[i++]) ) {
|
106
|
+
// Prepend if requested
|
107
|
+
if ( dataType.charAt( 0 ) === "+" ) {
|
108
|
+
dataType = dataType.slice( 1 ) || "*";
|
109
|
+
(structure[ dataType ] = structure[ dataType ] || []).unshift( func );
|
110
|
+
|
111
|
+
// Otherwise append
|
112
|
+
} else {
|
113
|
+
(structure[ dataType ] = structure[ dataType ] || []).push( func );
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
};
|
118
|
+
}
|
119
|
+
|
120
|
+
// Base inspection function for prefilters and transports
|
121
|
+
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
|
122
|
+
|
123
|
+
var inspected = {},
|
124
|
+
seekingTransport = ( structure === transports );
|
125
|
+
|
126
|
+
function inspect( dataType ) {
|
127
|
+
var selected;
|
128
|
+
inspected[ dataType ] = true;
|
129
|
+
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
130
|
+
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
131
|
+
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
132
|
+
options.dataTypes.unshift( dataTypeOrTransport );
|
133
|
+
inspect( dataTypeOrTransport );
|
134
|
+
return false;
|
135
|
+
} else if ( seekingTransport ) {
|
136
|
+
return !( selected = dataTypeOrTransport );
|
137
|
+
}
|
138
|
+
});
|
139
|
+
return selected;
|
140
|
+
}
|
141
|
+
|
142
|
+
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
|
143
|
+
}
|
144
|
+
|
145
|
+
// A special extend for ajax options
|
146
|
+
// that takes "flat" options (not to be deep extended)
|
147
|
+
// Fixes #9887
|
148
|
+
function ajaxExtend( target, src ) {
|
149
|
+
var deep, key,
|
150
|
+
flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
151
|
+
|
152
|
+
for ( key in src ) {
|
153
|
+
if ( src[ key ] !== undefined ) {
|
154
|
+
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
|
155
|
+
}
|
156
|
+
}
|
157
|
+
if ( deep ) {
|
158
|
+
jQuery.extend( true, target, deep );
|
159
|
+
}
|
160
|
+
|
161
|
+
return target;
|
162
|
+
}
|
163
|
+
|
164
|
+
/* Handles responses to an ajax request:
|
165
|
+
* - finds the right dataType (mediates between content-type and expected dataType)
|
166
|
+
* - returns the corresponding response
|
167
|
+
*/
|
168
|
+
function ajaxHandleResponses( s, jqXHR, responses ) {
|
169
|
+
var firstDataType, ct, finalDataType, type,
|
170
|
+
contents = s.contents,
|
171
|
+
dataTypes = s.dataTypes;
|
172
|
+
|
173
|
+
// Remove auto dataType and get content-type in the process
|
174
|
+
while ( dataTypes[ 0 ] === "*" ) {
|
175
|
+
dataTypes.shift();
|
176
|
+
if ( ct === undefined ) {
|
177
|
+
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
// Check if we're dealing with a known content-type
|
182
|
+
if ( ct ) {
|
183
|
+
for ( type in contents ) {
|
184
|
+
if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
185
|
+
dataTypes.unshift( type );
|
186
|
+
break;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
// Check to see if we have a response for the expected dataType
|
192
|
+
if ( dataTypes[ 0 ] in responses ) {
|
193
|
+
finalDataType = dataTypes[ 0 ];
|
194
|
+
} else {
|
195
|
+
// Try convertible dataTypes
|
196
|
+
for ( type in responses ) {
|
197
|
+
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
198
|
+
finalDataType = type;
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
if ( !firstDataType ) {
|
202
|
+
firstDataType = type;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
// Or just use first one
|
206
|
+
finalDataType = finalDataType || firstDataType;
|
207
|
+
}
|
208
|
+
|
209
|
+
// If we found a dataType
|
210
|
+
// We add the dataType to the list if needed
|
211
|
+
// and return the corresponding response
|
212
|
+
if ( finalDataType ) {
|
213
|
+
if ( finalDataType !== dataTypes[ 0 ] ) {
|
214
|
+
dataTypes.unshift( finalDataType );
|
215
|
+
}
|
216
|
+
return responses[ finalDataType ];
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
/* Chain conversions given the request and the original response
|
221
|
+
* Also sets the responseXXX fields on the jqXHR instance
|
222
|
+
*/
|
223
|
+
function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
224
|
+
var conv2, current, conv, tmp, prev,
|
225
|
+
converters = {},
|
226
|
+
// Work with a copy of dataTypes in case we need to modify it for conversion
|
227
|
+
dataTypes = s.dataTypes.slice();
|
228
|
+
|
229
|
+
// Create converters map with lowercased keys
|
230
|
+
if ( dataTypes[ 1 ] ) {
|
231
|
+
for ( conv in s.converters ) {
|
232
|
+
converters[ conv.toLowerCase() ] = s.converters[ conv ];
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
current = dataTypes.shift();
|
237
|
+
|
238
|
+
// Convert to each sequential dataType
|
239
|
+
while ( current ) {
|
240
|
+
|
241
|
+
if ( s.responseFields[ current ] ) {
|
242
|
+
jqXHR[ s.responseFields[ current ] ] = response;
|
243
|
+
}
|
244
|
+
|
245
|
+
// Apply the dataFilter if provided
|
246
|
+
if ( !prev && isSuccess && s.dataFilter ) {
|
247
|
+
response = s.dataFilter( response, s.dataType );
|
248
|
+
}
|
249
|
+
|
250
|
+
prev = current;
|
251
|
+
current = dataTypes.shift();
|
252
|
+
|
253
|
+
if ( current ) {
|
254
|
+
|
255
|
+
// There's only work to do if current dataType is non-auto
|
256
|
+
if ( current === "*" ) {
|
257
|
+
|
258
|
+
current = prev;
|
259
|
+
|
260
|
+
// Convert response if prev dataType is non-auto and differs from current
|
261
|
+
} else if ( prev !== "*" && prev !== current ) {
|
262
|
+
|
263
|
+
// Seek a direct converter
|
264
|
+
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
|
265
|
+
|
266
|
+
// If none found, seek a pair
|
267
|
+
if ( !conv ) {
|
268
|
+
for ( conv2 in converters ) {
|
269
|
+
|
270
|
+
// If conv2 outputs current
|
271
|
+
tmp = conv2.split( " " );
|
272
|
+
if ( tmp[ 1 ] === current ) {
|
273
|
+
|
274
|
+
// If prev can be converted to accepted input
|
275
|
+
conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
276
|
+
converters[ "* " + tmp[ 0 ] ];
|
277
|
+
if ( conv ) {
|
278
|
+
// Condense equivalence converters
|
279
|
+
if ( conv === true ) {
|
280
|
+
conv = converters[ conv2 ];
|
281
|
+
|
282
|
+
// Otherwise, insert the intermediate dataType
|
283
|
+
} else if ( converters[ conv2 ] !== true ) {
|
284
|
+
current = tmp[ 0 ];
|
285
|
+
dataTypes.unshift( tmp[ 1 ] );
|
286
|
+
}
|
287
|
+
break;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
293
|
+
// Apply converter (if not an equivalence)
|
294
|
+
if ( conv !== true ) {
|
295
|
+
|
296
|
+
// Unless errors are allowed to bubble, catch and return them
|
297
|
+
if ( conv && s[ "throws" ] ) {
|
298
|
+
response = conv( response );
|
299
|
+
} else {
|
300
|
+
try {
|
301
|
+
response = conv( response );
|
302
|
+
} catch ( e ) {
|
303
|
+
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
304
|
+
}
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
return { state: "success", data: response };
|
312
|
+
}
|
313
|
+
|
314
|
+
jQuery.extend({
|
315
|
+
|
316
|
+
// Counter for holding the number of active queries
|
317
|
+
active: 0,
|
318
|
+
|
319
|
+
// Last-Modified header cache for next request
|
320
|
+
lastModified: {},
|
321
|
+
etag: {},
|
322
|
+
|
323
|
+
ajaxSettings: {
|
324
|
+
url: ajaxLocation,
|
325
|
+
type: "GET",
|
326
|
+
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
327
|
+
global: true,
|
328
|
+
processData: true,
|
329
|
+
async: true,
|
330
|
+
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
331
|
+
/*
|
332
|
+
timeout: 0,
|
333
|
+
data: null,
|
334
|
+
dataType: null,
|
335
|
+
username: null,
|
336
|
+
password: null,
|
337
|
+
cache: null,
|
338
|
+
throws: false,
|
339
|
+
traditional: false,
|
340
|
+
headers: {},
|
341
|
+
*/
|
342
|
+
|
343
|
+
accepts: {
|
344
|
+
"*": allTypes,
|
345
|
+
text: "text/plain",
|
346
|
+
html: "text/html",
|
347
|
+
xml: "application/xml, text/xml",
|
348
|
+
json: "application/json, text/javascript"
|
349
|
+
},
|
350
|
+
|
351
|
+
contents: {
|
352
|
+
xml: /xml/,
|
353
|
+
html: /html/,
|
354
|
+
json: /json/
|
355
|
+
},
|
356
|
+
|
357
|
+
responseFields: {
|
358
|
+
xml: "responseXML",
|
359
|
+
text: "responseText",
|
360
|
+
json: "responseJSON"
|
361
|
+
},
|
362
|
+
|
363
|
+
// Data converters
|
364
|
+
// Keys separate source (or catchall "*") and destination types with a single space
|
365
|
+
converters: {
|
366
|
+
|
367
|
+
// Convert anything to text
|
368
|
+
"* text": String,
|
369
|
+
|
370
|
+
// Text to html (true = no transformation)
|
371
|
+
"text html": true,
|
372
|
+
|
373
|
+
// Evaluate text as a json expression
|
374
|
+
"text json": jQuery.parseJSON,
|
375
|
+
|
376
|
+
// Parse text as xml
|
377
|
+
"text xml": jQuery.parseXML
|
378
|
+
},
|
379
|
+
|
380
|
+
// For options that shouldn't be deep extended:
|
381
|
+
// you can add your own custom options here if
|
382
|
+
// and when you create one that shouldn't be
|
383
|
+
// deep extended (see ajaxExtend)
|
384
|
+
flatOptions: {
|
385
|
+
url: true,
|
386
|
+
context: true
|
387
|
+
}
|
388
|
+
},
|
389
|
+
|
390
|
+
// Creates a full fledged settings object into target
|
391
|
+
// with both ajaxSettings and settings fields.
|
392
|
+
// If target is omitted, writes into ajaxSettings.
|
393
|
+
ajaxSetup: function( target, settings ) {
|
394
|
+
return settings ?
|
395
|
+
|
396
|
+
// Building a settings object
|
397
|
+
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
|
398
|
+
|
399
|
+
// Extending ajaxSettings
|
400
|
+
ajaxExtend( jQuery.ajaxSettings, target );
|
401
|
+
},
|
402
|
+
|
403
|
+
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
404
|
+
ajaxTransport: addToPrefiltersOrTransports( transports ),
|
405
|
+
|
406
|
+
// Main method
|
407
|
+
ajax: function( url, options ) {
|
408
|
+
|
409
|
+
// If url is an object, simulate pre-1.5 signature
|
410
|
+
if ( typeof url === "object" ) {
|
411
|
+
options = url;
|
412
|
+
url = undefined;
|
413
|
+
}
|
414
|
+
|
415
|
+
// Force options to be an object
|
416
|
+
options = options || {};
|
417
|
+
|
418
|
+
var // Cross-domain detection vars
|
419
|
+
parts,
|
420
|
+
// Loop variable
|
421
|
+
i,
|
422
|
+
// URL without anti-cache param
|
423
|
+
cacheURL,
|
424
|
+
// Response headers as string
|
425
|
+
responseHeadersString,
|
426
|
+
// timeout handle
|
427
|
+
timeoutTimer,
|
428
|
+
|
429
|
+
// To know if global events are to be dispatched
|
430
|
+
fireGlobals,
|
431
|
+
|
432
|
+
transport,
|
433
|
+
// Response headers
|
434
|
+
responseHeaders,
|
435
|
+
// Create the final options object
|
436
|
+
s = jQuery.ajaxSetup( {}, options ),
|
437
|
+
// Callbacks context
|
438
|
+
callbackContext = s.context || s,
|
439
|
+
// Context for global events is callbackContext if it is a DOM node or jQuery collection
|
440
|
+
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
441
|
+
jQuery( callbackContext ) :
|
442
|
+
jQuery.event,
|
443
|
+
// Deferreds
|
444
|
+
deferred = jQuery.Deferred(),
|
445
|
+
completeDeferred = jQuery.Callbacks("once memory"),
|
446
|
+
// Status-dependent callbacks
|
447
|
+
statusCode = s.statusCode || {},
|
448
|
+
// Headers (they are sent all at once)
|
449
|
+
requestHeaders = {},
|
450
|
+
requestHeadersNames = {},
|
451
|
+
// The jqXHR state
|
452
|
+
state = 0,
|
453
|
+
// Default abort message
|
454
|
+
strAbort = "canceled",
|
455
|
+
// Fake xhr
|
456
|
+
jqXHR = {
|
457
|
+
readyState: 0,
|
458
|
+
|
459
|
+
// Builds headers hashtable if needed
|
460
|
+
getResponseHeader: function( key ) {
|
461
|
+
var match;
|
462
|
+
if ( state === 2 ) {
|
463
|
+
if ( !responseHeaders ) {
|
464
|
+
responseHeaders = {};
|
465
|
+
while ( (match = rheaders.exec( responseHeadersString )) ) {
|
466
|
+
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
467
|
+
}
|
468
|
+
}
|
469
|
+
match = responseHeaders[ key.toLowerCase() ];
|
470
|
+
}
|
471
|
+
return match == null ? null : match;
|
472
|
+
},
|
473
|
+
|
474
|
+
// Raw string
|
475
|
+
getAllResponseHeaders: function() {
|
476
|
+
return state === 2 ? responseHeadersString : null;
|
477
|
+
},
|
478
|
+
|
479
|
+
// Caches the header
|
480
|
+
setRequestHeader: function( name, value ) {
|
481
|
+
var lname = name.toLowerCase();
|
482
|
+
if ( !state ) {
|
483
|
+
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
484
|
+
requestHeaders[ name ] = value;
|
485
|
+
}
|
486
|
+
return this;
|
487
|
+
},
|
488
|
+
|
489
|
+
// Overrides response content-type header
|
490
|
+
overrideMimeType: function( type ) {
|
491
|
+
if ( !state ) {
|
492
|
+
s.mimeType = type;
|
493
|
+
}
|
494
|
+
return this;
|
495
|
+
},
|
496
|
+
|
497
|
+
// Status-dependent callbacks
|
498
|
+
statusCode: function( map ) {
|
499
|
+
var code;
|
500
|
+
if ( map ) {
|
501
|
+
if ( state < 2 ) {
|
502
|
+
for ( code in map ) {
|
503
|
+
// Lazy-add the new callback in a way that preserves old ones
|
504
|
+
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
505
|
+
}
|
506
|
+
} else {
|
507
|
+
// Execute the appropriate callbacks
|
508
|
+
jqXHR.always( map[ jqXHR.status ] );
|
509
|
+
}
|
510
|
+
}
|
511
|
+
return this;
|
512
|
+
},
|
513
|
+
|
514
|
+
// Cancel the request
|
515
|
+
abort: function( statusText ) {
|
516
|
+
var finalText = statusText || strAbort;
|
517
|
+
if ( transport ) {
|
518
|
+
transport.abort( finalText );
|
519
|
+
}
|
520
|
+
done( 0, finalText );
|
521
|
+
return this;
|
522
|
+
}
|
523
|
+
};
|
524
|
+
|
525
|
+
// Attach deferreds
|
526
|
+
deferred.promise( jqXHR ).complete = completeDeferred.add;
|
527
|
+
jqXHR.success = jqXHR.done;
|
528
|
+
jqXHR.error = jqXHR.fail;
|
529
|
+
|
530
|
+
// Remove hash character (#7531: and string promotion)
|
531
|
+
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
532
|
+
// Handle falsy url in the settings object (#10093: consistency with old signature)
|
533
|
+
// We also use the url parameter if available
|
534
|
+
s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
535
|
+
|
536
|
+
// Alias method option to type as per ticket #12004
|
537
|
+
s.type = options.method || options.type || s.method || s.type;
|
538
|
+
|
539
|
+
// Extract dataTypes list
|
540
|
+
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
|
541
|
+
|
542
|
+
// A cross-domain request is in order when we have a protocol:host:port mismatch
|
543
|
+
if ( s.crossDomain == null ) {
|
544
|
+
parts = rurl.exec( s.url.toLowerCase() );
|
545
|
+
s.crossDomain = !!( parts &&
|
546
|
+
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
|
547
|
+
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
|
548
|
+
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
|
549
|
+
);
|
550
|
+
}
|
551
|
+
|
552
|
+
// Convert data if not already a string
|
553
|
+
if ( s.data && s.processData && typeof s.data !== "string" ) {
|
554
|
+
s.data = jQuery.param( s.data, s.traditional );
|
555
|
+
}
|
556
|
+
|
557
|
+
// Apply prefilters
|
558
|
+
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
559
|
+
|
560
|
+
// If request was aborted inside a prefilter, stop there
|
561
|
+
if ( state === 2 ) {
|
562
|
+
return jqXHR;
|
563
|
+
}
|
564
|
+
|
565
|
+
// We can fire global events as of now if asked to
|
566
|
+
fireGlobals = s.global;
|
567
|
+
|
568
|
+
// Watch for a new set of requests
|
569
|
+
if ( fireGlobals && jQuery.active++ === 0 ) {
|
570
|
+
jQuery.event.trigger("ajaxStart");
|
571
|
+
}
|
572
|
+
|
573
|
+
// Uppercase the type
|
574
|
+
s.type = s.type.toUpperCase();
|
575
|
+
|
576
|
+
// Determine if request has content
|
577
|
+
s.hasContent = !rnoContent.test( s.type );
|
578
|
+
|
579
|
+
// Save the URL in case we're toying with the If-Modified-Since
|
580
|
+
// and/or If-None-Match header later on
|
581
|
+
cacheURL = s.url;
|
582
|
+
|
583
|
+
// More options handling for requests with no content
|
584
|
+
if ( !s.hasContent ) {
|
585
|
+
|
586
|
+
// If data is available, append data to url
|
587
|
+
if ( s.data ) {
|
588
|
+
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
589
|
+
// #9682: remove data so that it's not used in an eventual retry
|
590
|
+
delete s.data;
|
591
|
+
}
|
592
|
+
|
593
|
+
// Add anti-cache in url if needed
|
594
|
+
if ( s.cache === false ) {
|
595
|
+
s.url = rts.test( cacheURL ) ?
|
596
|
+
|
597
|
+
// If there is already a '_' parameter, set its value
|
598
|
+
cacheURL.replace( rts, "$1_=" + nonce++ ) :
|
599
|
+
|
600
|
+
// Otherwise add one to the end
|
601
|
+
cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
606
|
+
if ( s.ifModified ) {
|
607
|
+
if ( jQuery.lastModified[ cacheURL ] ) {
|
608
|
+
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
|
609
|
+
}
|
610
|
+
if ( jQuery.etag[ cacheURL ] ) {
|
611
|
+
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
|
612
|
+
}
|
613
|
+
}
|
614
|
+
|
615
|
+
// Set the correct header, if data is being sent
|
616
|
+
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
617
|
+
jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
618
|
+
}
|
619
|
+
|
620
|
+
// Set the Accepts header for the server, depending on the dataType
|
621
|
+
jqXHR.setRequestHeader(
|
622
|
+
"Accept",
|
623
|
+
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
624
|
+
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
625
|
+
s.accepts[ "*" ]
|
626
|
+
);
|
627
|
+
|
628
|
+
// Check for headers option
|
629
|
+
for ( i in s.headers ) {
|
630
|
+
jqXHR.setRequestHeader( i, s.headers[ i ] );
|
631
|
+
}
|
632
|
+
|
633
|
+
// Allow custom headers/mimetypes and early abort
|
634
|
+
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
635
|
+
// Abort if not done already and return
|
636
|
+
return jqXHR.abort();
|
637
|
+
}
|
638
|
+
|
639
|
+
// aborting is no longer a cancellation
|
640
|
+
strAbort = "abort";
|
641
|
+
|
642
|
+
// Install callbacks on deferreds
|
643
|
+
for ( i in { success: 1, error: 1, complete: 1 } ) {
|
644
|
+
jqXHR[ i ]( s[ i ] );
|
645
|
+
}
|
646
|
+
|
647
|
+
// Get transport
|
648
|
+
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
649
|
+
|
650
|
+
// If no transport, we auto-abort
|
651
|
+
if ( !transport ) {
|
652
|
+
done( -1, "No Transport" );
|
653
|
+
} else {
|
654
|
+
jqXHR.readyState = 1;
|
655
|
+
|
656
|
+
// Send global event
|
657
|
+
if ( fireGlobals ) {
|
658
|
+
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
659
|
+
}
|
660
|
+
// Timeout
|
661
|
+
if ( s.async && s.timeout > 0 ) {
|
662
|
+
timeoutTimer = setTimeout(function() {
|
663
|
+
jqXHR.abort("timeout");
|
664
|
+
}, s.timeout );
|
665
|
+
}
|
666
|
+
|
667
|
+
try {
|
668
|
+
state = 1;
|
669
|
+
transport.send( requestHeaders, done );
|
670
|
+
} catch ( e ) {
|
671
|
+
// Propagate exception as error if not done
|
672
|
+
if ( state < 2 ) {
|
673
|
+
done( -1, e );
|
674
|
+
// Simply rethrow otherwise
|
675
|
+
} else {
|
676
|
+
throw e;
|
677
|
+
}
|
678
|
+
}
|
679
|
+
}
|
680
|
+
|
681
|
+
// Callback for when everything is done
|
682
|
+
function done( status, nativeStatusText, responses, headers ) {
|
683
|
+
var isSuccess, success, error, response, modified,
|
684
|
+
statusText = nativeStatusText;
|
685
|
+
|
686
|
+
// Called once
|
687
|
+
if ( state === 2 ) {
|
688
|
+
return;
|
689
|
+
}
|
690
|
+
|
691
|
+
// State is "done" now
|
692
|
+
state = 2;
|
693
|
+
|
694
|
+
// Clear timeout if it exists
|
695
|
+
if ( timeoutTimer ) {
|
696
|
+
clearTimeout( timeoutTimer );
|
697
|
+
}
|
698
|
+
|
699
|
+
// Dereference transport for early garbage collection
|
700
|
+
// (no matter how long the jqXHR object will be used)
|
701
|
+
transport = undefined;
|
702
|
+
|
703
|
+
// Cache response headers
|
704
|
+
responseHeadersString = headers || "";
|
705
|
+
|
706
|
+
// Set readyState
|
707
|
+
jqXHR.readyState = status > 0 ? 4 : 0;
|
708
|
+
|
709
|
+
// Determine if successful
|
710
|
+
isSuccess = status >= 200 && status < 300 || status === 304;
|
711
|
+
|
712
|
+
// Get response data
|
713
|
+
if ( responses ) {
|
714
|
+
response = ajaxHandleResponses( s, jqXHR, responses );
|
715
|
+
}
|
716
|
+
|
717
|
+
// Convert no matter what (that way responseXXX fields are always set)
|
718
|
+
response = ajaxConvert( s, response, jqXHR, isSuccess );
|
719
|
+
|
720
|
+
// If successful, handle type chaining
|
721
|
+
if ( isSuccess ) {
|
722
|
+
|
723
|
+
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
724
|
+
if ( s.ifModified ) {
|
725
|
+
modified = jqXHR.getResponseHeader("Last-Modified");
|
726
|
+
if ( modified ) {
|
727
|
+
jQuery.lastModified[ cacheURL ] = modified;
|
728
|
+
}
|
729
|
+
modified = jqXHR.getResponseHeader("etag");
|
730
|
+
if ( modified ) {
|
731
|
+
jQuery.etag[ cacheURL ] = modified;
|
732
|
+
}
|
733
|
+
}
|
734
|
+
|
735
|
+
// if no content
|
736
|
+
if ( status === 204 || s.type === "HEAD" ) {
|
737
|
+
statusText = "nocontent";
|
738
|
+
|
739
|
+
// if not modified
|
740
|
+
} else if ( status === 304 ) {
|
741
|
+
statusText = "notmodified";
|
742
|
+
|
743
|
+
// If we have data, let's convert it
|
744
|
+
} else {
|
745
|
+
statusText = response.state;
|
746
|
+
success = response.data;
|
747
|
+
error = response.error;
|
748
|
+
isSuccess = !error;
|
749
|
+
}
|
750
|
+
} else {
|
751
|
+
// We extract error from statusText
|
752
|
+
// then normalize statusText and status for non-aborts
|
753
|
+
error = statusText;
|
754
|
+
if ( status || !statusText ) {
|
755
|
+
statusText = "error";
|
756
|
+
if ( status < 0 ) {
|
757
|
+
status = 0;
|
758
|
+
}
|
759
|
+
}
|
760
|
+
}
|
761
|
+
|
762
|
+
// Set data for the fake xhr object
|
763
|
+
jqXHR.status = status;
|
764
|
+
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
|
765
|
+
|
766
|
+
// Success/Error
|
767
|
+
if ( isSuccess ) {
|
768
|
+
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
769
|
+
} else {
|
770
|
+
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
771
|
+
}
|
772
|
+
|
773
|
+
// Status-dependent callbacks
|
774
|
+
jqXHR.statusCode( statusCode );
|
775
|
+
statusCode = undefined;
|
776
|
+
|
777
|
+
if ( fireGlobals ) {
|
778
|
+
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
|
779
|
+
[ jqXHR, s, isSuccess ? success : error ] );
|
780
|
+
}
|
781
|
+
|
782
|
+
// Complete
|
783
|
+
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
784
|
+
|
785
|
+
if ( fireGlobals ) {
|
786
|
+
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
787
|
+
// Handle the global AJAX counter
|
788
|
+
if ( !( --jQuery.active ) ) {
|
789
|
+
jQuery.event.trigger("ajaxStop");
|
790
|
+
}
|
791
|
+
}
|
792
|
+
}
|
793
|
+
|
794
|
+
return jqXHR;
|
795
|
+
},
|
796
|
+
|
797
|
+
getJSON: function( url, data, callback ) {
|
798
|
+
return jQuery.get( url, data, callback, "json" );
|
799
|
+
},
|
800
|
+
|
801
|
+
getScript: function( url, callback ) {
|
802
|
+
return jQuery.get( url, undefined, callback, "script" );
|
803
|
+
}
|
804
|
+
});
|
805
|
+
|
806
|
+
jQuery.each( [ "get", "post" ], function( i, method ) {
|
807
|
+
jQuery[ method ] = function( url, data, callback, type ) {
|
808
|
+
// shift arguments if data argument was omitted
|
809
|
+
if ( jQuery.isFunction( data ) ) {
|
810
|
+
type = type || callback;
|
811
|
+
callback = data;
|
812
|
+
data = undefined;
|
813
|
+
}
|
814
|
+
|
815
|
+
return jQuery.ajax({
|
816
|
+
url: url,
|
817
|
+
type: method,
|
818
|
+
dataType: type,
|
819
|
+
data: data,
|
820
|
+
success: callback
|
821
|
+
});
|
822
|
+
};
|
823
|
+
});
|
824
|
+
|
825
|
+
// Attach a bunch of functions for handling common AJAX events
|
826
|
+
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
|
827
|
+
jQuery.fn[ type ] = function( fn ) {
|
828
|
+
return this.on( type, fn );
|
829
|
+
};
|
830
|
+
});
|
831
|
+
})();
|
832
|
+
|
833
|
+
|
834
|
+
(function(){
|
835
|
+
var oldCallbacks = [],
|
836
|
+
rjsonp = /(=)\?(?=&|$)|\?\?/;
|
837
|
+
|
838
|
+
// Default jsonp settings
|
839
|
+
jQuery.ajaxSetup({
|
840
|
+
jsonp: "callback",
|
841
|
+
jsonpCallback: function() {
|
842
|
+
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
|
843
|
+
this[ callback ] = true;
|
844
|
+
return callback;
|
845
|
+
}
|
846
|
+
});
|
847
|
+
|
848
|
+
// Detect, normalize options and install callbacks for jsonp requests
|
849
|
+
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
850
|
+
|
851
|
+
var callbackName, overwritten, responseContainer,
|
852
|
+
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
853
|
+
"url" :
|
854
|
+
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
|
855
|
+
);
|
856
|
+
|
857
|
+
// Handle iff the expected data type is "jsonp" or we have a parameter to set
|
858
|
+
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
|
859
|
+
|
860
|
+
// Get callback name, remembering preexisting value associated with it
|
861
|
+
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
|
862
|
+
s.jsonpCallback() :
|
863
|
+
s.jsonpCallback;
|
864
|
+
|
865
|
+
// Insert callback into url or form data
|
866
|
+
if ( jsonProp ) {
|
867
|
+
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
|
868
|
+
} else if ( s.jsonp !== false ) {
|
869
|
+
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
870
|
+
}
|
871
|
+
|
872
|
+
// Use data converter to retrieve json after script execution
|
873
|
+
s.converters["script json"] = function() {
|
874
|
+
if ( !responseContainer ) {
|
875
|
+
jQuery.error( callbackName + " was not called" );
|
876
|
+
}
|
877
|
+
return responseContainer[ 0 ];
|
878
|
+
};
|
879
|
+
|
880
|
+
// force json dataType
|
881
|
+
s.dataTypes[ 0 ] = "json";
|
882
|
+
|
883
|
+
// Install callback
|
884
|
+
overwritten = window[ callbackName ];
|
885
|
+
window[ callbackName ] = function() {
|
886
|
+
responseContainer = arguments;
|
887
|
+
};
|
888
|
+
|
889
|
+
// Clean-up function (fires after converters)
|
890
|
+
jqXHR.always(function() {
|
891
|
+
// Restore preexisting value
|
892
|
+
window[ callbackName ] = overwritten;
|
893
|
+
|
894
|
+
// Save back as free
|
895
|
+
if ( s[ callbackName ] ) {
|
896
|
+
// make sure that re-using the options doesn't screw things around
|
897
|
+
s.jsonpCallback = originalSettings.jsonpCallback;
|
898
|
+
|
899
|
+
// save the callback name for future use
|
900
|
+
oldCallbacks.push( callbackName );
|
901
|
+
}
|
902
|
+
|
903
|
+
// Call if it was a function and we have a response
|
904
|
+
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
|
905
|
+
overwritten( responseContainer[ 0 ] );
|
906
|
+
}
|
907
|
+
|
908
|
+
responseContainer = overwritten = undefined;
|
909
|
+
});
|
910
|
+
|
911
|
+
// Delegate to script
|
912
|
+
return "script";
|
913
|
+
}
|
914
|
+
});
|
915
|
+
})();
|
916
|
+
|
917
|
+
(function(){
|
918
|
+
// Keep a copy of the old load method
|
919
|
+
var _load = jQuery.fn.load;
|
920
|
+
|
921
|
+
/**
|
922
|
+
* Load a url into a page
|
923
|
+
*/
|
924
|
+
jQuery.fn.load = function( url, params, callback ) {
|
925
|
+
if ( typeof url !== "string" && _load ) {
|
926
|
+
return _load.apply( this, arguments );
|
927
|
+
}
|
928
|
+
|
929
|
+
var selector, response, type,
|
930
|
+
self = this,
|
931
|
+
off = url.indexOf(" ");
|
932
|
+
|
933
|
+
if ( off >= 0 ) {
|
934
|
+
selector = url.slice( off, url.length );
|
935
|
+
url = url.slice( 0, off );
|
936
|
+
}
|
937
|
+
|
938
|
+
// If it's a function
|
939
|
+
if ( jQuery.isFunction( params ) ) {
|
940
|
+
|
941
|
+
// We assume that it's the callback
|
942
|
+
callback = params;
|
943
|
+
params = undefined;
|
944
|
+
|
945
|
+
// Otherwise, build a param string
|
946
|
+
} else if ( params && typeof params === "object" ) {
|
947
|
+
type = "POST";
|
948
|
+
}
|
949
|
+
|
950
|
+
// If we have elements to modify, make the request
|
951
|
+
if ( self.length > 0 ) {
|
952
|
+
jQuery.ajax({
|
953
|
+
url: url,
|
954
|
+
|
955
|
+
// if "type" variable is undefined, then "GET" method will be used
|
956
|
+
type: type,
|
957
|
+
dataType: "html",
|
958
|
+
data: params
|
959
|
+
}).done(function( responseText ) {
|
960
|
+
|
961
|
+
// Save response for use in complete callback
|
962
|
+
response = arguments;
|
963
|
+
|
964
|
+
self.html( selector ?
|
965
|
+
|
966
|
+
// If a selector was specified, locate the right elements in a dummy div
|
967
|
+
// Exclude scripts to avoid IE 'Permission Denied' errors
|
968
|
+
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
969
|
+
|
970
|
+
// Otherwise use the full result
|
971
|
+
responseText );
|
972
|
+
|
973
|
+
}).complete( callback && function( jqXHR, status ) {
|
974
|
+
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
|
975
|
+
});
|
976
|
+
}
|
977
|
+
|
978
|
+
return this;
|
979
|
+
};
|
980
|
+
|
981
|
+
})();
|
982
|
+
(function(){
|
983
|
+
// Install script dataType
|
984
|
+
jQuery.ajaxSetup({
|
985
|
+
accepts: {
|
986
|
+
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
987
|
+
},
|
988
|
+
contents: {
|
989
|
+
script: /(?:java|ecma)script/
|
990
|
+
},
|
991
|
+
converters: {
|
992
|
+
"text script": function( text ) {
|
993
|
+
jQuery.globalEval( text );
|
994
|
+
return text;
|
995
|
+
}
|
996
|
+
}
|
997
|
+
});
|
998
|
+
|
999
|
+
// Handle cache's special case and global
|
1000
|
+
jQuery.ajaxPrefilter( "script", function( s ) {
|
1001
|
+
if ( s.cache === undefined ) {
|
1002
|
+
s.cache = false;
|
1003
|
+
}
|
1004
|
+
if ( s.crossDomain ) {
|
1005
|
+
s.type = "GET";
|
1006
|
+
s.global = false;
|
1007
|
+
}
|
1008
|
+
});
|
1009
|
+
|
1010
|
+
// Bind script tag hack transport
|
1011
|
+
jQuery.ajaxTransport( "script", function(s) {
|
1012
|
+
|
1013
|
+
// This transport only deals with cross domain requests
|
1014
|
+
if ( s.crossDomain ) {
|
1015
|
+
|
1016
|
+
var script,
|
1017
|
+
head = document.head || jQuery("head")[0] || document.documentElement;
|
1018
|
+
|
1019
|
+
return {
|
1020
|
+
|
1021
|
+
send: function( _, callback ) {
|
1022
|
+
|
1023
|
+
script = document.createElement("script");
|
1024
|
+
|
1025
|
+
script.async = true;
|
1026
|
+
|
1027
|
+
if ( s.scriptCharset ) {
|
1028
|
+
script.charset = s.scriptCharset;
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
script.src = s.url;
|
1032
|
+
|
1033
|
+
// Attach handlers for all browsers
|
1034
|
+
script.onload = script.onreadystatechange = function( _, isAbort ) {
|
1035
|
+
|
1036
|
+
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
1037
|
+
|
1038
|
+
// Handle memory leak in IE
|
1039
|
+
script.onload = script.onreadystatechange = null;
|
1040
|
+
|
1041
|
+
// Remove the script
|
1042
|
+
if ( script.parentNode ) {
|
1043
|
+
script.parentNode.removeChild( script );
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
// Dereference the script
|
1047
|
+
script = null;
|
1048
|
+
|
1049
|
+
// Callback if not abort
|
1050
|
+
if ( !isAbort ) {
|
1051
|
+
callback( 200, "success" );
|
1052
|
+
}
|
1053
|
+
}
|
1054
|
+
};
|
1055
|
+
|
1056
|
+
// Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
|
1057
|
+
// Use native DOM manipulation to avoid our domManip AJAX trickery
|
1058
|
+
head.insertBefore( script, head.firstChild );
|
1059
|
+
},
|
1060
|
+
|
1061
|
+
abort: function() {
|
1062
|
+
if ( script ) {
|
1063
|
+
script.onload( undefined, true );
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
};
|
1067
|
+
}
|
1068
|
+
});
|
1069
|
+
})();
|
1070
|
+
(function(){
|
1071
|
+
var support = jQuery.support;
|
1072
|
+
// Create the request object
|
1073
|
+
// (This is still attached to ajaxSettings for backward compatibility)
|
1074
|
+
jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
|
1075
|
+
// Support: IE6+
|
1076
|
+
function() {
|
1077
|
+
|
1078
|
+
// XHR cannot access local files, always use ActiveX for that case
|
1079
|
+
return !this.isLocal &&
|
1080
|
+
|
1081
|
+
// Support: IE7-8
|
1082
|
+
// oldIE XHR does not support non-RFC2616 methods (#13240)
|
1083
|
+
// See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
|
1084
|
+
// and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
|
1085
|
+
// Although this check for six methods instead of eight
|
1086
|
+
// since IE also does not support "trace" and "connect"
|
1087
|
+
/^(get|post|head|put|delete|options)$/i.test( this.type ) &&
|
1088
|
+
|
1089
|
+
createStandardXHR() || createActiveXHR();
|
1090
|
+
} :
|
1091
|
+
// For all other browsers, use the standard XMLHttpRequest object
|
1092
|
+
createStandardXHR;
|
1093
|
+
|
1094
|
+
var xhrId = 0,
|
1095
|
+
xhrCallbacks = {},
|
1096
|
+
xhrSupported = jQuery.ajaxSettings.xhr();
|
1097
|
+
|
1098
|
+
// Support: IE<10
|
1099
|
+
// Open requests must be manually aborted on unload (#5280)
|
1100
|
+
if ( window.ActiveXObject ) {
|
1101
|
+
jQuery( window ).on( "unload", function() {
|
1102
|
+
for ( var key in xhrCallbacks ) {
|
1103
|
+
xhrCallbacks[ key ]( undefined, true );
|
1104
|
+
}
|
1105
|
+
});
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
// Determine support properties
|
1109
|
+
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
|
1110
|
+
xhrSupported = support.ajax = !!xhrSupported;
|
1111
|
+
|
1112
|
+
// Create transport if the browser can provide an xhr
|
1113
|
+
if ( xhrSupported ) {
|
1114
|
+
|
1115
|
+
jQuery.ajaxTransport(function( options ) {
|
1116
|
+
// Cross domain only allowed if supported through XMLHttpRequest
|
1117
|
+
if ( !options.crossDomain || support.cors ) {
|
1118
|
+
|
1119
|
+
var callback;
|
1120
|
+
|
1121
|
+
return {
|
1122
|
+
send: function( headers, complete ) {
|
1123
|
+
var i,
|
1124
|
+
xhr = options.xhr(),
|
1125
|
+
id = ++xhrId;
|
1126
|
+
|
1127
|
+
// Open the socket
|
1128
|
+
xhr.open( options.type, options.url, options.async, options.username, options.password );
|
1129
|
+
|
1130
|
+
// Apply custom fields if provided
|
1131
|
+
if ( options.xhrFields ) {
|
1132
|
+
for ( i in options.xhrFields ) {
|
1133
|
+
xhr[ i ] = options.xhrFields[ i ];
|
1134
|
+
}
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
// Override mime type if needed
|
1138
|
+
if ( options.mimeType && xhr.overrideMimeType ) {
|
1139
|
+
xhr.overrideMimeType( options.mimeType );
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
// X-Requested-With header
|
1143
|
+
// For cross-domain requests, seeing as conditions for a preflight are
|
1144
|
+
// akin to a jigsaw puzzle, we simply never set it to be sure.
|
1145
|
+
// (it can always be set on a per-request basis or even using ajaxSetup)
|
1146
|
+
// For same-domain requests, won't change header if already provided.
|
1147
|
+
if ( !options.crossDomain && !headers["X-Requested-With"] ) {
|
1148
|
+
headers["X-Requested-With"] = "XMLHttpRequest";
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
// Set headers
|
1152
|
+
for ( i in headers ) {
|
1153
|
+
// Support: IE<9
|
1154
|
+
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
|
1155
|
+
// request header to a null-value.
|
1156
|
+
//
|
1157
|
+
// To keep consistent with other XHR implementations, cast the value
|
1158
|
+
// to string and ignore `undefined`.
|
1159
|
+
if ( headers[ i ] !== undefined ) {
|
1160
|
+
xhr.setRequestHeader( i, headers[ i ] + "" );
|
1161
|
+
}
|
1162
|
+
}
|
1163
|
+
|
1164
|
+
// Do send the request
|
1165
|
+
// This may raise an exception which is actually
|
1166
|
+
// handled in jQuery.ajax (so no try/catch here)
|
1167
|
+
xhr.send( ( options.hasContent && options.data ) || null );
|
1168
|
+
|
1169
|
+
// Listener
|
1170
|
+
callback = function( _, isAbort ) {
|
1171
|
+
var status, statusText, responses;
|
1172
|
+
|
1173
|
+
// Was never called and is aborted or complete
|
1174
|
+
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
1175
|
+
// Clean up
|
1176
|
+
delete xhrCallbacks[ id ];
|
1177
|
+
callback = undefined;
|
1178
|
+
xhr.onreadystatechange = jQuery.noop;
|
1179
|
+
|
1180
|
+
// Abort manually if needed
|
1181
|
+
if ( isAbort ) {
|
1182
|
+
if ( xhr.readyState !== 4 ) {
|
1183
|
+
xhr.abort();
|
1184
|
+
}
|
1185
|
+
} else {
|
1186
|
+
responses = {};
|
1187
|
+
status = xhr.status;
|
1188
|
+
|
1189
|
+
// Support: IE<10
|
1190
|
+
// Accessing binary-data responseText throws an exception
|
1191
|
+
// (#11426)
|
1192
|
+
if ( typeof xhr.responseText === "string" ) {
|
1193
|
+
responses.text = xhr.responseText;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
// Firefox throws an exception when accessing
|
1197
|
+
// statusText for faulty cross-domain requests
|
1198
|
+
try {
|
1199
|
+
statusText = xhr.statusText;
|
1200
|
+
} catch( e ) {
|
1201
|
+
// We normalize with Webkit giving an empty statusText
|
1202
|
+
statusText = "";
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
// Filter status for non standard behaviors
|
1206
|
+
|
1207
|
+
// If the request is local and we have data: assume a success
|
1208
|
+
// (success with no data won't get notified, that's the best we
|
1209
|
+
// can do given current implementations)
|
1210
|
+
if ( !status && options.isLocal && !options.crossDomain ) {
|
1211
|
+
status = responses.text ? 200 : 404;
|
1212
|
+
// IE - #1450: sometimes returns 1223 when it should be 204
|
1213
|
+
} else if ( status === 1223 ) {
|
1214
|
+
status = 204;
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
// Call complete if needed
|
1220
|
+
if ( responses ) {
|
1221
|
+
complete( status, statusText, responses, xhr.getAllResponseHeaders() );
|
1222
|
+
}
|
1223
|
+
};
|
1224
|
+
|
1225
|
+
if ( !options.async ) {
|
1226
|
+
// if we're in sync mode we fire the callback
|
1227
|
+
callback();
|
1228
|
+
} else if ( xhr.readyState === 4 ) {
|
1229
|
+
// (IE6 & IE7) if it's in cache and has been
|
1230
|
+
// retrieved directly we need to fire the callback
|
1231
|
+
setTimeout( callback );
|
1232
|
+
} else {
|
1233
|
+
// Add to the list of active xhr callbacks
|
1234
|
+
xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
|
1235
|
+
}
|
1236
|
+
},
|
1237
|
+
|
1238
|
+
abort: function() {
|
1239
|
+
if ( callback ) {
|
1240
|
+
callback( undefined, true );
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
};
|
1244
|
+
}
|
1245
|
+
});
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
// Functions to create xhrs
|
1249
|
+
function createStandardXHR() {
|
1250
|
+
try {
|
1251
|
+
return new window.XMLHttpRequest();
|
1252
|
+
} catch( e ) {}
|
1253
|
+
}
|
1254
|
+
|
1255
|
+
function createActiveXHR() {
|
1256
|
+
try {
|
1257
|
+
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
|
1258
|
+
} catch( e ) {}
|
1259
|
+
}
|
1260
|
+
})();
|
1261
|
+
webshims.isReady('jajax', true);
|
1262
|
+
})();
|