From eea1e257bdd07fde9be161859dc55156805264b7 Mon Sep 17 00:00:00 2001 From: dolymood Date: Tue, 22 Aug 2017 15:54:31 +0800 Subject: [PATCH] build --- dist/uploader.js | 2 +- dist/uploader.min.js | 2 +- dist/uploader.min.js.map | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/uploader.js b/dist/uploader.js index e2477fb..548759d 100644 --- a/dist/uploader.js +++ b/dist/uploader.js @@ -1478,7 +1478,7 @@ var utils = { formatSize: function (size) { if (size < 1024) { - return size + ' bytes' + return size.toFixed(0) + ' bytes' } else if (size < 1024 * 1024) { return (size / 1024.0).toFixed(0) + ' KB' } else if (size < 1024 * 1024 * 1024) { diff --git a/dist/uploader.min.js b/dist/uploader.min.js index b7ef7c4..bc7b5f3 100644 --- a/dist/uploader.min.js +++ b/dist/uploader.min.js @@ -5,5 +5,5 @@ * @link https://github.com/simple-uploader/Uploader * @license MIT */ -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Uploader=e()}}(function(){return function e(t,i,s){function r(a,o){if(!i[a]){if(!t[a]){var h="function"==typeof require&&require;if(!o&&h)return h(a,!0);if(n)return n(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=i[a]={exports:{}};t[a][0].call(u.exports,function(e){var i=t[a][1][e];return r(i||e)},u,u.exports,e,t,i,s)}return i[a].exports}for(var n="function"==typeof require&&require,a=0;a-1?n.SUCCESS:this.uploader.opts.permanentErrors.indexOf(this.xhr.status)>-1||!e&&this.retries>=this.uploader.opts.maxChunkRetries?n.ERROR:(this.abort(),n.PENDING):n.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===n.SUCCESS||e===n.ERROR?1:e===n.PENDING?0:this.total>0?this.loaded/this.total:0},sizeUploaded:function(){var e=this.endByte-this.startByte;return this.status()!==n.SUCCESS&&(e=this.progress()*e),e},prepareXhrRequest:function(e,t,i,s){var n=r.evalOpts(this.uploader.opts.query,this.file,this,t);n=r.extend(this.getParams(),n);var a=r.evalOpts(this.uploader.opts.target,this.file,this,t),o=null;if("GET"===e||"octet"===i){var h=[];r.each(n,function(e,t){h.push([encodeURIComponent(t),encodeURIComponent(e)].join("="))}),a=this.getTarget(a,h),o=s||null}else o=new FormData,r.each(n,function(e,t){o.append(t,e)}),o.append(this.uploader.opts.fileParameterName,s,this.file.name);return this.xhr.open(e,a,!0),this.xhr.withCredentials=this.uploader.opts.withCredentials,r.each(r.evalOpts(this.uploader.opts.headers,this.file,this,t),function(e,t){this.xhr.setRequestHeader(t,e)},this),o}}),t.exports=s},{"./utils":5}],2:[function(e,t,i){var s=e("./utils").each,r={_eventData:null,on:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]||(this._eventData[e]=[]);var i=!1;s(this._eventData[e],function(e){if(e===t)return i=!0,!1}),i||this._eventData[e].push(t)},off:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]&&this._eventData[e].length&&(t?s(this._eventData[e],function(i,s){if(i===t)return this._eventData[e].splice(s,1),!1},this):this._eventData[e]=[])},trigger:function(e){if(this._eventData||(this._eventData={}),!this._eventData[e])return!0;var t=this._eventData[e].slice.call(arguments,1),i=!1;return s(this._eventData[e],function(e){i=!1===e.apply(this,t)||i},this),!i}};t.exports=r},{"./utils":5}],3:[function(e,t,i){function s(e){this.support=u,this.support&&(this.supportDirectory=l,this.filePaths={},this.opts=r.extend({},s.defaults,e||{}),a.call(this,this))}var r=e("./utils"),n=e("./event"),a=e("./file"),o=e("./chunk"),h=window.navigator.msPointerEnabled,u=function(){var e="slice",t=r.isDefined(window.File)&&r.isDefined(window.Blob)&&r.isDefined(window.FileList),i=null;return t&&(i=window.Blob.prototype,r.each(["slice","webkitSlice","mozSlice"],function(t){if(i[t])return e=t,!1}),t=!!i[e]),t&&(s.sliceName=e),i=null,t}(),l=function(){var e=window.document.createElement("input");e.type="file";var t="webkitdirectory"in e||"directory"in e;return e=null,t}();s.version="0.0.6",s.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,preprocess:null,method:"multipart",testMethod:"GET",uploadMethod:"POST",prioritizeFirstAndLastChunk:!1,allowDuplicateUploads:!1,target:"/",testChunks:!0,generateUniqueIdentifier:null,maxChunkRetries:0,chunkRetryInterval:null,permanentErrors:[404,415,500,501],successStatuses:[200,201,202],onDropStopPropagation:!1,initFileFn:null,readFileFn:function(e,t,i,r,n){n.readFinished(e.file[s.sliceName](i,r,t))}},s.utils=r,s.event=n,s.File=a,s.Chunk=o,s.prototype=r.extend({},a.prototype),r.extend(s.prototype,n),r.extend(s.prototype,{constructor:s,_trigger:function(e){var t=r.toArray(arguments),i=!this.trigger.apply(this,arguments);return"catchAll"!==e&&(t.unshift("catchAll"),i=!this.trigger.apply(this,t)||i),!i},_triggerAsync:function(){var e=arguments;r.nextTick(function(){this._trigger.apply(this,e)},this)},addFiles:function(e,t){var i=[],s=this.fileList.length;r.each(e,function(e){if((!h||h&&e.size>0)&&(e.size%4096!=0||"."!==e.name&&"."!==e.fileName)){var s=this.generateUniqueIdentifier(e);if(this.opts.allowDuplicateUploads||!this.getFromUniqueIdentifier(s)){var r=new a(this,e,this);r.uniqueIdentifier=s,this._trigger("fileAdded",r,t)&&i.push(r)}}},this);var n=this.fileList.slice(s);this._trigger("filesAdded",i,n,t)&&(r.each(i,function(e){this.opts.singleFile&&this.files.length>0&&this.removeFile(this.files[0]),this.files.push(e)},this),this._trigger("filesSubmitted",i,n,t))},addFile:function(e,t){this.addFiles([e],t)},cancel:function(){for(var e=this.fileList.length-1;e>=0;e--)this.fileList[e].cancel()},removeFile:function(e){a.prototype.removeFile.call(this,e),this._trigger("fileRemoved",e)},generateUniqueIdentifier:function(e){var t=this.opts.generateUniqueIdentifier;if(r.isFunction(t))return t(e);var i=e.relativePath||e.webkitRelativePath||e.fileName||e.name;return e.size+"-"+i.replace(/[^0-9a-zA-Z_-]/gim,"")},getFromUniqueIdentifier:function(e){var t=!1;return r.each(this.files,function(i){if(i.uniqueIdentifier===e)return t=i,!1}),t},uploadNextChunk:function(e){var t=!1,i=o.STATUS.PENDING;if(this.opts.prioritizeFirstAndLastChunk&&(r.each(this.files,function(e){return!e.paused&&e.chunks.length&&e.chunks[0].status()===i?(e.chunks[0].send(),t=!0,!1):!e.paused&&e.chunks.length>1&&e.chunks[e.chunks.length-1].status()===i?(e.chunks[e.chunks.length-1].send(),t=!0,!1):void 0}),t))return t;if(r.each(this.files,function(e){if(e.paused||r.each(e.chunks,function(e){if(e.status()===i)return e.send(),t=!0,!1}),t)return!1}),t)return!0;var s=!1;return r.each(this.files,function(e){if(!e.isComplete())return s=!0,!1}),s||e||this._triggerAsync("complete"),!1},upload:function(){var e=this._shouldUploadNext();if(!1!==e){this._trigger("uploadStart");for(var t=!1,i=1;i<=this.opts.simultaneousUploads-e;i++)t=this.uploadNextChunk(!0)||t;t||this._triggerAsync("complete")}},_shouldUploadNext:function(){var e=0,t=!0,i=this.opts.simultaneousUploads,s=o.STATUS.UPLOADING;return r.each(this.files,function(n){r.each(n.chunks,function(r){if(r.status()===s&&++e>=i)return t=!1,!1})}),t&&e},assignBrowse:function(e,t,i,s){void 0===e.length&&(e=[e]),r.each(e,function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),r.extend(n.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(n),e.addEventListener("click",function(){n.click()},!1)),this.opts.singleFile||i||n.setAttribute("multiple","multiple"),t&&n.setAttribute("webkitdirectory","webkitdirectory"),s&&r.each(s,function(e,t){n.setAttribute(t,e)});var a=this;n.addEventListener("change",function(e){e.target.value&&(a.addFiles(e.target.files,e),e.target.value="")},!1)},this)},onDrop:function(e){this.opts.onDropStopPropagation&&e.stopPropagation(),e.preventDefault(),this._parseDataTransfer(e.dataTransfer,e)},_parseDataTransfer:function(e,t){e.items&&e.items[0]&&e.items[0].webkitGetAsEntry?this.webkitReadDataTransfer(e,t):this.addFiles(e.files,t)},webkitReadDataTransfer:function(e,t){function i(e){e.readEntries(function(t){t.length?(h+=t.length,r.each(t,function(e){if(e.isFile){var t=e.fullPath;e.file(function(e){s(e,t)},n)}else e.isDirectory&&i(e.createReader())}),i(e)):a()},n)}function s(e,t){e.relativePath=t.substring(1),u.push(e),a()}function n(e){throw e}function a(){0==--h&&o.addFiles(u,t)}var o=this,h=e.items.length,u=[];r.each(e.items,function(e){var t=e.webkitGetAsEntry();t?t.isFile?s(e.getAsFile(),t.fullPath):i(t.createReader()):a()})},_assignHelper:function(e,t,i){void 0===e.length&&(e=[e]);var s=i?"removeEventListener":"addEventListener";r.each(e,function(e){r.each(t,function(t,i){e[s](i,t,!1)},this)},this)},assignDrop:function(e){this._onDrop=r.bind(this.onDrop,this),this._assignHelper(e,{dragover:r.preventEvent,dragenter:r.preventEvent,drop:this._onDrop})},unAssignDrop:function(e){this._assignHelper(e,{dragover:r.preventEvent,dragenter:r.preventEvent,drop:this._onDrop},!0),this._onDrop=null}}),t.exports=s},{"./chunk":1,"./event":2,"./file":4,"./utils":5}],4:[function(e,t,i){function s(e,t,i){n.defineNonEnumerable(this,"uploader",e),this.isRoot=this.isFolder=e===this,n.defineNonEnumerable(this,"parent",i||null),n.defineNonEnumerable(this,"files",[]),n.defineNonEnumerable(this,"fileList",[]),n.defineNonEnumerable(this,"chunks",[]),n.defineNonEnumerable(this,"_errorFiles",[]),n.defineNonEnumerable(this,"file",null),this.id=n.uid(),this.isRoot||!t?this.file=null:n.isString(t)?(this.isFolder=!0,this.file=null,this.path=t,this.parent.path&&(t=t.substr(this.parent.path.length)),this.name="/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t):(this.file=t,this.fileType=this.file.type,this.name=t.fileName||t.name,this.size=t.size,this.relativePath=t.relativePath||t.webkitRelativePath||this.name,this._parseFile()),this.paused=!1,this.error=!1,this.allError=!1,this.aborted=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevUploadedSize=0,this._prevProgress=0,this.bootstrap()}function r(e){var t=[],i=e.split("/"),s=i.length,r=1;if(i.splice(s-1,1),s--,i.length)for(;r<=s;)t.push(i.slice(0,r++).join("/")+"/");return t}var n=e("./utils"),a=e("./chunk");n.extend(s.prototype,{_parseFile:function(){var e=r(this.relativePath);if(e.length){var t=this.uploader.filePaths;n.each(e,function(i,r){var n=t[i];n||(n=new s(this.uploader,i,this.parent),t[i]=n,this._updateParentFileList(n)),this.parent=n,n.files.push(this),e[r+1]||n.fileList.push(this)},this)}else this._updateParentFileList()},_updateParentFileList:function(e){e||(e=this);var t=this.parent;t&&t.fileList.push(e)},_eachAccess:function(e,t){this.isFolder?n.each(this.files,function(t,i){return e.call(this,t,i)},this):t.call(this,this)},bootstrap:function(){if(!this.isFolder){var e=this.uploader.opts;n.isFunction(e.initFileFn)&&e.initFileFn.call(this,this),this.abort(!0),this._resetError(),this._prevProgress=0;for(var t=e.forceChunkSize?Math.ceil:Math.floor,i=Math.max(t(this.size/e.chunkSize),1),s=0;s=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(e,t,i){var s=this.uploader,r=a.STATUS,n=this,o=this.getRoot(),h=function(t){n._measureSpeed(t),s._trigger("fileProgress",o,n,e),n._lastProgressCallback=Date.now()};switch(t){case r.PROGRESS:this._checkProgress()&&h();break;case r.ERROR:this._error(),this.abort(!0),s._trigger("fileError",o,this,i,e);break;case r.SUCCESS:if(this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var u=Date.now()-this._lastProgressCallback;u0?e/t:this.isComplete()?1:0)},function(){if(this.error)i=1;else{if(1===this.chunks.length)return this._prevProgress=Math.max(this._prevProgress,this.chunks[0].progress()),void(i=this._prevProgress);var e=0;n.each(this.chunks,function(t){e+=t.progress()*(t.endByte-t.startByte)});var t=e/this.size;this._prevProgress=Math.max(this._prevProgress,t>.9999?1:t),i=this._prevProgress}}),i},getSize:function(){var e=0;return this._eachAccess(function(t){e+=t.size},function(){e+=this.size}),e},getFormatSize:function(){var e=this.getSize();return n.formatSize(e)},getRoot:function(){if(this.isRoot)return this;for(var e=this.parent;e;){if(e.parent===this.uploader)return e;e=e.parent}return this},sizeUploaded:function(){var e=0;return this._eachAccess(function(t){e+=t.sizeUploaded()},function(){n.each(this.chunks,function(t){e+=t.sizeUploaded()})}),e},timeRemaining:function(){function e(e,t){return e&&!t?Number.POSITIVE_INFINITY:e||t?Math.floor(e/t):0}var t=0,i=0,s=0;return this._eachAccess(function(r,n){r.paused||r.error||(i+=r.size-r.sizeUploaded(),s+=r.averageSpeed),n===this.files.length-1&&(t=e(i,s))},function(){if(this.paused||this.error)t=0;else{var i=this.size-this.sizeUploaded();t=e(i,this.averageSpeed)}}),t},removeFile:function(e){if(e.isFolder)for(;e.files.length;){var t=e.files[e.files.length-1];this._removeFile(t)}this._removeFile(e)},_delFilePath:function(e){e.path&&this.filePaths&&delete this.filePaths[e.path],n.each(e.fileList,function(e){this._delFilePath(e)},this)},_removeFile:function(e){!e.isFolder&&n.each(this.files,function(t,i){if(t===e){this.files.splice(i,1),e.abort();for(var s,r=e.parent;r&&r!==this;)s=r.parent,r._removeFile(e),r=s;return!1}},this),e.parent===this&&n.each(this.fileList,function(t,i){if(t===e)return this.fileList.splice(i,1),!1},this),this.isRoot||!this.isFolder||this.files.length||(this.parent._removeFile(this),this.uploader._delFilePath(this)),e.parent=null},getType:function(){return this.isFolder?"folder":this.file.type&&this.file.type.split("/")[1]},getExtension:function(){return this.isFolder?"":this.name.substr(2+(~-this.name.lastIndexOf(".")>>>0)).toLowerCase()}}),t.exports=s},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var s=Object.prototype,r=Array.prototype,n=s.toString,a=function(e){return"[object Function]"===n.call(e)},o=Array.isArray||function(e){return"[object Array]"===n.call(e)},h=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===s},u=0,l={uid:function(){return++u},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(l.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),r.slice.call(e,t,i)},isPlainObject:h,isFunction:a,isArray:o,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(l.isDefined(e.length))for(var s=0,r=e.length;s-1?n.SUCCESS:this.uploader.opts.permanentErrors.indexOf(this.xhr.status)>-1||!e&&this.retries>=this.uploader.opts.maxChunkRetries?n.ERROR:(this.abort(),n.PENDING):n.PENDING},message:function(){return this.xhr?this.xhr.responseText:""},progress:function(){if(this.pendingRetry)return 0;var e=this.status();return e===n.SUCCESS||e===n.ERROR?1:e===n.PENDING?0:this.total>0?this.loaded/this.total:0},sizeUploaded:function(){var e=this.endByte-this.startByte;return this.status()!==n.SUCCESS&&(e=this.progress()*e),e},prepareXhrRequest:function(e,t,i,s){var n=r.evalOpts(this.uploader.opts.query,this.file,this,t);n=r.extend(this.getParams(),n);var a=r.evalOpts(this.uploader.opts.target,this.file,this,t),o=null;if("GET"===e||"octet"===i){var h=[];r.each(n,function(e,t){h.push([encodeURIComponent(t),encodeURIComponent(e)].join("="))}),a=this.getTarget(a,h),o=s||null}else o=new FormData,r.each(n,function(e,t){o.append(t,e)}),o.append(this.uploader.opts.fileParameterName,s,this.file.name);return this.xhr.open(e,a,!0),this.xhr.withCredentials=this.uploader.opts.withCredentials,r.each(r.evalOpts(this.uploader.opts.headers,this.file,this,t),function(e,t){this.xhr.setRequestHeader(t,e)},this),o}}),t.exports=s},{"./utils":5}],2:[function(e,t,i){var s=e("./utils").each,r={_eventData:null,on:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]||(this._eventData[e]=[]);var i=!1;s(this._eventData[e],function(e){if(e===t)return i=!0,!1}),i||this._eventData[e].push(t)},off:function(e,t){this._eventData||(this._eventData={}),this._eventData[e]&&this._eventData[e].length&&(t?s(this._eventData[e],function(i,s){if(i===t)return this._eventData[e].splice(s,1),!1},this):this._eventData[e]=[])},trigger:function(e){if(this._eventData||(this._eventData={}),!this._eventData[e])return!0;var t=this._eventData[e].slice.call(arguments,1),i=!1;return s(this._eventData[e],function(e){i=!1===e.apply(this,t)||i},this),!i}};t.exports=r},{"./utils":5}],3:[function(e,t,i){function s(e){this.support=u,this.support&&(this.supportDirectory=l,this.filePaths={},this.opts=r.extend({},s.defaults,e||{}),a.call(this,this))}var r=e("./utils"),n=e("./event"),a=e("./file"),o=e("./chunk"),h=window.navigator.msPointerEnabled,u=function(){var e="slice",t=r.isDefined(window.File)&&r.isDefined(window.Blob)&&r.isDefined(window.FileList),i=null;return t&&(i=window.Blob.prototype,r.each(["slice","webkitSlice","mozSlice"],function(t){if(i[t])return e=t,!1}),t=!!i[e]),t&&(s.sliceName=e),i=null,t}(),l=function(){var e=window.document.createElement("input");e.type="file";var t="webkitdirectory"in e||"directory"in e;return e=null,t}();s.version="0.0.6",s.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,preprocess:null,method:"multipart",testMethod:"GET",uploadMethod:"POST",prioritizeFirstAndLastChunk:!1,allowDuplicateUploads:!1,target:"/",testChunks:!0,generateUniqueIdentifier:null,maxChunkRetries:0,chunkRetryInterval:null,permanentErrors:[404,415,500,501],successStatuses:[200,201,202],onDropStopPropagation:!1,initFileFn:null,readFileFn:function(e,t,i,r,n){n.readFinished(e.file[s.sliceName](i,r,t))}},s.utils=r,s.event=n,s.File=a,s.Chunk=o,s.prototype=r.extend({},a.prototype),r.extend(s.prototype,n),r.extend(s.prototype,{constructor:s,_trigger:function(e){var t=r.toArray(arguments),i=!this.trigger.apply(this,arguments);return"catchAll"!==e&&(t.unshift("catchAll"),i=!this.trigger.apply(this,t)||i),!i},_triggerAsync:function(){var e=arguments;r.nextTick(function(){this._trigger.apply(this,e)},this)},addFiles:function(e,t){var i=[],s=this.fileList.length;r.each(e,function(e){if((!h||h&&e.size>0)&&(e.size%4096!=0||"."!==e.name&&"."!==e.fileName)){var s=this.generateUniqueIdentifier(e);if(this.opts.allowDuplicateUploads||!this.getFromUniqueIdentifier(s)){var r=new a(this,e,this);r.uniqueIdentifier=s,this._trigger("fileAdded",r,t)&&i.push(r)}}},this);var n=this.fileList.slice(s);this._trigger("filesAdded",i,n,t)&&(r.each(i,function(e){this.opts.singleFile&&this.files.length>0&&this.removeFile(this.files[0]),this.files.push(e)},this),this._trigger("filesSubmitted",i,n,t))},addFile:function(e,t){this.addFiles([e],t)},cancel:function(){for(var e=this.fileList.length-1;e>=0;e--)this.fileList[e].cancel()},removeFile:function(e){a.prototype.removeFile.call(this,e),this._trigger("fileRemoved",e)},generateUniqueIdentifier:function(e){var t=this.opts.generateUniqueIdentifier;if(r.isFunction(t))return t(e);var i=e.relativePath||e.webkitRelativePath||e.fileName||e.name;return e.size+"-"+i.replace(/[^0-9a-zA-Z_-]/gim,"")},getFromUniqueIdentifier:function(e){var t=!1;return r.each(this.files,function(i){if(i.uniqueIdentifier===e)return t=i,!1}),t},uploadNextChunk:function(e){var t=!1,i=o.STATUS.PENDING;if(this.opts.prioritizeFirstAndLastChunk&&(r.each(this.files,function(e){return!e.paused&&e.chunks.length&&e.chunks[0].status()===i?(e.chunks[0].send(),t=!0,!1):!e.paused&&e.chunks.length>1&&e.chunks[e.chunks.length-1].status()===i?(e.chunks[e.chunks.length-1].send(),t=!0,!1):void 0}),t))return t;if(r.each(this.files,function(e){if(e.paused||r.each(e.chunks,function(e){if(e.status()===i)return e.send(),t=!0,!1}),t)return!1}),t)return!0;var s=!1;return r.each(this.files,function(e){if(!e.isComplete())return s=!0,!1}),s||e||this._triggerAsync("complete"),!1},upload:function(){var e=this._shouldUploadNext();if(!1!==e){this._trigger("uploadStart");for(var t=!1,i=1;i<=this.opts.simultaneousUploads-e;i++)t=this.uploadNextChunk(!0)||t;t||this._triggerAsync("complete")}},_shouldUploadNext:function(){var e=0,t=!0,i=this.opts.simultaneousUploads,s=o.STATUS.UPLOADING;return r.each(this.files,function(n){r.each(n.chunks,function(r){if(r.status()===s&&++e>=i)return t=!1,!1})}),t&&e},assignBrowse:function(e,t,i,s){void 0===e.length&&(e=[e]),r.each(e,function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),r.extend(n.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(n),e.addEventListener("click",function(){n.click()},!1)),this.opts.singleFile||i||n.setAttribute("multiple","multiple"),t&&n.setAttribute("webkitdirectory","webkitdirectory"),s&&r.each(s,function(e,t){n.setAttribute(t,e)});var a=this;n.addEventListener("change",function(e){e.target.value&&(a.addFiles(e.target.files,e),e.target.value="")},!1)},this)},onDrop:function(e){this.opts.onDropStopPropagation&&e.stopPropagation(),e.preventDefault(),this._parseDataTransfer(e.dataTransfer,e)},_parseDataTransfer:function(e,t){e.items&&e.items[0]&&e.items[0].webkitGetAsEntry?this.webkitReadDataTransfer(e,t):this.addFiles(e.files,t)},webkitReadDataTransfer:function(e,t){function i(e){e.readEntries(function(t){t.length?(h+=t.length,r.each(t,function(e){if(e.isFile){var t=e.fullPath;e.file(function(e){s(e,t)},n)}else e.isDirectory&&i(e.createReader())}),i(e)):a()},n)}function s(e,t){e.relativePath=t.substring(1),u.push(e),a()}function n(e){throw e}function a(){0==--h&&o.addFiles(u,t)}var o=this,h=e.items.length,u=[];r.each(e.items,function(e){var t=e.webkitGetAsEntry();t?t.isFile?s(e.getAsFile(),t.fullPath):i(t.createReader()):a()})},_assignHelper:function(e,t,i){void 0===e.length&&(e=[e]);var s=i?"removeEventListener":"addEventListener";r.each(e,function(e){r.each(t,function(t,i){e[s](i,t,!1)},this)},this)},assignDrop:function(e){this._onDrop=r.bind(this.onDrop,this),this._assignHelper(e,{dragover:r.preventEvent,dragenter:r.preventEvent,drop:this._onDrop})},unAssignDrop:function(e){this._assignHelper(e,{dragover:r.preventEvent,dragenter:r.preventEvent,drop:this._onDrop},!0),this._onDrop=null}}),t.exports=s},{"./chunk":1,"./event":2,"./file":4,"./utils":5}],4:[function(e,t,i){function s(e,t,i){n.defineNonEnumerable(this,"uploader",e),this.isRoot=this.isFolder=e===this,n.defineNonEnumerable(this,"parent",i||null),n.defineNonEnumerable(this,"files",[]),n.defineNonEnumerable(this,"fileList",[]),n.defineNonEnumerable(this,"chunks",[]),n.defineNonEnumerable(this,"_errorFiles",[]),n.defineNonEnumerable(this,"file",null),this.id=n.uid(),this.isRoot||!t?this.file=null:n.isString(t)?(this.isFolder=!0,this.file=null,this.path=t,this.parent.path&&(t=t.substr(this.parent.path.length)),this.name="/"===t.charAt(t.length-1)?t.substr(0,t.length-1):t):(this.file=t,this.fileType=this.file.type,this.name=t.fileName||t.name,this.size=t.size,this.relativePath=t.relativePath||t.webkitRelativePath||this.name,this._parseFile()),this.paused=!1,this.error=!1,this.allError=!1,this.aborted=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevUploadedSize=0,this._prevProgress=0,this.bootstrap()}function r(e){var t=[],i=e.split("/"),s=i.length,r=1;if(i.splice(s-1,1),s--,i.length)for(;r<=s;)t.push(i.slice(0,r++).join("/")+"/");return t}var n=e("./utils"),a=e("./chunk");n.extend(s.prototype,{_parseFile:function(){var e=r(this.relativePath);if(e.length){var t=this.uploader.filePaths;n.each(e,function(i,r){var n=t[i];n||(n=new s(this.uploader,i,this.parent),t[i]=n,this._updateParentFileList(n)),this.parent=n,n.files.push(this),e[r+1]||n.fileList.push(this)},this)}else this._updateParentFileList()},_updateParentFileList:function(e){e||(e=this);var t=this.parent;t&&t.fileList.push(e)},_eachAccess:function(e,t){this.isFolder?n.each(this.files,function(t,i){return e.call(this,t,i)},this):t.call(this,this)},bootstrap:function(){if(!this.isFolder){var e=this.uploader.opts;n.isFunction(e.initFileFn)&&e.initFileFn.call(this,this),this.abort(!0),this._resetError(),this._prevProgress=0;for(var t=e.forceChunkSize?Math.ceil:Math.floor,i=Math.max(t(this.size/e.chunkSize),1),s=0;s=this.uploader.opts.progressCallbacksInterval},_chunkEvent:function(e,t,i){var s=this.uploader,r=a.STATUS,n=this,o=this.getRoot(),h=function(t){n._measureSpeed(t),s._trigger("fileProgress",o,n,e),n._lastProgressCallback=Date.now()};switch(t){case r.PROGRESS:this._checkProgress()&&h();break;case r.ERROR:this._error(),this.abort(!0),s._trigger("fileError",o,this,i,e);break;case r.SUCCESS:if(this.error)return;clearTimeout(this._progeressId),this._progeressId=0;var u=Date.now()-this._lastProgressCallback;u0?e/t:this.isComplete()?1:0)},function(){if(this.error)i=1;else{if(1===this.chunks.length)return this._prevProgress=Math.max(this._prevProgress,this.chunks[0].progress()),void(i=this._prevProgress);var e=0;n.each(this.chunks,function(t){e+=t.progress()*(t.endByte-t.startByte)});var t=e/this.size;this._prevProgress=Math.max(this._prevProgress,t>.9999?1:t),i=this._prevProgress}}),i},getSize:function(){var e=0;return this._eachAccess(function(t){e+=t.size},function(){e+=this.size}),e},getFormatSize:function(){var e=this.getSize();return n.formatSize(e)},getRoot:function(){if(this.isRoot)return this;for(var e=this.parent;e;){if(e.parent===this.uploader)return e;e=e.parent}return this},sizeUploaded:function(){var e=0;return this._eachAccess(function(t){e+=t.sizeUploaded()},function(){n.each(this.chunks,function(t){e+=t.sizeUploaded()})}),e},timeRemaining:function(){function e(e,t){return e&&!t?Number.POSITIVE_INFINITY:e||t?Math.floor(e/t):0}var t=0,i=0,s=0;return this._eachAccess(function(r,n){r.paused||r.error||(i+=r.size-r.sizeUploaded(),s+=r.averageSpeed),n===this.files.length-1&&(t=e(i,s))},function(){if(this.paused||this.error)t=0;else{var i=this.size-this.sizeUploaded();t=e(i,this.averageSpeed)}}),t},removeFile:function(e){if(e.isFolder)for(;e.files.length;){var t=e.files[e.files.length-1];this._removeFile(t)}this._removeFile(e)},_delFilePath:function(e){e.path&&this.filePaths&&delete this.filePaths[e.path],n.each(e.fileList,function(e){this._delFilePath(e)},this)},_removeFile:function(e){!e.isFolder&&n.each(this.files,function(t,i){if(t===e){this.files.splice(i,1),e.abort();for(var s,r=e.parent;r&&r!==this;)s=r.parent,r._removeFile(e),r=s;return!1}},this),e.parent===this&&n.each(this.fileList,function(t,i){if(t===e)return this.fileList.splice(i,1),!1},this),this.isRoot||!this.isFolder||this.files.length||(this.parent._removeFile(this),this.uploader._delFilePath(this)),e.parent=null},getType:function(){return this.isFolder?"folder":this.file.type&&this.file.type.split("/")[1]},getExtension:function(){return this.isFolder?"":this.name.substr(2+(~-this.name.lastIndexOf(".")>>>0)).toLowerCase()}}),t.exports=s},{"./chunk":1,"./utils":5}],5:[function(e,t,i){var s=Object.prototype,r=Array.prototype,n=s.toString,a=function(e){return"[object Function]"===n.call(e)},o=Array.isArray||function(e){return"[object Array]"===n.call(e)},h=function(e){return"[object Object]"===n.call(e)&&Object.getPrototypeOf(e)===s},u=0,l={uid:function(){return++u},noop:function(){},bind:function(e,t){return function(){return e.apply(t,arguments)}},preventEvent:function(e){e.preventDefault()},stop:function(e){e.preventDefault(),e.stopPropagation()},nextTick:function(e,t){setTimeout(l.bind(e,t),0)},toArray:function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.length),r.slice.call(e,t,i)},isPlainObject:h,isFunction:a,isArray:o,isObject:function(e){return Object(e)===e},isString:function(e){return"string"==typeof e},isUndefined:function(e){return void 0===e},isDefined:function(e){return void 0!==e},each:function(e,t,i){if(l.isDefined(e.length))for(var s=0,r=e.length;s