How to use uploader method in Best

Best JavaScript code snippet using best

uploader-queue-coverage.js

Source:uploader-queue-coverage.js Github

copy

Full Screen

1/*2YUI 3.7.3 (build 5687)3Copyright 2012 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7if (typeof _yuitest_coverage == "undefined"){8 _yuitest_coverage = {};9 _yuitest_coverline = function(src, line){10 var coverage = _yuitest_coverage[src];11 if (!coverage.lines[line]){12 coverage.calledLines++;13 }14 coverage.lines[line]++;15 };16 _yuitest_coverfunc = function(src, name, line){17 var coverage = _yuitest_coverage[src],18 funcId = name + ":" + line;19 if (!coverage.functions[funcId]){20 coverage.calledFunctions++;21 }22 coverage.functions[funcId]++;23 };24}25_yuitest_coverage["build/uploader-queue/uploader-queue.js"] = {26 lines: {},27 functions: {},28 coveredLines: 0,29 calledLines: 0,30 coveredFunctions: 0,31 calledFunctions: 0,32 path: "build/uploader-queue/uploader-queue.js",33 code: []34};35_yuitest_coverage["build/uploader-queue/uploader-queue.js"].code=["YUI.add('uploader-queue', function (Y, NAME) {","",""," /**"," * 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"," */ ",""," var Lang = Y.Lang,"," Bind = Y.bind,"," Win = Y.config.win,"," queuedFiles,"," numberOfUploads, "," currentUploadedByteValues,"," currentFiles,"," totalBytesUploaded,"," totalBytes;",""," /**"," * This class manages a queue of files to be uploaded to the server."," * @class Uploader.Queue"," * @extends Base"," * @constructor"," * @param {Object} config Configuration object"," */"," var UploaderQueue = function(o) {"," this.queuedFiles = [];"," this.uploadRetries = {};"," this.numberOfUploads = 0;"," this.currentUploadedByteValues = {};"," this.currentFiles = {};"," this.totalBytesUploaded = 0;"," this.totalBytes = 0; "," "," UploaderQueue.superclass.constructor.apply(this, arguments);"," };","",""," Y.extend(UploaderQueue, Y.Base, {",""," /**"," * Stored value of the current queue state"," * @property _currentState"," * @type {String}"," * @protected"," * @default UploaderQueue.STOPPED"," */"," _currentState: UploaderQueue.STOPPED,",""," /**"," * Construction logic executed during UploaderQueue instantiation."," *"," * @method initializer"," * @protected"," */"," initializer : function (cfg) {",""," },",""," /**"," * Handles and retransmits upload start event."," * "," * @method _uploadStartHandler"," * @param event The event dispatched during the upload process."," * @private"," */"," _uploadStartHandler : function (event) {"," var updatedEvent = event;"," updatedEvent.file = event.target;"," updatedEvent.originEvent = event;"," "," this.fire(\"uploadstart\", updatedEvent); "," },",""," /**"," * Handles and retransmits upload error event."," * "," * @method _uploadErrorHandler"," * @param event The event dispatched during the upload process."," * @private"," */"," _uploadErrorHandler : function (event) {"," var errorAction = this.get(\"errorAction\");"," var updatedEvent = event;"," updatedEvent.file = event.target;"," updatedEvent.originEvent = event;",""," this.numberOfUploads-=1;"," delete this.currentFiles[event.target.get(\"id\")];"," this._detachFileEvents(event.target);",""," event.target.cancelUpload();",""," if (errorAction === UploaderQueue.STOP) {"," this.pauseUpload();"," }",""," else if (errorAction === UploaderQueue.RESTART_ASAP) {"," var fileid = event.target.get(\"id\"),"," retries = this.uploadRetries[fileid] || 0;"," if (retries < this.get(\"retryCount\")) {"," this.uploadRetries[fileid] = retries + 1;"," this.addToQueueTop(event.target);"," }"," this._startNextFile();"," }"," else if (errorAction === UploaderQueue.RESTART_AFTER) {"," var fileid = event.target.get(\"id\"),"," retries = this.uploadRetries[fileid] || 0;"," if (retries < this.get(\"retryCount\")) {"," this.uploadRetries[fileid] = retries + 1;"," this.addToQueueBottom(event.target);"," }"," this._startNextFile();"," }",""," this.fire(\"uploaderror\", updatedEvent); "," },",""," /**"," * Launches the upload of the next file in the queue."," * "," * @method _startNextFile"," * @private"," */"," _startNextFile : function () {"," if (this.queuedFiles.length > 0) {"," var currentFile = this.queuedFiles.shift(),"," fileId = currentFile.get(\"id\"),"," parameters = this.get(\"perFileParameters\"),"," fileParameters = parameters.hasOwnProperty(fileId) ? parameters[fileId] : parameters;",""," this.currentUploadedByteValues[fileId] = 0;",""," currentFile.on(\"uploadstart\", this._uploadStartHandler, this);"," currentFile.on(\"uploadprogress\", this._uploadProgressHandler, this);"," currentFile.on(\"uploadcomplete\", this._uploadCompleteHandler, this);"," currentFile.on(\"uploaderror\", this._uploadErrorHandler, this);"," currentFile.on(\"uploadcancel\", this._uploadCancelHandler, this);",""," currentFile.set(\"xhrHeaders\", this.get(\"uploadHeaders\"));"," currentFile.set(\"xhrWithCredentials\", this.get(\"withCredentials\"));",""," currentFile.startUpload(this.get(\"uploadURL\"), fileParameters, this.get(\"fileFieldName\"));",""," this._registerUpload(currentFile);"," }"," },",""," /**"," * Register a new upload process."," * "," * @method _registerUpload"," * @private"," */"," _registerUpload : function (file) {"," this.numberOfUploads += 1;"," this.currentFiles[file.get(\"id\")] = file;"," },",""," /**"," * Unregisters a new upload process."," * "," * @method _unregisterUpload"," * @private"," */"," _unregisterUpload : function (file) {"," if (this.numberOfUploads > 0) {"," this.numberOfUploads -=1;"," }"," delete this.currentFiles[file.get(\"id\")];"," delete this.uploadRetries[file.get(\"id\")];",""," this._detachFileEvents(file);"," },",""," _detachFileEvents : function (file) {"," file.detach(\"uploadstart\", this._uploadStartHandler);"," file.detach(\"uploadprogress\", this._uploadProgressHandler);"," file.detach(\"uploadcomplete\", this._uploadCompleteHandler);"," file.detach(\"uploaderror\", this._uploadErrorHandler);"," file.detach(\"uploadcancel\", this._uploadCancelHandler);"," },",""," /**"," * Handles and retransmits upload complete event."," * "," * @method _uploadCompleteHandler"," * @param event The event dispatched during the upload process."," * @private"," */"," _uploadCompleteHandler : function (event) {",""," this._unregisterUpload(event.target);",""," this.totalBytesUploaded += event.target.get(\"size\");"," delete this.currentUploadedByteValues[event.target.get(\"id\")];","",""," if (this.queuedFiles.length > 0 && this._currentState === UploaderQueue.UPLOADING) {"," this._startNextFile();"," }"," "," var updatedEvent = event;"," updatedEvent.file = event.target;"," updatedEvent.originEvent = event;",""," var uploadedTotal = this.totalBytesUploaded;",""," Y.each(this.currentUploadedByteValues, function (value) {"," uploadedTotal += value; "," });"," "," var percentLoaded = Math.min(100, Math.round(10000*uploadedTotal/this.totalBytes) / 100); "," "," this.fire(\"totaluploadprogress\", {bytesLoaded: uploadedTotal, "," bytesTotal: this.totalBytes,"," percentLoaded: percentLoaded});",""," this.fire(\"uploadcomplete\", updatedEvent);",""," if (this.queuedFiles.length === 0 && this.numberOfUploads <= 0) {"," this.fire(\"alluploadscomplete\");"," this._currentState = UploaderQueue.STOPPED;"," }","",""," },",""," /**"," * Handles and retransmits upload cancel event."," * "," * @method _uploadCancelHandler"," * @param event The event dispatched during the upload process."," * @private"," */"," _uploadCancelHandler : function (event) {"," "," var updatedEvent = event;"," updatedEvent.originEvent = event;"," updatedEvent.file = event.target;",""," this.fire(\"uploadcacel\", updatedEvent);"," },","","",""," /**"," * Handles and retransmits upload progress event."," * "," * @method _uploadProgressHandler"," * @param event The event dispatched during the upload process."," * @private"," */"," _uploadProgressHandler : function (event) {"," "," this.currentUploadedByteValues[event.target.get(\"id\")] = event.bytesLoaded;"," "," var updatedEvent = event;"," updatedEvent.originEvent = event;"," updatedEvent.file = event.target;",""," this.fire(\"uploadprogress\", updatedEvent);"," "," var uploadedTotal = this.totalBytesUploaded;",""," Y.each(this.currentUploadedByteValues, function (value) {"," uploadedTotal += value; "," });"," "," var percentLoaded = Math.min(100, Math.round(10000*uploadedTotal/this.totalBytes) / 100);",""," this.fire(\"totaluploadprogress\", {bytesLoaded: uploadedTotal, "," bytesTotal: this.totalBytes,"," percentLoaded: percentLoaded});"," },",""," /**"," * Starts uploading the queued up file list."," * "," * @method startUpload"," */"," startUpload: function() {"," "," this.queuedFiles = this.get(\"fileList\").slice(0);"," this.numberOfUploads = 0;"," this.currentUploadedByteValues = {};"," this.currentFiles = {};"," this.totalBytesUploaded = 0;"," "," this._currentState = UploaderQueue.UPLOADING;",""," while (this.numberOfUploads < this.get(\"simUploads\") && this.queuedFiles.length > 0) {"," this._startNextFile();"," }"," },",""," /**"," * Pauses the upload process. The ongoing file uploads"," * will complete after this method is called, but no"," * new ones will be launched."," * "," * @method pauseUpload"," */"," pauseUpload: function () {"," this._currentState = UploaderQueue.STOPPED;"," },",""," /**"," * Restarts a paused upload process."," * "," * @method restartUpload"," */"," restartUpload: function () {"," this._currentState = UploaderQueue.UPLOADING;"," while (this.numberOfUploads < this.get(\"simUploads\")) {"," this._startNextFile();"," }"," },",""," /**"," * If a particular file is stuck in an ongoing upload without"," * any progress events, this method allows to force its reupload"," * by cancelling its upload and immediately relaunching it."," * "," * @method forceReupload"," * @param file {Y.File} The file to force reupload on."," */"," forceReupload : function (file) {"," var id = file.get(\"id\");"," if (this.currentFiles.hasOwnProperty(id)) {"," file.cancelUpload();"," this._unregisterUpload(file);"," this.addToQueueTop(file);"," this._startNextFile();"," }"," },",""," /**"," * Add a new file to the top of the queue (the upload will be"," * launched as soon as the current number of uploading files"," * drops below the maximum permissible value)."," * "," * @method addToQueueTop"," * @param file {Y.File} The file to add to the top of the queue."," */"," addToQueueTop: function (file) {"," this.queuedFiles.unshift(file);"," },",""," /**"," * Add a new file to the bottom of the queue (the upload will be"," * launched after all the other queued files are uploaded.)"," * "," * @method addToQueueBottom"," * @param file {Y.File} The file to add to the bottom of the queue."," */"," addToQueueBottom: function (file) {"," this.queuedFiles.push(file);"," },",""," /**"," * Cancels a specific file's upload. If no argument is passed,"," * all ongoing uploads are cancelled and the upload process is"," * stopped."," * "," * @method cancelUpload"," * @param file {Y.File} An optional parameter - the file whose upload"," * should be cancelled."," */"," cancelUpload: function (file) {",""," if (file) {"," var id = file.get(\"id\");"," if (this.currentFiles[id]) {"," this.currentFiles[id].cancelUpload();"," this._unregisterUpload(this.currentFiles[id]);"," if (this._currentState === UploaderQueue.UPLOADING) {"," this._startNextFile();"," }"," }"," else {"," for (var i = 0, len = this.queuedFiles.length; i < len; i++) {"," if (this.queuedFiles[i].get(\"id\") === id) {"," this.queuedFiles.splice(i, 1);"," break;"," }"," }"," }"," }"," else {"," for (var fid in this.currentFiles) {"," this.currentFiles[fid].cancelUpload();"," this._unregisterUpload(this.currentFiles[fid]);"," }",""," this.currentUploadedByteValues = {};"," this.currentFiles = {};"," this.totalBytesUploaded = 0;"," this.fire(\"alluploadscancelled\");"," this._currentState = UploaderQueue.STOPPED;"," }"," }"," }, ",""," {"," /** "," * Static constant for the value of the `errorAction` attribute:"," * prescribes the queue to continue uploading files in case of "," * an error."," * @property CONTINUE"," * @readOnly"," * @type {String}"," * @static"," */"," CONTINUE: \"continue\",",""," /** "," * Static constant for the value of the `errorAction` attribute:"," * prescribes the queue to stop uploading files in case of "," * an error."," * @property STOP"," * @readOnly"," * @type {String}"," * @static"," */"," STOP: \"stop\",",""," /** "," * Static constant for the value of the `errorAction` attribute:"," * prescribes the queue to restart a file upload immediately in case of "," * an error."," * @property RESTART_ASAP"," * @readOnly"," * @type {String}"," * @static"," */"," RESTART_ASAP: \"restartasap\",",""," /** "," * Static constant for the value of the `errorAction` attribute:"," * prescribes the queue to restart an errored out file upload after "," * other files have finished uploading."," * @property RESTART_AFTER"," * @readOnly"," * @type {String}"," * @static"," */"," RESTART_AFTER: \"restartafter\",",""," /** "," * Static constant for the value of the `_currentState` property:"," * implies that the queue is currently not uploading files."," * @property STOPPED"," * @readOnly"," * @type {String}"," * @static"," */"," STOPPED: \"stopped\",",""," /** "," * Static constant for the value of the `_currentState` property:"," * implies that the queue is currently uploading files."," * @property UPLOADING"," * @readOnly"," * @type {String}"," * @static"," */"," UPLOADING: \"uploading\",",""," /**"," * The identity of the class."," *"," * @property NAME"," * @type String"," * @default 'uploaderqueue'"," * @readOnly"," * @protected"," * @static"," */"," NAME: 'uploaderqueue',",""," /**"," * Static property used to define the default attribute configuration of"," * the class."," *"," * @property ATTRS"," * @type {Object}"," * @protected"," * @static"," */"," ATTRS: {"," "," /**"," * Maximum number of simultaneous uploads; must be in the"," * range between 1 and 5. The value of `2` is default. It"," * is recommended that this value does not exceed 3."," * @property simUploads"," * @type Number"," * @default 2"," */"," simUploads: {"," value: 2,"," validator: function (val, name) {"," return (val >= 1 && val <= 5);"," }"," },"," "," /**"," * The action to take in case of error. The valid values for this attribute are: "," * `Y.Uploader.Queue.CONTINUE` (the upload process should continue on other files, "," * ignoring the error), `Y.Uploader.Queue.STOP` (the upload process "," * should stop completely), `Y.Uploader.Queue.RESTART_ASAP` (the upload "," * should restart immediately on the errored out file and continue as planned), or"," * Y.Uploader.Queue.RESTART_AFTER (the upload of the errored out file should restart"," * after all other files have uploaded)"," * @property errorAction"," * @type String"," * @default Y.Uploader.Queue.CONTINUE"," */"," errorAction: {"," value: \"continue\","," validator: function (val, name) {"," return (val === UploaderQueue.CONTINUE || val === UploaderQueue.STOP || val === UploaderQueue.RESTART_ASAP || val === UploaderQueue.RESTART_AFTER);"," }"," },",""," /**"," * The total number of bytes that has been uploaded."," * @property bytesUploaded"," * @type Number"," */ "," bytesUploaded: {"," readOnly: true,"," value: 0"," },"," "," /**"," * The total number of bytes in the queue."," * @property bytesTotal"," * @type Number"," */ "," bytesTotal: {"," readOnly: true,"," value: 0"," },",""," /**"," * The queue file list. This file list should only be modified"," * before the upload has been started; modifying it after starting"," * the upload has no effect, and `addToQueueTop` or `addToQueueBottom` methods"," * should be used instead."," * @property fileList"," * @type Number"," */ "," fileList: {"," value: [],"," lazyAdd: false,"," setter: function (val) {"," var newValue = val;"," Y.Array.each(newValue, function (value) {"," this.totalBytes += value.get(\"size\");"," }, this);"," "," return val;"," } "," },",""," /**"," * A String specifying what should be the POST field name for the file"," * content in the upload request."," *"," * @attribute fileFieldName"," * @type {String}"," * @default Filedata"," */ "," fileFieldName: {"," value: \"Filedata\""," },",""," /**"," * The URL to POST the file upload requests to."," *"," * @attribute uploadURL"," * @type {String}"," * @default \"\""," */ "," uploadURL: {"," value: \"\""," },",""," /**"," * Additional HTTP headers that should be included"," * in the upload request. Due to Flash Player security"," * restrictions, this attribute is only honored in the"," * HTML5 Uploader."," *"," * @attribute uploadHeaders"," * @type {Object}"," * @default {}"," */ "," uploadHeaders: {"," value: {}"," },",""," /**"," * A Boolean that specifies whether the file should be"," * uploaded with the appropriate user credentials for the"," * domain. Due to Flash Player security restrictions, this"," * attribute is only honored in the HTML5 Uploader."," *"," * @attribute withCredentials"," * @type {Boolean}"," * @default true"," */ "," withCredentials: {"," value: true"," },","",""," /**"," * An object, keyed by `fileId`, containing sets of key-value pairs"," * that should be passed as POST variables along with each corresponding"," * file."," *"," * @attribute perFileParameters"," * @type {Object}"," * @default {}"," */ "," perFileParameters: {"," value: {}"," },",""," /**"," * The number of times to try re-uploading a file that failed to upload before"," * cancelling its upload."," *"," * @attribute retryCount"," * @type {Number}"," * @default 3"," */ "," retryCount: {"," value: 3"," }",""," }"," });","",""," Y.namespace('Uploader');"," Y.Uploader.Queue = UploaderQueue;","","}, '3.7.3', {\"requires\": [\"base\"]});"];36_yuitest_coverage["build/uploader-queue/uploader-queue.js"].lines = {"1":0,"11":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"37":0,"41":0,"70":0,"71":0,"72":0,"74":0,"85":0,"86":0,"87":0,"88":0,"90":0,"91":0,"92":0,"94":0,"96":0,"97":0,"100":0,"101":0,"103":0,"104":0,"105":0,"107":0,"109":0,"110":0,"112":0,"113":0,"114":0,"116":0,"119":0,"129":0,"130":0,"135":0,"137":0,"138":0,"139":0,"140":0,"141":0,"143":0,"144":0,"146":0,"148":0,"159":0,"160":0,"170":0,"171":0,"173":0,"174":0,"176":0,"180":0,"181":0,"182":0,"183":0,"184":0,"196":0,"198":0,"199":0,"202":0,"203":0,"206":0,"207":0,"208":0,"210":0,"212":0,"213":0,"216":0,"218":0,"222":0,"224":0,"225":0,"226":0,"241":0,"242":0,"243":0,"245":0,"259":0,"261":0,"262":0,"263":0,"265":0,"267":0,"269":0,"270":0,"273":0,"275":0,"287":0,"288":0,"289":0,"290":0,"291":0,"293":0,"295":0,"296":0,"308":0,"317":0,"318":0,"319":0,"332":0,"333":0,"334":0,"335":0,"336":0,"337":0,"350":0,"361":0,"375":0,"376":0,"377":0,"378":0,"379":0,"380":0,"381":0,"385":0,"386":0,"387":0,"388":0,"394":0,"395":0,"396":0,"399":0,"400":0,"401":0,"402":0,"403":0,"507":0,"526":0,"562":0,"563":0,"564":0,"567":0,"652":0,"653":0};37_yuitest_coverage["build/uploader-queue/uploader-queue.js"].functions = {"UploaderQueue:28":0,"_uploadStartHandler:69":0,"_uploadErrorHandler:84":0,"_startNextFile:128":0,"_registerUpload:158":0,"_unregisterUpload:169":0,"_detachFileEvents:179":0,"(anonymous 2):212":0,"_uploadCompleteHandler:194":0,"_uploadCancelHandler:239":0,"(anonymous 3):269":0,"_uploadProgressHandler:257":0,"startUpload:285":0,"pauseUpload:307":0,"restartUpload:316":0,"forceReupload:331":0,"addToQueueTop:349":0,"addToQueueBottom:360":0,"cancelUpload:373":0,"validator:506":0,"validator:525":0,"(anonymous 4):563":0,"setter:561":0,"(anonymous 1):1":0};38_yuitest_coverage["build/uploader-queue/uploader-queue.js"].coveredLines = 141;39_yuitest_coverage["build/uploader-queue/uploader-queue.js"].coveredFunctions = 24;40_yuitest_coverline("build/uploader-queue/uploader-queue.js", 1);41YUI.add('uploader-queue', function (Y, NAME) {42 /**43 * The class manages a queue of files that should be uploaded to the server.44 * It initializes the required number of uploads, tracks them as they progress,45 * and automatically advances to the next upload when a preceding one has completed.46 * @module uploader-queue47 */ 48 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "(anonymous 1)", 1);49_yuitest_coverline("build/uploader-queue/uploader-queue.js", 11);50var Lang = Y.Lang,51 Bind = Y.bind,52 Win = Y.config.win,53 queuedFiles,54 numberOfUploads, 55 currentUploadedByteValues,56 currentFiles,57 totalBytesUploaded,58 totalBytes;59 /**60 * This class manages a queue of files to be uploaded to the server.61 * @class Uploader.Queue62 * @extends Base63 * @constructor64 * @param {Object} config Configuration object65 */66 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 28);67var UploaderQueue = function(o) {68 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "UploaderQueue", 28);69_yuitest_coverline("build/uploader-queue/uploader-queue.js", 29);70this.queuedFiles = [];71 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 30);72this.uploadRetries = {};73 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 31);74this.numberOfUploads = 0;75 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 32);76this.currentUploadedByteValues = {};77 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 33);78this.currentFiles = {};79 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 34);80this.totalBytesUploaded = 0;81 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 35);82this.totalBytes = 0; 83 84 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 37);85UploaderQueue.superclass.constructor.apply(this, arguments);86 };87 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 41);88Y.extend(UploaderQueue, Y.Base, {89 /**90 * Stored value of the current queue state91 * @property _currentState92 * @type {String}93 * @protected94 * @default UploaderQueue.STOPPED95 */96 _currentState: UploaderQueue.STOPPED,97 /**98 * Construction logic executed during UploaderQueue instantiation.99 *100 * @method initializer101 * @protected102 */103 initializer : function (cfg) {104 },105 /**106 * Handles and retransmits upload start event.107 * 108 * @method _uploadStartHandler109 * @param event The event dispatched during the upload process.110 * @private111 */112 _uploadStartHandler : function (event) {113 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_uploadStartHandler", 69);114_yuitest_coverline("build/uploader-queue/uploader-queue.js", 70);115var updatedEvent = event;116 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 71);117updatedEvent.file = event.target;118 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 72);119updatedEvent.originEvent = event;120 121 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 74);122this.fire("uploadstart", updatedEvent); 123 },124 /**125 * Handles and retransmits upload error event.126 * 127 * @method _uploadErrorHandler128 * @param event The event dispatched during the upload process.129 * @private130 */131 _uploadErrorHandler : function (event) {132 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_uploadErrorHandler", 84);133_yuitest_coverline("build/uploader-queue/uploader-queue.js", 85);134var errorAction = this.get("errorAction");135 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 86);136var updatedEvent = event;137 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 87);138updatedEvent.file = event.target;139 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 88);140updatedEvent.originEvent = event;141 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 90);142this.numberOfUploads-=1;143 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 91);144delete this.currentFiles[event.target.get("id")];145 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 92);146this._detachFileEvents(event.target);147 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 94);148event.target.cancelUpload();149 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 96);150if (errorAction === UploaderQueue.STOP) {151 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 97);152this.pauseUpload();153 }154 else {_yuitest_coverline("build/uploader-queue/uploader-queue.js", 100);155if (errorAction === UploaderQueue.RESTART_ASAP) {156 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 101);157var fileid = event.target.get("id"),158 retries = this.uploadRetries[fileid] || 0;159 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 103);160if (retries < this.get("retryCount")) {161 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 104);162this.uploadRetries[fileid] = retries + 1;163 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 105);164this.addToQueueTop(event.target);165 }166 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 107);167this._startNextFile();168 }169 else {_yuitest_coverline("build/uploader-queue/uploader-queue.js", 109);170if (errorAction === UploaderQueue.RESTART_AFTER) {171 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 110);172var fileid = event.target.get("id"),173 retries = this.uploadRetries[fileid] || 0;174 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 112);175if (retries < this.get("retryCount")) {176 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 113);177this.uploadRetries[fileid] = retries + 1;178 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 114);179this.addToQueueBottom(event.target);180 }181 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 116);182this._startNextFile();183 }}}184 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 119);185this.fire("uploaderror", updatedEvent); 186 },187 /**188 * Launches the upload of the next file in the queue.189 * 190 * @method _startNextFile191 * @private192 */193 _startNextFile : function () {194 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_startNextFile", 128);195_yuitest_coverline("build/uploader-queue/uploader-queue.js", 129);196if (this.queuedFiles.length > 0) {197 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 130);198var currentFile = this.queuedFiles.shift(),199 fileId = currentFile.get("id"),200 parameters = this.get("perFileParameters"),201 fileParameters = parameters.hasOwnProperty(fileId) ? parameters[fileId] : parameters;202 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 135);203this.currentUploadedByteValues[fileId] = 0;204 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 137);205currentFile.on("uploadstart", this._uploadStartHandler, this);206 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 138);207currentFile.on("uploadprogress", this._uploadProgressHandler, this);208 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 139);209currentFile.on("uploadcomplete", this._uploadCompleteHandler, this);210 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 140);211currentFile.on("uploaderror", this._uploadErrorHandler, this);212 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 141);213currentFile.on("uploadcancel", this._uploadCancelHandler, this);214 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 143);215currentFile.set("xhrHeaders", this.get("uploadHeaders"));216 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 144);217currentFile.set("xhrWithCredentials", this.get("withCredentials"));218 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 146);219currentFile.startUpload(this.get("uploadURL"), fileParameters, this.get("fileFieldName"));220 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 148);221this._registerUpload(currentFile);222 }223 },224 /**225 * Register a new upload process.226 * 227 * @method _registerUpload228 * @private229 */230 _registerUpload : function (file) {231 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_registerUpload", 158);232_yuitest_coverline("build/uploader-queue/uploader-queue.js", 159);233this.numberOfUploads += 1;234 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 160);235this.currentFiles[file.get("id")] = file;236 },237 /**238 * Unregisters a new upload process.239 * 240 * @method _unregisterUpload241 * @private242 */243 _unregisterUpload : function (file) {244 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_unregisterUpload", 169);245_yuitest_coverline("build/uploader-queue/uploader-queue.js", 170);246if (this.numberOfUploads > 0) {247 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 171);248this.numberOfUploads -=1;249 }250 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 173);251delete this.currentFiles[file.get("id")];252 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 174);253delete this.uploadRetries[file.get("id")];254 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 176);255this._detachFileEvents(file);256 },257 _detachFileEvents : function (file) {258 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_detachFileEvents", 179);259_yuitest_coverline("build/uploader-queue/uploader-queue.js", 180);260file.detach("uploadstart", this._uploadStartHandler);261 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 181);262file.detach("uploadprogress", this._uploadProgressHandler);263 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 182);264file.detach("uploadcomplete", this._uploadCompleteHandler);265 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 183);266file.detach("uploaderror", this._uploadErrorHandler);267 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 184);268file.detach("uploadcancel", this._uploadCancelHandler);269 },270 /**271 * Handles and retransmits upload complete event.272 * 273 * @method _uploadCompleteHandler274 * @param event The event dispatched during the upload process.275 * @private276 */277 _uploadCompleteHandler : function (event) {278 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_uploadCompleteHandler", 194);279_yuitest_coverline("build/uploader-queue/uploader-queue.js", 196);280this._unregisterUpload(event.target);281 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 198);282this.totalBytesUploaded += event.target.get("size");283 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 199);284delete this.currentUploadedByteValues[event.target.get("id")];285 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 202);286if (this.queuedFiles.length > 0 && this._currentState === UploaderQueue.UPLOADING) {287 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 203);288this._startNextFile();289 }290 291 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 206);292var updatedEvent = event;293 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 207);294updatedEvent.file = event.target;295 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 208);296updatedEvent.originEvent = event;297 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 210);298var uploadedTotal = this.totalBytesUploaded;299 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 212);300Y.each(this.currentUploadedByteValues, function (value) {301 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "(anonymous 2)", 212);302_yuitest_coverline("build/uploader-queue/uploader-queue.js", 213);303uploadedTotal += value; 304 });305 306 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 216);307var percentLoaded = Math.min(100, Math.round(10000*uploadedTotal/this.totalBytes) / 100); 308 309 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 218);310this.fire("totaluploadprogress", {bytesLoaded: uploadedTotal, 311 bytesTotal: this.totalBytes,312 percentLoaded: percentLoaded});313 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 222);314this.fire("uploadcomplete", updatedEvent);315 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 224);316if (this.queuedFiles.length === 0 && this.numberOfUploads <= 0) {317 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 225);318this.fire("alluploadscomplete");319 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 226);320this._currentState = UploaderQueue.STOPPED;321 }322 },323 /**324 * Handles and retransmits upload cancel event.325 * 326 * @method _uploadCancelHandler327 * @param event The event dispatched during the upload process.328 * @private329 */330 _uploadCancelHandler : function (event) {331 332 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_uploadCancelHandler", 239);333_yuitest_coverline("build/uploader-queue/uploader-queue.js", 241);334var updatedEvent = event;335 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 242);336updatedEvent.originEvent = event;337 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 243);338updatedEvent.file = event.target;339 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 245);340this.fire("uploadcacel", updatedEvent);341 },342 /**343 * Handles and retransmits upload progress event.344 * 345 * @method _uploadProgressHandler346 * @param event The event dispatched during the upload process.347 * @private348 */349 _uploadProgressHandler : function (event) {350 351 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "_uploadProgressHandler", 257);352_yuitest_coverline("build/uploader-queue/uploader-queue.js", 259);353this.currentUploadedByteValues[event.target.get("id")] = event.bytesLoaded;354 355 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 261);356var updatedEvent = event;357 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 262);358updatedEvent.originEvent = event;359 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 263);360updatedEvent.file = event.target;361 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 265);362this.fire("uploadprogress", updatedEvent);363 364 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 267);365var uploadedTotal = this.totalBytesUploaded;366 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 269);367Y.each(this.currentUploadedByteValues, function (value) {368 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "(anonymous 3)", 269);369_yuitest_coverline("build/uploader-queue/uploader-queue.js", 270);370uploadedTotal += value; 371 });372 373 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 273);374var percentLoaded = Math.min(100, Math.round(10000*uploadedTotal/this.totalBytes) / 100);375 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 275);376this.fire("totaluploadprogress", {bytesLoaded: uploadedTotal, 377 bytesTotal: this.totalBytes,378 percentLoaded: percentLoaded});379 },380 /**381 * Starts uploading the queued up file list.382 * 383 * @method startUpload384 */385 startUpload: function() {386 387 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "startUpload", 285);388_yuitest_coverline("build/uploader-queue/uploader-queue.js", 287);389this.queuedFiles = this.get("fileList").slice(0);390 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 288);391this.numberOfUploads = 0;392 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 289);393this.currentUploadedByteValues = {};394 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 290);395this.currentFiles = {};396 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 291);397this.totalBytesUploaded = 0;398 399 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 293);400this._currentState = UploaderQueue.UPLOADING;401 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 295);402while (this.numberOfUploads < this.get("simUploads") && this.queuedFiles.length > 0) {403 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 296);404this._startNextFile();405 }406 },407 /**408 * Pauses the upload process. The ongoing file uploads409 * will complete after this method is called, but no410 * new ones will be launched.411 * 412 * @method pauseUpload413 */414 pauseUpload: function () {415 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "pauseUpload", 307);416_yuitest_coverline("build/uploader-queue/uploader-queue.js", 308);417this._currentState = UploaderQueue.STOPPED;418 },419 /**420 * Restarts a paused upload process.421 * 422 * @method restartUpload423 */424 restartUpload: function () {425 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "restartUpload", 316);426_yuitest_coverline("build/uploader-queue/uploader-queue.js", 317);427this._currentState = UploaderQueue.UPLOADING;428 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 318);429while (this.numberOfUploads < this.get("simUploads")) {430 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 319);431this._startNextFile();432 }433 },434 /**435 * If a particular file is stuck in an ongoing upload without436 * any progress events, this method allows to force its reupload437 * by cancelling its upload and immediately relaunching it.438 * 439 * @method forceReupload440 * @param file {Y.File} The file to force reupload on.441 */442 forceReupload : function (file) {443 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "forceReupload", 331);444_yuitest_coverline("build/uploader-queue/uploader-queue.js", 332);445var id = file.get("id");446 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 333);447if (this.currentFiles.hasOwnProperty(id)) {448 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 334);449file.cancelUpload();450 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 335);451this._unregisterUpload(file);452 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 336);453this.addToQueueTop(file);454 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 337);455this._startNextFile();456 }457 },458 /**459 * Add a new file to the top of the queue (the upload will be460 * launched as soon as the current number of uploading files461 * drops below the maximum permissible value).462 * 463 * @method addToQueueTop464 * @param file {Y.File} The file to add to the top of the queue.465 */466 addToQueueTop: function (file) {467 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "addToQueueTop", 349);468_yuitest_coverline("build/uploader-queue/uploader-queue.js", 350);469this.queuedFiles.unshift(file);470 },471 /**472 * Add a new file to the bottom of the queue (the upload will be473 * launched after all the other queued files are uploaded.)474 * 475 * @method addToQueueBottom476 * @param file {Y.File} The file to add to the bottom of the queue.477 */478 addToQueueBottom: function (file) {479 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "addToQueueBottom", 360);480_yuitest_coverline("build/uploader-queue/uploader-queue.js", 361);481this.queuedFiles.push(file);482 },483 /**484 * Cancels a specific file's upload. If no argument is passed,485 * all ongoing uploads are cancelled and the upload process is486 * stopped.487 * 488 * @method cancelUpload489 * @param file {Y.File} An optional parameter - the file whose upload490 * should be cancelled.491 */492 cancelUpload: function (file) {493 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "cancelUpload", 373);494_yuitest_coverline("build/uploader-queue/uploader-queue.js", 375);495if (file) {496 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 376);497var id = file.get("id");498 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 377);499if (this.currentFiles[id]) {500 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 378);501this.currentFiles[id].cancelUpload();502 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 379);503this._unregisterUpload(this.currentFiles[id]);504 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 380);505if (this._currentState === UploaderQueue.UPLOADING) {506 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 381);507this._startNextFile();508 }509 }510 else {511 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 385);512for (var i = 0, len = this.queuedFiles.length; i < len; i++) {513 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 386);514if (this.queuedFiles[i].get("id") === id) {515 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 387);516this.queuedFiles.splice(i, 1);517 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 388);518break;519 }520 }521 }522 }523 else {524 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 394);525for (var fid in this.currentFiles) {526 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 395);527this.currentFiles[fid].cancelUpload();528 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 396);529this._unregisterUpload(this.currentFiles[fid]);530 }531 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 399);532this.currentUploadedByteValues = {};533 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 400);534this.currentFiles = {};535 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 401);536this.totalBytesUploaded = 0;537 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 402);538this.fire("alluploadscancelled");539 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 403);540this._currentState = UploaderQueue.STOPPED;541 }542 }543 }, 544 {545 /** 546 * Static constant for the value of the `errorAction` attribute:547 * prescribes the queue to continue uploading files in case of 548 * an error.549 * @property CONTINUE550 * @readOnly551 * @type {String}552 * @static553 */554 CONTINUE: "continue",555 /** 556 * Static constant for the value of the `errorAction` attribute:557 * prescribes the queue to stop uploading files in case of 558 * an error.559 * @property STOP560 * @readOnly561 * @type {String}562 * @static563 */564 STOP: "stop",565 /** 566 * Static constant for the value of the `errorAction` attribute:567 * prescribes the queue to restart a file upload immediately in case of 568 * an error.569 * @property RESTART_ASAP570 * @readOnly571 * @type {String}572 * @static573 */574 RESTART_ASAP: "restartasap",575 /** 576 * Static constant for the value of the `errorAction` attribute:577 * prescribes the queue to restart an errored out file upload after 578 * other files have finished uploading.579 * @property RESTART_AFTER580 * @readOnly581 * @type {String}582 * @static583 */584 RESTART_AFTER: "restartafter",585 /** 586 * Static constant for the value of the `_currentState` property:587 * implies that the queue is currently not uploading files.588 * @property STOPPED589 * @readOnly590 * @type {String}591 * @static592 */593 STOPPED: "stopped",594 /** 595 * Static constant for the value of the `_currentState` property:596 * implies that the queue is currently uploading files.597 * @property UPLOADING598 * @readOnly599 * @type {String}600 * @static601 */602 UPLOADING: "uploading",603 /**604 * The identity of the class.605 *606 * @property NAME607 * @type String608 * @default 'uploaderqueue'609 * @readOnly610 * @protected611 * @static612 */613 NAME: 'uploaderqueue',614 /**615 * Static property used to define the default attribute configuration of616 * the class.617 *618 * @property ATTRS619 * @type {Object}620 * @protected621 * @static622 */623 ATTRS: {624 625 /**626 * Maximum number of simultaneous uploads; must be in the627 * range between 1 and 5. The value of `2` is default. It628 * is recommended that this value does not exceed 3.629 * @property simUploads630 * @type Number631 * @default 2632 */633 simUploads: {634 value: 2,635 validator: function (val, name) {636 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "validator", 506);637_yuitest_coverline("build/uploader-queue/uploader-queue.js", 507);638return (val >= 1 && val <= 5);639 }640 },641 642 /**643 * The action to take in case of error. The valid values for this attribute are: 644 * `Y.Uploader.Queue.CONTINUE` (the upload process should continue on other files, 645 * ignoring the error), `Y.Uploader.Queue.STOP` (the upload process 646 * should stop completely), `Y.Uploader.Queue.RESTART_ASAP` (the upload 647 * should restart immediately on the errored out file and continue as planned), or648 * Y.Uploader.Queue.RESTART_AFTER (the upload of the errored out file should restart649 * after all other files have uploaded)650 * @property errorAction651 * @type String652 * @default Y.Uploader.Queue.CONTINUE653 */654 errorAction: {655 value: "continue",656 validator: function (val, name) {657 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "validator", 525);658_yuitest_coverline("build/uploader-queue/uploader-queue.js", 526);659return (val === UploaderQueue.CONTINUE || val === UploaderQueue.STOP || val === UploaderQueue.RESTART_ASAP || val === UploaderQueue.RESTART_AFTER);660 }661 },662 /**663 * The total number of bytes that has been uploaded.664 * @property bytesUploaded665 * @type Number666 */ 667 bytesUploaded: {668 readOnly: true,669 value: 0670 },671 672 /**673 * The total number of bytes in the queue.674 * @property bytesTotal675 * @type Number676 */ 677 bytesTotal: {678 readOnly: true,679 value: 0680 },681 /**682 * The queue file list. This file list should only be modified683 * before the upload has been started; modifying it after starting684 * the upload has no effect, and `addToQueueTop` or `addToQueueBottom` methods685 * should be used instead.686 * @property fileList687 * @type Number688 */ 689 fileList: {690 value: [],691 lazyAdd: false,692 setter: function (val) {693 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "setter", 561);694_yuitest_coverline("build/uploader-queue/uploader-queue.js", 562);695var newValue = val;696 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 563);697Y.Array.each(newValue, function (value) {698 _yuitest_coverfunc("build/uploader-queue/uploader-queue.js", "(anonymous 4)", 563);699_yuitest_coverline("build/uploader-queue/uploader-queue.js", 564);700this.totalBytes += value.get("size");701 }, this);702 703 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 567);704return val;705 } 706 },707 /**708 * A String specifying what should be the POST field name for the file709 * content in the upload request.710 *711 * @attribute fileFieldName712 * @type {String}713 * @default Filedata714 */ 715 fileFieldName: {716 value: "Filedata"717 },718 /**719 * The URL to POST the file upload requests to.720 *721 * @attribute uploadURL722 * @type {String}723 * @default ""724 */ 725 uploadURL: {726 value: ""727 },728 /**729 * Additional HTTP headers that should be included730 * in the upload request. Due to Flash Player security731 * restrictions, this attribute is only honored in the732 * HTML5 Uploader.733 *734 * @attribute uploadHeaders735 * @type {Object}736 * @default {}737 */ 738 uploadHeaders: {739 value: {}740 },741 /**742 * A Boolean that specifies whether the file should be743 * uploaded with the appropriate user credentials for the744 * domain. Due to Flash Player security restrictions, this745 * attribute is only honored in the HTML5 Uploader.746 *747 * @attribute withCredentials748 * @type {Boolean}749 * @default true750 */ 751 withCredentials: {752 value: true753 },754 /**755 * An object, keyed by `fileId`, containing sets of key-value pairs756 * that should be passed as POST variables along with each corresponding757 * file.758 *759 * @attribute perFileParameters760 * @type {Object}761 * @default {}762 */ 763 perFileParameters: {764 value: {}765 },766 /**767 * The number of times to try re-uploading a file that failed to upload before768 * cancelling its upload.769 *770 * @attribute retryCount771 * @type {Number}772 * @default 3773 */ 774 retryCount: {775 value: 3776 }777 }778 });779 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 652);780Y.namespace('Uploader');781 _yuitest_coverline("build/uploader-queue/uploader-queue.js", 653);782Y.Uploader.Queue = UploaderQueue;...

