2010-12-09 18:34:28 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2011-01-12 17:54:15 +00:00
|
|
|
// Install script dataType
|
|
|
|
jQuery.ajaxSetup({
|
2010-12-09 18:34:28 +00:00
|
|
|
|
|
|
|
accepts: {
|
|
|
|
script: "text/javascript, application/javascript"
|
|
|
|
},
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-28 01:30:51 +00:00
|
|
|
contents: {
|
2010-12-09 18:34:28 +00:00
|
|
|
script: /javascript/
|
|
|
|
},
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-28 01:30:51 +00:00
|
|
|
converters: {
|
2010-12-24 17:02:45 +00:00
|
|
|
"text script": jQuery.globalEval
|
2010-12-09 18:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bind script tag hack transport
|
2011-01-13 17:33:24 +00:00
|
|
|
}).ajaxTransport("script", function(s) {
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
// Handle cache special case
|
|
|
|
if ( s.cache === undefined ) {
|
|
|
|
s.cache = false;
|
|
|
|
}
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
// This transport only deals with cross domain get requests
|
|
|
|
if ( s.crossDomain && s.async && ( s.type === "GET" || ! s.data ) ) {
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
s.global = false;
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
var script,
|
|
|
|
head = document.getElementsByTagName("head")[0] || document.documentElement;
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
return {
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
send: function(_, callback) {
|
|
|
|
|
|
|
|
script = document.createElement("script");
|
|
|
|
|
|
|
|
script.async = "async";
|
|
|
|
|
|
|
|
if ( s.scriptCharset ) {
|
|
|
|
script.charset = s.scriptCharset;
|
|
|
|
}
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
script.src = s.url;
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
// Attach handlers for all browsers
|
2011-01-13 01:05:39 +00:00
|
|
|
script.onload = script.onreadystatechange = function( _ , isAbort ) {
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-30 03:41:52 +00:00
|
|
|
if ( ! script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
// Handle memory leak in IE
|
|
|
|
script.onload = script.onreadystatechange = null;
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-09 18:34:28 +00:00
|
|
|
// Remove the script
|
|
|
|
if ( head && script.parentNode ) {
|
|
|
|
head.removeChild( script );
|
|
|
|
}
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2011-01-13 01:05:39 +00:00
|
|
|
// Dereference the script
|
2010-12-30 03:41:52 +00:00
|
|
|
script = 0;
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2011-01-13 01:05:39 +00:00
|
|
|
// Callback if not abort
|
|
|
|
if ( ! isAbort ) {
|
|
|
|
callback( 200, "success" );
|
|
|
|
}
|
2010-12-09 18:34:28 +00: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 21:41:23 +00:00
|
|
|
|
2011-01-13 01:05:39 +00:00
|
|
|
abort: function() {
|
2010-12-09 18:34:28 +00:00
|
|
|
if ( script ) {
|
2011-01-13 01:05:39 +00:00
|
|
|
script.onload(0,1);
|
2010-12-09 18:34:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-12-10 02:14:03 +00:00
|
|
|
})( jQuery );
|