Projet

Général

Profil

Paste
Télécharger (1,92 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / libraries / flexslider-2.5.0 / bower_components / jquery / src / ajax / script.js @ 0aee3c58

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 global
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
                s.global = false;
30
        }
31
});
32

    
33
// Bind script tag hack transport
34
jQuery.ajaxTransport( "script", function(s) {
35

    
36
        // This transport only deals with cross domain requests
37
        if ( s.crossDomain ) {
38

    
39
                var script,
40
                        head = document.head || jQuery("head")[0] || document.documentElement;
41

    
42
                return {
43

    
44
                        send: function( _, callback ) {
45

    
46
                                script = document.createElement("script");
47

    
48
                                script.async = true;
49

    
50
                                if ( s.scriptCharset ) {
51
                                        script.charset = s.scriptCharset;
52
                                }
53

    
54
                                script.src = s.url;
55

    
56
                                // Attach handlers for all browsers
57
                                script.onload = script.onreadystatechange = function( _, isAbort ) {
58

    
59
                                        if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
60

    
61
                                                // Handle memory leak in IE
62
                                                script.onload = script.onreadystatechange = null;
63

    
64
                                                // Remove the script
65
                                                if ( script.parentNode ) {
66
                                                        script.parentNode.removeChild( script );
67
                                                }
68

    
69
                                                // Dereference the script
70
                                                script = null;
71

    
72
                                                // Callback if not abort
73
                                                if ( !isAbort ) {
74
                                                        callback( 200, "success" );
75
                                                }
76
                                        }
77
                                };
78

    
79
                                // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
80
                                // Use native DOM manipulation to avoid our domManip AJAX trickery
81
                                head.insertBefore( script, head.firstChild );
82
                        },
83

    
84
                        abort: function() {
85
                                if ( script ) {
86
                                        script.onload( undefined, true );
87
                                }
88
                        }
89
                };
90
        }
91
});
92

    
93
});