|
define( [ |
|
"../core", |
|
"../var/document", |
|
"../ajax" |
|
], function( jQuery, document ) { |
|
|
|
|
|
jQuery.ajaxSetup( { |
|
accepts: { |
|
script: "text/javascript, application/javascript, " + |
|
"application/ecmascript, application/x-ecmascript" |
|
}, |
|
contents: { |
|
script: /\b(?:java|ecma)script\b/ |
|
}, |
|
converters: { |
|
"text script": function( text ) { |
|
jQuery.globalEval( text ); |
|
return text; |
|
} |
|
} |
|
} ); |
|
|
|
|
|
jQuery.ajaxPrefilter( "script", function( s ) { |
|
if ( s.cache === undefined ) { |
|
s.cache = false; |
|
} |
|
if ( s.crossDomain ) { |
|
s.type = "GET"; |
|
} |
|
} ); |
|
|
|
|
|
jQuery.ajaxTransport( "script", function( s ) { |
|
|
|
|
|
if ( s.crossDomain ) { |
|
var script, callback; |
|
return { |
|
send: function( _, complete ) { |
|
script = jQuery( "<script>" ).prop( { |
|
charset: s.scriptCharset, |
|
src: s.url |
|
} ).on( |
|
"load error", |
|
callback = function( evt ) { |
|
script.remove(); |
|
callback = null; |
|
if ( evt ) { |
|
complete( evt.type === "error" ? 404 : 200, evt.type ); |
|
} |
|
} |
|
); |
|
|
|
|
|
document.head.appendChild( script[ 0 ] ); |
|
}, |
|
abort: function() { |
|
if ( callback ) { |
|
callback(); |
|
} |
|
} |
|
}; |
|
} |
|
} ); |
|
|
|
} ); |
|
|