浏览代码

Fix #1580: Correctly validate drop zone title

Kartik Visweswaran 4 年之前
父节点
当前提交
ccdd37d702
共有 3 个文件被更改,包括 6 次插入1 次删除
  1. 1 0
      CHANGE.md
  2. 5 1
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -5,6 +5,7 @@ Change Log: `bootstrap-fileinput`
 
 **Date:** _under development_
 
+- (enh #1580): Validate drop zone title by correctly checking if native input has files.
 - (enh #1578): Enhance progress bar styling.
 - (enh #1577): Use `…` instead of three dots.
 - (enh #1576): Update French Translations.

+ 5 - 1
js/fileinput.js

@@ -4250,6 +4250,10 @@
                 }
             }
         },
+        _hasFiles: function () {
+            var el = this.$element.get(0);
+            return !!(el && el.files && el.files.length);
+        },
         _setFileDropZoneTitle: function () {
             var self = this, $zone = self.$container.find('.file-drop-zone'), title = self.dropZoneTitle, strFiles;
             if (self.isClickable) {
@@ -4258,7 +4262,7 @@
             }
             $zone.find('.' + self.dropZoneTitleClass).remove();
             if (!self.showPreview || $zone.length === 0 || self.fileManager.count() > 0 || !self.dropZoneEnabled ||
-                (!self.isAjaxUpload && self.$element.files)) {
+                (!self.isAjaxUpload && self._hasFiles())) {
                 return;
             }
             if ($zone.find($h.FRAMES).length === 0 && $h.isEmpty(self.defaultPreviewContent)) {

文件差异内容过多而无法显示
+ 0 - 0
js/fileinput.min.js


部分文件因为文件数量过多而无法显示