|
@@ -683,6 +683,8 @@
|
|
uploadIcon: '<i class="glyphicon glyphicon-upload text-info"></i>',
|
|
uploadIcon: '<i class="glyphicon glyphicon-upload text-info"></i>',
|
|
uploadClass: 'btn btn-xs btn-default',
|
|
uploadClass: 'btn btn-xs btn-default',
|
|
uploadTitle: 'Upload file',
|
|
uploadTitle: 'Upload file',
|
|
|
|
+ uploadRetryIcon: '<i class="glyphicon glyphicon-repeat text-info"></i>',
|
|
|
|
+ uploadRetryTitle: 'Retry upload',
|
|
zoomIcon: '<i class="glyphicon glyphicon-zoom-in"></i>',
|
|
zoomIcon: '<i class="glyphicon glyphicon-zoom-in"></i>',
|
|
zoomClass: 'btn btn-xs btn-default',
|
|
zoomClass: 'btn btn-xs btn-default',
|
|
zoomTitle: 'View Details',
|
|
zoomTitle: 'View Details',
|
|
@@ -1796,7 +1798,7 @@
|
|
var xhrobj = $.ajaxSettings.xhr();
|
|
var xhrobj = $.ajaxSettings.xhr();
|
|
return self._initXhr(xhrobj, previewId, self.getFileStack().length);
|
|
return self._initXhr(xhrobj, previewId, self.getFileStack().length);
|
|
},
|
|
},
|
|
- url: self.uploadUrl,
|
|
|
|
|
|
+ url: index && self.uploadUrlThumb ? self.uploadUrlThumb : self.uploadUrl,
|
|
type: 'POST',
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
dataType: 'json',
|
|
data: self.formdata,
|
|
data: self.formdata,
|
|
@@ -1916,9 +1918,8 @@
|
|
var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
|
|
var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
|
|
previewId = self.previewInitId + "-" + i, $thumb, chkComplete, $btnUpload, $btnDelete,
|
|
previewId = self.previewInitId + "-" + i, $thumb, chkComplete, $btnUpload, $btnDelete,
|
|
hasPostData = self.filestack.length > 0 || !$.isEmptyObject(self.uploadExtraData),
|
|
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;
|
|
self.formdata = formdata;
|
|
if (self.showPreview) {
|
|
if (self.showPreview) {
|
|
$thumb = $('#' + previewId + ':not(.file-preview-initial)');
|
|
$thumb = $('#' + previewId + ':not(.file-preview-initial)');
|
|
@@ -1930,7 +1931,7 @@
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
updateUploadLog = function (i, previewId) {
|
|
updateUploadLog = function (i, previewId) {
|
|
- if (multiUploadMode || !uploadFailed) {
|
|
|
|
|
|
+ if (!uploadFailed) {
|
|
self.updateStack(i, undefined);
|
|
self.updateStack(i, undefined);
|
|
}
|
|
}
|
|
self.uploadLog.push(previewId);
|
|
self.uploadLog.push(previewId);
|
|
@@ -1947,7 +1948,7 @@
|
|
len = data.content.length;
|
|
len = data.content.length;
|
|
}
|
|
}
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
- var triggerReset = multiUploadMode || !uploadFailed;
|
|
|
|
|
|
+ var triggerReset = self.getFileStack(true).length === 0;
|
|
if (self.showPreview) {
|
|
if (self.showPreview) {
|
|
self.previewCache.set(u.content, u.config, u.tags, u.append);
|
|
self.previewCache.set(u.content, u.config, u.tags, u.append);
|
|
if (len) {
|
|
if (len) {
|
|
@@ -2034,10 +2035,14 @@
|
|
} else {
|
|
} else {
|
|
uploadFailed = true;
|
|
uploadFailed = true;
|
|
self._showUploadError(data.error, params);
|
|
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) {
|
|
if (allFiles) {
|
|
updateUploadLog(i, pid);
|
|
updateUploadLog(i, pid);
|
|
}
|
|
}
|
|
|
|
+ self._setProgress(101, $('#' + pid).find('.file-thumb-progress'), self.msgUploadError);
|
|
}
|
|
}
|
|
}, 100);
|
|
}, 100);
|
|
};
|
|
};
|
|
@@ -2066,9 +2071,13 @@
|
|
updateUploadLog(i, previewId);
|
|
updateUploadLog(i, previewId);
|
|
}
|
|
}
|
|
self.uploadStatus[previewId] = 100;
|
|
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));
|
|
$.extend(true, params, self._getOutData(jqXHR));
|
|
self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op));
|
|
self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op));
|
|
|
|
+ self._setProgress(101, $('#' + previewId).find('.file-thumb-progress'), self.msgUploadError);
|
|
self._showUploadError(errMsg, params);
|
|
self._showUploadError(errMsg, params);
|
|
}, 100);
|
|
}, 100);
|
|
};
|
|
};
|
|
@@ -2113,19 +2122,19 @@
|
|
};
|
|
};
|
|
fnSuccess = function (data, textStatus, jqXHR) {
|
|
fnSuccess = function (data, textStatus, jqXHR) {
|
|
/** @namespace data.errorkeys */
|
|
/** @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(':not(.file-preview-success)'),
|
|
keys = $h.isEmpty(data) || $h.isEmpty(data.errorkeys) ? [] : data.errorkeys;
|
|
keys = $h.isEmpty(data) || $h.isEmpty(data.errorkeys) ? [] : data.errorkeys;
|
|
|
|
+
|
|
if ($h.isEmpty(data) || $h.isEmpty(data.error)) {
|
|
if ($h.isEmpty(data) || $h.isEmpty(data.error)) {
|
|
self._raise('filebatchuploadsuccess', [outData]);
|
|
self._raise('filebatchuploadsuccess', [outData]);
|
|
setAllUploaded();
|
|
setAllUploaded();
|
|
if (self.showPreview) {
|
|
if (self.showPreview) {
|
|
$thumbs.each(function () {
|
|
$thumbs.each(function () {
|
|
- var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload');
|
|
|
|
- $thumb.find('.kv-file-upload').hide();
|
|
|
|
|
|
+ var $thumb = $(this);
|
|
self._setThumbStatus($thumb, 'Success');
|
|
self._setThumbStatus($thumb, 'Success');
|
|
$thumb.removeClass('file-uploading');
|
|
$thumb.removeClass('file-uploading');
|
|
- $btnUpload.removeAttr('disabled');
|
|
|
|
|
|
+ $thumb.find('.kv-file-upload').hide().removeAttr('disabled');
|
|
});
|
|
});
|
|
self._initUploadSuccess(data);
|
|
self._initUploadSuccess(data);
|
|
} else {
|
|
} else {
|
|
@@ -2135,27 +2144,29 @@
|
|
} else {
|
|
} else {
|
|
if (self.showPreview) {
|
|
if (self.showPreview) {
|
|
$thumbs.each(function () {
|
|
$thumbs.each(function () {
|
|
- var $thumb = $(this), $btnDelete = $thumb.find('.kv-file-remove'),
|
|
|
|
- $btnUpload = $thumb.find('.kv-file-upload');
|
|
|
|
|
|
+ var $thumb = $(this), i = $thumb.attr('data-fileindex');
|
|
$thumb.removeClass('file-uploading');
|
|
$thumb.removeClass('file-uploading');
|
|
- $btnUpload.removeAttr('disabled');
|
|
|
|
- $btnDelete.removeAttr('disabled');
|
|
|
|
- if (keys.length === 0) {
|
|
|
|
- self._setPreviewError($thumb);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if ($.inArray(key, keys) !== -1) {
|
|
|
|
- self._setPreviewError($thumb);
|
|
|
|
|
|
+ $thumb.find('.kv-file-upload').removeAttr('disabled');
|
|
|
|
+ $thumb.find('.kv-file-remove').removeAttr('disabled');
|
|
|
|
+ if (keys.length === 0 || $.inArray(key, keys) !== -1) {
|
|
|
|
+ self._setPreviewError($thumb, i, self.filestack[i], self.retryErrorUploads);
|
|
|
|
+ if (!self.retryErrorUploads) {
|
|
|
|
+ $thumb.find('.kv-file-upload').hide();
|
|
|
|
+ self.updateStack(i, undefined);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
$thumb.find('.kv-file-upload').hide();
|
|
$thumb.find('.kv-file-upload').hide();
|
|
self._setThumbStatus($thumb, 'Success');
|
|
self._setThumbStatus($thumb, 'Success');
|
|
- self.updateStack(key, undefined);
|
|
|
|
|
|
+ self.updateStack(i, undefined);
|
|
|
|
+ }
|
|
|
|
+ if (!$thumb.hasClass('file-preview-error') || self.retryErrorUploads) {
|
|
|
|
+ key++;
|
|
}
|
|
}
|
|
- key++;
|
|
|
|
});
|
|
});
|
|
self._initUploadSuccess(data);
|
|
self._initUploadSuccess(data);
|
|
}
|
|
}
|
|
self._showUploadError(data.error, outData, 'filebatchuploaderror');
|
|
self._showUploadError(data.error, outData, 'filebatchuploaderror');
|
|
|
|
+ self._setProgress(101, self.$progress, self.msgUploadError);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
fnComplete = function () {
|
|
fnComplete = function () {
|
|
@@ -2303,9 +2314,11 @@
|
|
var $el = $(this);
|
|
var $el = $(this);
|
|
self._handler($el, 'click', function () {
|
|
self._handler($el, 'click', function () {
|
|
var $frame = $el.closest($h.FRAMES), ind = $frame.attr('data-fileindex');
|
|
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);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -2800,9 +2813,6 @@
|
|
$indicator = $thumb.find('.file-upload-indicator'),
|
|
$indicator = $thumb.find('.file-upload-indicator'),
|
|
config = self.fileActionSettings;
|
|
config = self.fileActionSettings;
|
|
$thumb.removeClass('file-preview-success file-preview-error file-preview-loading');
|
|
$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') {
|
|
if (status === 'Success') {
|
|
$thumb.find('.file-drag-handle').remove();
|
|
$thumb.find('.file-drag-handle').remove();
|
|
$indicator.css('margin-left', 0);
|
|
$indicator.css('margin-left', 0);
|
|
@@ -2810,6 +2820,9 @@
|
|
$indicator.html(config[icon]);
|
|
$indicator.html(config[icon]);
|
|
$indicator.attr('title', config[msg]);
|
|
$indicator.attr('title', config[msg]);
|
|
$thumb.addClass(css);
|
|
$thumb.addClass(css);
|
|
|
|
+ if (status === 'Error' && !self.retryErrorUploads) {
|
|
|
|
+ $thumb.find('.kv-file-upload').attr('disabled', true);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
_setProgressCancelled: function () {
|
|
_setProgressCancelled: function () {
|
|
var self = this;
|
|
var self = this;
|
|
@@ -2856,7 +2869,6 @@
|
|
sum += value;
|
|
sum += value;
|
|
});
|
|
});
|
|
self._setProgress(Math.floor(sum / total));
|
|
self._setProgress(Math.floor(sum / total));
|
|
-
|
|
|
|
},
|
|
},
|
|
_validateMinCount: function () {
|
|
_validateMinCount: function () {
|
|
var self = this, len = self.isUploadable ? self.getFileStack().length : self.$element.get(0).files.length;
|
|
var self = this, len = self.isUploadable ? self.getFileStack().length : self.$element.get(0).files.length;
|
|
@@ -2904,16 +2916,29 @@
|
|
return (skipNull ? n !== undefined : n !== undefined && n !== null);
|
|
return (skipNull ? n !== undefined : n !== undefined && n !== null);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- _setPreviewError: function ($thumb, i, val) {
|
|
|
|
|
|
+ _setPreviewError: function ($thumb, i, val, repeat) {
|
|
var self = this;
|
|
var self = this;
|
|
if (i !== undefined) {
|
|
if (i !== undefined) {
|
|
self.updateStack(i, val);
|
|
self.updateStack(i, val);
|
|
}
|
|
}
|
|
- if (self.removeFromPreviewOnError) {
|
|
|
|
|
|
+ if (self.removeFromPreviewOnError && !repeat) {
|
|
$thumb.remove();
|
|
$thumb.remove();
|
|
} else {
|
|
} else {
|
|
self._setThumbStatus($thumb, 'Error');
|
|
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) {
|
|
_checkDimensions: function (i, chk, $img, $thumb, fname, type, params) {
|
|
var self = this, msg, dim, tag = chk === 'Small' ? 'min' : 'max', limit = self[tag + 'Image' + type],
|
|
var self = this, msg, dim, tag = chk === 'Small' ? 'min' : 'max', limit = self[tag + 'Image' + type],
|
|
@@ -3815,6 +3840,7 @@
|
|
uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
|
|
uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
|
|
uploadClass: 'btn btn-default',
|
|
uploadClass: 'btn btn-default',
|
|
uploadUrl: null,
|
|
uploadUrl: null,
|
|
|
|
+ uploadUrlThumb: null,
|
|
uploadAsync: true,
|
|
uploadAsync: true,
|
|
uploadExtraData: {},
|
|
uploadExtraData: {},
|
|
zoomModalHeight: 480,
|
|
zoomModalHeight: 480,
|
|
@@ -3857,7 +3883,8 @@
|
|
textEncoding: 'UTF-8',
|
|
textEncoding: 'UTF-8',
|
|
ajaxSettings: {},
|
|
ajaxSettings: {},
|
|
ajaxDeleteSettings: {},
|
|
ajaxDeleteSettings: {},
|
|
- showAjaxErrorDetails: true
|
|
|
|
|
|
+ showAjaxErrorDetails: true,
|
|
|
|
+ retryErrorUploads: true
|
|
};
|
|
};
|
|
|
|
|
|
$.fn.fileinputLocales.en = {
|
|
$.fn.fileinputLocales.en = {
|
|
@@ -3902,6 +3929,7 @@
|
|
msgUploadBegin: 'Initializing...',
|
|
msgUploadBegin: 'Initializing...',
|
|
msgUploadEnd: 'Done',
|
|
msgUploadEnd: 'Done',
|
|
msgUploadEmpty: 'No valid data available for upload.',
|
|
msgUploadEmpty: 'No valid data available for upload.',
|
|
|
|
+ msgUploadError: 'Error',
|
|
msgValidationError: 'Validation Error',
|
|
msgValidationError: 'Validation Error',
|
|
msgLoading: 'Loading file {index} of {files} …',
|
|
msgLoading: 'Loading file {index} of {files} …',
|
|
msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',
|
|
msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',
|