commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / bower_components / jquery-validation / src / ajax.js
1 // ajax mode: abort
2 // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
3 // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
4
5 var pendingRequests = {},
6 ajax;
7 // Use a prefilter if available (1.5+)
8 if ( $.ajaxPrefilter ) {
9 $.ajaxPrefilter(function( settings, _, xhr ) {
10 var port = settings.port;
11 if ( settings.mode === "abort" ) {
12 if ( pendingRequests[port] ) {
13 pendingRequests[port].abort();
14 }
15 pendingRequests[port] = xhr;
16 }
17 });
18 } else {
19 // Proxy ajax
20 ajax = $.ajax;
21 $.ajax = function( settings ) {
22 var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
23 port = ( "port" in settings ? settings : $.ajaxSettings ).port;
24 if ( mode === "abort" ) {
25 if ( pendingRequests[port] ) {
26 pendingRequests[port].abort();
27 }
28 pendingRequests[port] = ajax.apply(this, arguments);
29 return pendingRequests[port];
30 }
31 return ajax.apply(this, arguments);
32 };
33 }