sibanu_web/public/assets/vendor/dropzone/dist/min/dropzone-amd-module.min.js

2 lines
45 KiB
JavaScript
Raw Normal View History

2022-08-20 13:21:23 +07:00
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function c(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){return void 0!==a&&null!==a?b(a):void 0}function f(a,b,c){return void 0!==a&&null!==a&&"function"==typeof a[b]?c(a,b):void 0}var g={exports:{}},h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),i=function(){function a(){d(this,a)}return h(a,[{key:"on",value:function(a,b){return this._callbacks=this._callbacks||{},this._callbacks[a]||(this._callbacks[a]=[]),this._callbacks[a].push(b),this}},{key:"emit",value:function(a){this._callbacks=this._callbacks||{};var b=this._callbacks[a];if(b){for(var c=arguments.length,d=Array(c>1?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];for(var f=b,g=Array.isArray(f),h=0,f=g?f:f[Symbol.iterator]();;){var i;if(g){if(h>=f.length)break;i=f[h++]}else{if(h=f.next(),h.done)break;i=h.value}i.apply(this,d)}}return this}},{key:"off",value:function(a,b){if(!this._callbacks||0===arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1===arguments.length)return delete this._callbacks[a],this;for(var d=0;d<c.length;d++){if(c[d]===b){c.splice(d,1);break}}return this}}]),a}(),j=function(a){function g(a,c){d(this,g);var e=b(this,(g.__proto__||Object.getPrototypeOf(g)).call(this)),f=void 0,h=void 0;if(e.element=a,e.version=g.version,e.defaultOptions.previewTemplate=e.defaultOptions.previewTemplate.replace(/\n*/g,""),e.clickableElements=[],e.listeners=[],e.files=[],"string"==typeof e.element&&(e.element=document.querySelector(e.element)),!e.element||null==e.element.nodeType)throw new Error("Invalid dropzone element.");if(e.element.dropzone)throw new Error("Dropzone already attached.");g.instances.push(e),e.element.dropzone=e;var i=null!=(h=g.optionsForElement(e.element))?h:{};if(e.options=g.extend({},e.defaultOptions,i,null!=c?c:{}),e.options.forceFallback||!g.isBrowserSupported()){var j;return j=e.options.fallback.call(e),b(e,j)}if(null==e.options.url&&(e.options.url=e.element.getAttribute("action")),!e.options.url)throw new Error("No URL provided.");if(e.options.acceptedFiles&&e.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");if(e.options.uploadMultiple&&e.options.chunking)throw new Error("You cannot set both: uploadMultiple and chunking.");return e.options.acceptedMimeTypes&&(e.options.acceptedFiles=e.options.acceptedMimeTypes,delete e.options.acceptedMimeTypes),null!=e.options.renameFilename&&(e.options.renameFile=function(a){return e.options.renameFilename.call(e,a.name,a)}),e.options.method=e.options.method.toUpperCase(),(f=e.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),!1!==e.options.previewsContainer&&(e.options.previewsContainer?e.previewsContainer=g.getElement(e.options.previewsContainer,"previewsContainer"):e.previewsContainer=e.element),e.options.clickable&&(!0===e.options.clickable?e.clickableElements=[e.element]:e.clickableElements=g.getElements(e.options.clickable,"clickable")),e.init(),e}return c(g,a),h(g,null,[{key:"initClass",value:function(){this.prototype.Emitter=i,this.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","addedfiles","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","tota
for(var j=[],k=0;k<a.length;k++)j[k]={name:b._getParamName(k),data:c[k],filename:a[k].upload.filename};b._uploadData(a,j)}})}},{key:"_getChunk",value:function(a,b){for(var c=0;c<a.upload.totalChunkCount;c++)if(void 0!==a.upload.chunks[c]&&a.upload.chunks[c].xhr===b)return a.upload.chunks[c]}},{key:"_uploadData",value:function(a,b){for(var c=this,d=new XMLHttpRequest,e=a,f=Array.isArray(e),h=0,e=f?e:e[Symbol.iterator]();;){var i;if(f){if(h>=e.length)break;i=e[h++]}else{if(h=e.next(),h.done)break;i=h.value}i.xhr=d}a[0].upload.chunked&&(a[0].upload.chunks[b[0].chunkIndex].xhr=d);var j=this.resolveOption(this.options.method,a),k=this.resolveOption(this.options.url,a);d.open(j,k,!0),d.timeout=this.resolveOption(this.options.timeout,a),d.withCredentials=!!this.options.withCredentials,d.onload=function(b){c._finishedUploading(a,d,b)},d.onerror=function(){c._handleUploadError(a,d)},(null!=d.upload?d.upload:d).onprogress=function(b){return c._updateFilesUploadProgress(a,d,b)};var l={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};this.options.headers&&g.extend(l,this.options.headers);for(var m in l){var n=l[m];n&&d.setRequestHeader(m,n)}var o=new FormData;if(this.options.params){var p=this.options.params;"function"==typeof p&&(p=p.call(this,a,d,a[0].upload.chunked?this._getChunk(a[0],d):null));for(var q in p){var r=p[q];o.append(q,r)}}for(var s=a,t=Array.isArray(s),u=0,s=t?s:s[Symbol.iterator]();;){var v;if(t){if(u>=s.length)break;v=s[u++]}else{if(u=s.next(),u.done)break;v=u.value}var w=v;this.emit("sending",w,d,o)}this.options.uploadMultiple&&this.emit("sendingmultiple",a,d,o),this._addFormElementData(o);for(var x=0;x<b.length;x++){var y=b[x];o.append(y.name,y.data,y.filename)}this.submitRequest(d,o,a)}},{key:"_transformFiles",value:function(a,b){for(var c=this,d=[],e=0,f=0;f<a.length;f++)!function(f){c.options.transformFile.call(c,a[f],function(c){d[f]=c,++e===a.length&&b(d)})}(f)}},{key:"_addFormElementData",value:function(a){if("FORM"===this.element.tagName)for(var b=this.element.querySelectorAll("input, textarea, select, button"),c=Array.isArray(b),d=0,b=c?b:b[Symbol.iterator]();;){var e;if(c){if(d>=b.length)break;e=b[d++]}else{if(d=b.next(),d.done)break;e=d.value}var f=e,g=f.getAttribute("name"),h=f.getAttribute("type");if(h&&(h=h.toLowerCase()),void 0!==g&&null!==g)if("SELECT"===f.tagName&&f.hasAttribute("multiple"))for(var i=f.options,j=Array.isArray(i),k=0,i=j?i:i[Symbol.iterator]();;){var l;if(j){if(k>=i.length)break;l=i[k++]}else{if(k=i.next(),k.done)break;l=k.value}var m=l;m.selected&&a.append(g,m.value)}else(!h||"checkbox"!==h&&"radio"!==h||f.checked)&&a.append(g,f.value)}}},{key:"_updateFilesUploadProgress",value:function(a,b,c){var d=void 0;if(void 0!==c){if(d=100*c.loaded/c.total,a[0].upload.chunked){var e=a[0],f=this._getChunk(e,b);f.progress=d,f.total=c.total,f.bytesSent=c.loaded;e.upload.progress=0,e.upload.total=0,e.upload.bytesSent=0;for(var g=0;g<e.upload.totalChunkCount;g++)void 0!==e.upload.chunks[g]&&void 0!==e.upload.chunks[g].progress&&(e.upload.progress+=e.upload.chunks[g].progress,e.upload.total+=e.upload.chunks[g].total,e.upload.bytesSent+=e.upload.chunks[g].bytesSent);e.upload.progress=e.upload.progress/e.upload.totalChunkCount}else for(var h=a,i=Array.isArray(h),j=0,h=i?h:h[Symbol.iterator]();;){var k;if(i){if(j>=h.length)break;k=h[j++]}else{if(j=h.next(),j.done)break;k=j.value}var l=k;l.upload.progress=d,l.upload.total=c.total,l.upload.bytesSent=c.loaded}for(var m=a,n=Array.isArray(m),o=0,m=n?m:m[Symbol.iterator]();;){var p;if(n){if(o>=m.length)break;p=m[o++]}else{if(o=m.next(),o.done)break;p=o.value}var q=p;this.emit("uploadprogress",q,q.upload.progress,q.upload.bytesSent)}}else{var r=!0;d=100;for(var s=a,t=Array.isArray(s),u=0,s=t?s:s[Symbol.iterator]();;){var v;if(t){if(u>=s.length)break;v=s[u++]}else{if(u=s.next(),u.done)break;v=u.value}var w=v;100===w.upload.progress&&w.upload.bytesSent===w.upload.total||(r=!1),w.upload.progress=d,w.upload.bytesSent=w.upload.total}if(r)return;for(var x=a,y=Array.isArray(x),z=0,x=y?x:x[Symbol.iterator]();;){var A;if(y