Pārlūkot izejas kodu

Updates to release v4.1.8 fixes #177

Kartik Visweswaran 10 gadi atpakaļ
vecāks
revīzija
d11c78c408
3 mainītis faili ar 47 papildinājumiem un 28 dzēšanām
  1. 4 1
      CHANGE.md
  2. 43 27
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 4 - 1
CHANGE.md

@@ -1,11 +1,14 @@
 version 4.1.8
 =============
-**Date**: 21-Feb-2015
+**Date**: 24-Feb-2015
 
 1. (bug #171): Fix typo for files validation.
 2. (enh #167, #173): New `deleteExtraData` property for ajax deletions.
 3. (enh #174): New `deleteUrl` property.
 4. (enh #175): Ability to override delete extra data in `initialPreviewConfig`.
+5. (enh #176): Wrong file in README installation steps fixed.
+6. (enh #177): Trigger filebatchpreupload if showPreview is `false`.
+7. (enh #178): Updated README for cancel button configuration.
 
 version 4.1.7
 =============

+ 43 - 27
js/fileinput.js

@@ -28,6 +28,16 @@
             div.parentNode.removeChild(div);
             return status;
         },
+        getNum = function(num, def) {
+            def = def || 0;
+            if (typeof num === "number") {
+                return num;
+            }
+            if (typeof num === "string") {
+                num = parseFloat(num);
+            }
+            return isNaN(num) ? def : num;
+        },
         hasFileAPISupport = function () {
             return window.File && window.FileReader;
         },
@@ -293,6 +303,9 @@
         init: function (options) {
             var self = this, $el = self.$element, content, t;
             $.each(options, function (key, value) {
+                if (key === 'maxFileCount' || key === 'maxFileSize' || key === 'initialPreviewCount') {
+                    self[key] = getNum(value);
+                }
                 self[key] = value;
             });
             if (isEmpty(self.allowedPreviewTypes)) {
@@ -1112,15 +1125,14 @@
             fnBefore = function (jqXHR) {
                 self.lock();
                 var outData = self.getOutData(jqXHR);
-                if (!self.showPreview) {
-                    return;
+                if (self.showPreview) {
+                    self.$preview.find('.file-preview-frame').each(function () {
+                        var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'), $btnDelete = $thumb.find('.kv-file-remove');
+                        addCss($thumb, 'file-uploading');
+                        $btnUpload.attr('disabled', true);
+                        $btnDelete.attr('disabled', true);
+                    });
                 }
-                self.$preview.find('.file-preview-frame').each(function () {
-                    var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'), $btnDelete = $thumb.find('.kv-file-remove');
-                    addCss($thumb, 'file-uploading');
-                    $btnUpload.attr('disabled', true);
-                    $btnDelete.attr('disabled', true);
-                });
                 self.raise('filebatchpreupload', [outData]);
             };
             fnSuccess = function (data, textStatus, jqXHR) {
@@ -1141,22 +1153,24 @@
                         self.reset();
                     }
                 } else {
-                    self.$preview.find('.file-preview-frame').each(function () {
-                        var $thumb = $(this), key = parseInt($thumb.attr('data-fileindex'), 10);
-                        enableActions(key);
-                        if (keys.length === 0) {
-                            setIndicator(key, 'indicatorError', 'indicatorErrorTitle');
-                            return;
-                        }
-                        if ($.inArray(key, keys) !== -1) {
-                            setIndicator(key, 'indicatorError', 'indicatorErrorTitle');
-                        } else {
-                            $thumb.find('.kv-file-upload').hide();
-                            $thumb.find('.kv-file-remove').hide();
-                            setIndicator(key, 'indicatorSuccess', 'indicatorSuccessTitle');
-                            self.filestack[key] = undefined;
-                        }
-                    });
+                    if (self.showPreview) {
+                        self.$preview.find('.file-preview-frame').each(function () {
+                            var $thumb = $(this), key = parseInt($thumb.attr('data-fileindex'), 10);
+                            enableActions(key);
+                            if (keys.length === 0) {
+                                setIndicator(key, 'indicatorError', 'indicatorErrorTitle');
+                                return;
+                            }
+                            if ($.inArray(key, keys) !== -1) {
+                                setIndicator(key, 'indicatorError', 'indicatorErrorTitle');
+                            } else {
+                                $thumb.find('.kv-file-upload').hide();
+                                $thumb.find('.kv-file-remove').hide();
+                                setIndicator(key, 'indicatorSuccess', 'indicatorSuccessTitle');
+                                self.filestack[key] = undefined;
+                            }
+                        });
+                    }
                     self.showUploadError(data.error, outData, null, null, 'filebatchuploaderror');
                 }
             };
@@ -1170,6 +1184,9 @@
                 var outData = self.getOutData(jqXHR);
                 self.showUploadError(errorThrown, outData, null, null, 'filebatchuploaderror');
                 self.uploadFileCount = total - 1;
+                if (!self.showPreview) {
+                    return;
+                }
                 self.$preview.find('.file-preview-frame').each(function () {
                     var $thumb = $(this), key = $thumb.attr('data-fileindex');
                     $thumb.removeClass('file-uploading');
@@ -1402,9 +1419,8 @@
                     $status.html('');
                     return;
                 }
-                var node = ctr + i, previewId = previewInitId + "-" + node, isText,
-                    file = files[i], caption = self.slug(file.name),
-                    fileSize = (file.size || 0) / 1000, checkFile, fileExtExpr = '',
+                var node = ctr + i, previewId = previewInitId + "-" + node, isText, file = files[i], 
+                    caption = self.slug(file.name), fileSize = (file.size || 0) / 1000, checkFile, fileExtExpr = '',
                     previewData = objUrl.createObjectURL(file), fileCount = 0, j, msg, typ, chk,
                     fileTypes = self.allowedFileTypes, strTypes = isEmpty(fileTypes) ? '' : fileTypes.join(', '),
                     fileExt = self.allowedFileExtensions, strExt = isEmpty(fileExt) ? '' : fileExt.join(', ');

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
js/fileinput.min.js


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels