text: function FlowChunk(a,b,c){this.flowObj=a,this.fileObj=b,this.fileObjSize=b.size,this.offset=c,this.retries=0,this.pendingRetry=!1,this.loaded=0,this._lastLoaded=0,this.total=0,this.flowObj.opts.chunkSize?this.startByte=b.offset+this.offset*this.flowObj.opts.chunkSize:this.startByte=0,this.flowObj.opts.chunkSize?this.endByte=Math.min(this.fileObjSize,this.startByte+this.flowObj.opts.chunkSize):this.endByte=this.fileObjSize,this.size=this.endByte-this.startByte,this.xhr=null;var d=this;this.progressHandler=function(a){if(a.lengthComputable){if(d.loaded=Math.min(a.loaded,d.size),d.total=Math.min(a.total,d.size),d.loaded>d._lastLoaded){var b=d.loaded-d._lastLoaded;d.fileObj.completedBytes+=b,d.flowObj.completedBytes+=b}d._lastLoaded=d.loaded}d.fileObj.chunkEvent("progress")},this.doneHandler=function(a){var b=d.status(),c=d.message();if("success"===b)d.retries=0,d.fileObj.completedChunks++,d.fileObj.chunkEvent("success",c);else if(d.fileObj.uploadingChunk=!1,d.abort(),"error"===b)d.retries=0,d.fileObj.chunkEvent("error",c);else if(d.retries<d.flowObj.opts.maxChunkRetries){d.retries++;var e=d.flowObj.opts.chunkRetryInterval;null!==e?(d.retries>1&&(e*=d.retries),setTimeout(function(){d.send()},e)):d.send()}else d.retries=0,d.fileObj.chunkEvent("error",c)}}function FlowFile(a,b){this.flowObj=a,this.file=b,this.size=b.size,this.name=b.fileName||b.name;var c=/(iPad|iPhone|iPod)/g.test(navigator.userAgent);if(c&&"image"==this.name.substring(0,5)&&(this.name="image_"+this.size+this.name.substring(5)),this.relativePath=b.relativePath||b.webkitRelativePath||!1,this.relativePath&&this.relativePath!=this.name){baseNameStartPos=this.relativePath.length-this.name.length;var d=this.relativePath.substring(baseNameStartPos);d==this.name&&(this.relativePath=this.relativePath.substring(0,baseNameStartPos))}this.uniqueIdentifier=a.generateUniqueIdentifier(b),this.offset=0,this.chunks=[],this.uploadingChunk=!1,this.completedChunks=0,this.completedBytes=0,this.lastCompletedBytes=0,this.complete=!1,this.uploading=!1,this.paused=!1,this.progress=0,this.queuePaused=!1,this.error=!1,this.averageSpeed=0,this.currentSpeed=0,this._lastProgressCallback=Date.now(),this._prevTransferredSize=0}function Flow(a){this.files=[],this.paused=!1,this.averageSpeed=0,this.completedFiles=0,this.uploadingFiles=0,this.size=0,this.completedBytes=0,this.defaults={chunkSize:!1,singleFile:!1,fileParameterName:"file",progressCallbacksInterval:500,speedSmoothingFactor:.1,query:{},headers:{},withCredentials:!1,target:"/",generateUniqueIdentifier:null,maxChunkRetries:0,resumeLargerThan:0,chunkRetryInterval:null,maxSimultaneous:1},this.opts={},this.events={};var b=this;this.onDrop=function(a){a.stopPropagation(),a.preventDefault();var c=a.dataTransfer;c||(c=a.clipboardData),c.items&&c.items[0]&&c.items[0].webkitGetAsEntry?b.webkitReadDataTransfer(a):b.addFiles(c.files,a)},this.opts=this.extend({},this.defaults,a||{})}FlowChunk.prototype={getParams:function(){var a={flowTotalSize:this.fileObjSize,flowIsFirstChunk:0==this.startByte?1:0,flowIsLastChunk:this.endByte==this.fileObjSize?1:0};return this.fileObj.relativePath&&(a.flowRelativePath=this.fileObj.relativePath),navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&(a.flowFilename=this.fileObj.name),a},getTarget:function(a){var b=this.flowObj.opts.target;return b+=b.indexOf("?")<0?"?":"&",b+a.join("&")},send:function(){this.fileObj.uploadingChunk=this,this.loaded=0,this._lastLoaded=0,this.total=0,this.pendingRetry=!1;var a=this.fileObj.file.slice?"slice":this.fileObj.file.mozSlice?"mozSlice":this.fileObj.file.webkitSlice?"webkitSlice":"slice",b=this.fileObj.file[a](this.startByte,this.endByte);this.xhr=new XMLHttpRequest,this.xhr.upload.addEventListener("progress",this.progressHandler,!1),this.xhr.addEventListener("load",this.doneHandler,!1),this.xhr.addEventListener("error",this.doneHandler,!1);var c=this.prepareXhrRequest(b);this.xhr.send(c)},abort:function(){this.xhr&&(this.xhr.abort(),this.loaded&&(this.fileObj.completedBytes-=this.loaded,this.flowObj.completedBytes-=this.loaded)),this.fileObj.chunkEvent("abort")},status:function(){return this.pendingRetry?"uploading":this.xhr?this.xhr.readyState<4?"uploading":this.flowObj.opts.validateChunkResponse.call(this.flowObj.opts.validateChunkResponseScope||this,this.xhr.status,this.xhr.responseText):"pending"},message:function(){return this.xhr?this.xhr.responseText:""},prepareXhrRequest:function(a){var b=this.flowObj.opts.query;"function"==typeof b&&(b=b(this.fileObj,this)),b=this.flowObj.extend(this.getParams(),b);var c=new FormData;return this.flowObj.each(b,function(a,b){c.append(b,a)}),c.append(this.flowObj.opts.fileParameterName,a,this.fileObj.name),this.xhr.open("POST",this.flowObj.opts.target),this.xhr.withCredentials=this.flowObj.opts.withCredentials,this.flowObj.each(this.flowObj.opts.headers,function(a,b){this.xhr.setRequestHeader(b,a)},this),c}},FlowFile.prototype={measureSpeed:function(){var a=Date.now()-this._lastProgressCallback;if(a){var b=this.flowObj.opts.speedSmoothingFactor;this.currentSpeed=Math.max((this.completedBytes-this._prevTransferredSize)/a*1e3,0),this.averageSpeed=b*this.currentSpeed+(1-b)*this.averageSpeed,this.flowObj.averageSpeed=this.averageSpeed,this._prevTransferredSize=this.completedBytes}},chunkEvent:function(a,b){switch(a){case"progress":if(Date.now()-this._lastProgressCallback<this.flowObj.opts.progressCallbacksInterval)break;this.reportProgress();break;case"error":this.error=!0,this.paused=!0,this.flowObj.paused=!0,this.flowObj.completedBytes-=this.completedBytes,this.completedBytes=0,this.reset(),this.flowObj.onFileError(this,b);break;case"success":this.error=!1,this.paused=!1,this.removeUploadingChunk(this.uploadingChunk),this.completedChunks==this.chunks.length?(this.reportProgress(),this.uploading=!1,this.complete=!0,this.currentSpeed=0,this.averageSpeed=0,this.flowObj.onFileSuccess(this,b),this.file=null):this.uploadNextChunk();break;case"retry":this.flowObj.fire("fileRetry",this)}},reportProgress:function(){this.measureProgress(),this.measureSpeed(),this.flowObj.fire("fileProgress",this),this.flowObj.fire("progress",this.flowObj),this._lastProgressCallback=Date.now()},uploadNextChunk:function(){this.paused||this.flowObj.each(this.chunks,function(a){if(a&&"pending"===a.status())return a.send(),!1})},getOffsetHandler:function(a){this.offset=0;var b=this.xhr.status,c=this.xhr.responseText;this.xhr=null;var d=this.flowObj.opts.validateGetOffsetResponse.call(this.flowObj.opts.validateGetOffsetResponseScope||this,this,b,c);d?(this.lastCompletedBytes=this.completedBytes,this.completedBytes=this.offset,this.lastCompletedBytes>0&&(this.flowObj.completedBytes-=this.lastCompletedBytes),this.flowObj.completedBytes+=this.offset,this.prepareChunks(),this.uploadNextChunk()):(this.error=!0,this.uploading=!1,this.flowObj.onFileError(this,c))},getOffset:function(){this.xhr=new XMLHttpRequest,this.xhr.addEventListener("load",this.getOffsetHandler.bind(this),!1),this.xhr.addEventListener("error",this.getOffsetHandler.bind(this),!1);var a=this.flowObj.opts.query;"function"==typeof a&&(a=a(this));var b={flowGetOffset:1,flowTotalSize:this.size,flowFilename:this.name};this.relativePath&&(b.flowRelativePath=this.relativePath),a=this.flowObj.extend(b,a);var c=this.flowObj.opts.target,d=new FormData;this.flowObj.each(a,function(a,b){d.append(b,a)}),this.xhr.open("POST",c),this.xhr.withCredentials=this.flowObj.opts.withCredentials,this.flowObj.each(this.flowObj.opts.headers,function(a,b){this.xhr.setRequestHeader(b,a)},this),this.xhr.send(d)},reset:function(){this.paused=!1,this.queuePaused=!1,this.uploading=!1,this.currentSpeed=0,this.averageSpeed=0,this.offset=0,this.uploadingChunk=!1,this.completedChunks=0,this.chunks=[]},pause:function(a){if(this.complete)return!1;var b;this.uploading&&(this.uploadingChunk&&this.uploadingChunk.abort(),b=!0),this.reset(),a&&(this.queuePaused=!0),this.paused=!0,this.flowObj.onFilePause(this,a,b)},start:function(){return!this.complete&&(this.reset(),this.uploading=!0,this.flowObj.onFileStart(),void(!this.flowObj.opts.chunkSize||this.size<this.flowObj.opts.chunkSize&&this.size<this.flowObj.opts.resumeLargerThan?(this.prepareChunks(),this.uploadNextChunk()):this.getOffset()))},prepareChunks:function(){if(this.flowObj.opts.chunkSize>0)var a=Math.max(Math.ceil((this.file.size-this.offset)/this.flowObj.opts.chunkSize),1);else var a=1;for(var b=0;b<a;b++)this.chunks.push(new FlowChunk(this.flowObj,this,b))},removeUploadingChunk:function(){for(var a=this.chunks.length,b=0;b<a;b++)if(this.chunks[b]==this.uploadingChunk)return this.uploadingChunk=null,this.chunks[b]=null,!0;return!1},measureProgress:function(){this.error?this.progress=0:this.complete?this.progress=1:0==this.size&&0==this.completedBytes?this.progress=1:this.progress=this.completedBytes/this.size},timeRemaining:function(){if(this.paused||this.error||this.complete)return 0;var a=this.size-this.completedBytes;return a&&!this.averageSpeed?Number.POSITIVE_INFINITY:a||this.averageSpeed?Math.floor(a/this.averageSpeed):0}},Flow.prototype={on:function(a,b){a=a.toLowerCase(),this.events.hasOwnProperty(a)||(this.events[a]=[]),this.events[a].push(b)},off:function(a,b){void 0!==a?(a=a.toLowerCase(),void 0!==b?this.events.hasOwnProperty(a)&&arrayRemove(this.events[a],b):delete this.events[a]):this.events={}},fire:function(a,b){b=Array.prototype.slice.call(arguments),a=a.toLowerCase();var c=!1;return this.events.hasOwnProperty(a)&&this.each(this.events[a],function(a){c=a.apply(this,b.slice(1))===!1||c}),"catchall"!=a&&(b.unshift("catchAll"),c=this.fire.apply(this,b)===!1||c),!c},webkitReadDataTransfer:function(a){function e(a){c+=a.length,b.each(a,function(a){if(a.isFile){var b=a.fullPath;a.file(function(a){f(a,b)},g)}else a.isDirectory&&a.createReader().readEntries(e,g)}),h()}function f(a,b){a.relativePath=b,d.push(a),h()}function g(a){throw a}function h(){0==--c&&b.addFiles(d,a)}var b=this,c=a.dataTransfer.items.length,d=[];this.each(a.dataTransfer.items,function(a){var b=a.webkitGetAsEntry();return b?void(b.isFile?f(a.getAsFile(),b.fullPath):b.createReader().readEntries(e,g)):void h()})},generateUniqueIdentifier:function(a){var b=this.opts.generateUniqueIdentifier;if("function"==typeof b)return b(a);var c=a.relativePath||a.webkitRelativePath||a.fileName||a.name;return a.size+"-"+c.replace(/[^0-9a-zA-Z_-]/gim,"")},browseFiles:function(a,b){FlowUtils.browseFiles({entireFolder:a,singleFile:b,onSelect:function(a,b){a.length>0&&this.addFiles(a,b)},scope:this})},start:function(){this.paused=!1,this.uploadNextFile(),this.fire("uploadStart")},uploadNextFile:function(){if(this.paused)return!1;var a=0,b=0,c=!0;this.each(this.files,function(d){if(!d.complete)if(d.queuePaused)a++;else if(d.uploading)b++;else{if(!(this.uploadingFiles<this.opts.maxSimultaneous))return!1;c=!1,d.start()}},this),!c||a||b||this.fire("complete")},pause:function(){this.paused=!0,this.each(this.files,function(a){a.queuePaused||a.paused||a.complete||a.pause()}),this.uploadingFiles=0},removeAll:function(){for(var a=this.files.length-1;a>=0;a--)this.removeFile(this.files[a]);this.averageSpeed=0,this.uploadingFiles=0},getProgress:function(){return 0==this.size&&0==this.completedBytes?1:this.completedBytes/this.size},onFileSuccess:function(a,b){this.uploadingFiles--,this.completedFiles++,this.fire("progress",this),this.fire("fileSuccess",a,b),this.uploadNextFile()},onFileError:function(a,b){this.uploadingFiles--,this.fire("fileError",a,b),this.fire("error",b,a)},onFilePause:function(a,b,c){c&&this.uploadingFiles--,b&&this.uploadNextFile(),this.fire("fileProgress",a)},onFileStart:function(){this.uploadingFiles++},addFile:function(a,b){this.addFiles([a],b)},addFiles:function(a,b){this.each(a,function(a){if(this.opts.singleFile&&this.files.length>0)return!1;if((a.size%4096!==0||"."!==a.name&&"."!==a.fileName)&&!this.getFromUniqueIdentifier(this.generateUniqueIdentifier(a))){var c=new FlowFile(this,a);this.fire("fileAdded",c,b)&&(this.files.push(c),this.size+=c.size)}},this),this.fire("filesSubmitted",this.files,b),this.opts.startOnSubmit&&this.start()},removeFile:function(a){for(var b=!1,c=this.files.length-1;c>=0;c--)this.files[c]===a&&(this.size-=a.size,a.uploading&&(a.uploadingChunk&&a.uploadingChunk.abort(),b=!0,this.uploadingFiles--),a.complete&&this.completedFiles--,this.completedBytes-=a.completedBytes,a=null,this.files.splice(c,1));return b&&this.uploadNextFile(),!0},getFromUniqueIdentifier:function(a){var b=!1;return this.each(this.files,function(c){c.uniqueIdentifier===a&&(b=c)}),b},timeRemaining:function(){var a=this.size-this.completedBytes;return a&&!this.averageSpeed?Number.POSITIVE_INFINITY:a||this.averageSpeed?Math.floor(a/this.averageSpeed):0},arrayRemove:function(a,b){var c=a.indexOf(b);c>-1&&a.splice(c,1)},extend:function(a,b){return this.each(arguments,function(b){b!==a&&this.each(b,function(b,c){a[c]=b})},this),a},each:function(a,b,c){if(a)if("undefined"!=typeof a.length){for(var d=0;d<a.length;d++)if(b.call(c,a[d],d)===!1)return}else for(var d in a)if(a.hasOwnProperty(d)&&b.call(c,a[d],d)===!1)return}};var FlowUtils={browserSupport:{files:"undefined"!=typeof window.File&&"undefined"!=typeof Blob&&"undefined"!=typeof window.FileList&&("undefined"!=typeof Blob.prototype.slice||"undefined"!=typeof Blob.prototype.webkitSlice||"undefined"!=typeof Blob.prototype.mozSlice),folders:!0},browseFiles:function(a){var b=document.createElement("input");b.setAttribute("type","file"),a.singleFile||(b.setAttribute("multiple","multiple"),a.entireFolder&&(b.setAttribute("webkitdirectory","webkitdirectory"),b.setAttribute("directory","directory"))),b.style.display="none",b.addEventListener("change",function(b){a.onSelect.call(a.scope,b.target.files,b),document.body.removeChild(this)},!1),document.body.appendChild(b),b.click()}};FlowUtils.DropZone=function(a){FlowUtils.browserSupport.files&&(this.opts=a,a.domNode.addEventListener("dragenter",function(a){a.preventDefault();var b=this.opts.findTarget.call(this.opts.scope,a,this);b&&this.manager.addHighLight(b,this.opts.overClass)}.bind(this),!1),a.domNode.addEventListener("dragover",function(a){a.dataTransfer.dropEffect="copy",a.stopPropagation(),a.preventDefault()}.bind(this),!1),a.domNode.addEventListener("drop",function(a){if(a.stopPropagation(),a.preventDefault(),this.manager.removeHighlight(),0==a.dataTransfer.files.length)return FR.UI.feedback&&FR.UI.feedback(FR.T("To upload files, drag them from your computer")),!1;var b=this.opts.findTarget.call(this.opts.scope,a,this);b&&this.opts.onDrop.call(this.opts.scope,a,b)}.bind(this),!1))},FlowUtils.DropZoneManager={zones:[],lastTarget:!1,add:function(a){if(FlowUtils.browserSupport.files){var b=new FlowUtils.DropZone(a);b.manager=this,this.zones.push(b),this.lastHighlight||(this.lastHighlight=new Ext.util.DelayedTask(function(){this.removeHighlight()},this))}},addHighLight:function(a,b){var c=this.lastTarget;c&&c.el.classList.remove(c.cls),a.el.classList.add(b),this.lastTarget={el:a.el,cls:b},this.lastHighlight.delay(3e3)},removeHighlight:function(){this.lastTarget&&this.lastTarget.el.classList.remove(this.lastTarget.cls)}},FR.components.uploadPanel=Ext.extend(Ext.Panel,{initComponent:function(){this.initialPanelTitle=this.title,this.initialDocumentTitle=Settings.title,this.filesToBeLoaded=[],this.lastServerError=!1,this.initFlow(),this.btns={addFile:new Ext.Action({text:FR.T("Add Files"),handler:function(){this.flow.browseFiles()},scope:this,scale:"medium",iconCls:"fa fa-fw fa-upload"}),addFolderSep:new Ext.Toolbar.Separator({hidden:!0}),addFolder:new Ext.Action({text:FR.T("Add Folder"),handler:function(){this.flow.browseFiles(!0)},scope:this,hidden:!0,scale:"medium",iconCls:"fa fa-fw fa-upload"}),removeFile:new Ext.Action({text:FR.T("Remove from queue"),handler:this.removeFile,scope:this,iconCls:"fa fa-fw fa-remove"}),cancel:new Ext.Action({text:FR.T("Cancel all"),handler:this.cancel,scope:this,style:"margin-left:15px",iconCls:"fa fa-fw fa-remove",cls:"fr-btn-default"}),pauseFile:new Ext.Action({text:FR.T("Skip file"),handler:this.pauseFileToggle,scope:this,iconCls:"fa fa-fw fa-step-forward"}),pauseToggle:new Ext.Button({text:FR.T("Pause all"),handler:this.pauseToggle,scope:this,iconCls:"fa fa-fw fa-pause",cls:"fr-btn-default"})},this.statusText=new Ext.Toolbar.TextItem({style:"color:gray"}),this.pbar=new Ext.ProgressBar({animate:!0,width:150}),this.tbar=[this.btns.addFile,"-",this.btns.addFolder,"->",this.statusText,"-",this.pbar],this.buttons=[this.btns.pauseToggle,"-",this.btns.cancel],this.grid={},this.grid.contextMenu=new Ext.menu.Menu({items:[this.btns.pauseFile,this.btns.removeFile]}),this.grid.store=new Ext.data.ArrayStore({autoDestroy:!0,idIndex:0,fields:["id","name","size","progress","speed","remaining","status","completedBytes","lastServerReply","file"]}),this.grid.panel=new Ext.grid.GridPanel({border:!1,layout:"fit",store:this.grid.store,autoScroll:!0,enableDragDrop:!0,ddGroup:"dd",viewConfig:{headersDisabled:!0,forceFit:!0,scrollOffset:35},sm:new Ext.grid.RowSelectionModel({singleSelect:!0}),colModel:new Ext.grid.ColumnModel({defaults:{width:120,sortable:!1},columns:[{header:FR.T("File name"),width:200,renderer:function(a){var b=FR.utils.getFileExtension(a);return'<img class="itemIcon" src="images/fico/ext2ico.php?ext='+b+'" width="16" height="16" border="0" alt="" align="top" /> '+a},dataIndex:"name"},{header:FR.T("Size"),width:50,renderer:function(a){return Ext.util.Format.fileSize(a)},dataIndex:"size"},{header:FR.T("Uploaded"),width:80,dataIndex:"completedBytes"},new Ext.ux.ProgressColumn({header:FR.T("Progress"),dataIndex:"progress",width:130,align:"center",renderer:function(a,b,c){return"uploading"==c.data.status?1==a&&FR.T("Waiting (100%)"):"paused"==c.data.status?0==a?'<span style="font-style:oblique">'+FR.T("Paused")+"</span>":1!=a&&'<span style="font-style:oblique">'+FR.T("Paused (%1%)").replace("%1",Math.floor(100*a))+"</span>":FR.T(c.data.status)}}),{header:FR.T("Speed"),width:80,dataIndex:"speed"},{header:FR.T("Time remaining"),width:100,dataIndex:"remaining"}]}),listeners:{scope:this,rowclick:function(a,b,c){var d=this.grid.store.getAt(b),e=a.getSelectionModel().getSelected();e||this.grid.panel.getSelectionModel().selectRow(b),this.showContextMenu(d,c)},rowcontextmenu:function(a,b,c){var d=this.grid.store.getAt(b),e=a.getSelectionModel().getSelected();e!==d&&this.grid.panel.getSelectionModel().selectRow(b),this.showContextMenu(d,c)},render:function(a){"files"==this.triggerSelection?this.flow.browseFiles():"folder"==this.triggerSelection?this.flow.browseFiles(!0):this.files?this.flow.addFiles(this.files):this.dropEvent&&this.flow.onDrop(this.dropEvent),FlowUtils.DropZoneManager.add({domNode:this.grid.panel.getEl().dom,overClass:"dragged-over",findTarget:function(a){return{el:this.grid.panel.getEl()}},onDrop:this.flow.onDrop,scope:this})}}}),Ext.apply(this,{layout:"fit",items:this.grid.panel}),FR.components.uploadPanel.superclass.initComponent.apply(this,arguments)},initFlow:function(){this.flow=new Flow({target:"?module=fileman_myfiles&section=ajax&page=up",chunkSize:Settings.upload_chunk_size,progressCallbacksInterval:100,maxChunkRetries:3,resumeLargerThan:10485760,maxSimultaneous:Settings.upload_max_simultaneous,validateChunkResponse:function(a,b){if("200"!=a)return"retry";try{var c=Ext.util.JSON.decode(b)}catch(a){return"retry"}return c?c.success?"success":"error":void 0},validateChunkResponseScope:this,validateGetOffsetResponse:function(a,b,c){if(200==b){try{var d=Ext.util.JSON.decode(c)}catch(a){return!1}if(d&&d.success)return d.offset&&(d.offset=parseInt(d.offset),!isNaN(d.offset)&&isFinite(d.offset)&&(a.offset=d.offset)),!0}},validateGetOffsetResponseScope:this,query:{path:this.targetPath}}),this.flow.on("fileAdded",this.onFileAdded.createDelegate(this)),this.flow.on("filesSubmitted",this.onFilesSubmitted.createDelegate(this)),this.flow.on("fileProgress",this.onFileProgress.createDelegate(this)),this.flow.on("fileError",this.onFileError.createDelegate(this)),this.flow.on("fileSuccess",this.onFileSuccess.createDelegate(this)),this.flow.on("progress",this.onProgress.createDelegate(this)),this.flow.on("complete",this.onComplete.createDelegate(this))},start:function(){this.btns.pauseToggle.setIconClass("fa fa-fw fa-pause"),this.btns.pauseToggle.setText(FR.T("Pause all")),this.flow.start()},cancel:function(){document.title=this.initialDocumentTitle,this.targetPath==FR.currentPath&&FR.UI.gridPanel.load(FR.currentPath),this.flow.removeAll(),this.errPrompt&&this.errPrompt.close(),this.destroy(),this.window&&this.window.close()},pauseToggle:function(a){this.flow.paused?(a.setIconClass("fa fa-fw fa-pause"),a.setText(FR.T("Pause all")),this.flow.start(),this.setTitle(this.initialPanelTitle)):(a.setIconClass("fa fa-fw fa-play"),a.setText(FR.T("Resume")),this.setTitle("Upload paused"),this.flow.pause())},pauseFileToggle:function(){var a=this.grid.panel.getSelectionModel().getSelected();a&&(a.data.file.queuePaused?a.data.file.start():a.data.file.pause(!0))},removeFile:function(){var a=this.grid.panel.getSelectionModel().getSelected();this.flow.removeFile(a.data.file),this.flow.files.length>0&&(this.grid.store.remove(a),this.onProgress(this.flow))},onFileAdded:function(a,b){var c=a.name;return Settings.upload_blocked_types.length>0&&Settings.upload_blocked_types.indexOf(FR.utils.getFileExtension(a.name))!=-1?(FR.UI.feedback(FR.T('You are not allowed to upload the file "%1"').replace("%1",a.name)),!1):(a.relativePath&&(c=a.relativePath+c),void this.filesToBeLoaded.push(new Ext.data.Record({id:a.uniqueIdentifier,name:c,size:a.size,progress:0,status:FR.T("Queued"),file:a},a.uniqueIdentifier)))},onFilesSubmitted:function(){if(!this.flow.files.length)return!1;var a=100==this.filesToBeLoaded.length;a&&new Ext.ux.prompt({text:FR.T('The Google Chrome browser has a limitation when uploading folders by drag&drop. It will upload a maximum of 100 files per subfolder.<br /><br />It has now collected <b>%1 files</b> for uploading.<br><br>If your folder has more files than that, please click "Cancel all" and use the "NEW" red button to select the folder for uploading.<br>If it doesn\'t, you can click "Resume" to proceed with the current upload.').replace("%1",this.filesToBeLoaded.length),width:350}),this.grid.store.suspendEvents(),Ext.each(this.filesToBeLoaded,function(a){this.grid.store.add(a)},this),this.grid.store.resumeEvents(),this.grid.store.fireEvent("datachanged",this.grid.store),this.filesToBeLoaded=[],a?this.pauseToggle(this.btns.pauseToggle):this.flow.paused||this.start(),this.onProgress(this.flow)},onComplete:function(){document.title=this.initialDocumentTitle,this.flow.completedFiles>0&&(this.targetPath==FR.currentPath&&(FR.UI.gridPanel.load(FR.currentPath),0==FR.UI.tree.currentSelectedNode.loading&&1==FR.UI.tree.currentSelectedNode.loaded&&FR.UI.tree.reloadNode(FR.UI.tree.currentSelectedNode)),FR.UI.reloadStatusBar()),this.errPrompt&&this.errPrompt.close(),this.destroy(),this.window&&this.window.close()},onProgress:function(a){var b=Ext.util.Format.fileSize(a.completedBytes),c=Ext.util.Format.fileSize(a.size),d=a.files.length,e=a.getProgress(),f="",g=d-a.completedFiles;d>1&&g>0&&(f+=FR.T("%1 files left").replace("%1",g)+", "),f+=FR.T("%1 of %2").replace("%1",b).replace("%2",c),this.statusText.update(f);var h=Math.floor(100*e)+"%";this.pbar.updateProgress(e,h),this.setTitle("Uploading.. %1".replace("%1",h)),document.title="["+h+"] "+this.initialDocumentTitle},onFileProgress:function(a){var b=this.grid.store.getById(a.uniqueIdentifier);return!!b&&(a.paused?(a.queuePaused?b.data.status='<span style="font-style:oblique">'+FR.T("[Skipped]")+"</span>":b.data.status="paused",b.data.speed=""):(a.uploadingChunk&&a.uploadingChunk.retries>0?b.data.status=FR.T("Uploading (Retry #%1)...").replace("%1",a.uploadingChunk.retries):b.data.status="uploading",b.data.remaining=this.formatTime(a.timeRemaining())),b.data.progress=a.progress,a.completedBytes>0?(a.averageSpeed>=1?b.data.speed=Ext.util.Format.fileSize(a.averageSpeed)+"/s":b.data.speed="",b.data.completedBytes=Ext.util.Format.fileSize(a.completedBytes)):(b.data.speed="",b.data.completedBytes=""),void b.commit())},onFileSuccess:function(a,b){var c=this.grid.store.getById(a.uniqueIdentifier);try{var d=Ext.util.JSON.decode(b)}catch(a){c.data.status='<span style="color:red">'+FR.T("Server error")+"</span>",this.lastServerError=b}d?d.success?c.data.status='<span style="color:green">'+d.msg+"</span>":(this.lastServerError=b,d.msg?(c.data.status=d.msg,this.lastServerError=d.msg):c.data.status='<span style="color:red">'+FR.T("Server error")+"</span>"):(c.data.status='<span style="color:red">'+FR.T("Server error")+"</span>",this.lastServerError=b),c.commit();var e=this.grid.store.indexOfId(a.uniqueIdentifier);this.grid.panel.getView().focusRow(e)},onFileError:function(a,b){var c=this.grid.store.getById(a.uniqueIdentifier);try{var d=Ext.util.JSON.decode(b)}catch(a){c.data.status='<span style="color:red">'+FR.T("Server error")+"</span>",this.lastServerError=b}d?(d.success||(this.lastServerError=b),c.data.status='<span style="color:red">'+FR.T("Failed")+"</span>",d.msg&&(c.data.status+=": "+d.msg,this.lastServerError=d.msg)):(c.data.status='<span style="color:red">'+FR.T("Server error")+"</span>",this.lastServerError=b),c.commit(),this.btns.pauseToggle.setIconClass("fa fa-fw fa-play"),this.btns.pauseToggle.setText(FR.T("Resume")),this.errorPrompt(c)},showContextMenu:function(a,b){a.data.file.queuePaused?(this.btns.pauseFile.setText(FR.T("Resume file")),this.btns.pauseFile.setIconClass("fa fa-fw fa-play")):(this.btns.pauseFile.setText(FR.T("Skip file")),this.btns.pauseFile.setIconClass("fa fa-fw fa-step-forward")),this.grid.contextMenu.showAt([b.getPageX()+3,b.getPageY()+3])},errorPrompt:function(a){this.errPrompt||(this.errPrompt={tabPanel:new Ext.TabPanel({activeTab:0,items:[],listeners:{tabchange:function(a,b){b&&b.doLayout()},remove:function(a,b){0==a.items.getCount()&&this.errPrompt.win.hide()},scope:this}}),close:function(){this.win.close()}},this.errPrompt.win=new Ext.Window({title:FR.T("A problem has been encountered!"),width:450,height:240,resizable:!1,layout:"fit",items:this.errPrompt.tabPanel,hideBorders:!0,buttons:[{text:FR.T("Try again"),iconCls:"fa fa-fw fa-repeat",cls:"fr-btn-default",handler:function(){this.errPrompt.tabPanel.remove(a.id,!0),a.data.file.start(),this.start()},scope:this},{text:FR.T("Skip file"),cls:"fr-btn-default",style:"margin-left:15px",iconCls:"fa fa-fw fa-step-forward",hidden:this.grid.store.getCount()<2,handler:function(){this.errPrompt.tabPanel.remove(a.id,!0),a.data.file.pause(!0),this.start()},scope:this},{text:FR.T("Cancel all"),cls:"fr-btn-default",iconCls:"fa fa-fw fa-remove",style:"margin-left:15px",handler:function(){this.cancel()},scope:this}]})),this.errPrompt.win.show();var b=this.errPrompt.tabPanel.getItem(a.id);b||(b=new Ext.Panel({id:a.id,title:a.data.name,layout:"fit",contentEl:Ext.DomHelper.append(Ext.get("theBODY"),{tag:"IFRAME",frameborder:0,height:"100%",width:"100%"})}),this.errPrompt.tabPanel.add(b)),b.show();var c=b.contentEl;if(c.contentDocument)if(c.contentDocument.document)var d=c.contentDocument.document;else var d=c.contentDocument;else if(c.contentWindow.document)var d=c.contentWindow.document;d.open(),d.write("<style>body {background: white;font: 13px 'Roboto', Helvetica, sans-serif;color: #000;cursor: default;}</style>"),d.write(this.lastServerError),d.close()},formatTime:function(a){if(a==Number.POSITIVE_INFINITY)return"";var b=Math.floor(a/3600),c=a%3600,d=Math.floor(c/60),e=c%60,f=Math.ceil(e),g="";return b>24?FR.T("too long"):(b>0&&(g+=FR.T("%1 hours").replace("%1",b)),d>0&&(""!=g&&(g+=", "),g+=FR.T("%1 minutes").replace("%1",d)),f>0&&(""!=g&&(g+=", "),g+=FR.T("%1 seconds").replace("%1",f)),g)},onRender:function(){FR.components.uploadPanel.superclass.onRender.apply(this,arguments),FlowUtils.browserSupport.folders&&(this.btns.addFolder.show(),this.btns.addFolderSep.show())}}),Ext.reg("uploadPanel",FR.components.uploadPanel);