Blame view

app/bower_components/jquery/src/ajax/script.js 1.92 KB
f986e111b   TRUONG   add libs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  define([
  	"../core",
  	"../ajax"
  ], function( jQuery ) {
  
  // Install script dataType
  jQuery.ajaxSetup({
  	accepts: {
  		script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  	},
  	contents: {
  		script: /(?:java|ecma)script/
  	},
  	converters: {
  		"text script": function( text ) {
  			jQuery.globalEval( text );
  			return text;
  		}
  	}
  });
  
  // Handle cache's special case and global
  jQuery.ajaxPrefilter( "script", function( s ) {
  	if ( s.cache === undefined ) {
  		s.cache = false;
  	}
  	if ( s.crossDomain ) {
  		s.type = "GET";
  		s.global = false;
  	}
  });
  
  // Bind script tag hack transport
  jQuery.ajaxTransport( "script", function(s) {
  
  	// This transport only deals with cross domain requests
  	if ( s.crossDomain ) {
  
  		var script,
  			head = document.head || jQuery("head")[0] || document.documentElement;
  
  		return {
  
  			send: function( _, callback ) {
  
  				script = document.createElement("script");
  
  				script.async = true;
  
  				if ( s.scriptCharset ) {
  					script.charset = s.scriptCharset;
  				}
  
  				script.src = s.url;
  
  				// Attach handlers for all browsers
  				script.onload = script.onreadystatechange = function( _, isAbort ) {
  
  					if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  
  						// Handle memory leak in IE
  						script.onload = script.onreadystatechange = null;
  
  						// Remove the script
  						if ( script.parentNode ) {
  							script.parentNode.removeChild( script );
  						}
  
  						// Dereference the script
  						script = null;
  
  						// Callback if not abort
  						if ( !isAbort ) {
  							callback( 200, "success" );
  						}
  					}
  				};
  
  				// Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
  				// Use native DOM manipulation to avoid our domManip AJAX trickery
  				head.insertBefore( script, head.firstChild );
  			},
  
  			abort: function() {
  				if ( script ) {
  					script.onload( undefined, true );
  				}
  			}
  		};
  	}
  });
  
  });