|
@@ -638,6 +638,7 @@
|
|
switch (key) {
|
|
switch (key) {
|
|
case 'minFileCount':
|
|
case 'minFileCount':
|
|
case 'maxFileCount':
|
|
case 'maxFileCount':
|
|
|
|
+ case 'maxTotalFileCount':
|
|
case 'minFileSize':
|
|
case 'minFileSize':
|
|
case 'maxFileSize':
|
|
case 'maxFileSize':
|
|
case 'maxFilePreviewSize':
|
|
case 'maxFilePreviewSize':
|
|
@@ -657,6 +658,13 @@
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ if (self.maxTotalFileCount > 0) {
|
|
|
|
+ if (self.maxTotalFileCount < self.maxFileCount) {
|
|
|
|
+ self.maxTotalFileCount = self.maxFileCount;
|
|
|
|
+ } else {
|
|
|
|
+ self.validateInitialCount = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (self.rtl) { // swap buttons for rtl
|
|
if (self.rtl) { // swap buttons for rtl
|
|
tmp = self.previewZoomButtonIcons.prev;
|
|
tmp = self.previewZoomButtonIcons.prev;
|
|
self.previewZoomButtonIcons.prev = self.previewZoomButtonIcons.next;
|
|
self.previewZoomButtonIcons.prev = self.previewZoomButtonIcons.next;
|
|
@@ -3998,9 +4006,12 @@
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
},
|
|
},
|
|
- _getFileCount: function (fileCount) {
|
|
|
|
|
|
+ _getFileCount: function (fileCount, includeInitial) {
|
|
var self = this, addCount = 0;
|
|
var self = this, addCount = 0;
|
|
- if (self.validateInitialCount && !self.overwriteInitial) {
|
|
|
|
|
|
+ if (includeInitial === undefined) {
|
|
|
|
+ includeInitial = self.validateInitialCount && !self.overwriteInitial;
|
|
|
|
+ }
|
|
|
|
+ if (includeInitial) {
|
|
addCount = self.previewCache.count(true);
|
|
addCount = self.previewCache.count(true);
|
|
fileCount += addCount;
|
|
fileCount += addCount;
|
|
}
|
|
}
|
|
@@ -4574,17 +4585,18 @@
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var $el = self.$element, isDragDrop = arguments.length > 1, isAjaxUpload = self.isAjaxUpload,
|
|
var $el = self.$element, isDragDrop = arguments.length > 1, isAjaxUpload = self.isAjaxUpload,
|
|
- tfiles, files = isDragDrop ? arguments[1] : $el.get(0).files, total,
|
|
|
|
- maxCount = !isAjaxUpload && $h.isEmpty($el.attr('multiple')) ? 1 : self.maxFileCount,
|
|
|
|
- len, ctr = self.fileManager.count(), isSingleUpload = $h.isEmpty($el.attr('multiple')),
|
|
|
|
- flagSingle = (isSingleUpload && ctr > 0),
|
|
|
|
|
|
+ tfiles, files = isDragDrop ? arguments[1] : $el.get(0).files, ctr = self.fileManager.count(),
|
|
|
|
+ total, initCount, len, isSingleUpl = $h.isEmpty($el.attr('multiple')),
|
|
|
|
+ maxCount = !isAjaxUpload && isSingleUpl ? 1 : self.maxFileCount, maxTotCount = self.maxTotalFileCount,
|
|
|
|
+ inclAll = maxTotCount > 0 && maxTotCount > maxCount, flagSingle = (isSingleUpl && ctr > 0),
|
|
throwError = function (mesg, file, previewId, index) {
|
|
throwError = function (mesg, file, previewId, index) {
|
|
var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), {id: previewId, index: index}),
|
|
var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), {id: previewId, index: index}),
|
|
p2 = {id: previewId, index: index, file: file, files: files};
|
|
p2 = {id: previewId, index: index, file: file, files: files};
|
|
return isAjaxUpload ? self._showFileError(mesg, p1) : self._showError(mesg, p2);
|
|
return isAjaxUpload ? self._showFileError(mesg, p1) : self._showError(mesg, p2);
|
|
},
|
|
},
|
|
maxCountCheck = function (n, m) {
|
|
maxCountCheck = function (n, m) {
|
|
- var msg = self.msgFilesTooMany.replace('{m}', m).replace('{n}', n);
|
|
|
|
|
|
+ var msg = inclAll ? self.msgTotalFilesTooMany : self.msgFilesTooMany;
|
|
|
|
+ msg = msg.replace('{m}', m).replace('{n}', n);
|
|
self.isError = throwError(msg, null, null, null);
|
|
self.isError = throwError(msg, null, null, null);
|
|
self.$captionContainer.removeClass('icon-visible');
|
|
self.$captionContainer.removeClass('icon-visible');
|
|
self._setCaption('', true);
|
|
self._setCaption('', true);
|
|
@@ -4613,7 +4625,8 @@
|
|
}
|
|
}
|
|
self._resetErrors();
|
|
self._resetErrors();
|
|
len = tfiles.length;
|
|
len = tfiles.length;
|
|
- total = self._getFileCount(isAjaxUpload ? (self.fileManager.count() + len) : len);
|
|
|
|
|
|
+ initCount = isAjaxUpload ? (self.fileManager.count() + len) : len;
|
|
|
|
+ total = self._getFileCount(initCount);
|
|
if (maxCount > 0 && total > maxCount) {
|
|
if (maxCount > 0 && total > maxCount) {
|
|
if (!self.autoReplace || len > maxCount) {
|
|
if (!self.autoReplace || len > maxCount) {
|
|
maxCountCheck((self.autoReplace && len > maxCount ? len : total), maxCount);
|
|
maxCountCheck((self.autoReplace && len > maxCount ? len : total), maxCount);
|
|
@@ -4623,6 +4636,18 @@
|
|
self._resetPreviewThumbs(isAjaxUpload);
|
|
self._resetPreviewThumbs(isAjaxUpload);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ if (inclAll) {
|
|
|
|
+ total = self._getFileCount(initCount, true);
|
|
|
|
+ if (maxTotCount > 0 && total > maxTotCount) {
|
|
|
|
+ if (!self.autoReplace || len > maxCount) {
|
|
|
|
+ maxCountCheck((self.autoReplace && len > maxTotCount ? len : total), maxTotCount);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (total > maxCount) {
|
|
|
|
+ self._resetPreviewThumbs(isAjaxUpload);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (!isAjaxUpload || flagSingle) {
|
|
if (!isAjaxUpload || flagSingle) {
|
|
self._resetPreviewThumbs(false);
|
|
self._resetPreviewThumbs(false);
|
|
if (flagSingle) {
|
|
if (flagSingle) {
|
|
@@ -5482,6 +5507,7 @@
|
|
maxFilePreviewSize: 25600, // 25 MB
|
|
maxFilePreviewSize: 25600, // 25 MB
|
|
minFileCount: 0,
|
|
minFileCount: 0,
|
|
maxFileCount: 0,
|
|
maxFileCount: 0,
|
|
|
|
+ maxTotalFileCount: 0,
|
|
validateInitialCount: false,
|
|
validateInitialCount: false,
|
|
msgValidationErrorClass: 'text-danger',
|
|
msgValidationErrorClass: 'text-danger',
|
|
msgValidationErrorIcon: '<i class="glyphicon glyphicon-exclamation-sign"></i> ',
|
|
msgValidationErrorIcon: '<i class="glyphicon glyphicon-exclamation-sign"></i> ',
|
|
@@ -5547,6 +5573,7 @@
|
|
msgSizeTooLarge: 'File "{name}" (<b>{size} KB</b>) exceeds maximum allowed upload size of <b>{maxSize} KB</b>.',
|
|
msgSizeTooLarge: 'File "{name}" (<b>{size} KB</b>) exceeds maximum allowed upload size of <b>{maxSize} KB</b>.',
|
|
msgFilesTooLess: 'You must select at least <b>{n}</b> {files} to upload.',
|
|
msgFilesTooLess: 'You must select at least <b>{n}</b> {files} to upload.',
|
|
msgFilesTooMany: 'Number of files selected for upload <b>({n})</b> exceeds maximum allowed limit of <b>{m}</b>.',
|
|
msgFilesTooMany: 'Number of files selected for upload <b>({n})</b> exceeds maximum allowed limit of <b>{m}</b>.',
|
|
|
|
+ msgTotalFilesTooMany: 'You can upload a maximum of <b>{m}</b> files (<b>({n})</b> files detected).',
|
|
msgFileNotFound: 'File "{name}" not found!',
|
|
msgFileNotFound: 'File "{name}" not found!',
|
|
msgFileSecured: 'Security restrictions prevent reading the file "{name}".',
|
|
msgFileSecured: 'Security restrictions prevent reading the file "{name}".',
|
|
msgFileNotReadable: 'File "{name}" is not readable.',
|
|
msgFileNotReadable: 'File "{name}" is not readable.',
|