Browse Source

Fix #193: Better validation for triggering `filebatchuploadcomplete` on async batch upload completion

Kartik Visweswaran 10 năm trước cách đây
mục cha
commit
3c27a5dd07
4 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 1 0
      CHANGE.md
  2. 1 1
      README.md
  3. 4 1
      js/fileinput.js
  4. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -19,6 +19,7 @@ version 4.1.8
 15. (enh #192): Ability to extend and add one's own ajax settings.
     - New property `ajaxDeleteSettings` to help extend and add to delete ajax settings. 
     - `ajaxSettings` to help extend and add upload ajax settings
+16. (bug #193): Better validation for triggering `filebatchuploadcomplete` on async batch upload completion.
 
 version 4.1.7
 =============

+ 1 - 1
README.md

@@ -6,7 +6,7 @@ An enhanced HTML 5 file input for Bootstrap 3.x with file preview for various fi
 
 This plugin was initially inspired by [this blog article](http://www.abeautifulsite.net/blog/2013/08/whipping-file-inputs-into-shape-with-bootstrap-3/) and [Jasny's File Input plugin](http://jasny.github.io/bootstrap/javascript/#fileinput). But the plugin has now matured with various additional features and enhancements to be a complete (yet simple) file management tool and solution for web developers. 
 
-> NOTE: The latest version of the plugin v4.1.7 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/bootstrap-fileinput/blob/master/CHANGE.md) for details. 
+> NOTE: The latest version of the plugin v4.1.8 has been released. Refer the [CHANGE LOG](https://github.com/kartik-v/bootstrap-fileinput/blob/master/CHANGE.md) for details. 
 
 ## Features  
 

+ 4 - 1
js/fileinput.js

@@ -309,6 +309,7 @@
                 self[key] = value;
             });
             self.fileInputCleared = false;
+            self.fileBatchCompleted = true;
             if (isEmpty(self.allowedPreviewTypes)) {
                 self.allowedPreviewTypes = defaultPreviewTypes;
             }
@@ -476,6 +477,7 @@
             if ((self.uploadAsync || totLen === 1) && self.showPreview) {
                 outData = self.getOutData();
                 self.raise('filebatchpreupload', [outData]);
+                self.fileBatchCompleted = false;
                 for (i = 0; i < len; i += 1) {
                     if (self.filestack[i] !== undefined) {
                         self.uploadSingle(i, self.filestack, true);
@@ -1021,7 +1023,7 @@
                 return;
             }
             chkComplete = function () {
-                var $thumbs = self.$preview.find('.file-preview-frame.file-uploading'), chk = $thumbs.length;
+                var $thumbs = self.$preview.find('.file-preview-frame.file-uploading'), chk = $thumbs.length && self.fileBatchCompleted;
                 if (chk > 0) {
                     return;
                 }
@@ -1029,6 +1031,7 @@
                 self.unlock();
                 self.clearFileInput();
                 self.raise('filebatchuploadcomplete', [self.filestack, self.getExtraData()]);
+                self.fileBatchCompleted = true;
             };
             setIndicator = function (icon, msg) {
                 $indicator.html(config[icon]);

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
js/fileinput.min.js


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác