Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

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