瀏覽代碼

Fix #393: Minor enhancements to abort events before upload

Kartik Visweswaran 9 年之前
父節點
當前提交
04f471e42e
共有 3 個文件被更改,包括 9 次插入4 次删除
  1. 1 0
      CHANGE.md
  2. 8 4
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -17,6 +17,7 @@ Change Log: `bootstrap-fileinput`
 10. (enh #389): New templates and styling enhancements to caption and main buttons.
 10. (enh #389): New templates and styling enhancements to caption and main buttons.
 11. (enh #390): Thumbnail error display enhancements.
 11. (enh #390): Thumbnail error display enhancements.
 12. (enh #391): Thumbnail styling enhancements for flash, html, and object types.
 12. (enh #391): Thumbnail styling enhancements for flash, html, and object types.
+13. (enh #393): Minor enhancements to abort events before upload.
 
 
 ## version 4.2.5
 ## version 4.2.5
 
 

+ 8 - 4
js/fileinput.js

@@ -430,10 +430,11 @@
             return Math.round(new Date().getTime() + (Math.random() * 100));
             return Math.round(new Date().getTime() + (Math.random() * 100));
         },
         },
         htmlEncode = function (str) {
         htmlEncode = function (str) {
-            var $el = $(document.createElement('div')).html(str),
-                out = $el.text();
-            $el.remove();
-            return out;
+            return str.replace(/\</g, '&lt;')
+                .replace(/\</g, '&gt;')
+                .replace(/\&/g, '&amp;')
+                .replace(/\"/g, '&quot;')
+                .replace(/\'/g, '&apos;');
         },
         },
         replaceTags = function (str, tags) {
         replaceTags = function (str, tags) {
             var out = str;
             var out = str;
@@ -699,6 +700,8 @@
                 data = $.extend(self.getOutData(), params);
                 data = $.extend(self.getOutData(), params);
                 data.abortData = self.ajaxAborted.data || {};
                 data.abortData = self.ajaxAborted.data || {};
                 data.abortMessage = self.ajaxAborted.message;
                 data.abortMessage = self.ajaxAborted.message;
+                self.cancel();
+                self.setProgress(100);
                 self.showUploadError(self.ajaxAborted.message, data, 'filecustomerror');
                 self.showUploadError(self.ajaxAborted.message, data, 'filecustomerror');
                 return true;
                 return true;
             }
             }
@@ -1501,6 +1504,7 @@
                 self.raise('filebatchpreupload', [outData]);
                 self.raise('filebatchpreupload', [outData]);
                 if (self.abort(outData)) {
                 if (self.abort(outData)) {
                     jqXHR.abort();
                     jqXHR.abort();
+                    self.setProgress(100);
                 }
                 }
             };
             };
             fnSuccess = function (data, textStatus, jqXHR) {
             fnSuccess = function (data, textStatus, jqXHR) {

文件差異過大導致無法顯示
+ 0 - 0
js/fileinput.min.js


部分文件因文件數量過多而無法顯示