-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathupload.min.js
1 lines (1 loc) · 16.5 KB
/
upload.min.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.upload=e():(t.cube=t.cube||{},t.cube.upload=e())}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="./",e(e.s=428)}({0:function(t,e){var n=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=n)},1:function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},10:function(t,e,n){var r=n(1),o=n(0),i=n(31),u=n(6),s=n(5),a=function(t,e,n){var f,c,l,p=t&a.F,d=t&a.G,v=t&a.S,h=t&a.P,_=t&a.B,y=t&a.W,S=d?o:o[e]||(o[e]={}),m=S.prototype,x=d?r:v?r[e]:(r[e]||{}).prototype;d&&(n=e);for(f in n)(c=!p&&x&&void 0!==x[f])&&s(S,f)||(l=c?x[f]:n[f],S[f]=d&&"function"!=typeof x[f]?n[f]:_&&c?i(l,r):y&&x[f]==l?function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):h&&"function"==typeof l?i(Function.call,l):l,h&&((S.virtual||(S.virtual={}))[f]=l,t&a.R&&m&&!m[f]&&u(m,f,l)))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},11:function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},12:function(t,e,n){var r=n(8);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},13:function(t,e,n){var r=n(36),o=n(25);t.exports=Object.keys||function(t){return r(t,o)}},14:function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},15:function(t,e){t.exports=!0},17:function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36))}},171:function(t,e,n){var r,o,i;!function(u,s){o=[e,n(49)],r=s,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e){"use strict";function n(t,e,n,o){for(var i=[],u=t.length,s=0,a=0;a<u;a++)r(t[a],a,e,function(t,e){if(s++,i[e]=t,n(t,e),s===u)return o(i)})}function r(t,e,n,r){n(t,function(t){var n=o(t.name,t.size,a,0,t);r(n,e)})}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,u=o&&o.base64||"";return{name:t,size:e,url:u?"":i(o),base64:u,status:n,progress:r,file:o}}function i(t){return t&&s?s.createObjectURL(t):""}function u(t){if("function"==typeof t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.apply(this,n)}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.STATUS_SUCCESS=t.STATUS_ERROR=t.STATUS_UPLOADING=t.STATUS_READY=t.URL=void 0,t.processFiles=n,t.processFile=r,t.newFile=o,t.evalOpts=u;var s=t.URL=e.inBrowser?window.URL||window.webkitURL||window.mozURL:null,a=t.STATUS_READY="ready";t.STATUS_UPLOADING="uploading",t.STATUS_ERROR="error",t.STATUS_SUCCESS="success"})},19:function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},191:function(t,e,n){var r,o,i;!function(n,u){o=[t,e],r=u,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={props:{multiple:{type:Boolean,default:!0},accept:{type:String,default:"image/*"}}},t.exports=e.default})},196:function(t,e,n){function r(t){n(239)}var o=n(9)(n(240),n(241),r,null,null);t.exports=o.exports},197:function(t,e,n){function r(t){n(242)}var o=n(9)(n(243),n(244),r,null,null);t.exports=o.exports},20:function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},21:function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},22:function(t,e,n){var r=n(8);t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},23:function(t,e,n){var r=n(24)("keys"),o=n(17);t.exports=function(t){return r[t]||(r[t]=o(t))}},236:function(t,e,n){function r(t){n(237)}var o=n(9)(n(238),n(246),r,null,null);t.exports=o.exports},237:function(t,e){},238:function(t,e,n){var r,o,i;!function(u,s){o=[t,e,n(196),n(197),n(245),n(191),n(171)],r=s,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e,n,r,o,i,u){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var a=s(n),f=s(r),c=s(o),l=s(i);e.default={name:"cube-upload",mixins:[l.default],props:{value:{type:Array,default:function(){return[]}},action:{type:[String,Object],default:""},max:{type:Number,default:10},auto:{type:Boolean,default:!0},simultaneousUploads:{type:Number,default:1},processFile:{type:Function,default:function(t,e){e(t)}}},data:function(){return{files:this.value,paused:!this.auto}},computed:{actionOptions:function(){var t=this.action;return"string"==typeof t?t?{target:t}:null:t},isShowBtn:function(){return this.files.length<this.max}},watch:{value:function(t){this.files=t},files:function(t){this.$emit("input",t)}},methods:{addFiles:function(t){var e=this;this.$emit("files-added",t);for(var n=this.files.length,r=[],o=this.max-n,i=0,s=t[i];r.length<o&&s;)s.ignore||(r.push(s),this.files.push((0,u.newFile)())),s=t[++i];(0,u.processFiles)(r,this.processFile,function(t,r){e.$set(e.files,n+r,t),e.$emit("file-submitted",t)},function(){e.$nextTick(function(){e.upload()})})},removeFile:function(t){this.$emit("file-removed",t),t._xhr&&t._xhr.abort(),t.url&&u.URL.revokeObjectURL(t.url);var e=this.files.indexOf(t);this.files.splice(e,1),this.upload()},fileClick:function(t,e){this.$emit("file-click",t,e)},upload:function(t){var e=this,n=this.actionOptions;if(!this.paused&&n)for(var r=this.files.length,o=0,i=0;i<r&&o<this.simultaneousUploads;)!function(){var r=e.files[i],s=r.status;s===u.STATUS_READY||t&&s===u.STATUS_ERROR&&r._retryId!==e.retryId?((0,c.default)(r,n,function(n){s===u.STATUS_ERROR&&(n._retryId=e.retryId),e.$emit(n.status===u.STATUS_SUCCESS?"file-success":"file-error",n),e.upload(t)}),o++):s===u.STATUS_UPLOADING&&o++,i++}()},start:function(){this.paused=!1,this.upload()},pause:function(){this.paused=!0,this.files.forEach(function(t){t.status===u.STATUS_UPLOADING&&(t._xhr.abort(),t.status=u.STATUS_READY)})},retry:function(){this.retryId=Date.now(),this.paused=!1,this.upload(!0)}},components:{UploadBtn:a.default,UploadFile:f.default}},t.exports=e.default})},239:function(t,e){},24:function(t,e,n){var r=n(0),o=n(1),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,e){return i[t]||(i[t]=void 0!==e?e:{})})("versions",[]).push({version:r.version,mode:n(15)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},240:function(t,e,n){var r,o,i;!function(u,s){o=[t,e,n(191)],r=s,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(t){return t&&t.__esModule?t:{default:t}}(n);e.default={name:"cube-upload-btn",mixins:[r.default],methods:{changeHandler:function(t){var e=t.currentTarget,n=e.files;n&&(this.$parent.addFiles(n),e.value=null)}}},t.exports=e.default})},241:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cube-upload-btn"},[t._t("default",[t._m(0)]),t._v(" "),n("input",{staticClass:"cube-upload-input",attrs:{type:"file",multiple:t.multiple,accept:t.accept},on:{change:t.changeHandler}})],2)},staticRenderFns:[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cube-upload-btn-def"},[n("i")])}]}},242:function(t,e){},243:function(t,e,n){var r,o,i;!function(u,s){o=[t,e,n(171)],r=s,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={success:"cubeic-right",error:"cubeic-warn"};e.default={name:"cube-upload-file",props:{file:{type:Object,required:!0}},computed:{fileCls:function(){return"cube-upload-file_"+this.file.status},fileStatusCls:function(){var t=this.file,e=t.status;if(t.progress>=.01||e===n.STATUS_SUCCESS||e===n.STATUS_ERROR)return"cube-upload-file_stat"},fileStyle:function(){var t=this.file.url||this.file.base64;if(t)return{"background-image":'url("'+t+'")'}},statusCls:function(){var t=this.file.status;return r[t]},fileProgress:function(){return this.statusCls?"100%":Math.min(Math.floor(100*this.file.progress),99)+"%"}},methods:{clickHandler:function(){this.$emit("click",this.file)},removeFile:function(){this.$parent.removeFile(this.file)}}},t.exports=e.default})},244:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cube-upload-file",class:t.fileCls,on:{click:t.clickHandler}},[t._t("default",[n("div",{staticClass:"cube-upload-file-def",style:t.fileStyle},[n("i",{staticClass:"cubeic-wrong",on:{click:function(e){return e.stopPropagation(),t.removeFile(e)}}}),t._v(" "),n("div",{staticClass:"cube-upload-file-state",class:t.fileStatusCls},[n("i",{staticClass:"cube-upload-file-status",class:t.statusCls}),t._v(" "),n("span",{staticClass:"cube-upload-file-progress"},[t._v(t._s(t.fileProgress))])])])],{imgStyle:t.fileStyle,progress:t.fileProgress})],2)},staticRenderFns:[]}},245:function(t,e,n){var r,o,i;!function(u,s){o=[t,e,n(48),n(171)],r=s,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e,n,r){"use strict";function o(t,e,n){function o(e){clearTimeout(O),O=0,t.progress=1,t.status=e,n&&n(t)}function u(){var e=T.responseText||T.response;try{e=JSON.parse(e)}catch(t){}t.response=e,t.responseHeaders=T.getAllResponseHeaders()}var s=e.target,a=e.headers,f=void 0===a?{}:a,c=e.data,l=void 0===c?{}:c,p=e.fileName,d=void 0===p?"file":p,v=e.withCredentials,h=e.timeout,_=e.prop,y=void 0===_?"file":_,S=e.progressInterval,m=void 0===S?100:S,x=e.checkSuccess,b=void 0===x?function(){return!0}:x,g=(0,r.evalOpts)(s,t);t.progress=0,t.status=r.STATUS_UPLOADING;var T=new window.XMLHttpRequest;t._xhr=T;var O=0;if(T.upload){var w=Date.now();T.upload.onprogress=function(e){function n(){t.progress=e.loaded/e.total,w=Date.now()}if(e.total>0)if(O){clearTimeout(O);var r=Date.now(),o=r-w;o>=m?n():O=setTimeout(n,o)}else n(),O=1}}var R=new window.FormData,U=(0,r.evalOpts)(l,t);(0,i.default)(U).forEach(function(t){R.append(t,U[t])}),R.append(d,t[y]),T.onload=function(){if(T.status<200||T.status>=300)return void o(r.STATUS_ERROR);u();var e=t.response;if(b.length<=2){o(b(e,t)?r.STATUS_SUCCESS:r.STATUS_ERROR)}else b(e,t,function(t){o(t?r.STATUS_SUCCESS:r.STATUS_ERROR)})},T.onerror=function(){u(),o(r.STATUS_ERROR)},T.ontimeout=function(){u(),o(r.STATUS_ERROR)},T.open("POST",g,!0),v&&(T.withCredentials=!0);var C=(0,r.evalOpts)(f,t);(0,i.default)(C).forEach(function(t){T.setRequestHeader(t,C[t])}),h>0&&(T.timeout=h),T.send(R)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var i=function(t){return t&&t.__esModule?t:{default:t}}(n);t.exports=e.default})},246:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cube-upload"},[t._t("default",[n("div",{staticClass:"cube-upload-def clear-fix"},[t._l(t.files,function(e,r){return n("upload-file",{key:r,attrs:{file:e},on:{click:function(n){t.fileClick(e,r)}}})}),t._v(" "),n("upload-btn",{directives:[{name:"show",rawName:"v-show",value:t.isShowBtn,expression:"isShowBtn"}],attrs:{multiple:t.multiple,accept:t.accept}})],2)])],2)},staticRenderFns:[]}},25:function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},27:function(t,e,n){var r=n(19);t.exports=function(t){return Object(r(t))}},28:function(t,e,n){var r=n(8),o=n(1).document,i=r(o)&&r(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},3:function(t,e,n){t.exports=!n(11)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},31:function(t,e,n){var r=n(34);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},33:function(t,e,n){t.exports=!n(3)&&!n(11)(function(){return 7!=Object.defineProperty(n(28)("div"),"a",{get:function(){return 7}}).a})},34:function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},36:function(t,e,n){var r=n(5),o=n(7),i=n(50)(!1),u=n(23)("IE_PROTO");t.exports=function(t,e){var n,s=o(t),a=0,f=[];for(n in s)n!=u&&r(s,n)&&f.push(n);for(;e.length>a;)r(s,n=e[a++])&&(~i(f,n)||f.push(n));return f}},4:function(t,e,n){var r=n(12),o=n(33),i=n(22),u=Object.defineProperty;e.f=n(3)?Object.defineProperty:function(t,e,n){if(r(t),e=i(e,!0),r(n),o)try{return u(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},40:function(t,e,n){var r=n(21);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},41:function(t,e,n){var r=n(20),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},428:function(t,e,n){var r,o,i;!function(u,s){o=[t,e,n(236),n(196),n(197)],r=s,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t,e,n,r,o){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var u=i(n),s=i(r),a=i(o);u.default.install=function(t){t.component(u.default.name,u.default),t.component(s.default.name,s.default),t.component(a.default.name,a.default)},u.default.Btn=s.default,u.default.File=a.default,e.default=u.default,t.exports=e.default})},48:function(t,e,n){t.exports={default:n(59),__esModule:!0}},49:function(t,e,n){var r,o,i;!function(n,u){o=[e],r=u,void 0!==(i="function"==typeof r?r.apply(e,o):r)&&(t.exports=i)}(0,function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=t.inBrowser="undefined"!=typeof window,n=t.ua=e&&navigator.userAgent.toLowerCase();t.isAndroid=n&&n.indexOf("android")>0,t.isIOS=n&&/iphone|ipad|ipod|ios/.test(n)})},5:function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},50:function(t,e,n){var r=n(7),o=n(41),i=n(51);t.exports=function(t){return function(e,n,u){var s,a=r(e),f=o(a.length),c=i(u,f);if(t&&n!=n){for(;f>c;)if((s=a[c++])!=s)return!0}else for(;f>c;c++)if((t||c in a)&&a[c]===n)return t||c||0;return!t&&-1}}},51:function(t,e,n){var r=n(20),o=Math.max,i=Math.min;t.exports=function(t,e){return t=r(t),t<0?o(t+e,0):i(t,e)}},59:function(t,e,n){n(60),t.exports=n(0).Object.keys},6:function(t,e,n){var r=n(4),o=n(14);t.exports=n(3)?function(t,e,n){return r.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},60:function(t,e,n){var r=n(27),o=n(13);n(61)("keys",function(){return function(t){return o(r(t))}})},61:function(t,e,n){var r=n(10),o=n(0),i=n(11);t.exports=function(t,e){var n=(o.Object||{})[t]||Object[t],u={};u[t]=e(n),r(r.S+r.F*i(function(){n(1)}),"Object",u)}},7:function(t,e,n){var r=n(40),o=n(19);t.exports=function(t){return r(o(t))}},8:function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},9:function(t,e){t.exports=function(t,e,n,r,o){var i,u=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(i=t,u=t.default);var a="function"==typeof u?u.options:u;e&&(a.render=e.render,a.staticRenderFns=e.staticRenderFns),r&&(a._scopeId=r);var f;if(o?(f=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},a._ssrRegister=f):n&&(f=n),f){var c=a.functional,l=c?a.render:a.beforeCreate;c?a.render=function(t,e){return f.call(e),l(t,e)}:a.beforeCreate=l?[].concat(l,f):[f]}return{esModule:i,exports:u,options:a}}}})});