(function(){"use strict";u8.Base.FileUploadCommand=function(e){$.extend(this,u8.Base.FileUploadCommand.defaults,e)};u8.Base.FileUploadCommand.defaults={silent:false,title:$t("TXT_file_text_4"),autoClose:true,closeTimeout:3e3};$.extend(u8.Base.FileUploadCommand.prototype,{execute:function(e){if(this._isExecuted){$error("You can not call execute on a single command twice!")}if(this.silent){u8.services.files.uploadForm(this._createUploadOptions(),e)}else{this._openProgress(e)}this._isExecuted=true},_openProgress:function(e){var t=this;this._callback=e;var i=this._createUploadOptions();u8.Base.Widgets.Popup.openWidgetPopup({type:"FileUpload",widgetOptions:i,popupOptions:{sizing:"fit",position:"center",alignTo:"window",title:this.title,modal:true,disposeOnClose:true,onClose:this._onPopupClose.bind(this)}},function(e,i){var o={};t.raise("PreUploadStart",o);if(o.cancel){i.widget.cancel(o.reason);return}i.widget.startUpload();t.raise("UploadStart",{})})},_createUploadOptions:function(){return{params:this.params,form:this.form,file:this.file,url:this.url,progress:this.progress,okTimeout:this.autoClose&&this.closeTimeout>1?this.closeTimeout:undefined,onUploadStart:this.onUploadStart,onFinished:this._onFinished.bind(this),onCanceled:this._onFinished.bind(this),onDone:this._onDone.bind(this)}},_onFinished:function(e,t){if(!this.autoClose){return}if(!this.closeTimeout||this.closeTimeout<1){this._onDone(e,t)}},_onDone:function(e,t){var i=e.parent;i.close();return this._callback&&this._callback(this,t)},_onPopupClose:function(e,t){if(t.cancel&&this._callback){this._callback(this,{error:{canceled:true}})}}});u8.Base.FileUploadCommand.makeClass({name:"FileUploadCommand",events:["PreUploadStart","UploadStart"]})})();