Skip to content

Commit

Permalink
Updates to release v4.4.3 fixes #1048 fixes #1049
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Aug 18, 2017
1 parent d52d70b commit 17ab105
Show file tree
Hide file tree
Showing 41 changed files with 189 additions and 67 deletions.
14 changes: 12 additions & 2 deletions CHANGE.md
Expand Up @@ -3,8 +3,18 @@ Change Log: `bootstrap-fileinput`

## version 4.4.3 (_under development_)

**Date:** 17-Aug-2017

**Date:** 18-Aug-2017

- (enh #1049): New property `uploadUrlThumb`.
- (enh #1048): Add ability to retry errored file uploads.
- New plugin properties added:
- `retryErrorUploads`: _boolean_, will determine if errored out thumbnails can be retried for upload and submitted again.
- `fileActionSettings.uploadRetryIcon`: Will change the icon of the upload button to retry icon specified here.
- `fileActionSettings.uploadRetryTitle`: Will change the title of the upload button to retry title specified here.
- `msgUploadError`: will be displayed within the progress bar on the errored out thumbnails.
- Other enhancements include:
- resetting progress bar correctly
- enhancing upload validation behavior so that if `retryErrorUploads` is `false`, then no upload button is shown on the file thumbnails.
- (enh #1044): Add Slovak Translations.
- (enh #1043): Add Czech Translations.
- (enh #1042, #830): Fixes to initial preview delete (related to #1034).
Expand Down
84 changes: 60 additions & 24 deletions js/fileinput.js
Expand Up @@ -683,6 +683,8 @@
uploadIcon: '<i class="glyphicon glyphicon-upload text-info"></i>',
uploadClass: 'btn btn-xs btn-default',
uploadTitle: 'Upload file',
uploadRetryIcon: '<i class="glyphicon glyphicon-repeat text-info"></i>',
uploadRetryTitle: 'Retry upload',
zoomIcon: '<i class="glyphicon glyphicon-zoom-in"></i>',
zoomClass: 'btn btn-xs btn-default',
zoomTitle: 'View Details',
Expand Down Expand Up @@ -1796,7 +1798,7 @@
var xhrobj = $.ajaxSettings.xhr();
return self._initXhr(xhrobj, previewId, self.getFileStack().length);
},
url: self.uploadUrl,
url: index && self.uploadUrlThumb ? self.uploadUrlThumb : self.uploadUrl,
type: 'POST',
dataType: 'json',
data: self.formdata,
Expand Down Expand Up @@ -1916,9 +1918,8 @@
var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
previewId = self.previewInitId + "-" + i, $thumb, chkComplete, $btnUpload, $btnDelete,
hasPostData = self.filestack.length > 0 || !$.isEmptyObject(self.uploadExtraData),
$prog = $('#' + previewId).find('.file-thumb-progress'),
fnBefore, fnSuccess, fnComplete, fnError, updateUploadLog, params = {id: previewId, index: i},
uploadFailed, multiUploadMode = !$h.isEmpty(self.$element.attr('multiple'));
$prog = $('#' + previewId).find('.file-thumb-progress'), uploadFailed, refreshButtons,
fnBefore, fnSuccess, fnComplete, fnError, updateUploadLog, params = {id: previewId, index: i};
self.formdata = formdata;
if (self.showPreview) {
$thumb = $('#' + previewId + ':not(.file-preview-initial)');
Expand All @@ -1930,7 +1931,7 @@
return;
}
updateUploadLog = function (i, previewId) {
if (multiUploadMode || !uploadFailed) {
if (!uploadFailed) {
self.updateStack(i, undefined);
}
self.uploadLog.push(previewId);
Expand All @@ -1947,7 +1948,7 @@
len = data.content.length;
}
setTimeout(function () {
var triggerReset = multiUploadMode || !uploadFailed;
var triggerReset = self.getFileStack().length === 0;
if (self.showPreview) {
self.previewCache.set(u.content, u.config, u.tags, u.append);
if (len) {
Expand Down Expand Up @@ -2034,10 +2035,15 @@
} else {
uploadFailed = true;
self._showUploadError(data.error, params);
self._setPreviewError($thumb, i, (multiUploadMode ? null : self.filestack[i]));
self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
if (!self.retryErrorUploads) {
$btnUpload.hide();
}
if (allFiles) {
updateUploadLog(i, pid);
}
self._setProgress(101, $('#' + pid).find('.file-thumb-progress'), self.msgUploadError);
console.log('after 2 = ' + $btnUpload.attr('disabled'));
}
}, 100);
};
Expand Down Expand Up @@ -2066,9 +2072,13 @@
updateUploadLog(i, previewId);
}
self.uploadStatus[previewId] = 100;
self._setPreviewError($thumb, i, (multiUploadMode ? null : self.filestack[i]));
self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
if (!self.retryErrorUploads) {
$btnUpload.hide();
}
$.extend(true, params, self._getOutData(jqXHR));
self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op));
self._setProgress(101, $('#' + previewId).find('.file-thumb-progress'), self.msgUploadError);
self._showUploadError(errMsg, params);
}, 100);
};
Expand Down Expand Up @@ -2113,9 +2123,10 @@
};
fnSuccess = function (data, textStatus, jqXHR) {
/** @namespace data.errorkeys */
var outData = self._getOutData(jqXHR, data), $thumbs = self._getThumbs(':not(.file-preview-error)'),
key = 0,
var outData = self._getOutData(jqXHR, data), key = 0,
$thumbs = self._getThumbs(self.retryErrorUploads ? '' : ':not(.file-preview-error)'),
keys = $h.isEmpty(data) || $h.isEmpty(data.errorkeys) ? [] : data.errorkeys;

if ($h.isEmpty(data) || $h.isEmpty(data.error)) {
self._raise('filebatchuploadsuccess', [outData]);
setAllUploaded();
Expand All @@ -2135,8 +2146,8 @@
} else {
if (self.showPreview) {
$thumbs.each(function () {
var $thumb = $(this), $btnDelete = $thumb.find('.kv-file-remove'),
$btnUpload = $thumb.find('.kv-file-upload');
var $thumb = $(this), $btnDelete = $thumb.find('.kv-file-remove'),
i = $thumb.attr('data-fileindex'), $btnUpload = $thumb.find('.kv-file-upload');
$thumb.removeClass('file-uploading');
$btnUpload.removeAttr('disabled');
$btnDelete.removeAttr('disabled');
Expand All @@ -2145,23 +2156,31 @@
return;
}
if ($.inArray(key, keys) !== -1) {
self._setPreviewError($thumb);
self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
if (!self.retryErrorUploads) {
$thumb.find('.kv-file-upload').hide();
self.updateStack(i, undefined);
}
} else {
$thumb.find('.kv-file-upload').hide();
self._setThumbStatus($thumb, 'Success');
self.updateStack(key, undefined);
self.updateStack(i, undefined);
}
key++;
});
self._initUploadSuccess(data);
}
self._showUploadError(data.error, outData, 'filebatchuploaderror');
self._setProgress(101, self.$progress, self.msgUploadError);
}
};
fnComplete = function () {
var triggerReset = self.getFileStack().length === 0;
self.unlock();
self._initSuccessThumbs();
self._clearFileInput();
if (triggerReset) {
self._clearFileInput();
}
self._raise('filebatchuploadcomplete', [self.filestack, self._getExtraData()]);
};
fnError = function (jqXHR, textStatus, errorThrown) {
Expand Down Expand Up @@ -2303,9 +2322,11 @@
var $el = $(this);
self._handler($el, 'click', function () {
var $frame = $el.closest($h.FRAMES), ind = $frame.attr('data-fileindex');
if (!$frame.hasClass('file-preview-error')) {
self._uploadSingle(ind, false);
self.$progress.addClass('hide');
if ($frame.hasClass('file-preview-error') && !self.retryErrorUploads) {
return;
}
self._uploadSingle(ind, false);
});
});
},
Expand Down Expand Up @@ -2800,16 +2821,16 @@
$indicator = $thumb.find('.file-upload-indicator'),
config = self.fileActionSettings;
$thumb.removeClass('file-preview-success file-preview-error file-preview-loading');
if (status === 'Error') {
$thumb.find('.kv-file-upload').attr('disabled', true);
}
if (status === 'Success') {
$thumb.find('.file-drag-handle').remove();
$indicator.css('margin-left', 0);
}
$indicator.html(config[icon]);
$indicator.attr('title', config[msg]);
$thumb.addClass(css);
if (status === 'Error' && !self.retryErrorUploads) {
$thumb.find('.kv-file-upload').attr('disabled', true);
}
},
_setProgressCancelled: function () {
var self = this;
Expand Down Expand Up @@ -2856,7 +2877,6 @@
sum += value;
});
self._setProgress(Math.floor(sum / total));

},
_validateMinCount: function () {
var self = this, len = self.isUploadable ? self.getFileStack().length : self.$element.get(0).files.length;
Expand Down Expand Up @@ -2904,16 +2924,29 @@
return (skipNull ? n !== undefined : n !== undefined && n !== null);
});
},
_setPreviewError: function ($thumb, i, val) {
_setPreviewError: function ($thumb, i, val, repeat) {
var self = this;
if (i !== undefined) {
self.updateStack(i, val);
}
if (self.removeFromPreviewOnError) {
if (self.removeFromPreviewOnError && !repeat) {
$thumb.remove();
} else {
self._setThumbStatus($thumb, 'Error');
}
self._refreshUploadButton($thumb, repeat);
},
_refreshUploadButton: function($thumb, repeat) {
var self = this, $btn = $thumb.find('.kv-file-upload'), cfg = self.fileActionSettings,
icon = cfg.uploadIcon, title = cfg.uploadTitle;
if (!$btn.length) {
return;
}
if (repeat) {
icon = cfg.uploadRetryIcon;
title = cfg.uploadRetryTitle
}
$btn.attr('title', title).html(icon);
},
_checkDimensions: function (i, chk, $img, $thumb, fname, type, params) {
var self = this, msg, dim, tag = chk === 'Small' ? 'min' : 'max', limit = self[tag + 'Image' + type],
Expand Down Expand Up @@ -3815,6 +3848,7 @@
uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
uploadClass: 'btn btn-default',
uploadUrl: null,
uploadUrlThumb: null,
uploadAsync: true,
uploadExtraData: {},
zoomModalHeight: 480,
Expand Down Expand Up @@ -3857,7 +3891,8 @@
textEncoding: 'UTF-8',
ajaxSettings: {},
ajaxDeleteSettings: {},
showAjaxErrorDetails: true
showAjaxErrorDetails: true,
retryErrorUploads: true
};

$.fn.fileinputLocales.en = {
Expand Down Expand Up @@ -3902,6 +3937,7 @@
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgUploadError: 'Error',
msgValidationError: 'Validation Error',
msgLoading: 'Loading file {index} of {files} &hellip;',
msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',
Expand Down
6 changes: 3 additions & 3 deletions js/fileinput.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/locales/LANG.js
Expand Up @@ -53,7 +53,8 @@
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgValidationError: 'Validation Error',
msgUploadError: 'Error',
msgValidationError: : 'Validation Error',
msgLoading: 'Loading file {index} of {files} &hellip;',
msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',
msgSelected: '{n} {files} selected',
Expand All @@ -77,6 +78,7 @@
fileActionSettings: {
removeTitle: 'Remove file',
uploadTitle: 'Upload file',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'View details',
dragTitle: 'Move / Rearrange',
indicatorNewTitle: 'Not uploaded yet',
Expand Down
4 changes: 3 additions & 1 deletion js/locales/ar.js
Expand Up @@ -54,7 +54,8 @@
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgValidationError: 'خطأ التحقق من صحة',
msgUploadError: 'Error',
msgValidationError: : 'خطأ التحقق من صحة',
msgLoading: 'تحميل ملف {index} من {files} &hellip;',
msgProgress: 'تحميل ملف {index} من {files} - {name} - {percent}% منتهي.',
msgSelected: '{n} {files} مختار(ة)',
Expand All @@ -78,6 +79,7 @@
fileActionSettings: {
removeTitle: 'إزالة الملف',
uploadTitle: 'رفع الملف',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'مشاهدة التفاصيل',
dragTitle: 'Move / Rearrange',
indicatorNewTitle: 'لم يتم الرفع بعد',
Expand Down
4 changes: 3 additions & 1 deletion js/locales/az.js
Expand Up @@ -54,7 +54,8 @@
msgUploadBegin: 'Yoxlama...',
msgUploadEnd: 'Fayl(lar) yükləndi',
msgUploadEmpty: 'Yükləmə üçün verilmiş məlumatlar yanlışdır',
msgValidationError: 'Yoxlama nəticəsi səhvir',
msgUploadError: 'Error',
msgValidationError: : 'Yoxlama nəticəsi səhvir',
msgLoading: '{files} fayldan {index} yüklənir &hellip;',
msgProgress: '{files} fayldan {index} - {name} - {percent}% yükləndi.',
msgSelected: 'Faylların sayı: {n}',
Expand All @@ -78,6 +79,7 @@
fileActionSettings: {
removeTitle: 'Faylı sil',
uploadTitle: 'Faylı yüklə',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'məlumatlara bax',
dragTitle: 'Yerini dəyiş və ya sırala',
indicatorNewTitle: 'Davam edir',
Expand Down
4 changes: 3 additions & 1 deletion js/locales/bg.js
Expand Up @@ -53,7 +53,8 @@
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgValidationError: 'утвърждаване грешка',
msgUploadError: 'Error',
msgValidationError: : 'утвърждаване грешка',
msgLoading: 'Зареждане на файл {index} от общо {files} &hellip;',
msgProgress: 'Зареждане на файл {index} от общо {files} - {name} - {percent}% завършени.',
msgSelected: '{n} {files} избрани',
Expand All @@ -77,6 +78,7 @@
fileActionSettings: {
removeTitle: 'Махни файл',
uploadTitle: 'Качване на файл',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'Вижте детайли',
dragTitle: 'Move / Rearrange',
indicatorNewTitle: 'Все още не е качил',
Expand Down
4 changes: 3 additions & 1 deletion js/locales/ca.js
Expand Up @@ -53,7 +53,8 @@
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgValidationError: 'Error de validació',
msgUploadError: 'Error',
msgValidationError: : 'Error de validació',
msgLoading: 'Pujant fitxer {index} de {files} &hellip;',
msgProgress: 'Pujant fitxer {index} de {files} - {name} - {percent}% completat.',
msgSelected: '{n} {files} seleccionat(s)',
Expand All @@ -77,6 +78,7 @@
fileActionSettings: {
removeTitle: 'Eliminar arxiu',
uploadTitle: 'Pujar arxiu',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'Veure detalls',
dragTitle: 'Move / Rearrange',
indicatorNewTitle: 'No pujat encara',
Expand Down
4 changes: 3 additions & 1 deletion js/locales/cr.js
Expand Up @@ -54,7 +54,8 @@
msgUploadBegin: 'Initializing...',
msgUploadEnd: 'Done',
msgUploadEmpty: 'No valid data available for upload.',
msgValidationError: 'Provjera pogrešaka',
msgUploadError: 'Error',
msgValidationError: : 'Provjera pogrešaka',
msgLoading: 'Učitavanje datoteke {index} od {files} &hellip;',
msgProgress: 'Učitavanje datoteke {index} od {files} - {name} - {percent}% završeno.',
msgSelected: '{n} {files} je označeno',
Expand All @@ -78,6 +79,7 @@
fileActionSettings: {
removeTitle: 'Uklonite datoteku',
uploadTitle: 'Postavi datoteku',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'Pregledavati pojedinosti',
dragTitle: 'Move / Rearrange',
indicatorNewTitle: 'Još nije učitao',
Expand Down
4 changes: 3 additions & 1 deletion js/locales/cz.js
Expand Up @@ -53,7 +53,8 @@
msgUploadBegin: 'Inicializujem...',
msgUploadEnd: 'Hotovo',
msgUploadEmpty: 'Pro nahrávání nejsou k dispozici žádné platné údaje.',
msgValidationError: 'Chyba ověření',
msgUploadError: 'Error',
msgValidationError: : 'Chyba ověření',
msgLoading: 'Nahrávání souboru {index} z {files} &hellip;',
msgProgress: 'Nahrávání souboru {index} z {files} - {name} - {percent}% dokončeno.',
msgSelected: '{n} {files} vybráno',
Expand All @@ -77,6 +78,7 @@
fileActionSettings: {
removeTitle: 'Odstranit soubor',
uploadTitle: 'Nahrát soubor',
uploadRetryTitle: 'Retry upload',
zoomTitle: 'Zobrazit podrobnosti',
dragTitle: 'Posunout / Přeskládat',
indicatorNewTitle: 'Ještě nenahrál',
Expand Down

0 comments on commit 17ab105

Please sign in to comment.