mirror of
https://github.com/ascribe/onion.git
synced 2025-02-12 08:30:53 +01:00
update fineuploader
This commit is contained in:
parent
bb6deb3f68
commit
bf6b5e00a6
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2015, Widen Enterprises, Inc. info@fineuploader.com
|
* Copyright 2015, Widen Enterprises, Inc. info@fineuploader.com
|
||||||
*
|
*
|
||||||
* Version: 5.2.2
|
* Version: 5.3.0
|
||||||
*
|
*
|
||||||
* Homepage: http://fineuploader.com
|
* Homepage: http://fineuploader.com
|
||||||
*
|
*
|
||||||
@ -894,7 +894,7 @@ var qq = function(element) {
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
/*global qq */
|
/*global qq */
|
||||||
qq.version = "5.2.2";
|
qq.version = "5.3.0";
|
||||||
|
|
||||||
/* globals qq */
|
/* globals qq */
|
||||||
qq.supportedFeatures = (function() {
|
qq.supportedFeatures = (function() {
|
||||||
@ -1928,6 +1928,10 @@ qq.status = {
|
|||||||
this._endpointStore.set(endpoint, id);
|
this._endpointStore.set(endpoint, id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setForm: function(elementOrId) {
|
||||||
|
this._updateFormSupportAndParams(elementOrId);
|
||||||
|
},
|
||||||
|
|
||||||
setItemLimit: function(newItemLimit) {
|
setItemLimit: function(newItemLimit) {
|
||||||
this._currentItemLimit = newItemLimit;
|
this._currentItemLimit = newItemLimit;
|
||||||
},
|
},
|
||||||
@ -1945,16 +1949,11 @@ qq.status = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
uploadStoredFiles: function() {
|
uploadStoredFiles: function() {
|
||||||
var idToUpload;
|
|
||||||
|
|
||||||
if (this._storedIds.length === 0) {
|
if (this._storedIds.length === 0) {
|
||||||
this._itemError("noFilesError");
|
this._itemError("noFilesError");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (this._storedIds.length) {
|
this._uploadStoredFiles();
|
||||||
idToUpload = this._storedIds.shift();
|
|
||||||
this._uploadFile(idToUpload);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2038,10 +2037,11 @@ qq.status = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_createStore: function(initialValue, readOnlyValues) {
|
_createStore: function(initialValue, _readOnlyValues_) {
|
||||||
var store = {},
|
var store = {},
|
||||||
catchall = initialValue,
|
catchall = initialValue,
|
||||||
perIdReadOnlyValues = {},
|
perIdReadOnlyValues = {},
|
||||||
|
readOnlyValues = _readOnlyValues_,
|
||||||
copy = function(orig) {
|
copy = function(orig) {
|
||||||
if (qq.isObject(orig)) {
|
if (qq.isObject(orig)) {
|
||||||
return qq.extend({}, orig);
|
return qq.extend({}, orig);
|
||||||
@ -2095,9 +2095,21 @@ qq.status = {
|
|||||||
addReadOnly: function(id, values) {
|
addReadOnly: function(id, values) {
|
||||||
// Only applicable to Object stores
|
// Only applicable to Object stores
|
||||||
if (qq.isObject(store)) {
|
if (qq.isObject(store)) {
|
||||||
|
// If null ID, apply readonly values to all files
|
||||||
|
if (id === null) {
|
||||||
|
if (qq.isFunction(values)) {
|
||||||
|
readOnlyValues = values;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
readOnlyValues = readOnlyValues || {};
|
||||||
|
qq.extend(readOnlyValues, values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
perIdReadOnlyValues[id] = perIdReadOnlyValues[id] || {};
|
perIdReadOnlyValues[id] = perIdReadOnlyValues[id] || {};
|
||||||
qq.extend(perIdReadOnlyValues[id], values);
|
qq.extend(perIdReadOnlyValues[id], values);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function(fileId) {
|
remove: function(fileId) {
|
||||||
@ -2882,7 +2894,7 @@ qq.status = {
|
|||||||
_onBeforeManualRetry: function(id) {
|
_onBeforeManualRetry: function(id) {
|
||||||
var itemLimit = this._currentItemLimit,
|
var itemLimit = this._currentItemLimit,
|
||||||
fileName;
|
fileName;
|
||||||
console.log(this._handler.isValid(id));
|
|
||||||
if (this._preventRetries[id]) {
|
if (this._preventRetries[id]) {
|
||||||
this.log("Retries are forbidden for id " + id, "warn");
|
this.log("Retries are forbidden for id " + id, "warn");
|
||||||
return false;
|
return false;
|
||||||
@ -3005,13 +3017,14 @@ qq.status = {
|
|||||||
this._onSubmit.apply(this, arguments);
|
this._onSubmit.apply(this, arguments);
|
||||||
this._uploadData.setStatus(id, qq.status.SUBMITTED);
|
this._uploadData.setStatus(id, qq.status.SUBMITTED);
|
||||||
this._onSubmitted.apply(this, arguments);
|
this._onSubmitted.apply(this, arguments);
|
||||||
this._options.callbacks.onSubmitted.apply(this, arguments);
|
|
||||||
|
|
||||||
if (this._options.autoUpload) {
|
if (this._options.autoUpload) {
|
||||||
|
this._options.callbacks.onSubmitted.apply(this, arguments);
|
||||||
this._uploadFile(id);
|
this._uploadFile(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._storeForLater(id);
|
this._storeForLater(id);
|
||||||
|
this._options.callbacks.onSubmitted.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -3238,6 +3251,23 @@ qq.status = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateFormSupportAndParams: function(formElementOrId) {
|
||||||
|
this._options.form.element = formElementOrId;
|
||||||
|
|
||||||
|
this._formSupport = qq.FormSupport && new qq.FormSupport(
|
||||||
|
this._options.form, qq.bind(this.uploadStoredFiles, this), qq.bind(this.log, this)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this._formSupport && this._formSupport.attachedToForm) {
|
||||||
|
this._paramsStore.addReadOnly(null, this._formSupport.getFormInputsAsObject);
|
||||||
|
|
||||||
|
this._options.autoUpload = this._formSupport.newAutoUpload;
|
||||||
|
if (this._formSupport.newEndpoint) {
|
||||||
|
this.setEndpoint(this._formSupport.newEndpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_upload: function(id, params, endpoint) {
|
_upload: function(id, params, endpoint) {
|
||||||
var name = this.getName(id);
|
var name = this.getName(id);
|
||||||
|
|
||||||
@ -3264,6 +3294,25 @@ qq.status = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_uploadStoredFiles: function() {
|
||||||
|
var idToUpload, stillSubmitting,
|
||||||
|
self = this;
|
||||||
|
|
||||||
|
while (this._storedIds.length) {
|
||||||
|
idToUpload = this._storedIds.shift();
|
||||||
|
this._uploadFile(idToUpload);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are still waiting for some files to clear validation, attempt to upload these again in a bit
|
||||||
|
stillSubmitting = this.getUploads({status: qq.status.SUBMITTING}).length;
|
||||||
|
if (stillSubmitting) {
|
||||||
|
qq.log("Still waiting for " + stillSubmitting + " files to clear submit queue. Will re-parse stored IDs array shortly.");
|
||||||
|
setTimeout(function() {
|
||||||
|
self._uploadStoredFiles();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs some internal validation checks on an item, defined in the `validation` option.
|
* Performs some internal validation checks on an item, defined in the `validation` option.
|
||||||
*
|
*
|
||||||
@ -5271,6 +5320,7 @@ qq.XhrUploadHandler = function(spec) {
|
|||||||
*/
|
*/
|
||||||
getResumableFilesData: function() {
|
getResumableFilesData: function() {
|
||||||
var resumableFilesData = [];
|
var resumableFilesData = [];
|
||||||
|
|
||||||
handler._iterateResumeRecords(function(key, uploadData) {
|
handler._iterateResumeRecords(function(key, uploadData) {
|
||||||
handler.moveInProgressToRemaining(null, uploadData.chunking.inProgress, uploadData.chunking.remaining);
|
handler.moveInProgressToRemaining(null, uploadData.chunking.inProgress, uploadData.chunking.remaining);
|
||||||
|
|
||||||
@ -5461,7 +5511,7 @@ qq.XhrUploadHandler = function(spec) {
|
|||||||
_iterateResumeRecords: function(callback) {
|
_iterateResumeRecords: function(callback) {
|
||||||
if (resumeEnabled) {
|
if (resumeEnabled) {
|
||||||
qq.each(localStorage, function(key, item) {
|
qq.each(localStorage, function(key, item) {
|
||||||
if (key.indexOf(qq.format("qq{}resume-", namespace)) === 0) {
|
if (key.indexOf(qq.format("qq{}resume", namespace)) === 0) {
|
||||||
var uploadData = JSON.parse(item);
|
var uploadData = JSON.parse(item);
|
||||||
callback(key, uploadData);
|
callback(key, uploadData);
|
||||||
}
|
}
|
||||||
@ -5728,7 +5778,9 @@ qq.WindowReceiveMessage = function(o) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getItemByFileId: function(id) {
|
getItemByFileId: function(id) {
|
||||||
|
if (!this._templating.isHiddenForever(id)) {
|
||||||
return this._templating.getFileContainer(id);
|
return this._templating.getFileContainer(id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
@ -6238,11 +6290,6 @@ qq.WindowReceiveMessage = function(o) {
|
|||||||
dontDisplay = this._handler.isProxied(id) && this._options.scaling.hideScaled,
|
dontDisplay = this._handler.isProxied(id) && this._options.scaling.hideScaled,
|
||||||
record;
|
record;
|
||||||
|
|
||||||
// If we don't want this file to appear in the UI, skip all of this UI-related logic.
|
|
||||||
if (dontDisplay) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._options.display.prependFiles) {
|
if (this._options.display.prependFiles) {
|
||||||
if (this._totalFilesInBatch > 1 && this._filesInBatchAddedToUi > 0) {
|
if (this._totalFilesInBatch > 1 && this._filesInBatchAddedToUi > 0) {
|
||||||
prependIndex = this._filesInBatchAddedToUi - 1;
|
prependIndex = this._filesInBatchAddedToUi - 1;
|
||||||
@ -6274,7 +6321,7 @@ qq.WindowReceiveMessage = function(o) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._templating.addFile(id, this._options.formatFileName(name), prependData);
|
this._templating.addFile(id, this._options.formatFileName(name), prependData, dontDisplay);
|
||||||
|
|
||||||
if (canned) {
|
if (canned) {
|
||||||
this._thumbnailUrls[id] && this._templating.updateThumbnail(id, this._thumbnailUrls[id], true);
|
this._thumbnailUrls[id] && this._templating.updateThumbnail(id, this._thumbnailUrls[id], true);
|
||||||
@ -6638,6 +6685,7 @@ qq.Templating = function(spec) {
|
|||||||
HIDE_DROPZONE_ATTR = "qq-hide-dropzone",
|
HIDE_DROPZONE_ATTR = "qq-hide-dropzone",
|
||||||
DROPZPONE_TEXT_ATTR = "qq-drop-area-text",
|
DROPZPONE_TEXT_ATTR = "qq-drop-area-text",
|
||||||
IN_PROGRESS_CLASS = "qq-in-progress",
|
IN_PROGRESS_CLASS = "qq-in-progress",
|
||||||
|
HIDDEN_FOREVER_CLASS = "qq-hidden-forever",
|
||||||
isCancelDisabled = false,
|
isCancelDisabled = false,
|
||||||
generatedThumbnails = 0,
|
generatedThumbnails = 0,
|
||||||
thumbnailQueueMonitorRunning = false,
|
thumbnailQueueMonitorRunning = false,
|
||||||
@ -7273,7 +7321,7 @@ qq.Templating = function(spec) {
|
|||||||
isCancelDisabled = true;
|
isCancelDisabled = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
addFile: function(id, name, prependInfo) {
|
addFile: function(id, name, prependInfo, hideForever) {
|
||||||
var fileEl = qq.toElement(templateHtml.fileTemplate),
|
var fileEl = qq.toElement(templateHtml.fileTemplate),
|
||||||
fileNameEl = getTemplateEl(fileEl, selectorClasses.file),
|
fileNameEl = getTemplateEl(fileEl, selectorClasses.file),
|
||||||
uploaderEl = getTemplateEl(container, selectorClasses.uploader),
|
uploaderEl = getTemplateEl(container, selectorClasses.uploader),
|
||||||
@ -7296,6 +7344,11 @@ qq.Templating = function(spec) {
|
|||||||
fileList.appendChild(fileEl);
|
fileList.appendChild(fileEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hideForever) {
|
||||||
|
fileEl.style.display = "none";
|
||||||
|
qq(fileEl).addClass(HIDDEN_FOREVER_CLASS);
|
||||||
|
}
|
||||||
|
else {
|
||||||
hide(getProgress(id));
|
hide(getProgress(id));
|
||||||
hide(getSize(id));
|
hide(getSize(id));
|
||||||
hide(getDelete(id));
|
hide(getDelete(id));
|
||||||
@ -7321,6 +7374,7 @@ qq.Templating = function(spec) {
|
|||||||
show(thumb);
|
show(thumb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
removeFile: function(id) {
|
removeFile: function(id) {
|
||||||
@ -7413,6 +7467,10 @@ qq.Templating = function(spec) {
|
|||||||
icon && qq(icon).addClass(options.classes.editable);
|
icon && qq(icon).addClass(options.classes.editable);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isHiddenForever: function(id) {
|
||||||
|
return qq(getFile(id)).hasClass(HIDDEN_FOREVER_CLASS);
|
||||||
|
},
|
||||||
|
|
||||||
hideEditIcon: function(id) {
|
hideEditIcon: function(id) {
|
||||||
var icon = getEditIcon(id);
|
var icon = getEditIcon(id);
|
||||||
|
|
||||||
@ -7572,13 +7630,17 @@ qq.Templating = function(spec) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
generatePreview: function(id, optFileOrBlob) {
|
generatePreview: function(id, optFileOrBlob) {
|
||||||
|
if (!this.isHiddenForever(id)) {
|
||||||
thumbGenerationQueue.push({id: id, optFileOrBlob: optFileOrBlob});
|
thumbGenerationQueue.push({id: id, optFileOrBlob: optFileOrBlob});
|
||||||
!thumbnailQueueMonitorRunning && generateNextQueuedPreview();
|
!thumbnailQueueMonitorRunning && generateNextQueuedPreview();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateThumbnail: function(id, thumbnailUrl, showWaitingImg) {
|
updateThumbnail: function(id, thumbnailUrl, showWaitingImg) {
|
||||||
|
if (!this.isHiddenForever(id)) {
|
||||||
thumbGenerationQueue.push({update: true, id: id, thumbnailUrl: thumbnailUrl, showWaitingImg: showWaitingImg});
|
thumbGenerationQueue.push({update: true, id: id, thumbnailUrl: thumbnailUrl, showWaitingImg: showWaitingImg});
|
||||||
!thumbnailQueueMonitorRunning && generateNextQueuedPreview();
|
!thumbnailQueueMonitorRunning && generateNextQueuedPreview();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hasDialog: function(type) {
|
hasDialog: function(type) {
|
||||||
@ -9489,12 +9551,6 @@ qq.s3.XhrUploadHandler = function(spec, proxy) {
|
|||||||
result.success,
|
result.success,
|
||||||
|
|
||||||
function failure(reason, xhr) {
|
function failure(reason, xhr) {
|
||||||
console.logGlobal(reason + 'in chunked.combine', false, {
|
|
||||||
uploadId,
|
|
||||||
etagMap,
|
|
||||||
result
|
|
||||||
});
|
|
||||||
|
|
||||||
result.failure(upload.done(id, xhr).response, xhr);
|
result.failure(upload.done(id, xhr).response, xhr);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -12335,7 +12391,7 @@ qq.Scaler = function(spec, log) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var self = this,
|
var self = this,
|
||||||
includeReference = spec.sendOriginal,
|
includeOriginal = spec.sendOriginal,
|
||||||
orient = spec.orient,
|
orient = spec.orient,
|
||||||
defaultType = spec.defaultType,
|
defaultType = spec.defaultType,
|
||||||
defaultQuality = spec.defaultQuality / 100,
|
defaultQuality = spec.defaultQuality / 100,
|
||||||
@ -12385,16 +12441,18 @@ qq.Scaler = function(spec, log) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
includeReference && records.push({
|
records.push({
|
||||||
uuid: originalFileUuid,
|
uuid: originalFileUuid,
|
||||||
name: originalFileName,
|
name: originalFileName,
|
||||||
blob: originalBlob
|
size: originalBlob.size,
|
||||||
|
blob: includeOriginal ? originalBlob : null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
records.push({
|
records.push({
|
||||||
uuid: originalFileUuid,
|
uuid: originalFileUuid,
|
||||||
name: originalFileName,
|
name: originalFileName,
|
||||||
|
size: originalBlob.size,
|
||||||
blob: originalBlob
|
blob: originalBlob
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -12413,19 +12471,17 @@ qq.Scaler = function(spec, log) {
|
|||||||
proxyGroupId = qq.getUniqueId();
|
proxyGroupId = qq.getUniqueId();
|
||||||
|
|
||||||
qq.each(self.getFileRecords(uuid, name, file), function(idx, record) {
|
qq.each(self.getFileRecords(uuid, name, file), function(idx, record) {
|
||||||
var relatedBlob = file,
|
var blobSize = record.size,
|
||||||
relatedSize = size,
|
|
||||||
id;
|
id;
|
||||||
|
|
||||||
if (record.blob instanceof qq.BlobProxy) {
|
if (record.blob instanceof qq.BlobProxy) {
|
||||||
relatedBlob = record.blob;
|
blobSize = -1;
|
||||||
relatedSize = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
id = uploadData.addFile({
|
id = uploadData.addFile({
|
||||||
uuid: record.uuid,
|
uuid: record.uuid,
|
||||||
name: record.name,
|
name: record.name,
|
||||||
size: relatedSize,
|
size: blobSize,
|
||||||
batchId: batchId,
|
batchId: batchId,
|
||||||
proxyGroupId: proxyGroupId
|
proxyGroupId: proxyGroupId
|
||||||
});
|
});
|
||||||
@ -12437,10 +12493,13 @@ qq.Scaler = function(spec, log) {
|
|||||||
originalId = id;
|
originalId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
addFileToHandler(id, relatedBlob);
|
if (record.blob) {
|
||||||
|
addFileToHandler(id, record.blob);
|
||||||
fileList.push({id: id, file: relatedBlob});
|
fileList.push({id: id, file: record.blob});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uploadData.setStatus(id, qq.status.REJECTED);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we are potentially uploading an original file and some scaled versions,
|
// If we are potentially uploading an original file and some scaled versions,
|
||||||
@ -12453,8 +12512,8 @@ qq.Scaler = function(spec, log) {
|
|||||||
qqparentsize: uploadData.retrieve({id: originalId}).size
|
qqparentsize: uploadData.retrieve({id: originalId}).size
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make SURE the UUID for each scaled image is sent with the upload request,
|
// Make sure the UUID for each scaled image is sent with the upload request,
|
||||||
// to be consistent (since we need to ensure it is sent for the original file as well).
|
// to be consistent (since we may need to ensure it is sent for the original file as well).
|
||||||
params[uuidParamName] = uploadData.retrieve({id: scaledId}).uuid;
|
params[uuidParamName] = uploadData.retrieve({id: scaledId}).uuid;
|
||||||
|
|
||||||
uploadData.setParentId(scaledId, originalId);
|
uploadData.setParentId(scaledId, originalId);
|
||||||
@ -14411,4 +14470,4 @@ code.google.com/p/crypto-js/wiki/License
|
|||||||
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*! 2015-06-09 */
|
/*! 2015-08-26 */
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user