Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
9 lars 1
var FormFileUpload = function () {
2
    return {
3
        //main function to initiate the module
4
        init: function () {
5
 
6
             // Initialize the jQuery File Upload widget:
7
            $('#fileupload').fileupload({
8
                disableImageResize: false,
9
                autoUpload: false,
10
                disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
11
                maxFileSize: 5000000,
12
                acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
13
                // Uncomment the following to send cross-domain cookies:
14
                //xhrFields: {withCredentials: true},
15
            });
16
 
17
            // Enable iframe cross-domain access via redirect option:
18
            $('#fileupload').fileupload(
19
                'option',
20
                'redirect',
21
                window.location.href.replace(
22
                    /\/[^\/]*$/,
23
                    '/cors/result.html?%s'
24
                )
25
            );
26
 
27
            // Upload server status check for browsers with CORS support:
28
            if ($.support.cors) {
29
                $.ajax({
30
                    type: 'HEAD'
31
                }).fail(function () {
32
                    $('<div class="alert alert-danger"/>')
33
                        .text('Upload server currently unavailable - ' +
34
                                new Date())
35
                        .appendTo('#fileupload');
36
                });
37
            }
38
 
39
            // Load & display existing files:
40
            $('#fileupload').addClass('fileupload-processing');
41
            $.ajax({
42
                // Uncomment the following to send cross-domain cookies:
43
                //xhrFields: {withCredentials: true},
44
                url: $('#fileupload').attr("action"),
45
                dataType: 'json',
46
                context: $('#fileupload')[0]
47
            }).always(function () {
48
                $(this).removeClass('fileupload-processing');
49
            }).done(function (result) {
50
                $(this).fileupload('option', 'done')
51
                .call(this, $.Event('done'), {result: result});
52
            });
53
        }
54
 
55
    };
56
 
57
}();
58
 
59
jQuery(document).ready(function() {
60
    FormFileUpload.init();
61
});