(function(factory){if(typeofdefine==="function"&&define.amd){define(["jquery","tmpl","load-image","./jquery.fileupload-fp"],factory);}else{factory(window.jQuery,window.tmpl,window.loadImage);}}(function($,tmpl,loadImage){varparentWidget=($.blueimpFP||$.blueimp).fileupload;$.widget("blueimpUI.fileupload",parentWidget,{options:{autoUpload:false,maxNumberOfFiles:undefined,maxFileSize:undefined,minFileSize:undefined,acceptFileTypes:/.+$/i,previewSourceFileTypes:/^image\/(gif|jpeg|png)$/,previewSourceMaxFileSize:5000000,previewMaxWidth:80,previewMaxHeight:80,previewAsCanvas:true,uploadTemplateId:"template-upload",downloadTemplateId:"template-download",filesContainer:undefined,prependFiles:false,dataType:"json",add:function(e,data){varthat=$(this).data("fileupload"),options=that.options,files=data.files;$(this).fileupload("process",data).done(function(){that._adjustMaxNumberOfFiles(-files.length);data.isAdjusted=true;data.files.valid=data.isValidated=that._validate(files);data.context=that._renderUpload(files).data("data",data);options.filesContainer[options.prependFiles?"prepend":"append"](data.context);that._renderPreviews(files,data.context);that._forceReflow(data.context);that._transition(data.context).done(function(){if((that._trigger("added",e,data)!==false)&&(options.autoUpload||data.autoUpload)&&data.autoUpload!==false&&data.isValidated){data.submit();}});});},send:function(e,data){varthat=$(this).data("fileupload");if(!data.isValidated){if(!data.isAdjusted){that._adjustMaxNumberOfFiles(-data.files.length);}if(!that._validate(data.files)){returnfalse;}}if(data.context&&data.dataType&&data.dataType.substr(0,6)==="iframe"){data.context.find(".progress").addClass(!$.support.transition&&"progress-animated").find(".bar").css("width",parseInt(100,10)+"%");}returnthat._trigger("sent",e,data);},done:function(e,data){$(".saving-tip",$(this)).addClass("hide");varthat=$(this).data("fileupload"),template;if(data.context){data.context.each(function(index){varfile=($.isArray(data.result)&&data.result[index])||{error:"emptyResult"};file.size=data.files[index].size;if(file.error){file.error=data.result.error||"emptyResult";file.name=data.files[index].name;that._adjustMaxNumberOfFiles(1);}that._transition($(this)).done(function(){varnode=$(this);template=that._renderDownload([file]).css("height",node.height()).replaceAll(node);that._forceReflow(template);that._transition(template).done(function(){data.context=$(this);that._trigger("completed",e,data);});});});}else{template=that._renderDownload(data.result).appendTo(that.options.filesContainer);that._forceReflow(template);that._transition(template).done(function(){data.context=$(this);that._trigger("completed",e,data);});}},fail:function(e,data){$(".saving-tip",$(this)).addClass("hide");varthat=$(this).data("fileupload"),template;that._adjustMaxNumberOfFiles(data.files.length);if(data.context){data.context.each(function(index){if(data.errorThrown!=="abort"){varfile=data.files[index];varr_error;if(data.jqXHR.responseText){try{r_error=$.parseJSON(data.jqXHR.responseText).error;}catch(e){r_error="";}}if(data.dataType=="iframe json"){data.errorThrown="";}file.error=r_error||file.error||data.errorThrown||"can not connect the file server";that._transition($(this)).done(function(){varnode=$(this);template=that._renderDownload([file]).replaceAll(node);that._forceReflow(template);that._transition(template).done(function(){data.context=$(this);that._trigger("failed",e,data);});});}else{that._transition($(this)).done(function(){$(this).remove();that._trigger("failed",e,data);});}});}else{if(data.errorThrown!=="abort"){that._adjustMaxNumberOfFiles(-data.files.length);data.context=that._renderUpload(data.files).appendTo(that.options.filesContainer).data("data",data);that._forceReflow(data.context);that._transition(data.context).done(function(){data.context=$(this);that._trigger("failed",e,data);});}else{that._trigger("failed",e,data);}}},progress:function(e,data){if(data.context){data.context.find(".bar").css("width",parseInt(data.loaded/data.total*100,10)+"%");}},progressall:function