2010-12-09 19:34:28 +01:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2011-01-12 18:54:15 +01:00
|
|
|
// Install script dataType
|
|
|
|
jQuery.ajaxSetup({
|
2010-12-09 19:34:28 +01:00
|
|
|
accepts: {
|
2011-01-31 19:14:06 +01:00
|
|
|
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
2010-12-09 19:34:28 +01:00
|
|
|
},
|
2010-12-28 02:30:51 +01:00
|
|
|
contents: {
|
2011-01-31 19:14:06 +01:00
|
|
|
script: /javascript|ecmascript/
|
2010-12-09 19:34:28 +01:00
|
|
|
},
|
2010-12-28 02:30:51 +01:00
|
|
|
converters: {
|
2011-01-29 01:39:22 +01:00
|
|
|
"text script": function( text ) {
|
|
|
|
jQuery.globalEval( text );
|
|
|
|
return text;
|
|
|
|
}
|
2010-12-09 19:34:28 +01:00
|
|
|
}
|
2011-01-20 04:12:15 +01:00
|
|
|
});
|
2010-12-09 19:34:28 +01:00
|
|
|
|
2011-01-16 02:57:39 +01:00
|
|
|
// Handle cache's special case and global
|
2011-01-23 20:46:09 +01:00
|
|
|
jQuery.ajaxPrefilter( "script", function( s ) {
|
2010-12-09 19:34:28 +01:00
|
|
|
if ( s.cache === undefined ) {
|
|
|
|
s.cache = false;
|
|
|
|
}
|
2011-01-16 02:57:39 +01:00
|
|
|
if ( s.crossDomain ) {
|
2011-01-16 05:25:45 +01:00
|
|
|
s.type = "GET";
|
2010-12-09 19:34:28 +01:00
|
|
|
s.global = false;
|
2011-01-16 02:57:39 +01:00
|
|
|
}
|
2011-04-08 17:41:14 +02:00
|
|
|
});
|
2011-01-16 02:57:39 +01:00
|
|
|
|
|
|
|
// Bind script tag hack transport
|
2011-01-23 05:51:41 +01:00
|
|
|
jQuery.ajaxTransport( "script", function(s) {
|
2011-01-16 02:57:39 +01:00
|
|
|
|
|
|
|
// This transport only deals with cross domain requests
|
|
|
|
if ( s.crossDomain ) {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-09 19:34:28 +01:00
|
|
|
var script,
|
2011-01-24 11:18:57 +01:00
|
|
|
head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-09 19:34:28 +01:00
|
|
|
return {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2011-01-23 05:51:41 +01:00
|
|
|
send: function( _, callback ) {
|
2010-12-09 19:34:28 +01:00
|
|
|
|
2011-01-23 05:51:41 +01:00
|
|
|
script = document.createElement( "script" );
|
2010-12-09 19:34:28 +01:00
|
|
|
|
|
|
|
script.async = "async";
|
|
|
|
|
|
|
|
if ( s.scriptCharset ) {
|
|
|
|
script.charset = s.scriptCharset;
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-09 19:34:28 +01:00
|
|
|
script.src = s.url;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-09 19:34:28 +01:00
|
|
|
// Attach handlers for all browsers
|
2011-01-23 05:51:41 +01:00
|
|
|
script.onload = script.onreadystatechange = function( _, isAbort ) {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2011-04-04 17:41:30 +02:00
|
|
|
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-09 19:34:28 +01:00
|
|
|
// Handle memory leak in IE
|
|
|
|
script.onload = script.onreadystatechange = null;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-09 19:34:28 +01:00
|
|
|
// Remove the script
|
|
|
|
if ( head && script.parentNode ) {
|
|
|
|
head.removeChild( script );
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2011-01-13 02:05:39 +01:00
|
|
|
// Dereference the script
|
2011-01-23 05:51:41 +01:00
|
|
|
script = undefined;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2011-01-13 02:05:39 +01:00
|
|
|
// Callback if not abort
|
2011-01-23 05:51:41 +01:00
|
|
|
if ( !isAbort ) {
|
2011-01-13 02:05:39 +01:00
|
|
|
callback( 200, "success" );
|
|
|
|
}
|
2010-12-09 19:34:28 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
|
|
|
// This arises when a base node is used (#2709 and #4378).
|
|
|
|
head.insertBefore( script, head.firstChild );
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2011-01-13 02:05:39 +01:00
|
|
|
abort: function() {
|
2010-12-09 19:34:28 +01:00
|
|
|
if ( script ) {
|
2011-01-23 05:51:41 +01:00
|
|
|
script.onload( 0, 1 );
|
2010-12-09 19:34:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2011-04-08 17:41:14 +02:00
|
|
|
});
|
2010-12-09 19:34:28 +01:00
|
|
|
|
2010-12-10 03:14:03 +01:00
|
|
|
})( jQuery );
|