Skip to content

Commit 367045c

Browse files
committed
Merge branch 'master' into jquery-ui
2 parents 76a8fe3 + fe29267 commit 367045c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

js/jquery.fileupload-ui.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload User Interface Plugin 6.9.3
2+
* jQuery File Upload User Interface Plugin 6.9.4
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -89,7 +89,7 @@
8989
files = data.files;
9090
$(this).fileupload('process', data).done(function () {
9191
that._adjustMaxNumberOfFiles(-files.length);
92-
data.isAdjusted = true;
92+
data.maxNumberOfFilesAdjusted = true;
9393
data.files.valid = data.isValidated = that._validate(files);
9494
data.context = that._renderUpload(files).data('data', data);
9595
options.filesContainer[
@@ -112,8 +112,9 @@
112112
send: function (e, data) {
113113
var that = $(this).data('fileupload');
114114
if (!data.isValidated) {
115-
if (!data.isAdjusted) {
115+
if (!data.maxNumberOfFilesAdjusted) {
116116
that._adjustMaxNumberOfFiles(-data.files.length);
117+
data.maxNumberOfFilesAdjusted = true;
117118
}
118119
if (!that._validate(data.files)) {
119120
return false;
@@ -163,6 +164,17 @@
163164
);
164165
});
165166
} else {
167+
if ($.isArray(data.result)) {
168+
$.each(data.result, function (index, file) {
169+
if (data.maxNumberOfFilesAdjusted && file.error) {
170+
that._adjustMaxNumberOfFiles(1);
171+
} else if (!data.maxNumberOfFilesAdjusted &&
172+
!file.error) {
173+
that._adjustMaxNumberOfFiles(-1);
174+
}
175+
});
176+
data.maxNumberOfFilesAdjusted = true;
177+
}
166178
template = that._renderDownload(data.result)
167179
.appendTo(that.options.filesContainer);
168180
that._forceReflow(template);
@@ -178,7 +190,9 @@
178190
fail: function (e, data) {
179191
var that = $(this).data('fileupload'),
180192
template;
181-
that._adjustMaxNumberOfFiles(data.files.length);
193+
if (data.maxNumberOfFilesAdjusted) {
194+
that._adjustMaxNumberOfFiles(data.files.length);
195+
}
182196
if (data.context) {
183197
data.context.each(function (index) {
184198
if (data.errorThrown !== 'abort') {
@@ -209,7 +223,6 @@
209223
}
210224
});
211225
} else if (data.errorThrown !== 'abort') {
212-
that._adjustMaxNumberOfFiles(-data.files.length);
213226
data.context = that._renderUpload(data.files)
214227
.appendTo(that.options.filesContainer)
215228
.data('data', data);

0 commit comments

Comments
 (0)