Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: allenrabinovich/yui3
...
head fork: allenrabinovich/yui3
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
299 build/uploader-html5/uploader-html5-coverage.js
151 additions, 148 deletions not shown
View
82 build/uploader-html5/uploader-html5-debug.js
@@ -344,46 +344,48 @@ Y.UploaderHTML5 = Y.extend( UploaderHTML5, Y.Widget, {
event.stopPropagation();
event.preventDefault();
-
- switch (event.type) {
- case "dragenter":
- this.fire("dragenter");
- break;
- case "dragover":
- this.fire("dragover");
- break;
- case "dragleave":
- this.fire("dragleave");
- break;
- case "drop":
-
- var newfiles = event._event.dataTransfer.files,
- parsedFiles = [],
- filterFunc = this.get("fileFilterFunction");
-
- if (filterFunc) {
- Y.each(newfiles, function (value) {
- var newfile = new Y.FileHTML5(value);
- if (filterFunc(newfile)) {
- parsedFiles.push(newfile);
- }
- });
- }
- else {
- Y.each(newfiles, function (value) {
- parsedFiles.push(new Y.FileHTML5(value));
- });
- }
-
- if (parsedFiles.length > 0) {
- var oldfiles = this.get("fileList");
- this.set("fileList",
- this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles);
- this.fire("fileselect", {fileList: parsedFiles});
- }
-
- this.fire("drop");
- break;
+
+ if (Y.Array.indexOf(event._event.dataTransfer.types, 'Files') > -1) {
+ switch (event.type) {
+ case "dragenter":
+ this.fire("dragenter");
+ break;
+ case "dragover":
+ this.fire("dragover");
+ break;
+ case "dragleave":
+ this.fire("dragleave");
+ break;
+ case "drop":
+
+ var newfiles = event._event.dataTransfer.files,
+ parsedFiles = [],
+ filterFunc = this.get("fileFilterFunction");
+
+ if (filterFunc) {
+ Y.each(newfiles, function (value) {
+ var newfile = new Y.FileHTML5(value);
+ if (filterFunc(newfile)) {
+ parsedFiles.push(newfile);
+ }
+ });
+ }
+ else {
+ Y.each(newfiles, function (value) {
+ parsedFiles.push(new Y.FileHTML5(value));
+ });
+ }
+
+ if (parsedFiles.length > 0) {
+ var oldfiles = this.get("fileList");
+ this.set("fileList",
+ this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles);
+ this.fire("fileselect", {fileList: parsedFiles});
+ }
+
+ this.fire("drop");
+ break;
+ }
}
},
View
2  build/uploader-html5/uploader-html5-min.js
@@ -1 +1 @@
-YUI.add("uploader-html5",function(e,t){function i(e){i.superclass.constructor.apply(this,arguments)}var n=e.Lang.sub,r=e.Uploader.Queue;e.UploaderHTML5=e.extend(i,e.Widget,{_fileInputField:null,_buttonBinding:null,queue:null,initializer:function(){this._fileInputField=null,this.queue=null,this._buttonBinding=null,this._fileList=[],this.publish("fileselect"),this.publish("uploadstart"),this.publish("fileuploadstart"),this.publish("uploadprogress"),this.publish("totaluploadprogress"),this.publish("uploadcomplete"),this.publish("alluploadscomplete"),this.publish("uploaderror"),this.publish("dragenter"),this.publish("dragover"),this.publish("dragleave"),this.publish("drop")},renderUI:function(){var t=this.get("boundingBox"),n=this.get("contentBox"),r=this.get("selectFilesButton");r.setStyles({width:"100%",height:"100%"}),n.append(r),this._fileInputField=e.Node.create(i.HTML5FILEFIELD_TEMPLATE),n.append(this._fileInputField)},bindUI:function(){this._bindSelectButton(),this._setMultipleFiles(),this._setFileFilters(),this._bindDropArea(),this._triggerEnabled(),this.after("multipleFilesChange",this._setMultipleFiles,this),this.after("fileFiltersChange",this._setFileFilters,this),this.after("enabledChange",this._triggerEnabled,this),this.after("selectFilesButtonChange",this._bindSelectButton,this),this.after("dragAndDropAreaChange",this._bindDropArea,this),this.after("tabIndexChange",function(e){this.get("selectFilesButton").set("tabIndex",this.get("tabIndex"))},this),this._fileInputField.on("change",this._updateFileList,this),this.get("selectFilesButton").set("tabIndex",this.get("tabIndex"))},_rebindFileField:function(){this._fileInputField.remove(!0),this._fileInputField=e.Node.create(i.HTML5FILEFIELD_TEMPLATE),this.get("contentBox").append(this._fileInputField),this._fileInputField.on("change",this._updateFileList,this),this._setMultipleFiles(),this._setFileFilters()},_bindDropArea:function(e){var t=e||{prevVal:null};t.prevVal!==null&&(t.prevVal.detach("drop",this._ddEventHandler),t.prevVal.detach("dragenter",this._ddEventHandler),t.prevVal.detach("dragover",this._ddEventHandler),t.prevVal.detach("dragleave",this._ddEventHandler));var n=this.get("dragAndDropArea");n!==null&&(n.on("drop",this._ddEventHandler,this),n.on("dragenter",this._ddEventHandler,this),n.on("dragover",this._ddEventHandler,this),n.on("dragleave",this._ddEventHandler,this))},_bindSelectButton:function(){this._buttonBinding=this.get("selectFilesButton").on("click",this.openFileSelectDialog,this)},_ddEventHandler:function(t){t.stopPropagation(),t.preventDefault();switch(t.type){case"dragenter":this.fire("dragenter");break;case"dragover":this.fire("dragover");break;case"dragleave":this.fire("dragleave");break;case"drop":var n=t._event.dataTransfer.files,r=[],i=this.get("fileFilterFunction");i?e.each(n,function(t){var n=new e.FileHTML5(t);i(n)&&r.push(n)}):e.each(n,function(t){r.push(new e.FileHTML5(t))});if(r.length>0){var s=this.get("fileList");this.set("fileList",this.get("appendNewFiles")?s.concat(r):r),this.fire("fileselect",{fileList:r})}this.fire("drop")}},_setButtonClass:function(e,t){t?this.get("selectFilesButton").addClass(this.get("buttonClassNames")[e]):this.get("selectFilesButton").removeClass(this.get("buttonClassNames")[e])},_setMultipleFiles:function(){this.get("multipleFiles")===!0?this._fileInputField.set("multiple","multiple"):this._fileInputField.set("multiple","")},_setFileFilters:function(){this.get("fileFilters").length>0?this._fileInputField.set("accept",this.get("fileFilters").join(",")):this._fileInputField.set("accept","")},_triggerEnabled:function(){this.get("enabled")&&this._buttonBinding===null?(this._bindSelectButton(),this._setButtonClass("disabled",!1),this.get("selectFilesButton").setAttribute("aria-disabled","false")):!this.get("enabled")&&this._buttonBinding&&(this._buttonBinding.detach(),this._buttonBinding=null,this._setButtonClass("disabled",!0),this.get("selectFilesButton").setAttribute("aria-disabled","true"))},_getFileList:function(e){return this._fileList.concat()},_setFileList:function(e){return this._fileList=e.concat(),this._fileList.concat()},_updateFileList:function(t){var n=t.target.getDOMNode().files,r=[],i=this.get("fileFilterFunction");i?e.each(n,function(t){var n=new e.FileHTML5(t);i(n)&&r.push(n)}):e.each(n,function(t){r.push(new e.FileHTML5(t))});if(r.length>0){var s=this.get("fileList");this.set("fileList",this.get("appendNewFiles")?s.concat(r):r),this.fire("fileselect",{fileList:r})}this._rebindFileField()},_uploadEventHandler:function(e){switch(e.type){case"file:uploadstart":this.fire("fileuploadstart",e);break;case"file:uploadprogress":this.fire("uploadprogress",e);break;case"uploaderqueue:totaluploadprogress":this.fire("totaluploadprogress",e);break;case"file:uploadcomplete":this.fire("uploadcomplete",e);break;case"uploaderqueue:alluploadscomplete":this.queue=null,this.fire("alluploadscomplete",e);break;case"file:uploaderror":case"uploaderqueue:uploaderror":this.fire("uploaderror",e);break;case"file:uploadcancel":case"uploaderqueue:uploadcancel":this.fire("uploadcancel",e)}},openFileSelectDialog:function(){var e=this._fileInputField.getDOMNode();e.click&&e.click()},upload:function(t,n,r){var i=n||this.get("uploadURL"),s=r||this.get("postVarsPerFile"),o=t.get("id");s=s.hasOwnProperty(o)?s[o]:s,t instanceof e.FileHTML5&&(t.on("uploadstart",this._uploadEventHandler,this),t.on("uploadprogress",this._uploadEventHandler,this),t.on("uploadcomplete",this._uploadEventHandler,this),t.on("uploaderror",this._uploadEventHandler,this),t.on("uploadcancel",this._uploadEventHandler,this),t.startUpload(i,s,this.get("fileFieldName")))},uploadAll:function(e,t){this.uploadThese(this.get("fileList"),e,t)},uploadThese:function(t,n,i){if(!this.queue){var s=n||this.get("uploadURL"),o=i||this.get("postVarsPerFile");this.queue=new r({simUploads:this.get("simLimit"),errorAction:this.get("errorAction"),fileFieldName:this.get("fileFieldName"),fileList:t,uploadURL:s,perFileParameters:o,retryCount:this.get("retryCount"),uploadHeaders:this.get("uploadHeaders"),withCredentials:this.get("withCredentials")}),this.queue.on("uploadstart",this._uploadEventHandler,this),this.queue.on("uploadprogress",this._uploadEventHandler,this),this.queue.on("totaluploadprogress",this._uploadEventHandler,this),this.queue.on("uploadcomplete",this._uploadEventHandler,this),this.queue.on("alluploadscomplete",this._uploadEventHandler,this),this.queue.on("uploadcancel",this._uploadEventHandler,this),this.queue.on("uploaderror",this._uploadEventHandler,this),this.queue.startUpload(),this.fire("uploadstart")}else this.queue._currentState===r.UPLOADING&&(this.queue.set("perFileParameters",this.get("postVarsPerFile")),e.each(t,function(e){this.queue.addToQueueBottom(e)},this))}},{HTML5FILEFIELD_TEMPLATE:"<input type='file' style='visibility:hidden; width:0px; height: 0px;'>",SELECT_FILES_BUTTON:"<button type='button' class='yui3-button' role='button' aria-label='{selectButtonLabel}' tabindex='{tabIndex}'>{selectButtonLabel}</button>",TYPE:"html5",NAME:"uploader",ATTRS:{appendNewFiles:{value:!0},buttonClassNames:{value:{hover:"yui3-button-hover",active:"yui3-button-active",disabled:"yui3-button-disabled",focus:"yui3-button-selected"}},dragAndDropArea:{value:null,setter:function(t){return e.one(t)}},enabled:{value:!0},errorAction:{value:"continue",validator:function(e,t){return e===r.CONTINUE||e===r.STOP||e===r.RESTART_ASAP||e===r.RESTART_AFTER}},fileFilters:{value:[]},fileFilterFunction:{value:null},fileFieldName:{value:"Filedata"},fileList:{value:[],getter:"_getFileList",setter:"_setFileList"},multipleFiles:{value:!1},postVarsPerFile:{value:{}},selectButtonLabel:{value:"Select Files"},selectFilesButton:{valueFn:function(){return e.Node.create(n(e.UploaderHTML5.SELECT_FILES_BUTTON,{selectButtonLabel:this.get("selectButtonLabel"),tabIndex:this.get("tabIndex")}))}},simLimit:{value:2,validator:function(e,t){return e>=1&&e<=5}},uploadURL:{value:""},uploadHeaders:{value:{}},withCredentials:{value:!0},retryCount:{value:3}}}),e.UploaderHTML5.Queue=r},"@VERSION@",{requires:["widget","node-event-simulate","substitute","file-html5","uploader-queue"]});
+YUI.add("uploader-html5",function(e,t){function i(e){i.superclass.constructor.apply(this,arguments)}var n=e.Lang.sub,r=e.Uploader.Queue;e.UploaderHTML5=e.extend(i,e.Widget,{_fileInputField:null,_buttonBinding:null,queue:null,initializer:function(){this._fileInputField=null,this.queue=null,this._buttonBinding=null,this._fileList=[],this.publish("fileselect"),this.publish("uploadstart"),this.publish("fileuploadstart"),this.publish("uploadprogress"),this.publish("totaluploadprogress"),this.publish("uploadcomplete"),this.publish("alluploadscomplete"),this.publish("uploaderror"),this.publish("dragenter"),this.publish("dragover"),this.publish("dragleave"),this.publish("drop")},renderUI:function(){var t=this.get("boundingBox"),n=this.get("contentBox"),r=this.get("selectFilesButton");r.setStyles({width:"100%",height:"100%"}),n.append(r),this._fileInputField=e.Node.create(i.HTML5FILEFIELD_TEMPLATE),n.append(this._fileInputField)},bindUI:function(){this._bindSelectButton(),this._setMultipleFiles(),this._setFileFilters(),this._bindDropArea(),this._triggerEnabled(),this.after("multipleFilesChange",this._setMultipleFiles,this),this.after("fileFiltersChange",this._setFileFilters,this),this.after("enabledChange",this._triggerEnabled,this),this.after("selectFilesButtonChange",this._bindSelectButton,this),this.after("dragAndDropAreaChange",this._bindDropArea,this),this.after("tabIndexChange",function(e){this.get("selectFilesButton").set("tabIndex",this.get("tabIndex"))},this),this._fileInputField.on("change",this._updateFileList,this),this.get("selectFilesButton").set("tabIndex",this.get("tabIndex"))},_rebindFileField:function(){this._fileInputField.remove(!0),this._fileInputField=e.Node.create(i.HTML5FILEFIELD_TEMPLATE),this.get("contentBox").append(this._fileInputField),this._fileInputField.on("change",this._updateFileList,this),this._setMultipleFiles(),this._setFileFilters()},_bindDropArea:function(e){var t=e||{prevVal:null};t.prevVal!==null&&(t.prevVal.detach("drop",this._ddEventHandler),t.prevVal.detach("dragenter",this._ddEventHandler),t.prevVal.detach("dragover",this._ddEventHandler),t.prevVal.detach("dragleave",this._ddEventHandler));var n=this.get("dragAndDropArea");n!==null&&(n.on("drop",this._ddEventHandler,this),n.on("dragenter",this._ddEventHandler,this),n.on("dragover",this._ddEventHandler,this),n.on("dragleave",this._ddEventHandler,this))},_bindSelectButton:function(){this._buttonBinding=this.get("selectFilesButton").on("click",this.openFileSelectDialog,this)},_ddEventHandler:function(t){t.stopPropagation(),t.preventDefault();if(e.Array.indexOf(t._event.dataTransfer.types,"Files")>-1)switch(t.type){case"dragenter":this.fire("dragenter");break;case"dragover":this.fire("dragover");break;case"dragleave":this.fire("dragleave");break;case"drop":var n=t._event.dataTransfer.files,r=[],i=this.get("fileFilterFunction");i?e.each(n,function(t){var n=new e.FileHTML5(t);i(n)&&r.push(n)}):e.each(n,function(t){r.push(new e.FileHTML5(t))});if(r.length>0){var s=this.get("fileList");this.set("fileList",this.get("appendNewFiles")?s.concat(r):r),this.fire("fileselect",{fileList:r})}this.fire("drop")}},_setButtonClass:function(e,t){t?this.get("selectFilesButton").addClass(this.get("buttonClassNames")[e]):this.get("selectFilesButton").removeClass(this.get("buttonClassNames")[e])},_setMultipleFiles:function(){this.get("multipleFiles")===!0?this._fileInputField.set("multiple","multiple"):this._fileInputField.set("multiple","")},_setFileFilters:function(){this.get("fileFilters").length>0?this._fileInputField.set("accept",this.get("fileFilters").join(",")):this._fileInputField.set("accept","")},_triggerEnabled:function(){this.get("enabled")&&this._buttonBinding===null?(this._bindSelectButton(),this._setButtonClass("disabled",!1),this.get("selectFilesButton").setAttribute("aria-disabled","false")):!this.get("enabled")&&this._buttonBinding&&(this._buttonBinding.detach(),this._buttonBinding=null,this._setButtonClass("disabled",!0),this.get("selectFilesButton").setAttribute("aria-disabled","true"))},_getFileList:function(e){return this._fileList.concat()},_setFileList:function(e){return this._fileList=e.concat(),this._fileList.concat()},_updateFileList:function(t){var n=t.target.getDOMNode().files,r=[],i=this.get("fileFilterFunction");i?e.each(n,function(t){var n=new e.FileHTML5(t);i(n)&&r.push(n)}):e.each(n,function(t){r.push(new e.FileHTML5(t))});if(r.length>0){var s=this.get("fileList");this.set("fileList",this.get("appendNewFiles")?s.concat(r):r),this.fire("fileselect",{fileList:r})}this._rebindFileField()},_uploadEventHandler:function(e){switch(e.type){case"file:uploadstart":this.fire("fileuploadstart",e);break;case"file:uploadprogress":this.fire("uploadprogress",e);break;case"uploaderqueue:totaluploadprogress":this.fire("totaluploadprogress",e);break;case"file:uploadcomplete":this.fire("uploadcomplete",e);break;case"uploaderqueue:alluploadscomplete":this.queue=null,this.fire("alluploadscomplete",e);break;case"file:uploaderror":case"uploaderqueue:uploaderror":this.fire("uploaderror",e);break;case"file:uploadcancel":case"uploaderqueue:uploadcancel":this.fire("uploadcancel",e)}},openFileSelectDialog:function(){var e=this._fileInputField.getDOMNode();e.click&&e.click()},upload:function(t,n,r){var i=n||this.get("uploadURL"),s=r||this.get("postVarsPerFile"),o=t.get("id");s=s.hasOwnProperty(o)?s[o]:s,t instanceof e.FileHTML5&&(t.on("uploadstart",this._uploadEventHandler,this),t.on("uploadprogress",this._uploadEventHandler,this),t.on("uploadcomplete",this._uploadEventHandler,this),t.on("uploaderror",this._uploadEventHandler,this),t.on("uploadcancel",this._uploadEventHandler,this),t.startUpload(i,s,this.get("fileFieldName")))},uploadAll:function(e,t){this.uploadThese(this.get("fileList"),e,t)},uploadThese:function(t,n,i){if(!this.queue){var s=n||this.get("uploadURL"),o=i||this.get("postVarsPerFile");this.queue=new r({simUploads:this.get("simLimit"),errorAction:this.get("errorAction"),fileFieldName:this.get("fileFieldName"),fileList:t,uploadURL:s,perFileParameters:o,retryCount:this.get("retryCount"),uploadHeaders:this.get("uploadHeaders"),withCredentials:this.get("withCredentials")}),this.queue.on("uploadstart",this._uploadEventHandler,this),this.queue.on("uploadprogress",this._uploadEventHandler,this),this.queue.on("totaluploadprogress",this._uploadEventHandler,this),this.queue.on("uploadcomplete",this._uploadEventHandler,this),this.queue.on("alluploadscomplete",this._uploadEventHandler,this),this.queue.on("uploadcancel",this._uploadEventHandler,this),this.queue.on("uploaderror",this._uploadEventHandler,this),this.queue.startUpload(),this.fire("uploadstart")}else this.queue._currentState===r.UPLOADING&&(this.queue.set("perFileParameters",this.get("postVarsPerFile")),e.each(t,function(e){this.queue.addToQueueBottom(e)},this))}},{HTML5FILEFIELD_TEMPLATE:"<input type='file' style='visibility:hidden; width:0px; height: 0px;'>",SELECT_FILES_BUTTON:"<button type='button' class='yui3-button' role='button' aria-label='{selectButtonLabel}' tabindex='{tabIndex}'>{selectButtonLabel}</button>",TYPE:"html5",NAME:"uploader",ATTRS:{appendNewFiles:{value:!0},buttonClassNames:{value:{hover:"yui3-button-hover",active:"yui3-button-active",disabled:"yui3-button-disabled",focus:"yui3-button-selected"}},dragAndDropArea:{value:null,setter:function(t){return e.one(t)}},enabled:{value:!0},errorAction:{value:"continue",validator:function(e,t){return e===r.CONTINUE||e===r.STOP||e===r.RESTART_ASAP||e===r.RESTART_AFTER}},fileFilters:{value:[]},fileFilterFunction:{value:null},fileFieldName:{value:"Filedata"},fileList:{value:[],getter:"_getFileList",setter:"_setFileList"},multipleFiles:{value:!1},postVarsPerFile:{value:{}},selectButtonLabel:{value:"Select Files"},selectFilesButton:{valueFn:function(){return e.Node.create(n(e.UploaderHTML5.SELECT_FILES_BUTTON,{selectButtonLabel:this.get("selectButtonLabel"),tabIndex:this.get("tabIndex")}))}},simLimit:{value:2,validator:function(e,t){return e>=1&&e<=5}},uploadURL:{value:""},uploadHeaders:{value:{}},withCredentials:{value:!0},retryCount:{value:3}}}),e.UploaderHTML5.Queue=r},"@VERSION@",{requires:["widget","node-event-simulate","substitute","file-html5","uploader-queue"]});
View
82 build/uploader-html5/uploader-html5.js
@@ -344,46 +344,48 @@ Y.UploaderHTML5 = Y.extend( UploaderHTML5, Y.Widget, {
event.stopPropagation();
event.preventDefault();
-
- switch (event.type) {
- case "dragenter":
- this.fire("dragenter");
- break;
- case "dragover":
- this.fire("dragover");
- break;
- case "dragleave":
- this.fire("dragleave");
- break;
- case "drop":
-
- var newfiles = event._event.dataTransfer.files,
- parsedFiles = [],
- filterFunc = this.get("fileFilterFunction");
-
- if (filterFunc) {
- Y.each(newfiles, function (value) {
- var newfile = new Y.FileHTML5(value);
- if (filterFunc(newfile)) {
- parsedFiles.push(newfile);
- }
- });
- }
- else {
- Y.each(newfiles, function (value) {
- parsedFiles.push(new Y.FileHTML5(value));
- });
- }
-
- if (parsedFiles.length > 0) {
- var oldfiles = this.get("fileList");
- this.set("fileList",
- this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles);
- this.fire("fileselect", {fileList: parsedFiles});
- }
-
- this.fire("drop");
- break;
+
+ if (Y.Array.indexOf(event._event.dataTransfer.types, 'Files') > -1) {
+ switch (event.type) {
+ case "dragenter":
+ this.fire("dragenter");
+ break;
+ case "dragover":
+ this.fire("dragover");
+ break;
+ case "dragleave":
+ this.fire("dragleave");
+ break;
+ case "drop":
+
+ var newfiles = event._event.dataTransfer.files,
+ parsedFiles = [],
+ filterFunc = this.get("fileFilterFunction");
+
+ if (filterFunc) {
+ Y.each(newfiles, function (value) {
+ var newfile = new Y.FileHTML5(value);
+ if (filterFunc(newfile)) {
+ parsedFiles.push(newfile);
+ }
+ });
+ }
+ else {
+ Y.each(newfiles, function (value) {
+ parsedFiles.push(new Y.FileHTML5(value));
+ });
+ }
+
+ if (parsedFiles.length > 0) {
+ var oldfiles = this.get("fileList");
+ this.set("fileList",
+ this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles);
+ this.fire("fileselect", {fileList: parsedFiles});
+ }
+
+ this.fire("drop");
+ break;
+ }
}
},
View
5 build/uploader-queue/uploader-queue-coverage.js
@@ -26,7 +26,7 @@ _yuitest_coverage["build/uploader-queue/uploader-queue.js"] = {
path: "build/uploader-queue/uploader-queue.js",
code: []
};
-_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;","","}, '@VERSION@', {\"requires\": [\"base\"]});"];
+_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(\"uploadcancel\", 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;","","","}, '@VERSION@', {\"requires\": [\"base\"]});"];
_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};
_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};
_yuitest_coverage["build/uploader-queue/uploader-queue.js"].coveredLines = 141;
@@ -370,7 +370,7 @@ updatedEvent.originEvent = event;
updatedEvent.file = event.target;
_yuitest_coverline("build/uploader-queue/uploader-queue.js", 245);
-this.fire("uploadcacel", updatedEvent);
+this.fire("uploadcancel", updatedEvent);
},
@@ -850,4 +850,5 @@ Y.namespace('Uploader');
_yuitest_coverline("build/uploader-queue/uploader-queue.js", 653);
Y.Uploader.Queue = UploaderQueue;
+
}, '@VERSION@', {"requires": ["base"]});
View
3  build/uploader-queue/uploader-queue-debug.js
@@ -242,7 +242,7 @@ YUI.add('uploader-queue', function (Y, NAME) {
updatedEvent.originEvent = event;
updatedEvent.file = event.target;
- this.fire("uploadcacel", updatedEvent);
+ this.fire("uploadcancel", updatedEvent);
},
@@ -652,4 +652,5 @@ YUI.add('uploader-queue', function (Y, NAME) {
Y.namespace('Uploader');
Y.Uploader.Queue = UploaderQueue;
+
}, '@VERSION@', {"requires": ["base"]});
View
2  build/uploader-queue/uploader-queue-min.js
@@ -1 +1 @@
-YUI.add("uploader-queue",function(e,t){var n=e.Lang,r=e.bind,i=e.config.win,s,o,u,a,f,l,c=function(e){this.queuedFiles=[],this.uploadRetries={},this.numberOfUploads=0,this.currentUploadedByteValues={},this.currentFiles={},this.totalBytesUploaded=0,this.totalBytes=0,c.superclass.constructor.apply(this,arguments)};e.extend(c,e.Base,{_currentState:c.STOPPED,initializer:function(e){},_uploadStartHandler:function(e){var t=e;t.file=e.target,t.originEvent=e,this.fire("uploadstart",t)},_uploadErrorHandler:function(e){var t=this.get("errorAction"),n=e;n.file=e.target,n.originEvent=e,this.numberOfUploads-=1,delete this.currentFiles[e.target.get("id")],this._detachFileEvents(e.target),e.target.cancelUpload();if(t===c.STOP)this.pauseUpload();else if(t===c.RESTART_ASAP){var r=e.target.get("id"),i=this.uploadRetries[r]||0;i<this.get("retryCount")&&(this.uploadRetries[r]=i+1,this.addToQueueTop(e.target)),this._startNextFile()}else if(t===c.RESTART_AFTER){var r=e.target.get("id"),i=this.uploadRetries[r]||0;i<this.get("retryCount")&&(this.uploadRetries[r]=i+1,this.addToQueueBottom(e.target)),this._startNextFile()}this.fire("uploaderror",n)},_startNextFile:function(){if(this.queuedFiles.length>0){var e=this.queuedFiles.shift(),t=e.get("id"),n=this.get("perFileParameters"),r=n.hasOwnProperty(t)?n[t]:n;this.currentUploadedByteValues[t]=0,e.on("uploadstart",this._uploadStartHandler,this),e.on("uploadprogress",this._uploadProgressHandler,this),e.on("uploadcomplete",this._uploadCompleteHandler,this),e.on("uploaderror",this._uploadErrorHandler,this),e.on("uploadcancel",this._uploadCancelHandler,this),e.set("xhrHeaders",this.get("uploadHeaders")),e.set("xhrWithCredentials",this.get("withCredentials")),e.startUpload(this.get("uploadURL"),r,this.get("fileFieldName")),this._registerUpload(e)}},_registerUpload:function(e){this.numberOfUploads+=1,this.currentFiles[e.get("id")]=e},_unregisterUpload:function(e){this.numberOfUploads>0&&(this.numberOfUploads-=1),delete this.currentFiles[e.get("id")],delete this.uploadRetries[e.get("id")],this._detachFileEvents(e)},_detachFileEvents:function(e){e.detach("uploadstart",this._uploadStartHandler),e.detach("uploadprogress",this._uploadProgressHandler),e.detach("uploadcomplete",this._uploadCompleteHandler),e.detach("uploaderror",this._uploadErrorHandler),e.detach("uploadcancel",this._uploadCancelHandler)},_uploadCompleteHandler:function(t){this._unregisterUpload(t.target),this.totalBytesUploaded+=t.target.get("size"),delete this.currentUploadedByteValues[t.target.get("id")],this.queuedFiles.length>0&&this._currentState===c.UPLOADING&&this._startNextFile();var n=t;n.file=t.target,n.originEvent=t;var r=this.totalBytesUploaded;e.each(this.currentUploadedByteValues,function(e){r+=e});var i=Math.min(100,Math.round(1e4*r/this.totalBytes)/100);this.fire("totaluploadprogress",{bytesLoaded:r,bytesTotal:this.totalBytes,percentLoaded:i}),this.fire("uploadcomplete",n),this.queuedFiles.length===0&&this.numberOfUploads<=0&&(this.fire("alluploadscomplete"),this._currentState=c.STOPPED)},_uploadCancelHandler:function(e){var t=e;t.originEvent=e,t.file=e.target,this.fire("uploadcacel",t)},_uploadProgressHandler:function(t){this.currentUploadedByteValues[t.target.get("id")]=t.bytesLoaded;var n=t;n.originEvent=t,n.file=t.target,this.fire("uploadprogress",n);var r=this.totalBytesUploaded;e.each(this.currentUploadedByteValues,function(e){r+=e});var i=Math.min(100,Math.round(1e4*r/this.totalBytes)/100);this.fire("totaluploadprogress",{bytesLoaded:r,bytesTotal:this.totalBytes,percentLoaded:i})},startUpload:function(){this.queuedFiles=this.get("fileList").slice(0),this.numberOfUploads=0,this.currentUploadedByteValues={},this.currentFiles={},this.totalBytesUploaded=0,this._currentState=c.UPLOADING;while(this.numberOfUploads<this.get("simUploads")&&this.queuedFiles.length>0)this._startNextFile()},pauseUpload:function(){this._currentState=c.STOPPED},restartUpload:function(){this._currentState=c.UPLOADING;while(this.numberOfUploads<this.get("simUploads"))this._startNextFile()},forceReupload:function(e){var t=e.get("id");this.currentFiles.hasOwnProperty(t)&&(e.cancelUpload(),this._unregisterUpload(e),this.addToQueueTop(e),this._startNextFile())},addToQueueTop:function(e){this.queuedFiles.unshift(e)},addToQueueBottom:function(e){this.queuedFiles.push(e)},cancelUpload:function(e){if(e){var t=e.get("id");if(this.currentFiles[t])this.currentFiles[t].cancelUpload(),this._unregisterUpload(this.currentFiles[t]),this._currentState===c.UPLOADING&&this._startNextFile();else for(var n=0,r=this.queuedFiles.length;n<r;n++)if(this.queuedFiles[n].get("id")===t){this.queuedFiles.splice(n,1);break}}else{for(var i in this.currentFiles)this.currentFiles[i].cancelUpload(),this._unregisterUpload(this.currentFiles[i]);this.currentUploadedByteValues={},this.currentFiles={},this.totalBytesUploaded=0,this.fire("alluploadscancelled"),this._currentState=c.STOPPED}}},{CONTINUE:"continue",STOP:"stop",RESTART_ASAP:"restartasap",RESTART_AFTER:"restartafter",STOPPED:"stopped",UPLOADING:"uploading",NAME:"uploaderqueue",ATTRS:{simUploads:{value:2,validator:function(e,t){return e>=1&&e<=5}},errorAction:{value:"continue",validator:function(e,t){return e===c.CONTINUE||e===c.STOP||e===c.RESTART_ASAP||e===c.RESTART_AFTER}},bytesUploaded:{readOnly:!0,value:0},bytesTotal:{readOnly:!0,value:0},fileList:{value:[],lazyAdd:!1,setter:function(t){var n=t;return e.Array.each(n,function(e){this.totalBytes+=e.get("size")},this),t}},fileFieldName:{value:"Filedata"},uploadURL:{value:""},uploadHeaders:{value:{}},withCredentials:{value:!0},perFileParameters:{value:{}},retryCount:{value:3}}}),e.namespace("Uploader"),e.Uploader.Queue=c},"@VERSION@",{requires:["base"]});
+YUI.add("uploader-queue",function(e,t){var n=e.Lang,r=e.bind,i=e.config.win,s,o,u,a,f,l,c=function(e){this.queuedFiles=[],this.uploadRetries={},this.numberOfUploads=0,this.currentUploadedByteValues={},this.currentFiles={},this.totalBytesUploaded=0,this.totalBytes=0,c.superclass.constructor.apply(this,arguments)};e.extend(c,e.Base,{_currentState:c.STOPPED,initializer:function(e){},_uploadStartHandler:function(e){var t=e;t.file=e.target,t.originEvent=e,this.fire("uploadstart",t)},_uploadErrorHandler:function(e){var t=this.get("errorAction"),n=e;n.file=e.target,n.originEvent=e,this.numberOfUploads-=1,delete this.currentFiles[e.target.get("id")],this._detachFileEvents(e.target),e.target.cancelUpload();if(t===c.STOP)this.pauseUpload();else if(t===c.RESTART_ASAP){var r=e.target.get("id"),i=this.uploadRetries[r]||0;i<this.get("retryCount")&&(this.uploadRetries[r]=i+1,this.addToQueueTop(e.target)),this._startNextFile()}else if(t===c.RESTART_AFTER){var r=e.target.get("id"),i=this.uploadRetries[r]||0;i<this.get("retryCount")&&(this.uploadRetries[r]=i+1,this.addToQueueBottom(e.target)),this._startNextFile()}this.fire("uploaderror",n)},_startNextFile:function(){if(this.queuedFiles.length>0){var e=this.queuedFiles.shift(),t=e.get("id"),n=this.get("perFileParameters"),r=n.hasOwnProperty(t)?n[t]:n;this.currentUploadedByteValues[t]=0,e.on("uploadstart",this._uploadStartHandler,this),e.on("uploadprogress",this._uploadProgressHandler,this),e.on("uploadcomplete",this._uploadCompleteHandler,this),e.on("uploaderror",this._uploadErrorHandler,this),e.on("uploadcancel",this._uploadCancelHandler,this),e.set("xhrHeaders",this.get("uploadHeaders")),e.set("xhrWithCredentials",this.get("withCredentials")),e.startUpload(this.get("uploadURL"),r,this.get("fileFieldName")),this._registerUpload(e)}},_registerUpload:function(e){this.numberOfUploads+=1,this.currentFiles[e.get("id")]=e},_unregisterUpload:function(e){this.numberOfUploads>0&&(this.numberOfUploads-=1),delete this.currentFiles[e.get("id")],delete this.uploadRetries[e.get("id")],this._detachFileEvents(e)},_detachFileEvents:function(e){e.detach("uploadstart",this._uploadStartHandler),e.detach("uploadprogress",this._uploadProgressHandler),e.detach("uploadcomplete",this._uploadCompleteHandler),e.detach("uploaderror",this._uploadErrorHandler),e.detach("uploadcancel",this._uploadCancelHandler)},_uploadCompleteHandler:function(t){this._unregisterUpload(t.target),this.totalBytesUploaded+=t.target.get("size"),delete this.currentUploadedByteValues[t.target.get("id")],this.queuedFiles.length>0&&this._currentState===c.UPLOADING&&this._startNextFile();var n=t;n.file=t.target,n.originEvent=t;var r=this.totalBytesUploaded;e.each(this.currentUploadedByteValues,function(e){r+=e});var i=Math.min(100,Math.round(1e4*r/this.totalBytes)/100);this.fire("totaluploadprogress",{bytesLoaded:r,bytesTotal:this.totalBytes,percentLoaded:i}),this.fire("uploadcomplete",n),this.queuedFiles.length===0&&this.numberOfUploads<=0&&(this.fire("alluploadscomplete"),this._currentState=c.STOPPED)},_uploadCancelHandler:function(e){var t=e;t.originEvent=e,t.file=e.target,this.fire("uploadcancel",t)},_uploadProgressHandler:function(t){this.currentUploadedByteValues[t.target.get("id")]=t.bytesLoaded;var n=t;n.originEvent=t,n.file=t.target,this.fire("uploadprogress",n);var r=this.totalBytesUploaded;e.each(this.currentUploadedByteValues,function(e){r+=e});var i=Math.min(100,Math.round(1e4*r/this.totalBytes)/100);this.fire("totaluploadprogress",{bytesLoaded:r,bytesTotal:this.totalBytes,percentLoaded:i})},startUpload:function(){this.queuedFiles=this.get("fileList").slice(0),this.numberOfUploads=0,this.currentUploadedByteValues={},this.currentFiles={},this.totalBytesUploaded=0,this._currentState=c.UPLOADING;while(this.numberOfUploads<this.get("simUploads")&&this.queuedFiles.length>0)this._startNextFile()},pauseUpload:function(){this._currentState=c.STOPPED},restartUpload:function(){this._currentState=c.UPLOADING;while(this.numberOfUploads<this.get("simUploads"))this._startNextFile()},forceReupload:function(e){var t=e.get("id");this.currentFiles.hasOwnProperty(t)&&(e.cancelUpload(),this._unregisterUpload(e),this.addToQueueTop(e),this._startNextFile())},addToQueueTop:function(e){this.queuedFiles.unshift(e)},addToQueueBottom:function(e){this.queuedFiles.push(e)},cancelUpload:function(e){if(e){var t=e.get("id");if(this.currentFiles[t])this.currentFiles[t].cancelUpload(),this._unregisterUpload(this.currentFiles[t]),this._currentState===c.UPLOADING&&this._startNextFile();else for(var n=0,r=this.queuedFiles.length;n<r;n++)if(this.queuedFiles[n].get("id")===t){this.queuedFiles.splice(n,1);break}}else{for(var i in this.currentFiles)this.currentFiles[i].cancelUpload(),this._unregisterUpload(this.currentFiles[i]);this.currentUploadedByteValues={},this.currentFiles={},this.totalBytesUploaded=0,this.fire("alluploadscancelled"),this._currentState=c.STOPPED}}},{CONTINUE:"continue",STOP:"stop",RESTART_ASAP:"restartasap",RESTART_AFTER:"restartafter",STOPPED:"stopped",UPLOADING:"uploading",NAME:"uploaderqueue",ATTRS:{simUploads:{value:2,validator:function(e,t){return e>=1&&e<=5}},errorAction:{value:"continue",validator:function(e,t){return e===c.CONTINUE||e===c.STOP||e===c.RESTART_ASAP||e===c.RESTART_AFTER}},bytesUploaded:{readOnly:!0,value:0},bytesTotal:{readOnly:!0,value:0},fileList:{value:[],lazyAdd:!1,setter:function(t){var n=t;return e.Array.each(n,function(e){this.totalBytes+=e.get("size")},this),t}},fileFieldName:{value:"Filedata"},uploadURL:{value:""},uploadHeaders:{value:{}},withCredentials:{value:!0},perFileParameters:{value:{}},retryCount:{value:3}}}),e.namespace("Uploader"),e.Uploader.Queue=c},"@VERSION@",{requires:["base"]});
View
3  build/uploader-queue/uploader-queue.js
@@ -242,7 +242,7 @@ YUI.add('uploader-queue', function (Y, NAME) {
updatedEvent.originEvent = event;
updatedEvent.file = event.target;
- this.fire("uploadcacel", updatedEvent);
+ this.fire("uploadcancel", updatedEvent);
},
@@ -652,4 +652,5 @@ YUI.add('uploader-queue', function (Y, NAME) {
Y.namespace('Uploader');
Y.Uploader.Queue = UploaderQueue;
+
}, '@VERSION@', {"requires": ["base"]});
View
82 src/uploader/js/uploader-html5.js
@@ -342,46 +342,48 @@ Y.UploaderHTML5 = Y.extend( UploaderHTML5, Y.Widget, {
event.stopPropagation();
event.preventDefault();
-
- switch (event.type) {
- case "dragenter":
- this.fire("dragenter");
- break;
- case "dragover":
- this.fire("dragover");
- break;
- case "dragleave":
- this.fire("dragleave");
- break;
- case "drop":
-
- var newfiles = event._event.dataTransfer.files,
- parsedFiles = [],
- filterFunc = this.get("fileFilterFunction");
-
- if (filterFunc) {
- Y.each(newfiles, function (value) {
- var newfile = new Y.FileHTML5(value);
- if (filterFunc(newfile)) {
- parsedFiles.push(newfile);
- }
- });
- }
- else {
- Y.each(newfiles, function (value) {
- parsedFiles.push(new Y.FileHTML5(value));
- });
- }
-
- if (parsedFiles.length > 0) {
- var oldfiles = this.get("fileList");
- this.set("fileList",
- this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles);
- this.fire("fileselect", {fileList: parsedFiles});
- }
-
- this.fire("drop");
- break;
+
+ if (Y.Array.indexOf(event._event.dataTransfer.types, 'Files') > -1) {
+ switch (event.type) {
+ case "dragenter":
+ this.fire("dragenter");
+ break;
+ case "dragover":
+ this.fire("dragover");
+ break;
+ case "dragleave":
+ this.fire("dragleave");
+ break;
+ case "drop":
+
+ var newfiles = event._event.dataTransfer.files,
+ parsedFiles = [],
+ filterFunc = this.get("fileFilterFunction");
+
+ if (filterFunc) {
+ Y.each(newfiles, function (value) {
+ var newfile = new Y.FileHTML5(value);
+ if (filterFunc(newfile)) {
+ parsedFiles.push(newfile);
+ }
+ });
+ }
+ else {
+ Y.each(newfiles, function (value) {
+ parsedFiles.push(new Y.FileHTML5(value));
+ });
+ }
+
+ if (parsedFiles.length > 0) {
+ var oldfiles = this.get("fileList");
+ this.set("fileList",
+ this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles);
+ this.fire("fileselect", {fileList: parsedFiles});
+ }
+
+ this.fire("drop");
+ break;
+ }
}
},
View
4 src/uploader/js/uploader-queue.js
@@ -240,7 +240,7 @@
updatedEvent.originEvent = event;
updatedEvent.file = event.target;
- this.fire("uploadcacel", updatedEvent);
+ this.fire("uploadcancel", updatedEvent);
},
@@ -648,4 +648,4 @@
Y.namespace('Uploader');
- Y.Uploader.Queue = UploaderQueue;
+ Y.Uploader.Queue = UploaderQueue;

No commit comments for this range

Something went wrong with that request. Please try again.