| 1 | define( [
|
| 2 | "../core",
|
| 3 | "../var/document",
|
| 4 | "../ajax"
|
| 5 | ], function( jQuery, document ) {
|
| 6 |
|
| 7 | "use strict";
|
| 8 |
|
| 9 |
|
| 10 | jQuery.ajaxPrefilter( function( s ) {
|
| 11 | if ( s.crossDomain ) {
|
| 12 | s.contents.script = false;
|
| 13 | }
|
| 14 | } );
|
| 15 |
|
| 16 |
|
| 17 | jQuery.ajaxSetup( {
|
| 18 | accepts: {
|
| 19 | script: "text/javascript, application/javascript, " +
|
| 20 | "application/ecmascript, application/x-ecmascript"
|
| 21 | },
|
| 22 | contents: {
|
| 23 | script: /\b(?:java|ecma)script\b/
|
| 24 | },
|
| 25 | converters: {
|
| 26 | "text script": function( text ) {
|
| 27 | jQuery.globalEval( text );
|
| 28 | return text;
|
| 29 | }
|
| 30 | }
|
| 31 | } );
|
| 32 |
|
| 33 |
|
| 34 | jQuery.ajaxPrefilter( "script", function( s ) {
|
| 35 | if ( s.cache === undefined ) {
|
| 36 | s.cache = false;
|
| 37 | }
|
| 38 | if ( s.crossDomain ) {
|
| 39 | s.type = "GET";
|
| 40 | }
|
| 41 | } );
|
| 42 |
|
| 43 |
|
| 44 | jQuery.ajaxTransport( "script", function( s ) {
|
| 45 |
|
| 46 |
|
| 47 | if ( s.crossDomain || s.scriptAttrs ) {
|
| 48 | var script, callback;
|
| 49 | return {
|
| 50 | send: function( _, complete ) {
|
| 51 | script = jQuery( "<script>" )
|
| 52 | .attr( s.scriptAttrs || {} )
|
| 53 | .prop( { charset: s.scriptCharset, src: s.url } )
|
| 54 | .on( "load error", callback = function( evt ) {
|
| 55 | script.remove();
|
| 56 | callback = null;
|
| 57 | if ( evt ) {
|
| 58 | complete( evt.type === "error" ? 404 : 200, evt.type );
|
| 59 | }
|
| 60 | } );
|
| 61 |
|
| 62 |
|
| 63 | document.head.appendChild( script[ 0 ] );
|
| 64 | },
|
| 65 | abort: function() {
|
| 66 | if ( callback ) {
|
| 67 | callback();
|
| 68 | }
|
| 69 | }
|
| 70 | };
|
| 71 | }
|
| 72 | } );
|
| 73 |
|
| 74 | } );
|