uploader-queue-debug.js revision bb2dfd6657cd525faa66dd17e2d809ac775be8fa
/**
* The class manages a queue of files that should be uploaded to the server.
* It initializes the required number of uploads, tracks them as they progress,
* and automatically advances to the next upload when a preceding one has completed.
* @module uploader-queue
*/
/**
* The class manages a queue of files to be uploaded to the server.
* @class UploaderQueue
* @extends Base
* @constructor
*/
var UploaderQueue = function(o) {
this.queuedFiles = [];
this.numberOfUploads = 0;
this.currentUploadedByteValues = {};
this.currentFiles = {};
this.totalBytesUploaded = 0;
this.totalBytes = 0;
};
initializer : function (cfg) {
},
_uploadStartHandler : function (event) {
var updatedEvent = event;
},
_uploadErrorHandler : function (event) {
var updatedEvent = event;
this.numberOfUploads-=1;
this.pauseUpload();
}
this._startNextFile();
}
this._startNextFile();
}
},
_startNextFile : function () {
this._registerUpload(currentFile);
}
},
_registerUpload : function (file) {
this.numberOfUploads += 1;
},
_unregisterUpload : function (file) {
if (this.numberOfUploads > 0) {
this.numberOfUploads -=1;
}
},
_uploadCompleteHandler : function (event) {
this._startNextFile();
}
var updatedEvent = event;
this.fire("alluploadscomplete");
}
},
_uploadProgressHandler : function (event) {
var updatedEvent = event;
var uploadedTotal = this.totalBytesUploaded;
uploadedTotal += value;
});
bytesTotal: this.totalBytes,
},
startUpload: function() {
this.numberOfUploads = 0;
this.currentUploadedByteValues = {};
this.currentFiles = {};
this.totalBytesUploaded = 0;
this._startNextFile();
}
},
pauseUpload: function () {
},
restartUpload: function () {
this._startNextFile();
}
},
forceReupload : function (file) {
file.cancelUpload();
this._unregisterUpload(file);
this._startNextFile();
}
},
cancelUpload: function (file) {
for (var fid in this.currentFiles) {
}
this.currentUploadedByteValues = {};
this.currentFiles = {};
this.totalBytesUploaded = 0;
}
},
{
CONTINUE: "continue",
STOP: "stop",
RESTART_ASAP: "restartasap",
RESTART_AFTER: "restartafter",
STOPPED: "stopped",
UPLOADING: "uploading",
NAME: 'uploaderqueue',
ATTRS: {
/**
* @property simUploads
* @type Number
* @description Maximum number of simultaneous uploads
*/
simUploads: {
value: 2,
}
},
errorAction: {
value: "continue",
return (val === UploaderQueue.CONTINUE || val === UploaderQueue.STOP || val === UploaderQueue.RESTART_ASAP || val === UploaderQueue.RESTART_AFTER);
}
},
readOnly: true,
value: 0
},
bytesTotal: {
readOnly: true,
value: 0
},
fileList: {
value: [],
lazyAdd: false,
}, this);
return val;
}
},
value: "Filedata"
},
uploadURL: {
value: ""
},
value: {}
}
}
});
Y.namespace('Uploader');