/bower_components/jquery/src/ajax/jsonp.js |
@@ -1,4 +1,4 @@ |
define( [ |
define([ |
"../core", |
"./var/nonce", |
"./var/rquery", |
@@ -5,13 +5,11 @@ |
"../ajax" |
], function( jQuery, nonce, rquery ) { |
|
"use strict"; |
|
var oldCallbacks = [], |
rjsonp = /(=)\?(?=&|$)|\?\?/; |
|
// Default jsonp settings |
jQuery.ajaxSetup( { |
jQuery.ajaxSetup({ |
jsonp: "callback", |
jsonpCallback: function() { |
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); |
@@ -18,7 +16,7 @@ |
this[ callback ] = true; |
return callback; |
} |
} ); |
}); |
|
// Detect, normalize options and install callbacks for jsonp requests |
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
@@ -26,10 +24,7 @@ |
var callbackName, overwritten, responseContainer, |
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
"url" : |
typeof s.data === "string" && |
( s.contentType || "" ) |
.indexOf( "application/x-www-form-urlencoded" ) === 0 && |
rjsonp.test( s.data ) && "data" |
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" |
); |
|
// Handle iff the expected data type is "jsonp" or we have a parameter to set |
@@ -48,7 +43,7 @@ |
} |
|
// Use data converter to retrieve json after script execution |
s.converters[ "script json" ] = function() { |
s.converters["script json"] = function() { |
if ( !responseContainer ) { |
jQuery.error( callbackName + " was not called" ); |
} |
@@ -55,7 +50,7 @@ |
return responseContainer[ 0 ]; |
}; |
|
// Force json dataType |
// force json dataType |
s.dataTypes[ 0 ] = "json"; |
|
// Install callback |
@@ -65,24 +60,16 @@ |
}; |
|
// Clean-up function (fires after converters) |
jqXHR.always( function() { |
jqXHR.always(function() { |
// Restore preexisting value |
window[ callbackName ] = overwritten; |
|
// If previous value didn't exist - remove it |
if ( overwritten === undefined ) { |
jQuery( window ).removeProp( callbackName ); |
|
// Otherwise restore preexisting value |
} else { |
window[ callbackName ] = overwritten; |
} |
|
// Save back as free |
if ( s[ callbackName ] ) { |
|
// Make sure that re-using the options doesn't screw things around |
// make sure that re-using the options doesn't screw things around |
s.jsonpCallback = originalSettings.jsonpCallback; |
|
// Save the callback name for future use |
// save the callback name for future use |
oldCallbacks.push( callbackName ); |
} |
|
@@ -92,11 +79,11 @@ |
} |
|
responseContainer = overwritten = undefined; |
} ); |
}); |
|
// Delegate to script |
return "script"; |
} |
} ); |
}); |
|
} ); |
}); |