Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
/*
2
 * jQuery File Upload jQuery UI Plugin
3
 * https://github.com/blueimp/jQuery-File-Upload
4
 *
5
 * Copyright 2013, Sebastian Tschan
6
 * https://blueimp.net
7
 *
8
 * Licensed under the MIT license:
9
 * http://www.opensource.org/licenses/MIT
10
 */
11
 
12
/* jshint nomen:false */
13
/* global define, require, window */
14
 
15
(function (factory) {
16
    'use strict';
17
    if (typeof define === 'function' && define.amd) {
18
        // Register as an anonymous AMD module:
19
        define(['jquery', './jquery.fileupload-ui'], factory);
20
    } else if (typeof exports === 'object') {
21
        // Node/CommonJS:
22
        factory(require('jquery'));
23
    } else {
24
        // Browser globals:
25
        factory(window.jQuery);
26
    }
27
}(function ($) {
28
    'use strict';
29
 
30
    $.widget('blueimp.fileupload', $.blueimp.fileupload, {
31
 
32
        options: {
33
            processdone: function (e, data) {
34
                data.context.find('.start').button('enable');
35
            },
36
            progress: function (e, data) {
37
                if (data.context) {
38
                    data.context.find('.progress').progressbar(
39
                        'option',
40
                        'value',
41
                        parseInt(data.loaded / data.total * 100, 10)
42
                    );
43
                }
44
            },
45
            progressall: function (e, data) {
46
                var $this = $(this);
47
                $this.find('.fileupload-progress')
48
                    .find('.progress').progressbar(
49
                        'option',
50
                        'value',
51
                        parseInt(data.loaded / data.total * 100, 10)
52
                    ).end()
53
                    .find('.progress-extended').each(function () {
54
                        $(this).html(
55
                            ($this.data('blueimp-fileupload') ||
56
                                    $this.data('fileupload'))
57
                                ._renderExtendedProgress(data)
58
                        );
59
                    });
60
            }
61
        },
62
 
63
        _renderUpload: function (func, files) {
64
            var node = this._super(func, files),
65
                showIconText = $(window).width() > 480;
66
            node.find('.progress').empty().progressbar();
67
            node.find('.start').button({
68
                icons: {primary: 'ui-icon-circle-arrow-e'},
69
                text: showIconText
70
            });
71
            node.find('.cancel').button({
72
                icons: {primary: 'ui-icon-cancel'},
73
                text: showIconText
74
            });
75
            if (node.hasClass('fade')) {
76
                node.hide();
77
            }
78
            return node;
79
        },
80
 
81
        _renderDownload: function (func, files) {
82
            var node = this._super(func, files),
83
                showIconText = $(window).width() > 480;
84
            node.find('.delete').button({
85
                icons: {primary: 'ui-icon-trash'},
86
                text: showIconText
87
            });
88
            if (node.hasClass('fade')) {
89
                node.hide();
90
            }
91
            return node;
92
        },
93
 
94
        _startHandler: function (e) {
95
            $(e.currentTarget).button('disable');
96
            this._super(e);
97
        },
98
 
99
        _transition: function (node) {
100
            var deferred = $.Deferred();
101
            if (node.hasClass('fade')) {
102
                node.fadeToggle(
103
                    this.options.transitionDuration,
104
                    this.options.transitionEasing,
105
                    function () {
106
                        deferred.resolveWith(node);
107
                    }
108
                );
109
            } else {
110
                deferred.resolveWith(node);
111
            }
112
            return deferred;
113
        },
114
 
115
        _create: function () {
116
            this._super();
117
            this.element
118
                .find('.fileupload-buttonbar')
119
                .find('.fileinput-button').each(function () {
120
                    var input = $(this).find('input:file').detach();
121
                    $(this)
122
                        .button({icons: {primary: 'ui-icon-plusthick'}})
123
                        .append(input);
124
                })
125
                .end().find('.start')
126
                .button({icons: {primary: 'ui-icon-circle-arrow-e'}})
127
                .end().find('.cancel')
128
                .button({icons: {primary: 'ui-icon-cancel'}})
129
                .end().find('.delete')
130
                .button({icons: {primary: 'ui-icon-trash'}})
131
                .end().find('.progress').progressbar();
132
        },
133
 
134
        _destroy: function () {
135
            this.element
136
                .find('.fileupload-buttonbar')
137
                .find('.fileinput-button').each(function () {
138
                    var input = $(this).find('input:file').detach();
139
                    $(this)
140
                        .button('destroy')
141
                        .append(input);
142
                })
143
                .end().find('.start')
144
                .button('destroy')
145
                .end().find('.cancel')
146
                .button('destroy')
147
                .end().find('.delete')
148
                .button('destroy')
149
                .end().find('.progress').progressbar('destroy');
150
            this._super();
151
        }
152
 
153
    });
154
 
155
}));