Blame view

app/bower_components/jquery/src/ajax/script.js 1.55 KB
87c93a029   Dang YoungWorld   add modal
1
  define( [
f986e111b   TRUONG   add libs
2
  	"../core",
87c93a029   Dang YoungWorld   add modal
3
  	"../var/document",
f986e111b   TRUONG   add libs
4
  	"../ajax"
87c93a029   Dang YoungWorld   add modal
5
6
7
8
9
10
11
12
13
14
  ], function( jQuery, document ) {
  
  "use strict";
  
  // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  jQuery.ajaxPrefilter( function( s ) {
  	if ( s.crossDomain ) {
  		s.contents.script = false;
  	}
  } );
f986e111b   TRUONG   add libs
15
16
  
  // Install script dataType
87c93a029   Dang YoungWorld   add modal
17
  jQuery.ajaxSetup( {
f986e111b   TRUONG   add libs
18
  	accepts: {
87c93a029   Dang YoungWorld   add modal
19
20
  		script: "text/javascript, application/javascript, " +
  			"application/ecmascript, application/x-ecmascript"
f986e111b   TRUONG   add libs
21
22
  	},
  	contents: {
87c93a029   Dang YoungWorld   add modal
23
  		script: /\b(?:java|ecma)script\b/
f986e111b   TRUONG   add libs
24
25
26
27
28
29
30
  	},
  	converters: {
  		"text script": function( text ) {
  			jQuery.globalEval( text );
  			return text;
  		}
  	}
87c93a029   Dang YoungWorld   add modal
31
  } );
f986e111b   TRUONG   add libs
32

87c93a029   Dang YoungWorld   add modal
33
  // Handle cache's special case and crossDomain
f986e111b   TRUONG   add libs
34
35
36
37
38
39
  jQuery.ajaxPrefilter( "script", function( s ) {
  	if ( s.cache === undefined ) {
  		s.cache = false;
  	}
  	if ( s.crossDomain ) {
  		s.type = "GET";
f986e111b   TRUONG   add libs
40
  	}
87c93a029   Dang YoungWorld   add modal
41
  } );
f986e111b   TRUONG   add libs
42
43
  
  // Bind script tag hack transport
87c93a029   Dang YoungWorld   add modal
44
  jQuery.ajaxTransport( "script", function( s ) {
f986e111b   TRUONG   add libs
45
46
47
  
  	// This transport only deals with cross domain requests
  	if ( s.crossDomain ) {
87c93a029   Dang YoungWorld   add modal
48
  		var script, callback;
f986e111b   TRUONG   add libs
49
  		return {
87c93a029   Dang YoungWorld   add modal
50
51
52
53
54
55
56
57
58
59
60
  			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 );
f986e111b   TRUONG   add libs
61
62
  						}
  					}
87c93a029   Dang YoungWorld   add modal
63
  				);
f986e111b   TRUONG   add libs
64

f986e111b   TRUONG   add libs
65
  				// Use native DOM manipulation to avoid our domManip AJAX trickery
87c93a029   Dang YoungWorld   add modal
66
  				document.head.appendChild( script[ 0 ] );
f986e111b   TRUONG   add libs
67
  			},
f986e111b   TRUONG   add libs
68
  			abort: function() {
87c93a029   Dang YoungWorld   add modal
69
70
  				if ( callback ) {
  					callback();
f986e111b   TRUONG   add libs
71
72
73
74
  				}
  			}
  		};
  	}
87c93a029   Dang YoungWorld   add modal
75
  } );
f986e111b   TRUONG   add libs
76

87c93a029   Dang YoungWorld   add modal
77
  } );