Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / policyApp / libs / bower_components / jquery / src / ajax / script.js
1 define([
2         "../core",
3         "../ajax"
4 ], function( jQuery ) {
5
6 // Install script dataType
7 jQuery.ajaxSetup({
8         accepts: {
9                 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
10         },
11         contents: {
12                 script: /(?:java|ecma)script/
13         },
14         converters: {
15                 "text script": function( text ) {
16                         jQuery.globalEval( text );
17                         return text;
18                 }
19         }
20 });
21
22 // Handle cache's special case and crossDomain
23 jQuery.ajaxPrefilter( "script", function( s ) {
24         if ( s.cache === undefined ) {
25                 s.cache = false;
26         }
27         if ( s.crossDomain ) {
28                 s.type = "GET";
29         }
30 });
31
32 // Bind script tag hack transport
33 jQuery.ajaxTransport( "script", function( s ) {
34         // This transport only deals with cross domain requests
35         if ( s.crossDomain ) {
36                 var script, callback;
37                 return {
38                         send: function( _, complete ) {
39                                 script = jQuery("<script>").prop({
40                                         async: true,
41                                         charset: s.scriptCharset,
42                                         src: s.url
43                                 }).on(
44                                         "load error",
45                                         callback = function( evt ) {
46                                                 script.remove();
47                                                 callback = null;
48                                                 if ( evt ) {
49                                                         complete( evt.type === "error" ? 404 : 200, evt.type );
50                                                 }
51                                         }
52                                 );
53                                 document.head.appendChild( script[ 0 ] );
54                         },
55                         abort: function() {
56                                 if ( callback ) {
57                                         callback();
58                                 }
59                         }
60                 };
61         }
62 });
63
64 });