Full Screen

Full Screen

bp-plupload.js

Source:bp-plupload.js Github

copy

Full Screen

...281 this.model = new Backbone.Model( this.defaults );282 this.on( 'ready', this.initUploader );283 },284 initUploader: function() {285 this.uploader = new bp.Uploader.uploader();286 $( this.uploader ).on( 'bp-uploader-warning', _.bind( this.setWarning, this ) );287 $( this.uploader ).on( 'bp-uploader-new-upload', _.bind( this.resetWarning, this ) );288 },289 setWarning: function( event, message ) {290 if ( _.isUndefined( message ) ) {291 return;292 }293 var warning = new bp.Views.uploaderWarning( {294 value: message295 } ).render();296 this.warnings.push( warning );297 this.$el.after( warning.el );298 },299 resetWarning: function() {...

Full Screen

Full Screen

uploader-coverage.js

Source:uploader-coverage.js Github

copy

Full Screen

1/*2YUI 3.7.3 (build 5687)3Copyright 2012 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7if (typeof _yuitest_coverage == "undefined"){8 _yuitest_coverage = {};9 _yuitest_coverline = function(src, line){10 var coverage = _yuitest_coverage[src];11 if (!coverage.lines[line]){12 coverage.calledLines++;13 }14 coverage.lines[line]++;15 };16 _yuitest_coverfunc = function(src, name, line){17 var coverage = _yuitest_coverage[src],18 funcId = name + ":" + line;19 if (!coverage.functions[funcId]){20 coverage.calledFunctions++;21 }22 coverage.functions[funcId]++;23 };24}25_yuitest_coverage["build/uploader/uploader.js"] = {26 lines: {},27 functions: {},28 coveredLines: 0,29 calledLines: 0,30 coveredFunctions: 0,31 calledFunctions: 0,32 path: "build/uploader/uploader.js",33 code: []34};35_yuitest_coverage["build/uploader/uploader.js"].code=["YUI.add('uploader', function (Y, NAME) {","","/**"," * Provides UI for selecting multiple files and functionality for "," * uploading multiple files to the server with support for either"," * html5 or Flash transport mechanisms, automatic queue management,"," * upload progress monitoring, and error events."," * @module uploader"," * @main uploader"," * @since 3.5.0"," */","","/**"," * `Y.Uploader` serves as an alias for either <a href=\"UploaderFlash.html\">`Y.UploaderFlash`</a>"," * or <a href=\"UploaderHTML5.html\">`Y.UploaderHTML5`</a>, depending on the feature set available"," * in a specific browser. If neither HTML5 nor Flash transport layers are available, `Y.Uploader.TYPE` "," * static property is set to `\"none\"`."," *"," * @class Uploader"," */",""," /**"," * The static property reflecting the type of uploader that `Y.Uploader`"," * aliases. The possible values are:"," * <ul>"," * <li><strong>`\"html5\"`</strong>: Y.Uploader is an alias for <a href=\"UploaderHTML5.html\">Y.UploaderHTML5</a></li>"," * <li><strong>`\"flash\"`</strong>: Y.Uploader is an alias for <a href=\"UploaderFlash.html\">Y.UploaderFlash</a></li>"," * <li><strong>`\"none\"`</strong>: Neither Flash not HTML5 are available, and Y.Uploader does"," * not reference an actual implementation.</li>"," * </ul>"," *"," * @property TYPE"," * @type {String}"," * @static"," */",""," var Win = Y.config.win;",""," if (Win && Win.File && Win.FormData && Win.XMLHttpRequest) {"," Y.Uploader = Y.UploaderHTML5;"," }",""," else if (Y.SWFDetect.isFlashVersionAtLeast(10,0,45)) {"," Y.Uploader = Y.UploaderFlash;"," }",""," else {"," Y.namespace(\"Uploader\");"," Y.Uploader.TYPE = \"none\";"," }","","}, '3.7.3', {\"requires\": [\"uploader-html5\", \"uploader-flash\"]});"];36_yuitest_coverage["build/uploader/uploader.js"].lines = {"1":0,"37":0,"39":0,"40":0,"43":0,"44":0,"48":0,"49":0};37_yuitest_coverage["build/uploader/uploader.js"].functions = {"(anonymous 1):1":0};38_yuitest_coverage["build/uploader/uploader.js"].coveredLines = 8;39_yuitest_coverage["build/uploader/uploader.js"].coveredFunctions = 1;40_yuitest_coverline("build/uploader/uploader.js", 1);41YUI.add('uploader', function (Y, NAME) {42/**43 * Provides UI for selecting multiple files and functionality for 44 * uploading multiple files to the server with support for either45 * html5 or Flash transport mechanisms, automatic queue management,46 * upload progress monitoring, and error events.47 * @module uploader48 * @main uploader49 * @since 3.5.050 */51/**52 * `Y.Uploader` serves as an alias for either <a href="UploaderFlash.html">`Y.UploaderFlash`</a>53 * or <a href="UploaderHTML5.html">`Y.UploaderHTML5`</a>, depending on the feature set available54 * in a specific browser. If neither HTML5 nor Flash transport layers are available, `Y.Uploader.TYPE` 55 * static property is set to `"none"`.56 *57 * @class Uploader58 */59 /**60 * The static property reflecting the type of uploader that `Y.Uploader`61 * aliases. The possible values are:62 * <ul>63 * <li><strong>`"html5"`</strong>: Y.Uploader is an alias for <a href="UploaderHTML5.html">Y.UploaderHTML5</a></li>64 * <li><strong>`"flash"`</strong>: Y.Uploader is an alias for <a href="UploaderFlash.html">Y.UploaderFlash</a></li>65 * <li><strong>`"none"`</strong>: Neither Flash not HTML5 are available, and Y.Uploader does66 * not reference an actual implementation.</li>67 * </ul>68 *69 * @property TYPE70 * @type {String}71 * @static72 */73 _yuitest_coverfunc("build/uploader/uploader.js", "(anonymous 1)", 1);74_yuitest_coverline("build/uploader/uploader.js", 37);75var Win = Y.config.win;76 _yuitest_coverline("build/uploader/uploader.js", 39);77if (Win && Win.File && Win.FormData && Win.XMLHttpRequest) {78 _yuitest_coverline("build/uploader/uploader.js", 40);79Y.Uploader = Y.UploaderHTML5;80 }81 else {_yuitest_coverline("build/uploader/uploader.js", 43);82if (Y.SWFDetect.isFlashVersionAtLeast(10,0,45)) {83 _yuitest_coverline("build/uploader/uploader.js", 44);84Y.Uploader = Y.UploaderFlash;85 }86 else {87 _yuitest_coverline("build/uploader/uploader.js", 48);88Y.namespace("Uploader");89 _yuitest_coverline("build/uploader/uploader.js", 49);90Y.Uploader.TYPE = "none";91 }}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestie = require('bestie');2var uploader = bestie.uploader;3uploader.uploadFile('test.txt', 'test.txt', function(err, data){4 if(err){5 console.log('Error: ' + err);6 }7 else{8 console.log('Success: ' + data);9 }10});11var bestie = require('bestie');12var downloader = bestie.downloader;13downloader.downloadFile('test.txt', 'test.txt', function(err, data){14 if(err){15 console.log('Error: ' + err);16 }17 else{18 console.log('Success: ' + data);19 }20});21var bestie = require('bestie');22var uploader = bestie.uploader;23uploader.uploadFile('test.txt', 'test.txt', function(err, data){24 if(err){25 console.log('Error: ' + err);26 }27 else{28 console.log('Success: ' + data);29 }30});31var bestie = require('bestie');32var downloader = bestie.downloader;33downloader.downloadFile('test.txt', 'test.txt', function(err, data){34 if(err){35 console.log('Error: ' + err);36 }37 else{38 console.log('Success: ' + data);39 }40});41var bestie = require('bestie');42var uploader = bestie.uploader;43uploader.uploadFile('test.txt', 'test.txt', function(err, data){44 if(err){45 console.log('Error: ' + err);46 }47 else{48 console.log('Success: ' + data);49 }50});51var bestie = require('bestie');52var downloader = bestie.downloader;53downloader.downloadFile('test.txt', 'test.txt', function(err, data){54 if(err){55 console.log('Error: ' + err);56 }57 else{58 console.log('Success: ' + data);59 }60});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestFit = require('bestfit');2var bestfit = new BestFit();3var options = {4};5bestfit.uploader(options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12var BestFit = require('bestfit');13var bestfit = new BestFit();14var options = {15};16bestfit.downloader(options, function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22});23var BestFit = require('bestfit');24var bestfit = new BestFit();25var options = {26};27bestfit.deleter(options, function(err, data) {28 if (err) {29 console.log(err);30 } else {31 console.log(data);32 }33});34var BestFit = require('bestfit');35var bestfit = new BestFit();36var options = {37};38bestfit.lister(options, function(err, data) {39 if (err) {40 console.log(err);41 } else {42 console.log(data);43 }44});45var BestFit = require('bestfit');46var bestfit = new BestFit();47bestfit.listBuckets(function(err, data) {48 if (err) {49 console.log(err);50 } else {51 console.log(data);52 }53});54var BestFit = require('bestfit');55var bestfit = new BestFit();56var options = {57};58bestfit.makeBucket(options, function(err, data) {59 if (err)

Full Screen

Using AI Code Generation

copy

Full Screen

1function BestInPlaceEditorUploaders() {2 this.uploaders = {3 "upload": {4 "onProgress": function(id, fileName, loaded, total){5 },6 "onComplete": function(id, fileName, responseJSON){7 if (responseJSON.success) {8 var editor = BestInPlaceEditorUploaders.prototype.editors[id];9 var url = responseJSON.url;10 var html = "<img src='" + url + "' />";11 editor.element.html(html);12 editor.activateForm();13 }14 },15 "onCancel": function(id, fileName){16 },17 "onError": function(id, fileName, xhr){18 }19 }20 };21}22BestInPlaceEditorUploaders.prototype.editors = {};23BestInPlaceEditorUploaders.prototype.uploaders = {};24BestInPlaceEditorUploaders.prototype.create = function(id, url, options) {25 var editor = new BestInPlaceEditor(id, url, options);26 this.editors[id] = editor;27 return editor;28};29BestInPlaceEditorUploaders.prototype.uploader = function(id) {30 var editor = this.editors[id];31 var uploader = this.uploaders[editor.options.uploader];32 return uploader;33};34BestInPlaceEditorUploaders.prototype.activate = function(id) {35 var editor = this.editors[id];

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful