uploader-queue.js revision 66900b43227bf441b6a6b1084af2c96ce2c747c8
/**
* 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) {
currentUploads = {};
lastUploadPointer = 0;
fileListLength = 0;
uploadsLeftCounter = 0;
totalBytesUploaded = 0;
totalBytes = 0;
};
initializer : function (cfg) {
},
_uploadErrorHandler : function (event) {
var updatedEvent = event;
},
_uploadCompleteHandler : function (event) {
uploadsLeftCounter -= 1;
if (lastUploadPointer < fileListLength) {
lastUploadPointer += 1;
}
var updatedEvent = event;
if (uploadsLeftCounter == 0) {
this.fire("alluploadscomplete");
}
},
_uploadProgressHandler : function (event) {
var updatedEvent = event;
var uploadedTotal = totalBytesUploaded;
uploadedTotal += value;
});
},
startUpload: function() {
}
},
pauseUpload: function () {
},
restartUpload: function () {
},
cancelUpload: function () {
}
}, {
NAME: 'uploaderqueue',
ATTRS: {
/**
* @property simUploads
* @type Number
* @description Maximum number of simultaneous uploads
*/
simUploads: {
value: 2,
}
},
errorAction: {
return (val === UploaderQueue.CONTINUE || val === UploaderQueue.STOP || val === UploaderQueue.RESTART);
}
},
readOnly: true,
value: 0
},
bytesTotal: {
readOnly: true,
value: 0
},
fileList: {
value: [],
lazyAdd: false,
});
return val;
}
},
value: "Filedata"
},
uploadURL: {
value: ""
},
value: []
}
},
CONTINUE: "continue",
STOP: "stop",
RESTART: "restart"
});
Y.namespace('Uploader');