Skip to content

Commit 6feb900

Browse files
committed
Fix #731: New method getFilesCount for returning upl + non-upl files count
1 parent d2a3a3d commit 6feb900

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

CHANGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Change Log: `bootstrap-fileinput`
1515
8. (enh #728): Change sortable plugin name to avoid conflict with JUI Sortable.
1616
9. (enh #729): Implement `progressUploadThreshold` to show processing when waiting for server response.
1717
10. (enh #730): Correct Romanian Translations.
18+
11. (enh #731): New method `getFilesCount` for returning upl + non-upl files count.
1819

1920
## version 4.3.3
2021

js/fileinput.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@
346346
'</div>\n';
347347
//noinspection HtmlUnknownAttribute
348348
tBtnDefault = '<button type="{type}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</button>';
349+
//noinspection HtmlUnknownAttribute
349350
tBtnLink = '<a href="{href}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</a>';
351+
//noinspection HtmlUnknownAttribute
350352
tBtnBrowse = '<div tabindex="500" class="{css}" {status}>{icon} {label}</div>';
351353
tModalMain = '<div id="' + MODAL_ID + '" class="file-zoom-dialog modal fade" tabindex="-1" aria-labelledby="' +
352354
MODAL_ID + 'Label"></div>';
@@ -381,8 +383,8 @@
381383
' <div class="file-upload-indicator" title="{indicatorTitle}">{indicator}</div>\n' +
382384
' <div class="clearfix"></div>\n' +
383385
'</div>';
384-
tActionDelete = '<button type="button" class="kv-file-remove {removeClass}" ' +
385-
'title="{removeTitle}" {dataUrl}{dataKey}>{removeIcon}</button>\n';
386+
//noinspection HtmlUnknownAttribute
387+
tActionDelete = '<button type="button" class="kv-file-remove {removeClass}" ' + 'title="{removeTitle}" {dataUrl}{dataKey}>{removeIcon}</button>\n';
386388
tActionUpload = '<button type="button" class="kv-file-upload {uploadClass}" title="{uploadTitle}">' +
387389
'{uploadIcon}</button>';
388390
tActionZoom = '<button type="button" class="kv-file-zoom {zoomClass}" title="{zoomTitle}">{zoomIcon}</button>';
@@ -1049,6 +1051,7 @@
10491051
return;
10501052
}
10511053
$el = $preview.find('.file-initial-thumbs');
1054+
//noinspection JSUnusedGlobalSymbols
10521055
settings = {
10531056
handle: '.drag-handle-init',
10541057
dataIdAttr: 'data-preview-id',
@@ -1556,6 +1559,7 @@
15561559
form: self.formdata,
15571560
files: filesData,
15581561
filenames: self.filenames,
1562+
filescount: self.getFilesCount(),
15591563
extra: self._getExtraData(),
15601564
response: responseData,
15611565
reader: self.reader,
@@ -1620,7 +1624,7 @@
16201624
},
16211625
_initUploadSuccess: function (out, $thumb, allFiles) {
16221626
var self = this, append, data, index, $newThumb, content, config, tags, i,
1623-
mergeArray = function(prop, content) {
1627+
mergeArray = function (prop, content) {
16241628
if (!(self[prop] instanceof Array)) {
16251629
self[prop] = [];
16261630
}
@@ -2342,7 +2346,7 @@
23422346
},
23432347
_setProgress: function (p, $el, error) {
23442348
var self = this, pct = Math.min(p, 100), template = pct < 100 ? self.progressTemplate :
2345-
(error ? self.progressErrorTemplate : (p <= 100 ? self.progressTemplate : self.progressCompleteTemplate)),
2349+
(error ? self.progressErrorTemplate : (p <= 100 ? self.progressTemplate : self.progressCompleteTemplate)),
23462350
pctLimit = self.progressUploadThreshold;
23472351
$el = $el || self.$progress;
23482352
if (!isEmpty(template)) {
@@ -2385,8 +2389,7 @@
23852389
},
23862390
_validateMinCount: function () {
23872391
var self = this, len = self.isUploadable ? self.getFileStack().length : self.$element.get(0).files.length;
2388-
if (self.validateInitialCount && self.minFileCount > 0 && self._getFileCount(
2389-
len - 1) < self.minFileCount) {
2392+
if (self.validateInitialCount && self.minFileCount > 0 && self._getFileCount(len - 1) < self.minFileCount) {
23902393
self._noFilesError({});
23912394
return false;
23922395
}
@@ -2871,6 +2874,10 @@
28712874
return (skipNull ? n !== undefined : n !== undefined && n !== null);
28722875
});
28732876
},
2877+
getFilesCount: function () {
2878+
var self = this, len = self.isUploadable ? self.getFileStack().length : self.$element.get(0).files.length;
2879+
return self._getFileCount(len);
2880+
},
28742881
lock: function () {
28752882
var self = this;
28762883
self._resetErrors();

0 commit comments

Comments
 (0)