Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21627 kshitij.so 1
/*
2
 * jQuery File Upload Plugin JS Example 7.0
3
 * https://github.com/blueimp/jQuery-File-Upload
4
 *
5
 * Copyright 2010, Sebastian Tschan
6
 * https://blueimp.net
7
 *
8
 * Licensed under the MIT license:
9
 * http://www.opensource.org/licenses/MIT
10
 */
11
 
12
/*jslint nomen: true, unparam: true, regexp: true */
13
/*global $, window, document */
14
 
15
$(function () {
16
    'use strict';
17
 
18
    // Initialize the jQuery File Upload widget:
19
    $('#fileupload').fileupload({
20
        // Uncomment the following to send cross-domain cookies:
21
        //xhrFields: {withCredentials: true},
22
        url: 'assets/jquery-file-upload/server/php/'
23
    });
24
 
25
    // Enable iframe cross-domain access via redirect option(only if you uplaod to another domain):
26
    /*
27
    $('#fileupload').fileupload(
28
        'option',
29
        'redirect',
30
        'assets/jquery-file-upload/cors/result.html?%s'
31
    );
32
    */
33
 
34
    if (window.location.hostname === 'blueimp.github.com') {
35
        // Demo settings:
36
        $('#fileupload').fileupload('option', {
37
            url: '//jquery-file-upload.appspot.com/',
38
            maxFileSize: 5000000,
39
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
40
            process: [
41
                {
42
                    action: 'load',
43
                    fileTypes: /^image\/(gif|jpeg|png)$/,
44
                    maxFileSize: 20000000 // 20MB
45
                },
46
                {
47
                    action: 'resize',
48
                    maxWidth: 1440,
49
                    maxHeight: 900
50
                },
51
                {
52
                    action: 'save'
53
                }
54
            ]
55
        });
56
        // Upload server status check for browsers with CORS support:
57
        if ($.support.cors) {
58
            $.ajax({
59
                url: '//jquery-file-upload.appspot.com/',
60
                type: 'HEAD'
61
            }).fail(function () {
62
                $('<span class="alert alert-error"/>')
63
                    .text('Upload server currently unavailable - ' +
64
                            new Date())
65
                    .appendTo('#fileupload');
66
            });
67
        }
68
    } else {
69
        // Load existing files:
70
        // Demo settings:
71
        $.ajax({
72
            // Uncomment the following to send cross-domain cookies:
73
            //xhrFields: {withCredentials: true},
74
            url: $('#fileupload').fileupload('option', 'url'),
75
            dataType: 'json',            
76
            context: $('#fileupload')[0],
77
            maxFileSize: 5000000,
78
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
79
            process: [
80
                {
81
                    action: 'load',
82
                    fileTypes: /^image\/(gif|jpeg|png)$/,
83
                    maxFileSize: 20000000 // 20MB
84
                },
85
                {
86
                    action: 'resize',
87
                    maxWidth: 1440,
88
                    maxHeight: 900
89
                },
90
                {
91
                    action: 'save'
92
                }
93
            ]
94
        }).done(function (result) {
95
            $(this).fileupload('option', 'done')
96
                .call(this, null, {result: result});
97
        });
98
 
99
        // Upload server status check for browsers with CORS support:
100
        if ($.support.cors) {
101
            $.ajax({
102
                url: 'assets/jquery-file-upload/server/php/',
103
                type: 'HEAD'
104
            }).fail(function () {
105
                $('<span class="alert alert-error"/>')
106
                    .text('Upload server currently unavailable - ' +
107
                            new Date())
108
                    .appendTo('#fileupload');
109
            });
110
        }
111
    }
112
 
113
});