|
1098 | 1098 | } else {
|
1099 | 1099 | $btnUpload.removeAttr('disabled');
|
1100 | 1100 | }
|
1101 |
| - self._setProgress(101, $prog, self.msgUploadError); |
1102 |
| - self._setProgress(101, self.$progress, self.msgUploadError); |
| 1101 | + self._setProgress(101, $prog, self.msgProgressError); |
| 1102 | + self._setProgress(101, self.$progress, self.msgProgressError); |
1103 | 1103 | self.cancelling = true;
|
1104 | 1104 | }
|
1105 | 1105 | if (!self.$errorContainer.find('li[data-file-id="' + params.fileId + '"]').length) {
|
|
1108 | 1108 | max: self.resumableUploadOptions.maxRetries,
|
1109 | 1109 | error: rm.error
|
1110 | 1110 | });
|
1111 |
| - self._showUploadError(msg, params); |
| 1111 | + self._showFileError(msg, params); |
1112 | 1112 | }
|
1113 | 1113 | }
|
1114 | 1114 | if (fm.isProcessed()) {
|
|
2043 | 2043 | $error.fadeIn(800);
|
2044 | 2044 | self._raise('filefoldererror', [folders, msg]);
|
2045 | 2045 | },
|
2046 |
| - _showUploadError: function (msg, params, event) { |
| 2046 | + _showFileError: function (msg, params, event) { |
2047 | 2047 | var self = this, $error = self.$errorContainer, ev = event || 'fileuploaderror',
|
2048 | 2048 | fId = params && params.fileId || '', e = params && params.id ?
|
2049 | 2049 | '<li data-thumb-id="' + params.id + '" data-file-id="' + fId + '">' + msg + '</li>' : '<li>' + msg + '</li>';
|
|
3157 | 3157 | var self = this, fm = self.fileManager, count = fm.count(), formdata = new FormData(), outData,
|
3158 | 3158 | previewId = self.previewInitId + '-' + i, $thumb, chkComplete, $btnUpload, $btnDelete,
|
3159 | 3159 | hasPostData = count > 0 || !$.isEmptyObject(self.uploadExtraData), uploadFailed,
|
3160 |
| - $prog, fnBefore, fnSuccess, fnComplete, fnError, updateUploadLog, |
3161 |
| - fileObj = fm.getFile(id), rm = self.resumableManager, |
| 3160 | + $prog, fnBefore, fnSuccess, fnComplete, fnError, updateUploadLog, op = self.ajaxOperations.uploadThumb, |
| 3161 | + errMsg, fileObj = fm.getFile(id), rm = self.resumableManager, |
3162 | 3162 | params = {id: previewId, index: i, fileId: id}, fileName = self.fileManager.getFileName(id, true);
|
3163 | 3163 | if (self.enableResumableUpload) {
|
3164 | 3164 | self.paused = false;
|
|
3269 | 3269 | }
|
3270 | 3270 | } else {
|
3271 | 3271 | uploadFailed = true;
|
3272 |
| - self._showUploadError(data.error, params); |
| 3272 | + errMsg = self._parseError(op, jqXHR, self.msgUploadError, self.fileManager.getFileName(id)); |
| 3273 | + self._showFileError(errMsg, params); |
3273 | 3274 | self._setPreviewError($thumb, true);
|
3274 | 3275 | if (!self.retryErrorUploads) {
|
3275 | 3276 | $btnUpload.hide();
|
|
3298 | 3299 | }, self.processDelay);
|
3299 | 3300 | };
|
3300 | 3301 | fnError = function (jqXHR, textStatus, errorThrown) {
|
3301 |
| - var op = self.ajaxOperations.uploadThumb, |
3302 |
| - errMsg = self._parseError(op, jqXHR, errorThrown, self.fileManager.getFileName(id)); |
| 3302 | + errMsg = self._parseError(op, jqXHR, errorThrown, self.fileManager.getFileName(id)); |
3303 | 3303 | uploadFailed = true;
|
3304 | 3304 | setTimeout(function () {
|
3305 | 3305 | if (isBatch) {
|
|
3313 | 3313 | $.extend(true, params, self._getOutData(formdata, jqXHR));
|
3314 | 3314 | self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op));
|
3315 | 3315 | self._setProgress(101, $thumb.find('.file-thumb-progress'), self.msgUploadError);
|
3316 |
| - self._showUploadError(errMsg, params); |
| 3316 | + self._showFileError(errMsg, params); |
3317 | 3317 | }, self.processDelay);
|
3318 | 3318 | };
|
3319 | 3319 | formdata.append(self.uploadFileAttr, fileObj.file, fileName);
|
|
3322 | 3322 | },
|
3323 | 3323 | _uploadBatch: function () {
|
3324 | 3324 | var self = this, fm = self.fileManager, total = fm.total(), params = {}, fnBefore, fnSuccess, fnError,
|
3325 |
| - fnComplete, hasPostData = total > 0 || !$.isEmptyObject(self.uploadExtraData), |
3326 |
| - setAllUploaded, formdata = new FormData(); |
| 3325 | + fnComplete, hasPostData = total > 0 || !$.isEmptyObject(self.uploadExtraData), errMsg, |
| 3326 | + setAllUploaded, formdata = new FormData(), op = self.ajaxOperations.uploadBatch; |
3327 | 3327 | if (total === 0 || !hasPostData || self._abort(params)) {
|
3328 | 3328 | return;
|
3329 | 3329 | }
|
|
3409 | 3409 | });
|
3410 | 3410 | self._initUploadSuccess(data);
|
3411 | 3411 | }
|
3412 |
| - self._showUploadError(data.error, outData, 'filebatchuploaderror'); |
| 3412 | + errMsg = self._parseError(op, jqXHR, self.msgUploadError); |
| 3413 | + self._showFileError(errMsg, outData, 'filebatchuploaderror'); |
3413 | 3414 | self._setProgress(101, self.$progress, self.msgUploadError);
|
3414 | 3415 | }
|
3415 | 3416 | };
|
|
3420 | 3421 | self._raise('filebatchuploadcomplete', [self.fileManager.stack, self._getExtraData()]);
|
3421 | 3422 | };
|
3422 | 3423 | fnError = function (jqXHR, textStatus, errorThrown) {
|
3423 |
| - var outData = self._getOutData(formdata, jqXHR), op = self.ajaxOperations.uploadBatch, |
3424 |
| - errMsg = self._parseError(op, jqXHR, errorThrown); |
3425 |
| - self._showUploadError(errMsg, outData, 'filebatchuploaderror'); |
| 3424 | + var outData = self._getOutData(formdata, jqXHR); |
| 3425 | + errMsg = self._parseError(op, jqXHR, errorThrown); |
| 3426 | + self._showFileError(errMsg, outData, 'filebatchuploaderror'); |
3426 | 3427 | self.uploadFileCount = total - 1;
|
3427 | 3428 | if (!self.showPreview) {
|
3428 | 3429 | return;
|
|
3449 | 3450 | self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata);
|
3450 | 3451 | },
|
3451 | 3452 | _uploadExtraOnly: function () {
|
3452 |
| - var self = this, params = {}, fnBefore, fnSuccess, fnComplete, fnError, formdata = new FormData(); |
| 3453 | + var self = this, params = {}, fnBefore, fnSuccess, fnComplete, fnError, formdata = new FormData(), errMsg, |
| 3454 | + op = self.ajaxOperations.uploadExtra; |
3453 | 3455 | if (self._abort(params)) {
|
3454 | 3456 | return;
|
3455 | 3457 | }
|
|
3473 | 3475 | self._initUploadSuccess(data);
|
3474 | 3476 | self._setProgress(101);
|
3475 | 3477 | } else {
|
3476 |
| - self._showUploadError(data.error, outData, 'filebatchuploaderror'); |
| 3478 | + errMsg = self._parseError(op, jqXHR, self.msgUploadError); |
| 3479 | + self._showFileError(errMsg, outData, 'filebatchuploaderror'); |
3477 | 3480 | }
|
3478 | 3481 | };
|
3479 | 3482 | fnComplete = function () {
|
|
3482 | 3485 | self._raise('filebatchuploadcomplete', [self.fileManager.stack, self._getExtraData()]);
|
3483 | 3486 | };
|
3484 | 3487 | fnError = function (jqXHR, textStatus, errorThrown) {
|
3485 |
| - var outData = self._getOutData(formdata, jqXHR), op = self.ajaxOperations.uploadExtra, |
3486 |
| - errMsg = self._parseError(op, jqXHR, errorThrown); |
| 3488 | + var outData = self._getOutData(formdata, jqXHR); |
| 3489 | + errMsg = self._parseError(op, jqXHR, errorThrown); |
3487 | 3490 | params.data = outData;
|
3488 |
| - self._showUploadError(errMsg, outData, 'filebatchuploaderror'); |
| 3491 | + self._showFileError(errMsg, outData, 'filebatchuploaderror'); |
3489 | 3492 | self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op));
|
3490 | 3493 | };
|
3491 | 3494 | self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata);
|
|
3587 | 3590 | };
|
3588 | 3591 | self._initZoomButton();
|
3589 | 3592 | $preview.find(btnRemove).each(function () {
|
3590 |
| - var $el = $(this), vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'), |
3591 |
| - fnBefore, fnSuccess, fnError; |
| 3593 | + var $el = $(this), vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'), errMsg, fnBefore, |
| 3594 | + fnSuccess, fnError, op = self.ajaxOperations.deleteThumb; |
3592 | 3595 | if ($h.isEmpty(vUrl) || vKey === undefined) {
|
3593 | 3596 | return;
|
3594 | 3597 | }
|
3595 | 3598 | if (typeof vUrl === 'function') {
|
3596 | 3599 | vUrl = vUrl();
|
3597 | 3600 | }
|
3598 |
| - var $frame = $el.closest($h.FRAMES), cache = self.previewCache.data, |
3599 |
| - settings, params, index = $frame.attr('data-fileindex'), config, extraData; |
| 3601 | + var $frame = $el.closest($h.FRAMES), cache = self.previewCache.data, settings, params, config, |
| 3602 | + fileName, extraData, index = $frame.attr('data-fileindex'); |
3600 | 3603 | index = parseInt(index.replace('init_', ''));
|
3601 | 3604 | config = $h.isEmpty(cache.config) && $h.isEmpty(cache.config[index]) ? null : cache.config[index];
|
3602 | 3605 | extraData = $h.isEmpty(config) || $h.isEmpty(config.extra) ? deleteExtraData : config.extra;
|
| 3606 | + fileName = config.filename || config.caption || ''; |
3603 | 3607 | if (typeof extraData === 'function') {
|
3604 | 3608 | extraData = extraData();
|
3605 | 3609 | }
|
|
3620 | 3624 | if (!$h.isEmpty(data) && !$h.isEmpty(data.error)) {
|
3621 | 3625 | params.jqXHR = jqXHR;
|
3622 | 3626 | params.response = data;
|
3623 |
| - self._showError(data.error, params, 'filedeleteerror'); |
| 3627 | + errMsg = self._parseError(op, jqXHR, self.msgDeleteError, fileName); |
| 3628 | + self._showFileError(errMsg, params, 'filedeleteerror'); |
3624 | 3629 | $frame.removeClass('file-uploading');
|
3625 | 3630 | $el.removeClass('disabled ' + origClass).addClass(errClass);
|
3626 | 3631 | resetProgress();
|
|
3642 | 3647 | });
|
3643 | 3648 | };
|
3644 | 3649 | fnError = function (jqXHR, textStatus, errorThrown) {
|
3645 |
| - var op = self.ajaxOperations.deleteThumb, errMsg = self._parseError(op, jqXHR, errorThrown); |
| 3650 | + var errMsg = self._parseError(op, jqXHR, errorThrown, fileName); |
3646 | 3651 | params.jqXHR = jqXHR;
|
3647 | 3652 | params.response = {};
|
3648 |
| - self._showError(errMsg, params, 'filedeleteerror'); |
| 3653 | + self._showFileError(errMsg, params, 'filedeleteerror'); |
3649 | 3654 | $frame.removeClass('file-uploading');
|
3650 | 3655 | $el.removeClass('disabled ' + origClass).addClass(errClass);
|
3651 | 3656 | resetProgress();
|
|
4110 | 4115 | return;
|
4111 | 4116 | }
|
4112 | 4117 | msg = self['msgImage' + type + chk].setTokens({'name': fname, 'size': limit});
|
4113 |
| - self._showUploadError(msg, params); |
| 4118 | + self._showFileError(msg, params); |
4114 | 4119 | self._setPreviewError($thumb);
|
4115 | 4120 | },
|
4116 | 4121 | _getExifObj: function (data) {
|
|
4213 | 4218 | $thumb = config.thumb, throwError, msg, exifObj = config.exifObj, exifStr, file, params, evParams;
|
4214 | 4219 | throwError = function (msg, params, ev) {
|
4215 | 4220 | if (self.isAjaxUpload) {
|
4216 |
| - self._showUploadError(msg, params, ev); |
| 4221 | + self._showFileError(msg, params, ev); |
4217 | 4222 | } else {
|
4218 | 4223 | self._showError(msg, params, ev);
|
4219 | 4224 | }
|
|
4578 | 4583 | throwError = function (mesg, file, previewId, index) {
|
4579 | 4584 | var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), {id: previewId, index: index}),
|
4580 | 4585 | p2 = {id: previewId, index: index, file: file, files: files};
|
4581 |
| - return isAjaxUpload ? self._showUploadError(mesg, p1) : self._showError(mesg, p2); |
| 4586 | + return isAjaxUpload ? self._showFileError(mesg, p1) : self._showError(mesg, p2); |
4582 | 4587 | },
|
4583 | 4588 | maxCountCheck = function (n, m) {
|
4584 | 4589 | var msg = self.msgFilesTooMany.replace('{m}', m).replace('{n}', n);
|
|
4640 | 4645 | data.abortData = self.ajaxAborted.data || {};
|
4641 | 4646 | data.abortMessage = self.ajaxAborted.message;
|
4642 | 4647 | self._setProgress(101, self.$progress, self.msgCancelled);
|
4643 |
| - self._showUploadError(self.ajaxAborted.message, data, 'filecustomerror'); |
| 4648 | + self._showFileError(self.ajaxAborted.message, data, 'filecustomerror'); |
4644 | 4649 | self.cancel();
|
4645 | 4650 | return true;
|
4646 | 4651 | }
|
|
4670 | 4675 | cnt = cnt || 0;
|
4671 | 4676 | if (self.required && !self.getFilesCount()) {
|
4672 | 4677 | self.$errorContainer.html('');
|
4673 |
| - self._showUploadError(self.msgFileRequired); |
| 4678 | + self._showFileError(self.msgFileRequired); |
4674 | 4679 | return false;
|
4675 | 4680 | }
|
4676 | 4681 | if (self.minFileCount > 0 && self._getFileCount(cnt) < self.minFileCount) {
|
|
4730 | 4735 | }
|
4731 | 4736 | self._initFileActions();
|
4732 | 4737 | $thumb.remove();
|
4733 |
| - self.isError = self.isAjaxUpload ? self._showUploadError(msg, p1) : self._showError(msg, p2); |
| 4738 | + self.isError = self.isAjaxUpload ? self._showFileError(msg, p1) : self._showError(msg, p2); |
4734 | 4739 | self._updateFileDetails(numFiles);
|
4735 | 4740 | };
|
4736 | 4741 | self.fileManager.clearImages();
|
|
5136 | 5141 | self.lastProgress = 0;
|
5137 | 5142 | self._resetUpload();
|
5138 | 5143 | if (totLen === 0 && !hasExtraData) {
|
5139 |
| - self._showUploadError(self.msgUploadEmpty); |
| 5144 | + self._showFileError(self.msgUploadEmpty); |
5140 | 5145 | return;
|
5141 | 5146 | }
|
5142 | 5147 | self.cancelling = false;
|
|
5527 | 5532 | msgUploadEnd: 'Done',
|
5528 | 5533 | msgUploadResume: 'Resuming upload...',
|
5529 | 5534 | msgUploadEmpty: 'No valid data available for upload.',
|
5530 |
| - msgUploadError: 'Error', |
| 5535 | + msgUploadError: 'Upload Error', |
| 5536 | + msgDeleteError: 'Delete Error', |
| 5537 | + msgProgressError: 'Error', |
5531 | 5538 | msgValidationError: 'Validation Error',
|
5532 | 5539 | msgLoading: 'Loading file {index} of {files} …',
|
5533 | 5540 | msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.',
|
|
0 commit comments