ordersprinter/webapp/php/3rdparty/hayageek_jquery_uploadfile.js

8 lines
16 KiB
JavaScript
Raw Permalink Normal View History

2020-11-19 23:03:35 +01:00
/*!
* jQuery Upload File Plugin
* version: 4.0.10
* @requires jQuery v1.5 or later & form plugin
* Copyright (c) 2013 Ravishanker Kusuma
* http://hayageek.com/
*/
2020-11-19 23:10:26 +01:00
(function(b){if(b.fn.ajaxForm==undefined){b.getScript("php/3rdparty/jquery.form.js")}var a={};a.fileapi=b("<input type='file'/>").get(0).files!==undefined;a.formdata=window.FormData!==undefined;b.fn.uploadFile=function(h){var t=b.extend({url:"",method:"POST",enctype:"multipart/form-data",returnType:null,allowDuplicates:true,duplicateStrict:false,allowedTypes:"*",acceptFiles:"*",fileName:"file",formData:false,dynamicFormData:false,maxFileSize:-1,maxFileCount:-1,multiple:true,dragDrop:true,autoSubmit:true,showCancel:true,showAbort:true,showDone:false,showDelete:false,showError:true,showStatusAfterSuccess:true,showStatusAfterError:true,showFileCounter:true,fileCounterStyle:"). ",showFileSize:true,showProgress:false,nestedForms:true,showDownload:false,onLoad:function(s){},onSelect:function(s){return true},onSubmit:function(s,B){},onSuccess:function(C,B,D,s){},onError:function(D,s,C,B){},onCancel:function(B,s){},onAbort:function(B,s){},downloadCallback:false,deleteCallback:false,afterUploadAll:false,serialize:true,sequential:false,sequentialCount:2,customProgressBar:false,abortButtonClass:"ajax-file-upload-abort",cancelButtonClass:"ajax-file-upload-cancel",dragDropContainerClass:"ajax-upload-dragdrop",dragDropHoverClass:"state-hover",errorClass:"ajax-file-upload-error",uploadButtonClass:"ajax-file-upload",dragDropStr:"<span><b>Drag &amp; Drop Files</b></span>",uploadStr:"Upload",abortStr:"Abort",cancelStr:"Cancel",deletelStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag &amp; Drop is not allowed.",extErrorStr:"is not allowed. Allowed extensions: ",duplicateErrorStr:"is not allowed. File already exists.",sizeErrorStr:"is not allowed. Allowed Max size: ",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:" is not allowed. Maximum allowed files are:",downloadStr:"Download",customErrorKeyStr:"jquery-upload-file-error",showQueueDiv:false,statusBarWidth:400,dragdropWidth:400,showPreview:false,previewHeight:"auto",previewWidth:"100%",extraHTML:false,uploadQueueOrder:"top",headers:{}},h);this.fileCounter=1;this.selectedFiles=0;var g="ajax-file-upload-"+(new Date().getTime());this.formGroup=g;this.errorLog=b("<div></div>");this.responses=[];this.existingFileNames=[];if(!a.formdata){t.dragDrop=false}if(!a.formdata||t.maxFileCount===1){t.multiple=false}b(this).html("");var p=this;var v=b("<div>"+t.uploadStr+"</div>");b(v).addClass(t.uploadButtonClass);(function o(){if(b.fn.ajaxForm){if(t.dragDrop){var s=b('<div class="'+t.dragDropContainerClass+'" style="vertical-align:top;"></div>').width(t.dragdropWidth);b(p).append(s);b(s).append(v);b(s).append(b(t.dragDropStr));c(p,t,s)}else{b(p).append(v)}b(p).append(p.errorLog);if(t.showQueueDiv){p.container=b("#"+t.showQueueDiv)}else{p.container=b("<div class='ajax-file-upload-container'></div>").insertAfter(b(p))}t.onLoad.call(this,p);y(p,g,t,v)}else{window.setTimeout(o,10)}})();this.startUpload=function(){b("form").each(function(B,s){if(b(this).hasClass(p.formGroup)){q.push(b(this))}});if(q.length>=1){f()}};this.getFileCount=function(){return p.selectedFiles};this.stopUpload=function(){b("."+t.abortButtonClass).each(function(B,s){if(b(this).hasClass(p.formGroup)){b(this).click()}});b("."+t.cancelButtonClass).each(function(B,s){if(b(this).hasClass(p.formGroup)){b(this).click()}})};this.cancelAll=function(){b("."+t.cancelButtonClass).each(function(B,s){if(b(this).hasClass(p.formGroup)){b(this).click()}})};this.update=function(s){t=b.extend(t,s)};this.enqueueFile=function(s){if(!(s instanceof File)){return}var B=[s];w(t,p,B)};this.reset=function(s){p.fileCounter=1;p.selectedFiles=0;p.errorLog.html("");if(s!=false){p.container.html("")}};this.remove=function(){p.container.html("");b(p).remove()};this.createProgress=function(C,E,D){var B=new n(this,t);B.progressDiv.show();B.progressbar.width("100%");var s="";if(t.showFileCounter){s=p.fileCounter+t.fileCounterStyle+C}else{s=C}if(t.showFileSize){s+=" ("+x(D)+")"}B.filename.html(s);p.fileCounter++;p.selectedFiles++;if(t.showPreview){B.preview.attr("src",E);B.preview.show()}if(t.showDownload){B.download.show();B.download.click(