rich-filemanager
Advanced tools
Comparing version 2.6.2 to 2.6.3
@@ -28,5 +28,4 @@ { | ||
"require": { | ||
"servocoder/richfilemanager-php": "*", | ||
"aws/aws-sdk-php": "^3.18.0" | ||
"servocoder/richfilemanager-php": "*" | ||
} | ||
} |
@@ -122,2 +122,30 @@ { | ||
}, | ||
"onlyoffice": { | ||
"enabled": false, | ||
"extensions": [ | ||
"doc", | ||
"docx", | ||
"odt", | ||
"rtf", | ||
"txt", | ||
"pdf", | ||
"html", | ||
"epub", | ||
"xps", | ||
"djvu", | ||
"xls", | ||
"xlsx", | ||
"ods", | ||
"csv", | ||
"pptx", | ||
"ppt", | ||
"odp" | ||
], | ||
"editorWidth": "95%", | ||
"editorHeight": "600", | ||
"apiUrl": "https://doc.onlyoffice.com/web-apps/apps/api/documents/api.js", | ||
"connectorUrl": false, | ||
"downloadUrl": false, | ||
"callbackUrl": false | ||
}, | ||
"opendoc": { | ||
@@ -185,3 +213,3 @@ "enabled": true, | ||
"url": "https://github.com/servocoder/RichFilemanager", | ||
"version": "2.6.2" | ||
"version": "2.6.3" | ||
} |
@@ -14,3 +14,3 @@ { | ||
"ERROR_OPENING_FILE": "Error al abrir el archivo.", | ||
"ERROR_MOVING_DIRECTORY": "Error while moving the directory %s to %s.", | ||
"ERROR_MOVING_DIRECTORY": "Error mientras se movía el directorio %s a %s.", | ||
"ERROR_MOVING_FILE": "Error while moving the file %s to %s.", | ||
@@ -26,3 +26,3 @@ "ERROR_RENAMING_DIRECTORY": "Error al intentar renombrar la carpeta de %s a %s.", | ||
"FILE_DOES_NOT_EXIST": "El archivo %s no existe.", | ||
"FILE_EMPTY": "The file is empty", | ||
"FILE_EMPTY": "El archivo está vacío", | ||
"FORBIDDEN_ACTION_DIR": "No se puede realizar la acción. Prohibido para directorios.", | ||
@@ -52,3 +52,3 @@ "FORBIDDEN_ACTION_FILE": "No se puede realizar la acción. Prohibido para archivos.", | ||
"action_download": "Descargar", | ||
"action_extract": "Extract", | ||
"action_extract": "Extraer", | ||
"action_move": "Mover", | ||
@@ -62,12 +62,12 @@ "action_rename": "Renombrar", | ||
"close": "Cerrar", | ||
"clipboard_clear": "Clear", | ||
"clipboard_clear_full": "Clear clipboard", | ||
"clipboard_clear": "Limpiar", | ||
"clipboard_clear_full": "Limpiar portapapeles", | ||
"clipboard_cleared": "Clipboard is cleared.", | ||
"clipboard_copy": "Copy", | ||
"clipboard_copy_full": "Copy selected", | ||
"clipboard_cut": "Cut", | ||
"clipboard_cut_full": "Cut selected", | ||
"clipboard_empty": "Clipboard is empty.", | ||
"clipboard_paste": "Paste", | ||
"clipboard_paste_full": "Paste to the current folder", | ||
"clipboard_copy": "Copiar", | ||
"clipboard_copy_full": "Copiar seleccionado", | ||
"clipboard_cut": "Cortar", | ||
"clipboard_cut_full": "Cortar seleccionado", | ||
"clipboard_empty": "El portapapeles está vacío.", | ||
"clipboard_paste": "Pegar", | ||
"clipboard_paste_full": "Pegar al directorio actual", | ||
"confirm_delete": "¿Estás seguro de eliminar este archivo?", | ||
@@ -74,0 +74,0 @@ "confirm_delete_multiple": "Are you sure you wish to delete %s items?", |
{ | ||
"name": "rich-filemanager", | ||
"version": "2.6.2", | ||
"version": "2.6.3", | ||
"description": "Highly customizable open-source file manager", | ||
@@ -5,0 +5,0 @@ "main": "scripts/filemanager.js", |
@@ -0,0 +0,0 @@ // Type definitions for Alertify.js v1.0.11 |
@@ -0,0 +0,0 @@ /* eslint-env node */ |
@@ -0,0 +0,0 @@ (function() { |
@@ -0,0 +0,0 @@ /*eslint strict: [2, "global"], global: {ga: false} */ |
@@ -1,1 +0,1 @@ | ||
!function(e){e.richFilemanagerPlugin=function(t,i){function r(t,i){if(-1===j.indexOf(i))return!1;if("select"===i&&"folder"===t.type)return!1;if("extract"===i){var r=se(t.attributes.name);return"file"===t.type&&"zip"===r}return"download"===i&&"folder"===t.type?!0===k.options.allowFolderDownload:void 0===t.attributes.capabilities||e.inArray(i,t.attributes.capabilities)>-1}function o(){k.filetree.enabled&&(g.show(),m.splitter({sizeLeft:k.filetree.width,minLeft:k.filetree.minWidth,minRight:200}),E.treeModel.loadNodes(null,!1))}function n(){E.itemsModel.loadList(x)}function s(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||N.param("field_name")||N.param("CKEditor")||N.param("ImperaviElementId")}function a(e){if(!e.attributes.readable)return c.error(H("NOT_ALLOWED_SYSTEM")),!1;"file"===e.type&&E.previewModel.applyObject(e),"folder"!==e.type&&"parent"!==e.type||(E.previewFile(!1),E.itemsModel.loadList(e.id))}function l(e){var t=!E.clipboardModel.enabled(),i={select:{name:H("action_select"),className:"select"},download:{name:H("action_download"),className:"download"},rename:{name:H("action_rename"),className:"rename"},move:{name:H("action_move"),className:"move"},separator1:"-----",copy:{name:H("clipboard_copy"),className:"copy"},cut:{name:H("clipboard_cut"),className:"cut"},delete:{name:H("action_delete"),className:"delete"},extract:{name:H("action_extract"),className:"extract"},copyUrl:{name:H("copy_to_clipboard"),className:"copy-url"}};return r(e,"download")||delete i.download,r(e,"select")&&s()||delete i.select,r(e,"rename")&&!0!==k.options.browseOnly||delete i.rename,r(e,"delete")&&!0!==k.options.browseOnly||delete i.delete,r(e,"extract")&&!0!==k.options.browseOnly||delete i.extract,r(e,"copy")&&!0!==k.options.browseOnly&&!t||delete i.copy,r(e,"move")&&!0!==k.options.browseOnly&&!t||(delete i.cut,delete i.move),i}var d={baseUrl:".",config:{},callbacks:{beforeCreateImageUrl:function(e,t){return t},beforeCreatePreviewUrl:function(e,t){return t},beforeSelectItem:function(e,t){return t},afterSelectItem:function(e,t,i){}}},c=this,u=e(t),p=u.children(".fm-wrapper"),f=p.find(".fm-header"),h=f.find(".fm-uploader"),m=p.children(".fm-splitter"),v=p.children(".fm-footer"),b=m.children(".fm-fileinfo"),g=m.children(".fm-filetree"),w=b.find(".view-items-wrapper"),y=b.find(".fm-preview-wrapper"),M=w.find(".view-items"),C=h.children(".fm-upload"),k=null,x="/",S=null,j=[],_=null,L=null,E=null,I=null,O=null,N=purl(),F=(new Date).getTime();c.settings=e.extend(!0,d,i),c.write=function(t,i){var r=alertify,o=e.extend({},{reset:!0,delay:5e3,logMaxItems:5,logPosition:"bottom right",logContainerClass:"fm-log",logMessageTemplate:null,parent:document.body,onClick:void 0,unique:!1,type:"log"},i);if(o.logClass&&o.unique&&e(".fm-log").children("."+o.logClass).length>0)return r;o.reset&&r.reset(),r.parent(o.parent),r.logDelay(o.delay),r.logMaxItems(o.logMaxItems),r.logPosition(o.logPosition),r.logContainerClass(o.logContainerClass),r.logMessageTemplate(o.logMessageTemplate),r[o.type](t,o.onClick);var n=r.getLogs();return n[n.length-1]},c.error=function(t,i){return c.write(t,e.extend({},{type:"error",delay:1e4},i))},c.warning=function(t,i){return c.write(t,e.extend({},{type:"warning",delay:1e4},i))},c.success=function(t,i){return c.write(t,e.extend({},{type:"success",delay:6e3},i))},c.alert=function(e){alertify.reset().dialogContainerClass("fm-popup").alert(e)},c.confirm=function(e){alertify.reset().dialogWidth(e.width).dialogPersistent(e.persistent).dialogContainerClass("fm-popup").confirm(e.message,e.okBtn,e.cancelBtn)},c.prompt=function(e){alertify.reset().dialogWidth(e.width).dialogPersistent(e.persistent).dialogContainerClass("fm-popup").theme(e.template).prompt(e.message,e.value||"",e.okBtn,e.cancelBtn)},c.dialog=function(e){alertify.reset().dialogWidth(e.width).dialogPersistent(e.persistent).dialogContainerClass("fm-popup").dialog(e.message,e.buttons)},c.setDimensions=function(){var t=p.outerHeight(!0)-p.height(),i=e(window).height()-f.height()-v.height()-t,r=m.width()-m.children(".splitter-bar-vertical").outerWidth()-g.outerWidth();m.height(i),b.width(r)},c.log=function(){k.options.logger&&arguments&&([].unshift.call(arguments,(new Date).getTime()),console.log.apply(this,arguments))};var T=function(){return e.when(q("default"),q("user")).done(function(t,i){var r=t[0],o=i[0];if(void 0!==o&&null!==o&&delete o.version,(k=e.extend({},r,o)).api.connectorUrl)S=k.api.connectorUrl;else{var n=location.origin+location.pathname,s="connectors/"+k.api.lang+"/filemanager."+k.api.lang;se(n).length>0&&(n=n.substring(0,n.lastIndexOf("/")+1)),S=n+s}})},P=function(){return Me("GET",{mode:"initiate"}).done(function(t){if(t.data){var i=t.data.attributes.config;e.each(i,function(t,i){e.each(i,function(e,i){void 0===k[t]&&(k[t]=[]),k[t][e]=i})}),k.security.readOnly&&(k.options.browseOnly=!0)}X(t)}).fail(function(){c.error("Unable to perform initial request to server.")}).then(function(t){if(t.errors)return e.Deferred().reject()})},D=function(){return I=new B,e.ajax().then(function(){var e=N.param("langCode");if(e)return G(I.buildLangFileUrl(e)).done(function(){I.setLang(e)}).fail(function(){setTimeout(function(){c.error("Given language file ("+I.buildLangFileUrl(e)+") does not exist!")},500)});I.setLang(k.language.default)}).then(function(){return e.ajax({type:"GET",url:I.buildLangFileUrl(I.getLang()),dataType:"json"}).done(function(e){I.setTranslations(e)})})},z=function(){return e.when(V("upload-container"),V("upload-item")).done(function(e,t){var i=e[0],r=t[0];p.append(i).append(r)})},A=function(e){var t=[],i=[];if(t.push("/themes/"+k.options.theme+"/styles/theme.css"),k.viewer.image.lazyLoad&&t.push("/scripts/lazyload/dist/lazyload.min.js"),k.customScrollbar.enabled&&(t.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"),t.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js")),t.push(e),K(t),k.editor.enabled){var r=k.editor.theme;r&&"default"!==r&&i.push("/scripts/CodeMirror/theme/"+r+".css"),i.push("/scripts/CodeMirror/lib/codemirror.css"),i.push("/scripts/CodeMirror/lib/codemirror.js"),i.push("/scripts/CodeMirror/addon/selection/active-line.js"),i.push("/scripts/CodeMirror/addon/display/fullscreen.css"),i.push("/scripts/CodeMirror/addon/display/fullscreen.js")}k.viewer.markdownRenderer.enabled&&(i.push("/styles/fm-markdown.css"),i.push("/scripts/markdown-it/markdown-it.min.js"),i.push("/scripts/markdown-it/default.min.css"),i.push("/scripts/markdown-it/highlight.min.js"),i.push("/scripts/markdown-it/markdown-it-footnote.min.js"),i.push("/scripts/markdown-it/markdown-it-replace-link.min.js")),k.options.browseOnly||(i.push("/scripts/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"),i.push("/scripts/jQuery-File-Upload/js/canvas-to-blob.min.js"),i.push("/scripts/jQuery-File-Upload/js/load-image.all.min.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.iframe-transport.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-process.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-image.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-validate.js"),k.upload.multiple&&i.push("/scripts/jQuery-File-Upload/css/dropzone.css")),i.length&&K(i)},U=function(){j=k.options.capabilities||["upload","select","download","rename","copy","move","delete","extract"];var t=[];k.options.fileSorting&&(t=k.options.fileSorting.toLowerCase().split("_")),_=t[0]||"name",L=t[1]||"asc";var i=N.param("exclusiveFolder");i&&(x=ne(x="/"+i+"/"));var r=N.param("expandedFolder");if(r&&(O=ne(O=x+r+"/")),E=new R,ko.applyBindings(E),E.itemsModel.initiateLazyLoad(),E.filterModel.setName(N.param("filter")),ko.bindingHandlers.toggleNodeVisibility={init:function(t,i){var r=i();e(t).toggle(r.isExpanded())},update:function(t,i){var r=i();if(!1===r.isSliding())return!1;!1===r.isExpanded()&&e(t).slideDown(k.filetree.expandSpeed,function(){r.isSliding(!1),r.isExpanded(!0)}),!0===r.isExpanded()&&e(t).slideUp(k.filetree.expandSpeed,function(){r.isSliding(!1),r.isExpanded(!1)})}},ko.bindingHandlers.draggableView={init:function(e,t,i){E.ddModel.makeDraggable(t(),e)}},ko.bindingHandlers.droppableView={init:function(e,t,i){E.ddModel.makeDroppable(t(),e)}},ko.bindingHandlers.draggableTree={init:function(e,t,i){E.ddModel.makeDraggable(t(),e)}},ko.bindingHandlers.droppableTree={init:function(e,t,i){E.ddModel.makeDroppable(t(),e)}},p.mousewheel(function(t){if(!E.ddModel.dragHelper)return!0;var i=null;if((k.customScrollbar.enabled?e([w[0],g[0]]):m.children(".splitter-pane")).each(function(r){var o=e(this),n=o.offset().top,s=o.offset().left;if(t.offsetY>=n&&t.offsetY<=n+o.height()&&t.offsetX>=s&&t.offsetX<=s+o.width())return i=o,!1}),null===i)return!1;if(k.customScrollbar.enabled){var r=i.find(".mCSB_scrollTools_vertical"),o=1===t.deltaY?"+":"-";r.is(":visible")&&i.mCustomScrollbar("scrollTo",[o+"=250",0],{scrollInertia:500,scrollEasing:"easeOut",callbacks:!0})}else if(i[0].scrollHeight>i[0].clientHeight){var n=i.scrollTop()-200*t.deltaY;E.ddModel.isScrolling=!0,n=n<0?0:n,i.stop().animate({scrollTop:n},100,"linear",function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0})}}),M.selectable({filter:"li:not(.directory-parent), tbody > tr:not(.directory-parent)",cancel:".directory-parent, thead",disabled:!k.manager.selection.enabled,appendTo:M,start:function(e,t){Ee(),E.itemsModel.isSelecting(!0)},stop:function(e,t){E.itemsModel.isSelecting(!1)},selected:function(e,t){ko.dataFor(t.selected).selected(!0)},unselected:function(e,t){ko.dataFor(t.unselected).selected(!1)}}),b.contextMenu({selector:".view-items",zIndex:10,build:function(e,t){var i={createFolder:{name:H("create_folder"),className:"create-folder"},paste:{name:H("clipboard_paste"),className:"paste",disabled:function(e,t){return E.clipboardModel.isEmpty()}}};return E.clipboardModel.enabled()&&!0!==k.options.browseOnly||delete i.paste,{appendTo:".fm-container",items:i,reposition:!1,callback:function(e,t){switch(e){case"createFolder":E.headerModel.createFolder();break;case"paste":E.clipboardModel.paste()}}}}}),k.extras.extra_js)for(var s=0;s<k.extras.extra_js.length;s++)e.ajax({type:"GET",url:k.extras.extra_js[s],dataType:"script",async:k.extras.extra_js_async});if(N.param("CKEditorCleanUpFuncNum")&&(E.headerModel.closeButton(!0),E.headerModel.closeButtonOnClick=function(){parent.CKEDITOR.tools.callFunction(N.param("CKEditorCleanUpFuncNum"))}),e("#newfile").change(function(){e("#filepath").val(e(this).val().replace(/.+[\\\/]/,""))}),o(),n(),qe(),k.customScrollbar.enabled&&(g.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onScrollStart:function(){E.ddModel.isScrolling=!0},onScroll:function(){E.ddModel.isScrolling=!1}},axis:"yx"}),y.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0,updateOnSelectorChange:".fm-preview-viewer"}}),w.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0,updateOnSelectorChange:".grid, .list"},callbacks:{onScrollStart:function(){E.itemsModel.continiousSelection()||(this.yStartPosition=this.mcs.top,this.yStartTime=(new Date).getTime()),E.ddModel.isScrolling=!0},onScroll:function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0},whileScrolling:function(){if(k.manager.selection.enabled){var e=(new Date).getTime()-this.yStartTime;!E.itemsModel.continiousSelection()&&e>400&&(this.yStartPosition=this.mcs.top),E.itemsModel.isSelecting()&&E.itemsModel.continiousSelection(!0);var t=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);M.selectable("repositionCssHelper",t,0)}E.itemsModel.lazyLoad&&E.itemsModel.lazyLoad.handleScroll()}},axis:"y",alwaysShowScrollbar:0})),document.documentElement.setAttribute("data-useragent",navigator.userAgent),k.options.logger){var a=(new Date).getTime()-F;console.log("Total execution time : "+a+" ms")}u.find(".fm-loading-wrap").fadeOut(800,function(){c.setDimensions()}),c.setDimensions()},B=function(){var e=null,t={},i=c.settings.baseUrl+"/languages/";this.buildLangFileUrl=function(e){return i+e+".json"},this.setLang=function(t){e=t},this.getLang=function(){return e},this.setTranslations=function(e){t=e},this.getTranslations=function(){return t},this.translate=function(e){return t[e]}},R=function(){function t(e){return(!k.manager.selection.enabled||!k.manager.selection.useCtrlKey||!0!==e.ctrlKey)&&(!k.manager.dblClickOpen||"click"!==e.type)}var i=this;this.config=ko.observable(k),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(k.manager.defaultViewMode),this.currentPath=ko.observable(x),this.browseOnly=ko.observable(k.options.browseOnly),this.previewModel=ko.observable(null),this.currentLang=I.getLang(),this.lg=I.getTranslations(),this.previewFile.subscribe(function(e){e||(i.previewModel.closeEditor(),i.itemsModel.descriptivePanel.rdo().id===i.previewModel.rdo().id&&i.itemsModel.descriptivePanel.render(i.previewModel.viewer.content()))}),this.addItem=function(e,t){var r=E.treeModel.findByParam("id",t);if(r){var o=E.treeModel.createNode(e);E.treeModel.addNodes(r,o)}E.currentPath()===t&&i.itemsModel.addNew(e)},this.removeItem=function(e){var t=E.treeModel.findByParam("id",e.id);t&&t.remove();var r=i.itemsModel.findByParam("id",e.id);r&&r.remove()},this.fetchSelectedItems=function(e){var t,r;if(e===n.name)return i.itemsModel.getSelected();if(e===o.name)return i.treeModel.getSelected();if(!e)return t=i.treeModel.getSelected(),(r=i.itemsModel.getSelected()).length>0?r:t;throw new Error("Unknown item type.")},this.fetchSelectedObjects=function(t){var r=[];return e.each(i.fetchSelectedItems(t.constructor.name),function(e,t){r.push(t.rdo)}),r};var o=function(t){var r=this;this.id=t.id,this.rdo=t,this.cdo={isFolder:"folder"===t.type,extension:"file"===t.type?se(t.id):null,dimensions:t.attributes.width?t.attributes.width+"x"+t.attributes.height:null,cssItemClass:"folder"===t.type?"directory":"file",hiddenByType:!1,hiddenBySearch:!1},this.visible=ko.observable(!0),this.nodeTitle=ko.observable(t.attributes.name),this.children=ko.observableArray([]),this.parentNode=ko.observable(null),this.isSliding=ko.observable(!1),this.isLoading=ko.observable(!1),this.isLoaded=ko.observable(!1),this.isExpanded=ko.observable(!1),this.selected=ko.observable(!1),this.dragHovered=ko.observable(!1),this.level=ko.observable(0),this.isFirstNode=ko.observable(!1),this.isLastNode=ko.observable(!1),this.nodeTitle.subscribe(function(e){r.rdo.attributes.name=e}),this.children.subscribe(function(e){i.treeModel.arrangeNode(r)}),this.isLoaded.subscribe(function(e){r.isLoading(!e)}),this.selected.subscribe(function(e){e?(null!==i.treeModel.selectedNode()&&i.treeModel.selectedNode().selected(!1),i.treeModel.selectedNode(r),i.itemsModel.unselectItems()):i.treeModel.selectedNode(null)}),this.switchNode=function(e){return!!e.cdo.isFolder&&(e.rdo.attributes.readable?void(e.isLoaded()?i.treeModel.toggleNode(e):r.openNode(e)):(c.error(H("NOT_ALLOWED_SYSTEM")),!1))},this.mouseDown=function(e,t){e.selected(!0)},this.nodeClick=function(e,t){k.manager.dblClickOpen||r.openNode(e)},this.nodeDblClick=function(e,t){k.manager.dblClickOpen&&r.openNode(e)},this.openNode=function(t,r){if("file"===t.rdo.type&&a(t.rdo),"folder"===t.rdo.type)if(!t.isLoaded()||t.isExpanded()&&k.filetree.reloadOnClick)i.treeModel.loadNodes(t,!0),a(t.rdo);else{i.treeModel.toggleNode(t),E.currentPath(t.id),E.breadcrumbsModel.splitCurrent();var o=[];e.each(t.children(),function(e,t){o.push(t.rdo)}),i.itemsModel.setList(o)}},this.remove=function(){r.parentNode().children.remove(r)},this.isRoot=function(){return r.level()===i.treeModel.treeData.id},this.title=ko.pureComputed(function(){return k.options.showTitleAttr?this.rdo.id:null},this),this.itemClass=ko.pureComputed(function(){var e=[];return this.selected()&&k.manager.selection.enabled&&e.push("ui-selected"),this.dragHovered()&&e.push(i.ddModel.hoveredCssClass),e.join(" ")},this),this.iconClass=ko.pureComputed(function(){var e,t=["ico"];return!0===this.cdo.isFolder?(e="ico_folder",!0===this.isLoading()?t.push("loading"):(t.push("folder"),this.rdo.attributes.readable?(this.isExpanded()||!this.isExpanded()&&this.isSliding())&&t.push("open"):t.push("lock"))):(e="ico_file",this.rdo.attributes.readable?t.push("ext",this.cdo.extension):t.push("file","lock")),e+" "+t.join("_")},this),this.switcherClass=ko.pureComputed(function(){var e=[];if(k.filetree.showLine?0===this.level()&&this.isFirstNode()&&this.isLastNode()?e.push("root"):0===this.level()&&this.isFirstNode()?e.push("roots"):this.isLastNode()?e.push("bottom"):e.push("center"):e.push("noline"),this.cdo.isFolder){var t=this.isExpanded()||!this.isExpanded()&&this.isSliding();e.push(t?"open":"close")}else e.push("docu");return e.join("_")},this),this.clusterClass=ko.pureComputed(function(){return k.filetree.showLine&&!this.isLastNode()?"line":""},this)},n=function(e){var o=k.viewer.image.thumbMaxWidth;e.attributes.width&&e.attributes.width<o&&(o=e.attributes.width),this.id=e.id,this.rdo=e,this.cdo={isFolder:"folder"===e.type,sizeFormatted:$(e.attributes.size),extension:"file"===e.type?se(e.id):null,dimensions:e.attributes.width?e.attributes.width+"x"+e.attributes.height:null,cssItemClass:"folder"===e.type?"directory":"file",imageUrl:xe(e,!0,!0),previewWidth:o,hiddenByType:!1,hiddenBySearch:!1},this.visible=ko.observable(!0),this.selected=ko.observable(!1),this.dragHovered=ko.observable(!1),this.lazyPreview=k.viewer.image.lazyLoad&&this.cdo.imageUrl,this.selected.subscribe(function(e){e&&null!==i.treeModel.selectedNode()&&i.treeModel.selectedNode().selected(!1)}),this.title=ko.pureComputed(function(){return k.options.showTitleAttr?this.rdo.id:null},this),this.itemClass=ko.pureComputed(function(){var e=[];return this.selected()&&k.manager.selection.enabled&&e.push("ui-selected"),this.dragHovered()&&e.push(i.ddModel.hoveredCssClass),this.cdo.cssItemClass+" "+e.join(" ")},this),this.listIconClass=ko.pureComputed(function(){var e,t=["ico"];return!0===this.cdo.isFolder?(e="ico_folder",t.push("folder"),this.rdo.attributes.readable||t.push("lock")):(e="ico_file",this.rdo.attributes.readable?t.push("ext",this.cdo.extension):t.push("file","lock")),e+" "+t.join("_")},this),this.gridIconClass=ko.pureComputed(function(){var e=[],t=["ico"];return this.cdo.imageUrl||(e.push("grid-icon"),!0===this.cdo.isFolder?(e.push("ico_folder"),t.push("folder"),this.rdo.attributes.readable||t.push("lock")):(e.push("ico_file"),this.rdo.attributes.readable?t.push("ext",this.cdo.extension):t.push("file","lock")),e.push(t.join("_"))),e.join(" ")},this),this.mouseDown=function(e,t){e.selected()||i.itemsModel.unselectItems(t.ctrlKey),i.selectionModel.unselect=e.selected(),e.selected(!0)},this.open=function(e,o){i.selectionModel.unselect&&(o.ctrlKey&&e.selected(!1),!o.ctrlKey&&k.manager.dblClickOpen&&(i.itemsModel.unselectItems(o.ctrlKey),e.selected(!0))),t(o)&&(k.options.quickSelect&&"file"===e.rdo.type&&r(e.rdo,"select")?Ie(e.rdo):a(e.rdo))},this.remove=function(){i.itemsModel.objects.remove(this)}},d=function(){var t,i=this;this.rdo=ko.observable({}),this.content=ko.observable(null),this.renderer=ko.observable(null),this.render=function(e){i.renderer()&&i.renderer().processContent(e)},this.setRenderer=function(e){i.rdo(e),we(e.attributes.name)?i.renderer(new o):i.renderer(new r)},this.setContainer=function(r){e.each(r,function(){if(e(this).hasClass("fm-renderer-container"))return t=e(this),!1}),i.renderer().processDomElements(t)};var r=function(){this.name="codeMirror",this.interactive=!1;var e=new f;this.processContent=function(t){e.render(t),i.content(t)},this.processDomElements=function(t){if(!e.instance){var r=t.find(".fm-cm-renderer-content")[0],o=se(i.rdo().id);e.createInstance(o,r,{readOnly:"nocursor",styleActiveLine:!1,lineNumbers:!1})}}},o=function(){function r(){t.find("a").each(function(){var t=e(this).attr("href"),i=E.previewModel.editor;if(i.enabled()&&i.isInteractive())e(this).off("click"),e(this).on("click",function(){return!1});else{if(-1!=t.search("://")||re(t,"mailto:"))return;we(t)&&e(this).on("click",function(e){return Be(t).then(function(e){e.data&&a(e.data)}),!1})}})}this.name="markdown",this.interactive=!0;var o=window.markdownit({html:!0,linkify:!0,typographer:!0,highlight:function(e,t){if(t&&hljs.getLanguage(t))try{return'<pre class="highlight"><code>'+hljs.highlight(t,e,!0).value+"</code></pre>"}catch(e){}return'<pre class="highlight"><code>'+o.utils.escapeHtml(e)+"</code></pre>"},replaceLink:function(e,t){if(-1!=e.search("://")||re(e,"mailto:"))return e;var r=(re(e,"/")?x:le(i.rdo().id))+te(e,"/");if(we(r))return r;var o=ye("GET",{mode:"readfile",path:r});return Ce(o)}}).use(window.markdownitReplaceLink);this.processContent=function(e){var t=o.render(e);i.content(t),r()},this.processDomElements=function(e){}}},f=function(){function t(e){r.enabled(!0),r.instance.setValue(e),setTimeout(function(){r.instance.refresh()},0)}function i(e){var t=[],i="default";k.editor.codeHighlight&&("js"===e&&(t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),i="javascript"),"css"===e&&(t.push("/scripts/CodeMirror/mode/css/css.js"),i="css"),"html"===e&&(t.push("/scripts/CodeMirror/mode/xml/xml.js"),i="text/html"),"xml"===e&&(t.push("/scripts/CodeMirror/mode/xml/xml.js"),i="application/xml"),"php"===e&&(t.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),t.push("/scripts/CodeMirror/mode/xml/xml.js"),t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),t.push("/scripts/CodeMirror/mode/css/css.js"),t.push("/scripts/CodeMirror/mode/clike/clike.js"),t.push("/scripts/CodeMirror/mode/php/php.js"),i="application/x-httpd-php"),"java"===e&&(t.push("/scripts/CodeMirror/mode/clike/clike.js"),i="text/x-java"),"sql"===e&&(t.push("/scripts/CodeMirror/mode/sql/sql.js"),i="text/x-mysql"),"md"===e&&(t.push("/scripts/CodeMirror/addon/mode/overlay.js"),t.push("/scripts/CodeMirror/mode/xml/xml.js"),t.push("/scripts/CodeMirror/mode/markdown/markdown.js"),t.push("/scripts/CodeMirror/mode/gfm/gfm.js"),t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),t.push("/scripts/CodeMirror/mode/css/css.js"),t.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),t.push("/scripts/CodeMirror/mode/clike/clike.js"),t.push("/scripts/CodeMirror/mode/shell/shell.js"),t.push("/scripts/CodeMirror/mode/meta.js"),i="gfm"),"sh"===e&&(t.push("/scripts/CodeMirror/addon/mode/overlay.js"),t.push("/scripts/CodeMirror/mode/markdown/markdown.js"),t.push("/scripts/CodeMirror/mode/gfm/gfm.js"),t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),t.push("/scripts/CodeMirror/mode/css/css.js"),t.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),t.push("/scripts/CodeMirror/mode/clike/clike.js"),t.push("/scripts/CodeMirror/mode/meta.js"),t.push("/scripts/CodeMirror/mode/shell/shell.js"),i="shell")),t.length?(t.push(function(){r.mode(i)}),K(t)):r.mode(i)}var r=this,o=null;this.instance=null,this.enabled=ko.observable(!1),this.content=ko.observable(null),this.mode=ko.observable(null),this.isInteractive=ko.observable(!1),this.mode.subscribe(function(e){e&&(r.instance.setOption("mode",e),o&&(t(o),o=null))}),this.render=function(e){r.mode()?t(e):o=e},this.createInstance=function(t,o,n){var s,a={readOnly:"nocursor",styleActiveLine:!1,viewportMargin:1/0,lineNumbers:k.editor.lineNumbers,lineWrapping:k.editor.lineWrapping,theme:k.editor.theme,matchBrackets:k.editor.matchBrackets,extraKeys:{F11:function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},Esc:function(e){e.getOption("fullScreen")&&e.setOption("fullScreen",!1)}}};(s=CodeMirror.fromTextArea(o,e.extend({},a,n))).on("changes",function(e,t){r.content(e.getValue())}),r.instance=s,i(t)}};this.treeModel=new function(){var t=this;this.selectedNode=ko.observable(null),this.treeData={id:x,level:ko.observable(-1),children:ko.observableArray([])},this.treeData.children.subscribe(function(e){t.arrangeNode(t.treeData)});var r=function(e){if(null!==O){e||(e=t.treeData);var i=t.findByFilter(function(e){return 0===O.indexOf(e.id)},e);i?(k.filetree.expandSpeed=10,t.loadNodes(i,!1)):(O=null,k.filetree.expandSpeed=200)}};this.mapNodes=function(e,i){i||(i=t.treeData),i.id!==t.treeData.id&&e.call(this,i);var r=i.children();if(!r||0===r.length)return null;for(var o=0,n=r.length;o<n;o++)e.call(this,r[o]),t.findByFilter(e,r[o])},this.findByParam=function(e,i,r){if(!r&&(r=t.treeData)[e]===i)return r;var o=r.children();if(!o||0===o.length)return null;for(var n=0,s=o.length;n<s;n++){if(o[n][e]===i)return o[n];var a=t.findByParam(e,i,o[n]);if(a)return a}return null},this.findByFilter=function(e,i){if(!i&&(i=t.treeData,e(i)))return i;var r=i.children();if(!r||0===r.length)return null;for(var o=0,n=r.length;o<n;o++){if(e(r[o]))return r[o];var s=t.findByFilter(e,r[o]);if(s)return s}return null},this.getSelected=function(){var e=[];return t.selectedNode()&&e.push(t.selectedNode()),e},this.loadNodes=function(i,o){var n=i?i.id:t.treeData.id;i&&i.isLoaded(!1),Me("GET",{mode:"getfolder",path:n}).done(function(n){if(n.data){var s=[];e.each(n.data,function(e,i){var r=t.createNode(i);s.push(r)}),o&&i.children([]),t.addNodes(i,s),i&&(i.isLoaded(!0),t.expandNode(i)),r(i)}X(n)}).fail(Y)},this.createNode=function(e){var t=new o(e);return E.filterModel.filterItem(t),t},this.addNodes=function(i,r){e.isArray(r)||(r=[r]),i||(i=t.treeData),k.filetree.foldersOnly&&(r=e.grep(r,function(e){return e.cdo.isFolder})),e.each(r,function(e,t){t.parentNode(i)});var o=i.children().concat(r);i.children(W(o))},this.expandNode=function(e){return!1===e.isExpanded()&&!0===e.isLoaded()&&(e.isSliding(!0),!0)},this.collapseNode=function(e){return!0===e.isExpanded()&&(e.isSliding(!0),!0)},this.toggleNode=function(e){t.collapseNode(e)||t.expandNode(e)},this.arrangeNode=function(t){var i=t.children().length;e.each(t.children(),function(e,r){r.level(t.level()+1),r.isFirstNode(0===e),r.isLastNode(e===i-1)})},this.nodeRendered=function(t,r){e(t[1]).contextMenu({selector:".file, .directory",zIndex:100,build:function(e,t){return r.selected(!0),{appendTo:".fm-container",items:l(r.rdo),callback:function(e,t){Ge(e,t,r.rdo,i.fetchSelectedObjects(r))}}}})},this.actualizeNodeObject=function(i,r,o){var n=new RegExp("^"+r),s=i.rdo.id,a=s.replace(n,o);i.id=a,i.rdo.id=a,i.rdo.attributes.path=i.rdo.attributes.path.replace(new RegExp(s+"$"),a),i.children().length&&e.each(i.children(),function(e,i){t.actualizeNodeObject(i,r,o)})}},this.itemsModel=new function(){var r=this;this.objects=ko.observableArray([]),this.objectsSize=ko.observable(0),this.objectsNumber=ko.observable(0),this.selectedNumber=ko.observable(0),this.listSortField=ko.observable(_),this.listSortOrder=ko.observable(L),this.isSelecting=ko.observable(!1),this.continiousSelection=ko.observable(!1),this.descriptivePanel=new d,this.lazyLoad=null,this.isSelecting.subscribe(function(e){e||r.continiousSelection(!1)}),this.createObject=function(e){var t=new n(e);return E.filterModel.filterItem(t),t},this.addNew=function(t){var o=i.itemsModel.objects();e.isArray(t)||(t=[t]),e.each(t,function(e,t){o.push(r.createObject(t))}),o=W(o),i.itemsModel.objects.valueHasMutated()},this.loadList=function(e){i.loadingView(!0);var t={mode:"getfolder",path:e};N.param("type")&&(t.type=N.param("type")),Me("GET",t).done(function(t){t.data&&(i.currentPath(e),i.breadcrumbsModel.splitCurrent(),i.itemsModel.setList(t.data),i.itemsModel.lazyLoad&&i.itemsModel.lazyLoad.update()),X(t)}).fail(Y)},this.setList=function(o){var n=[];if(!Z(i.currentPath())&&i.currentPath()!==x){var s=de(i.currentPath()),a={id:s,rdo:{id:s,type:"parent",attributes:{readable:!0,writable:!0}},dragHovered:ko.observable(!1)};a.open=function(e,i){t(i)&&r.loadList(a.id)},a.itemClass=ko.pureComputed(function(){var e=[];return a.dragHovered()&&e.push(i.ddModel.hoveredCssClass),e.join(" ")}),n.push(a)}r.descriptivePanel.content(null),e.each(o,function(e,t){k.manager.renderer.position&&"string"==typeof k.manager.renderer.indexFile&&t.attributes.name.toLowerCase()===k.manager.renderer.indexFile.toLowerCase()&&(r.descriptivePanel.setRenderer(t),Ae(r.descriptivePanel.rdo()).then(function(e){e.data&&r.descriptivePanel.render(e.data.attributes.content)})),n.push(r.createObject(t))}),i.itemsModel.objects(W(n)),i.loadingView(!1)},this.findByParam=function(e,t){return ko.utils.arrayFirst(i.itemsModel.objects(),function(i){return i[e]===t})},this.findByFilter=function(e,t){var i=!t,o=[],n=r.objects();if(!n||0===n.length)return null;for(var s=0,a=n.length;s<a;s++)if(e(n[s])){if(i)return n[s];o.push(n[s])}return i?null:o},this.sortObjects=function(){var e=W(r.objects());r.objects(e)},this.getSelected=function(){var e=r.findByFilter(function(e){return"parent"!==e.rdo.type&&e.selected()},!0);return r.selectedNumber(e.length),e},this.unselectItems=function(t){k.manager.selection.enabled&&k.manager.selection.useCtrlKey&&!0===t||e.each(r.getSelected(),function(e,t){t.selected(!1)})},this.initiateLazyLoad=function(){!0!==k.viewer.image.lazyLoad||r.lazyLoad||(r.lazyLoad=new LazyLoad({container:b[0],callback_load:function(e){c.log("LOADED",e.getAttribute("data-original"))},callback_set:function(e){c.log("SET",e.getAttribute("data-original"))},callback_processed:function(e){c.log("PROCESSED",e+" images left")}}))},this.objects.subscribe(function(t){var o=0,n=0;e.each(t,function(e,t){"parent"!==t.rdo.type&&o++,"file"===t.rdo.type&&(n+=Number(t.rdo.attributes.size))}),r.objectsNumber(o),r.objectsSize($(n)),r.lazyLoad&&setTimeout(function(){r.lazyLoad.update()},50),M.contextMenu({selector:".file, .directory",zIndex:100,build:function(e,t){var r=ko.dataFor(e[0]);return r.selected()||(i.itemsModel.unselectItems(!1),r.selected(!0)),{appendTo:".fm-container",items:l(r.rdo),callback:function(e,t){Ge(e,t,r.rdo,i.fetchSelectedObjects(r))}}}})})},this.tableViewModel=new function(){var e=function(e){var t=this;this.column=ko.observable(e),this.order=ko.observable(i.itemsModel.listSortOrder()),this.sortClass=ko.pureComputed(function(){var e;return i.itemsModel.listSortField()===t.column()&&(e="sorted sorted-"+this.order()),e},this),this.sort=function(){var e="asc"===t.order(),r=i.itemsModel.listSortField()===t.column();t.order(r?e?"desc":"asc":i.itemsModel.listSortOrder()),i.itemsModel.listSortField(t.column()),i.itemsModel.listSortOrder(t.order()),i.itemsModel.sortObjects()}};this.thName=new e("name"),this.thType=new e("type"),this.thSize=new e("size"),this.thDimensions=new e("dimensions"),this.thModified=new e("modified")},this.previewModel=new function(){var e=this,t=null;this.rdo=ko.observable({}),this.cdo=ko.observable({}),this.viewer={type:ko.observable("default"),isEditable:ko.observable(!1),url:ko.observable(null),pureUrl:ko.observable(null),options:ko.observable({}),content:ko.observable(null),codeMirror:ko.observable(null)},this.renderer=new d,this.editor=new f,this.rdo.subscribe(function(t){e.cdo({isFolder:"folder"===t.type,sizeFormatted:$(t.attributes.size),extension:"file"===t.type?se(t.id):null,dimensions:t.attributes.width?t.attributes.width+"x"+t.attributes.height:null})}),this.editor.content.subscribe(function(t){e.editor.isInteractive()&&e.renderer.render(t)}),this.applyObject=function(r){t&&t.destroy(),i.previewFile(!1);var o=r.attributes.name,n={interactive:!1},s={type:"default",url:null,options:{}};e.rdo(r),pe(o)&&(s.type="image",s.url=xe(r,!1,!0)),he(o)&&!0===k.viewer.audio.enabled&&(s.type="audio",s.url=ke(r,!0)),fe(o)&&!0===k.viewer.video.enabled&&(s.type="video",s.url=ke(r,!0),s.options={width:k.viewer.video.playerWidth,height:k.viewer.video.playerHeight}),ve(o)&&!0===k.viewer.opendoc.enabled&&(s.type="opendoc",s.url=c.settings.baseUrl+"/scripts/ViewerJS/index.html#"+ke(r,!0),s.options={width:k.viewer.opendoc.readerWidth,height:k.viewer.opendoc.readerHeight}),be(o)&&!0===k.viewer.google.enabled&&(s.type="google",s.url="https://docs.google.com/viewer?url="+encodeURIComponent(ke(r,!1))+"&embedded=true",s.options={width:k.viewer.google.readerWidth,height:k.viewer.google.readerHeight}),me(o)&&!0===k.viewer.iframe.enabled&&(s.type="iframe",s.url=ke(r,!0),s.options={width:k.viewer.iframe.readerWidth,height:k.viewer.iframe.readerHeight}),(ge(o)&&!0===k.viewer.codeMirrorRenderer.enabled||we(o)&&!0===k.viewer.markdownRenderer.enabled)&&(s.type="renderer",s.options={is_writable:r.attributes.writable},e.renderer.setRenderer(r),n.interactive=e.renderer.renderer().interactive),e.viewer.type(s.type),e.viewer.url(s.url),e.viewer.options(s.options),e.viewer.pureUrl(je(r)),e.viewer.isEditable(ue(o)&&!0===k.editor.enabled),e.editor.isInteractive(n.interactive),"renderer"===s.type||e.viewer.isEditable()?Ae(r).then(function(t){if(t.data){var r=t.data.attributes.content;e.viewer.content(r),i.previewFile(!0)}}):i.previewFile(!0)},this.afterRender=function(){e.renderer.render(e.viewer.content());var i=y.find(".btn-copy-url")[0];(t=new Clipboard(i)).on("success",function(e){c.success(H("copied"))})},this.initiateEditor=function(t){var i=y.find(".fm-cm-editor-content")[0];e.editor.createInstance(e.cdo().extension,i,{readOnly:!1,styleActiveLine:!0})},this.bindToolbar=function(t){r(e.rdo(),t)&&Ge(t,{},e.rdo())},this.previewIconClass=ko.pureComputed(function(){var t=[],i=["ico"];return"default"!==e.viewer.type()&&e.viewer.url()||(t.push("grid-icon"),!0===this.cdo().isFolder?(t.push("ico_folder"),i.push("folder"),this.rdo().attributes.readable||i.push("lock")):(t.push("ico_file"),this.rdo().attributes.readable?i.push("ext",this.cdo().extension):i.push("file","lock")),t.push(i.join("_"))),t.join(" ")},this),this.editFile=function(){var t=e.viewer.content();e.renderer.render(t),e.editor.render(t)},this.saveFile=function(){Ue(e.rdo())},this.closeEditor=function(){e.editor.enabled(!1),e.renderer.render(e.viewer.content())},this.buttonVisibility=function(t){switch(t){case"select":return r(e.rdo(),t)&&s();case"move":case"rename":case"delete":case"download":return r(e.rdo(),t)}}},this.headerModel=new function(){this.closeButton=ko.observable(!1),this.langSwitcher=e.isArray(k.language.available)&&k.language.available.length>0,this.closeButtonOnClick=function(){c.log("CLOSE button is clicked")},this.navHome=function(){i.previewFile(!1),i.itemsModel.loadList(x)},this.navLevelUp=function(){var e=i.previewFile()?le(i.previewModel.rdo().id):de(i.currentPath());i.previewFile()&&i.previewFile(!1),e!==i.currentPath()&&i.itemsModel.loadList(e)},this.navRefresh=function(){i.previewFile()?(i.previewFile(!1),i.previewFile(!0)):i.itemsModel.loadList(i.currentPath())},this.displayGrid=function(){i.viewMode("grid"),i.previewFile(!1),i.itemsModel.lazyLoad&&i.itemsModel.lazyLoad.update()},this.displayList=function(){i.viewMode("list"),i.previewFile(!1)},this.switchLang=function(t){var i=t.target.value,r=I.getLang();if(i&&i.toLowerCase()!==r.toLowerCase()){var o,n=window.location.toString(),s=new RegExp("(langCode=)"+r);o=s.test(n)?n.replace(s,"$1"+i):n+(e.isEmptyObject(N.param())?"?":"#")+"langCode="+i,window.location.href=o}},this.createFolder=function(){c.prompt({message:H("prompt_foldername"),value:H("default_foldername"),okBtn:{label:H("create_folder"),autoClose:!1,click:function(e,t){var i=t.getInputValue();i?Me("GET",{mode:"addfolder",path:E.currentPath(),name:i}).done(function(e){e.data&&(E.addItem(e.data,E.currentPath()),t.closeDialog(),k.options.showConfirmation&&c.success(H("successful_added_folder"))),X(e)}).fail(Y):c.error(H("no_foldername"))}},cancelBtn:{label:H("cancel")}})}},this.summaryModel=new function(){this.files=ko.observable(null),this.folders=ko.observable(null),this.size=ko.observable(null),this.enabled=ko.observable(!1),this.doSummarize=function(){Re()}},this.filterModel=new function(){var t=this;this.name=ko.observable(null),this.setName=function(i){i&&k.filter&&e.isArray(k.filter[i])&&t.name(i)},this.getExtensions=function(){return t.name()?k.filter[t.name()]:null},this.filterItem=function(i){if("parent"!==i.rdo.type){var r=t.getExtensions(),o=!i.cdo.hiddenBySearch;if("file"===i.rdo.type&&e.isArray(r)){var n=se(i.id),s=-1!==r.indexOf(n);o=o&&s,i.cdo.hiddenByType=!s}i.visible(o)}},this.filter=function(r){i.searchModel.reset(),t.setName(r),e.each(i.itemsModel.objects(),function(e,i){t.filterItem(i)}),i.treeModel.mapNodes(function(e){t.filterItem(e)}),i.itemsModel.lazyLoad&&i.itemsModel.lazyLoad.update()},this.reset=function(){t.name(null),t.filter(null)}},this.searchModel=new function(){var t=this;this.value=ko.observable(""),this.findAll=function(r,o){t.value(o.target.value),_e(function(){var r=t.value().toLowerCase();e.each(i.itemsModel.objects(),function(e,t){if("parent"!==t.rdo.type&&!t.cdo.hiddenByType){var i=t.rdo.attributes.name,o=0===(i=i.toLowerCase()).indexOf(r);t.cdo.hiddenBySearch=!o,t.visible(o)}})},200)},this.reset=function(r,o){t.value(""),e.each(i.itemsModel.objects(),function(e,t){"parent"!==t.rdo.type&&(t.cdo.hiddenBySearch=!1,t.visible(!t.cdo.hiddenByType))})}},this.clipboardModel=new function(){function e(){r=[],t=null,o.itemsNum(0)}var t=null,r=[],o=this,n=j.indexOf("copy")>-1||j.indexOf("move")>-1;this.itemsNum=ko.observable(0),this.enabled=ko.observable(i.config().clipboard.enabled&&n),this.copy=function(){o.hasCapability("copy")&&(t="copy",r=i.fetchSelectedItems(),o.itemsNum(r.length))},this.cut=function(){o.hasCapability("cut")&&(t="cut",r=i.fetchSelectedItems(),o.itemsNum(r.length))},this.paste=function(){if(o.hasCapability("paste")&&!o.isEmpty())if(null!==t&&0!==r.length){var n=i.currentPath();Le(r,function(e,i){return"cut"===t?Te(i,n):"copy"===t?Fe(i,n):void 0},e)}else c.warning(H("clipboard_empty"))},this.clear=function(){o.hasCapability("clear")&&!o.isEmpty()&&(e(),c.success(H("clipboard_cleared")))},this.isEmpty=function(){return 0===r.length},this.hasCapability=function(e){if(!o.enabled)return!1;switch(e){case"copy":return j.indexOf("copy")>-1;case"cut":return j.indexOf("move")>-1;default:return!0}}},this.breadcrumbsModel=new function(){var e=this;this.items=ko.observableArray([]),this.add=function(i,r){e.items.push(new t(i,r))},this.splitCurrent=function(){var t=x,r=i.currentPath().replace(new RegExp("^"+x),"").split("/");for(e.items([]),e.add(x,"");r.length>0;){var o=r.shift();o&&(t+=o+"/",e.add(t,o))}};var t=function(e,t){var r=this;this.path=e,this.label=t,this.isRoot=e===x,this.active=e===i.currentPath(),this.itemClass=function(){var e=["nav-item"];return r.isRoot&&e.push("root"),r.active&&e.push("active"),e.join(" ")},this.goto=function(e,t){e.active||i.itemsModel.loadList(e.path)}}},this.ddModel=new function(){function t(t){var i=e.grep(s.items,function(e,i){if("folder"===t.rdo.type||"parent"===t.rdo.type){if(re(t.rdo.id,e.rdo.id))return!0;if(t.rdo.id===ce(e.rdo.id))return!0}return e.id===t.id});return t.rdo.attributes.writable&&0===i.length}function r(e){null!==s.hoveredItem&&s.hoveredItem.dragHovered(!1),s.hoveredItem=e,e&&e.dragHovered(!0)}function o(e,t){t?e.addClass(a):e.removeClass(a)}var s=this,a="drop-restricted",l=e("#drag-helper-template");this.items=[],this.hoveredItem=null,this.dragHelper=null,this.isScrolling=!1,this.isScrolled=!1,this.hoveredCssClass="drop-hover",this.makeDraggable=function(t,r){"file"!==t.rdo.type&&"folder"!==t.rdo.type||e(r).draggable({distance:3,cursor:"pointer",cursorAt:{left:Math.floor(l.width()/2),bottom:15},scroll:!1,appendTo:p,containment:u,refreshPositions:!1,helper:function(){var e,r;return r=i.fetchSelectedItems(t.constructor.name).length>1?"ico_multiple":"folder"===t.rdo.type?"ico_folder":"ico_file ico_ext_"+se(t.rdo.id),(e=l.children(".drag-helper").clone()).find(".clip").addClass(r),s.dragHelper=e,e},start:function(e,r){s.items=i.fetchSelectedItems(t.constructor.name)},drag:function(t,i){e(this).draggable("option","refreshPositions",s.isScrolling||s.isScrolled),s.isScrolled=!1},stop:function(e,t){s.items=[],s.dragHelper=null}})},this.makeDroppable=function(i,a){"folder"!==i.rdo.type&&"parent"!==i.rdo.type||e(a).droppable({tolerance:"pointer",enableExtendedEvents:i instanceof n,accept:function(e){var t=ko.dataFor(e[0]),i=t?t.rdo.type:null;return"file"===i||"folder"===i},over:function(e,n){setTimeout(function(){r(null),o(n.helper,!1),t(i)||o(n.helper,!0),r(i)},0)},out:function(e,t){r(null),o(t.helper,!1)},drop:function(e,o){if(r(null),!t(i))return!1;Le(s.items,function(e,t){return Te(t.rdo,i.id)})}})}},this.selectionModel=new function(){this.unselect=!1}},H=function(e){return I.translate(e)},W=function(e){function t(e){var t,i=_;switch("list"===E.viewMode()&&(i=E.itemsModel.listSortField()),i){case"type":t=e.cdo.extension||"";break;case"size":t=e.rdo.attributes.size;break;case"modified":t=e.rdo.attributes.timestamp;break;case"dimensions":t=e.cdo.dimensions||"";break;default:t=e.rdo.attributes.name}return"string"==typeof t&&(n.cases||(t=t.toLowerCase()),t=t.replace(/\s+/g," ")),t}function i(e,t){for(var i=r(e.toString()),o=r(t.toString()),n=0;i[n]&&o[n];n++)if(i[n]!==o[n]){var s=Number(i[n]),a=Number(o[n]);return s==i[n]&&a==o[n]?s-a:i[n]>o[n]?1:-1}return i.length-o.length}function r(e){for(var t,i,r=[],o=0,n=-1,s=0;t=(i=e.charAt(o++)).charCodeAt(0);){var a=46==t||t>=48&&t<=57;a!==s&&(r[++n]="",s=a),r[n]+=i}return r}var o,n={natural:!0,order:"asc"===("list"===E.viewMode()?E.itemsModel.listSortOrder():L)?1:-1,cases:!1};e.length>0&&"parent"===e[0].rdo.type&&(o=e.shift()),e.sort(function(e,r){var o,s=t(e),a=t(r);return o=s===a?0:void 0===s||void 0===a?0:n.natural&&(isNaN(s)||isNaN(a))?i(s,a):s<a?-1:s>a?1:0,o*=n.order});for(var s=[],a=e.length;a--;)"folder"===e[a].rdo.type&&(s.push(e[a]),e.splice(a,1));"top"!==k.options.folderPosition&&s.reverse();for(var l=0,d=s.length;l<d;l++)"top"===k.options.folderPosition?e.unshift(s[l]):e.push(s[l]);return o&&e.unshift(o),e},G=function(t){return e.ajax({type:"HEAD",url:t})},q=function(t){var i=null;return t=void 0===t?"user":t,i="user"===t?N.param("config")?c.settings.baseUrl+"/config/"+N.param("config"):c.settings.baseUrl+"/config/filemanager.config.json":c.settings.baseUrl+"/config/filemanager.config.default.json",e.ajax({type:"GET",url:i,dataType:"json",cache:!1,error:function(e){c.error("Given config file ("+i+") does not exist!")}})},K=function(e){for(var t=0,i=e.length;t<i;t++)"string"==typeof e[t]&&(e[t]=c.settings.baseUrl+e[t]);toast.apply(this,e)},V=function(t,i){return e.ajax({type:"GET",url:c.settings.baseUrl+"/scripts/templates/"+t+".html",error:Y})},$=function(e,t){if(!e)return"";t=t||!1;for(var i=parseFloat(e),r=parseFloat(t?1e3:1024),o=0,n=[H("unit_bytes"),H("unit_kb"),H("unit_mb"),H("unit_gb")];;){if(i<r)return(i=Math.round(100*i)/100)+" "+n[o];i/=r,o+=1}},Q=function(t){var i;return I.getLang()&&H(t.message)?(i=H(t.message),e.each(t.arguments,function(e,t){i=i.replace("%s",t)})):i=t.message,i},Y=function(e){c.log(e.responseText||e),c.error(H("ERROR_SERVER")),c.error(e.responseText)},X=function(t){t.errors&&(c.log(t.errors),e.each(t.errors,function(e,t){c.error(Q(t)),t.arguments.redirect&&(window.location.href=t.arguments.redirect)}))};!function(e){e.extend({inArrayInsensitive:function(t,i,r){if("string"!=typeof t)return e.inArray.apply(this,arguments);if(i){var o=i.length;for(r=r?r<0?Math.max(0,o+r):r:0,t=t.toLowerCase();r<o;r++)if(r in i&&i[r].toLowerCase()==t)return r}return-1}})}(jQuery);var J=function(t){var i=se(t);if(k.security.extensions.ignoreCase){if("ALLOW_LIST"==k.security.extensions.policy&&-1!==e.inArrayInsensitive(i,k.security.extensions.restrictions))return!0;if("DISALLOW_LIST"==k.security.extensions.policy&&-1===e.inArrayInsensitive(i,k.security.extensions.restrictions))return!0}else{if("ALLOW_LIST"==k.security.extensions.policy&&-1!==e.inArray(i,k.security.extensions.restrictions))return!0;if("DISALLOW_LIST"==k.security.extensions.policy&&-1===e.inArray(i,k.security.extensions.restrictions))return!0}return!1},Z=function(e){return"/"!==e.charAt(e.length-1)},ee=function(e,t){var i=new RegExp("^"+t+"+|"+t+"+$","g");return e.replace(i,"")},te=function(e,t){var i=new RegExp("^"+t+"+","g");return e.replace(i,"")},ie=function(e,t){var i=new RegExp(t+"+$","g");return e.replace(i,"")},re=function(e,t,i){return i=i||0,e.substr(i,t.length)===t},oe=function(t){var i=[];return e.each(t.split("/"),function(e,t){i.push(encodeURIComponent(t))}),i.join("/")},ne=function(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")},se=function(e){return 1===e.split(".").length?"":e.split(".").pop().toLowerCase()},ae=function(e){return-1!==e.lastIndexOf(".")?e.substring(0,e.lastIndexOf(".")):e},le=function(e){return e.lastIndexOf("/")!==e.length-1?e.substr(0,e.lastIndexOf("/")+1):e},de=function(e){return e.split("/").reverse().slice(2).reverse().join("/")+"/"},ce=function(e){return e.substring(0,e.slice(0,-1).lastIndexOf("/"))+"/"},ue=function(t){return-1!==e.inArray(se(t),k.editor.extensions)},pe=function(t){return-1!==e.inArray(se(t),k.viewer.image.extensions)},fe=function(t){return-1!==e.inArray(se(t),k.viewer.video.extensions)},he=function(t){return-1!==e.inArray(se(t),k.viewer.audio.extensions)},me=function(t){return-1!==e.inArray(se(t),k.viewer.iframe.extensions)},ve=function(t){return-1!==e.inArray(se(t),k.viewer.opendoc.extensions)},be=function(t){return-1!==e.inArray(se(t),k.viewer.google.extensions)},ge=function(t){return-1!==e.inArray(se(t),k.viewer.codeMirrorRenderer.extensions)},we=function(t){return-1!==e.inArray(se(t),k.viewer.markdownRenderer.extensions)},ye=function(t,i){var r,o=k.api.requestParams;if(t=t.toUpperCase(),e.isPlainObject(o)&&(r=o[t],e.isPlainObject(r)&&!e.isEmptyObject(r))){var n=e.extend({},o.MIXED||{},r);"POST"===t&&e.isArray(i)?e.each(n,function(e,t){i.push({name:e,value:t})}):i=e.extend({},i,n)}return i},Me=function(t,i){return e.ajax({type:t,cache:!1,url:Ce(),dataType:"json",data:ye(t,i)})},Ce=function(t){var i={time:(new Date).getTime()},r=e.extend({},t||{},i);return S+"?"+e.param(r)},ke=function(e,t){var i,r=e.attributes.path;if(k.viewer.absolutePath&&r)t&&(r=oe(r)),i=Se(r,!1);else{var o=ye("GET",{mode:"readfile",path:e.id});i=Ce(o)}return i=c.settings.callbacks.beforeCreatePreviewUrl(e,i)},xe=function(e,t,i){var r;if(pe(e.id)&&e.attributes.readable&&(t&&k.viewer.image.showThumbs||!t&&!0===k.viewer.image.enabled)){if(k.viewer.absolutePath&&!t&&e.attributes.path)r=Se(oe(e.attributes.path),i);else{var o={path:e.id};"svg"===se(e.id)?o.mode="readfile":(o.mode="getimage",t&&(o.thumbnail="true")),o=ye("GET",o),r=Ce(o)}r=c.settings.callbacks.beforeCreateImageUrl(e,r)}return r},Se=function(e,t){var i="string"==typeof k.viewer.previewUrl?k.viewer.previewUrl:location.origin;return i=ee(i,"/")+e,t&&(i+="?time="+(new Date).getTime()),i},je=function(e){function t(e){return k.clipboard.encodeCopyUrl?oe(e):e}if(k.viewer.absolutePath&&e.attributes.path){i=t(e.attributes.path);return Se(i,!1)}var i=t(e.id),r="folder"===e.type?"getfolder":"readfile";return S+"?path="+i+"&mode="+r},_e=function(){var e=0;return function(t,i){clearTimeout(e),e=setTimeout(t,i)}}(),Le=function(t,i,r){var o,n=new function(){this.total=0,this.succeed=0,this.failure=0,this.processed=0,this.getProgress=function(){return Math.round(this.processed/this.total*100)},this.getProgressSucceed=function(){return Math.round(this.succeed/this.total*100)},this.getProgressFailure=function(){return Math.round(this.failure/this.total*100)},this.getMessage=function(){return H("successful_processed").replace("%s",this.succeed).replace("%s",this.total)},this.succeeded=function(){this.succeed++,this.processed++},this.failed=function(){this.failure++,this.processed++},this.isProcessed=function(){return this.processed===this.total}},s=e.Deferred().resolve();n.total=t.length,n.total>1&&(o=c.write(n.getMessage(),{delay:0,logMessageTemplate:function(e){n.getProgress();var t=n.isProcessed()?"striped":"striped animated";return"<div>"+e+'</div><div class="progress"><div class="progress-counter">'+n.getProgress()+'%</div><div class="progress-bar '+t+'"><div class="progress-segment progress-succeed" style="width: '+n.getProgressSucceed()+'%"></div><div class="progress-segment progress-failure" style="width: '+n.getProgressFailure()+'%"></div></div></div>'}})).stick(!0),e.each(t,function(e,t){s=s.then(function(){return i(e,t)}).then(function(e){e&&e.data?n.succeeded():n.failed(),o&&o.setMessage(n.getMessage())})}),s.then(function(){o&&n.isProcessed()&&(o.stick(!1),setTimeout(function(){o.remove()},6e3))}),s.then(function(){"function"==typeof r&&r()})},Ee=function(){document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},Ie=function(e){var t=null,i=ke(e,!0);if(i=c.settings.callbacks.beforeSelectItem(e,i),window.tinyMCEPopup){var r=tinyMCEPopup.getWindowArg("window");return r.document.getElementById(tinyMCEPopup.getWindowArg("input")).value=i,void 0!==r.ImageDialog&&(r.ImageDialog.getImageData&&r.ImageDialog.getImageData(),r.ImageDialog.showPreviewImage&&r.ImageDialog.showPreviewImage(i)),void tinyMCEPopup.close()}if(N.param("field_name")&&(parent.document.getElementById(N.param("field_name")).value=i,void 0!==parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),void 0!==parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),N.param("ImperaviElementId"))if(window.opener);else{var o=N.param("ImperaviElementId"),n=parent.$("#"+o).redactor("core.getObject");n&&(n.modal.close(),n.buffer.set(),pe(e.attributes.name)?n.insert.html('<img src="'+i+'">'):n.insert.html('<a href="'+i+'">'+e.attributes.name+"</a>"))}if(N.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(N.param("CKEditorFuncNum"),i):(parent.CKEDITOR.tools.callFunction(N.param("CKEditorFuncNum"),i),parent.CKEDITOR.tools.callFunction(N.param("CKEditorCleanUpFuncNum")))),window.opener&&"function"==typeof window.opener.SetUrl)if(e.attributes.width){var s=i,a=e.attributes.width,l=e.attributes.height;window.opener.SetUrl(s,a,l)}else window.opener.SetUrl(i);window.opener&&(t=window.opener),window.parent&&window.self!==window.parent&&(t=window.parent),t&&t.postMessage({source:"richfilemanager",preview_url:i},"*"),c.settings.callbacks.afterSelectItem(e,i,t)},Oe=function(t){c.prompt({message:H("new_filename"),value:k.options.allowChangeExtensions?t.attributes.name:ae(t.attributes.name),okBtn:{label:H("action_rename"),autoClose:!1,click:function(i,r){var o=t.id,n=r.getInputValue();if(n){if(!k.options.allowChangeExtensions){var s=se(t.attributes.name);s.length>0&&(n=n+"."+s)}if(Z(o)&&!J(n)){var a="<p>"+H("INVALID_FILE_TYPE")+"</p>";return"ALLOW_LIST"==k.security.extensions.policy&&(a+="<p>"+H("ALLOWED_FILE_TYPE").replace("%s",k.security.extensions.restrictions.join(", "))+".</p>"),"DISALLOW_LIST"==k.security.extensions.policy&&(a+="<p>"+H("DISALLOWED_FILE_TYPE").replace("%s",k.security.extensions.restrictions.join(", "))+".</p>"),e("#filepath").val(""),void c.error(a)}Me("GET",{mode:"rename",old:o,new:n}).done(function(e){if(e.data){var t=e.data,i=E.treeModel.findByParam("id",o);if(i&&("folder"===i.rdo.type&&(i.nodeTitle(t.attributes.name),E.treeModel.actualizeNodeObject(i,o,t.id)),"file"===i.rdo.type)){var n=i.parentNode(),s=E.treeModel.createNode(t);i.remove(),n&&E.treeModel.addNodes(n,s)}var a=E.itemsModel.findByParam("id",o);a&&("parent"===a.rdo.type?a.id=t.id:(a.remove(),E.itemsModel.addNew(t))),E.currentPath()===o&&E.itemsModel.loadList(t.id),E.previewFile()&&E.previewModel.rdo().id===o&&E.previewModel.applyObject(t),r.closeDialog(),k.options.showConfirmation&&c.success(H("successful_rename"))}X(e)}).fail(Y)}else c.error(H("new_filename"))}},cancelBtn:{label:H("cancel")}})},Ne=function(e,t){var i=e.length,r=i>1?H("prompt_move_multiple").replace("%s",i):H("prompt_move");c.prompt({message:r,value:E.currentPath(),okBtn:{label:H("action_move"),autoClose:!1,click:function(e,i){var r=i.getInputValue();r?(r=ie(r,"/")+"/",t(r)):c.error(H("prompt_foldername"))}},cancelBtn:{label:H("cancel")},template:{dialogInput:'<input data-alertify-input type="text" value="" /><div class="prompt-info">'+H("help_move")+"</div>"}})},Fe=function(e,t){return Me("GET",{mode:"copy",source:e.id,target:t}).done(function(e){if(e.data){var i=e.data;E.addItem(i,t),alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("successful_copied"))}X(e)}).fail(Y)},Te=function(e,t){return Me("GET",{mode:"move",old:e.id,new:t}).done(function(i){if(i.data){var r=i.data;E.removeItem(e),E.addItem(r,t),E.currentPath()===e.id&&E.itemsModel.loadList(r.id),E.previewFile()&&E.previewModel.rdo().id===e.id&&E.previewFile(!1),alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("successful_moved"))}X(i)}).fail(Y)},Pe=function(e,t){var i=e.length,r=i>1?H("confirm_delete_multiple").replace("%s",i):H("confirm_delete");c.confirm({message:r,okBtn:{label:H("yes"),click:function(e,i){t()}},cancelBtn:{label:H("no")}})},De=function(e){return Me("GET",{mode:"delete",path:e}).done(function(e){if(e.data){var t=e.data;E.removeItem(t),E.previewFile()&&E.previewModel.rdo().id===t.id&&E.previewFile(!1),k.options.showConfirmation&&c.success(H("successful_delete"))}X(e)}).fail(Y)},ze=function(t){var i={mode:"download",path:t.id};return Me("GET",i).done(function(t){t.data&&e.fileDownload(Ce(i)),X(t)}).fail(Y)},Ae=function(e){return Me("GET",{mode:"editfile",path:e.id}).done(function(e){X(e)}).fail(Y)},Ue=function(t){var i=e("#fm-js-editor-form").serializeArray();Me("POST",i).done(function(e){if(e.data){var t=e.data,i=E.previewModel,r=i.editor.content();i.rdo(t),i.viewer.content(r),i.closeEditor();var o=E.itemsModel.createObject(t),n=E.itemsModel.findByParam("id",t.id);E.itemsModel.objects.replace(n,o),c.success(H("successful_edit"))}X(e)}).fail(Y)},Be=function(e){return Me("GET",{mode:"getfile",path:e}).done(function(e){X(e)}).fail(Y)},Re=function(){return Me("GET",{mode:"summarize"}).done(function(t){if(t.data){var i=t.data.attributes,r=$(i.size,!0);if(i.sizeLimit>0){var o=$(i.sizeLimit,!0),n=100*i.size/i.sizeLimit;r+=" ("+Math.round(100*n)/100+"%) "+H("of")+" "+o}E.summaryModel.files(i.files),E.summaryModel.folders(i.folders),E.summaryModel.size(r),E.summaryModel.enabled(!0);var s=e("#summary-popup").clone().show();E.summaryModel.enabled(!1),c.alert(s[0].outerHTML)}X(t)}).fail(Y)},He=function(e){c.prompt({message:H("prompt_extract"),value:E.currentPath(),okBtn:{label:H("action_extract"),autoClose:!1,click:function(t,i){var r=i.getInputValue();r?(r=ie(r,"/")+"/",We(e,r)):c.error(H("prompt_foldername"))}},cancelBtn:{label:H("cancel")}})},We=function(t,i){Me("POST",{mode:"extract",source:t.id,target:i}).done(function(t){t.data&&(e.each(t.data,function(e,t){E.addItem(t,i)}),alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("successful_extracted"))),X(t)}).fail(Y)},Ge=function(t,i,r,o){var n=o||[r];switch(t){case"select":Ie(r);break;case"download":e.each(n,function(e,t){ze(t)});break;case"rename":Oe(r);break;case"move":Ne(n,function(e){Le(n,function(t,i){return Te(i,e)})});break;case"delete":Pe(n,function(){Le(n,function(e,t){return De(t.id)})});break;case"extract":He(r);break;case"copy":E.clipboardModel.copy(n);break;case"cut":E.clipboardModel.cut(n);break;case"copyUrl":var s=new Clipboard(i.$selected[0],{text:function(e){return je(r)}});s.on("success",function(e){c.success(H("copied")),s.destroy()})}},qe=function(){if(k.options.browseOnly)return!1;k.upload.multiple?(e("#file-input-container").remove(),C.unbind().click(function(){if(-1===j.indexOf("upload"))return c.error(H("NOT_ALLOWED")),!1;var t=null,i=E.currentPath(),r=tmpl("tmpl-fileupload-container",{folder:H("current_folder")+i,info:H("upload_files_number_limit").replace("%s",k.upload.maxNumberOfFiles)+" "+H("upload_file_size_limit").replace("%s",$(k.upload.fileSizeLimit,!0)),lang:I.getTranslations()});"ALLOW_LIST"==k.security.extensions.policy&&(t=new RegExp("(\\.|\\/)("+k.security.extensions.restrictions.join("|")+")$","i")),c.dialog({message:r,width:"auto",buttons:[{type:"ok",label:H("action_upload"),autoClose:!1,click:function(e,t){n.children(".upload-item").length>0?n.find(".button-start").trigger("click"):c.error(H("upload_choose_file"))}},{label:H("action_select"),closeOnClick:!1,click:function(t,i){e("#fileupload",o).trigger("click")}},{type:"cancel",label:H("close")}]});var o=e(".fm-fileupload-container"),n=e(".dropzone",o),s=e(".dropzone-wrapper",o),a=e("#total-progress",o).children();k.customScrollbar.enabled&&s.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){s.find(".mCSB_container").css({"margin-right":s.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){s.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),s.on("click",function(t){(t.target===this||e(t.target).parent()[0]===this||t.target===n[0]||e(t.target).parent().hasClass("default-message"))&&e("#fileupload",o).trigger("click")}),n.on("click",".button-start",function(t){var i=e(this);i.parent().parent().data().submit(),i.remove()}),n.on("click",".button-abort",function(t){var i=e(this).parent().parent().data(),r=i.files[0].context;i.abort(),r.find(".error-message").text(H("upload_aborted")),r.addClass("aborted")}),n.on("click",".button-resume",function(t){function r(i){e.blueimp.fileupload.prototype.options.add.call(e("#fileupload")[0],t,i),i.submit()}var o=e(this).parent().parent().data(),n=o.files[0];if(n.chunkUploaded){var s=i+n.serverName;Be(s).then(function(e){e.data&&(o.uploadedBytes=Number(e.data.attributes.size),o.uploadedBytes||(n.chunkUploaded=void 0),r(o))})}else r(o)}),n.on("click",".button-remove",function(t){var r=e(this),o=r.parent().parent().data().files[0];o.chunkUploaded&&De(i+o.serverName),r.closest(".upload-item").remove(),l()}),n.on("click",".button-info",function(t){var i=e(this).closest(".upload-item");if(i.hasClass("error")){var r=i.find(".error-message");c.error(r.text())}});var l=function(){n.children(".upload-item").length>0?n.addClass("started"):n.removeClass("started")},d=E.filterModel.getExtensions();d&&e("#fileupload").attr("accept",d.map(function(e){return"."+e}).join()),e("#fileupload",o).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:n,maxChunkSize:k.upload.chunkSize,url:Ce(),paramName:"files",singleFileUploads:!0,formData:ye("POST",{mode:"upload",path:i}),maxNumberOfFiles:k.upload.maxNumberOfFiles,acceptFileTypes:t,maxFileSize:k.upload.fileSizeLimit,messages:{maxNumberOfFiles:H("upload_files_number_limit").replace("%s",k.upload.maxNumberOfFiles),acceptFileTypes:H("upload_file_type_invalid"),maxFileSize:H("upload_file_too_big")+" "+H("upload_file_size_limit").replace("%s",$(k.upload.fileSizeLimit,!0))},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(t,i){var r=n.children(".upload-item");e.each(i.files,function(t,o){if(r.length>=k.upload.maxNumberOfFiles)return c.error(H("upload_files_number_limit").replace("%s",k.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;o.formattedSize=$(o.size);var s=e(tmpl("tmpl-upload-item",{file:o,lang:I.getTranslations(),imagesPath:c.settings.baseUrl+"/scripts/jQuery-File-Upload/img"}));o.context=s,s.find(".buttons").data(i),s.appendTo(n)}),l()}).on("fileuploadsend",function(t,i){e.each(i.files,function(e,t){var r=t.context;r.removeClass("added aborted error").addClass("process"),t.chunkUploaded&&i.total===i.uploadedBytes&&r.remove()})}).on("fileuploadfail",function(t,i){e.each(i.files,function(e,t){t.error=H("upload_failed"),t.context.removeClass("added process").addClass("error")})}).on("fileuploaddone",function(t,i){var r=i.result;e.each(i.files,function(e,t){var i=t.context;r&&r.errors?(i.removeClass("added process").addClass("error"),i.find(".error-message").text(Q(r.errors[0])),i.find(".button-start").remove()):i.remove()})}).on("fileuploadalways",function(t,i){var r=i.result;e.each(i.files,function(e,t){if(r&&r.data&&r.data[e]){var i=r.data[e];E.removeItem(i),E.addItem(i,E.currentPath())}});var o=n.children(".upload-item");0===o.filter(".added").length&&0===o.filter(".process").length&&(0===o.length&&(alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("upload_successful_files"))),o.filter(".error").length&&c.error(H("upload_partially")+"<br>"+H("upload_failed_details"))),l()}).on("fileuploadchunkdone",function(t,i){var r=i.result;e.each(i.files,function(e,t){if(r.data&&r.data[e]){var i=r.data[e];E.removeItem(i),E.addItem(i,E.currentPath()),t.serverName=i.attributes.name,t.chunkUploaded=1}})}).on("fileuploadprocessalways",function(t,i){e.each(i.files,function(e,t){var i=t.context;void 0!==i&&(t.preview&&(i.find(".image").append(t.preview),i.find(".preview").removeClass("file-preview").addClass("image-preview")),t.error&&(i.removeClass("added process").addClass("error"),i.find(".error-message").text(t.error),i.find(".button-start").remove()))})}).on("fileuploadprogress",function(t,i){e.each(i.files,function(e,t){var r=t.context,o=parseInt(i.loaded/i.total*100,10);r.find(".progress-bar").css("width",o+"%")})}).on("fileuploadprogressall",function(e,t){var i=parseInt(t.loaded/t.total*100,10);a.css("width",i+"%")})})):(C.click(function(){if(-1===j.indexOf("upload"))return c.error(H("NOT_ALLOWED")),!1;var t=e(this).data();e.isEmptyObject(t)?c.error(H("upload_choose_file")):t.submit()}),h.fileupload({autoUpload:!1,dataType:"json",url:Ce(),paramName:"files",maxChunkSize:k.upload.chunkSize}).on("fileuploadadd",function(e,t){C.data(t)}).on("fileuploadsubmit",function(e,t){t.formData=ye("POST",{mode:"upload",path:E.currentPath()}),C.addClass("loading").prop("disabled",!0),C.children("span").text(H("loading_data"))}).on("fileuploadalways",function(t,i){e("#filepath").val(""),C.removeData().removeClass("loading").prop("disabled",!1),C.children("span").text(H("action_upload"));var r=i.result;if(r&&r.errors&&c.error(H("upload_failed")+"<br>"+Q(r.errors[0])),r&&r.data){var o=r.data[0];E.removeItem(o),E.addItem(o,E.currentPath()),k.options.showConfirmation&&c.success(H("upload_successful_file"))}}).on("fileuploadchunkdone",function(e,t){var i=t.result;if(i.data&&i.data[0]){var r=i.data[0];E.removeItem(r),E.addItem(r,E.currentPath())}}).on("fileuploadfail",function(e,t){c.error(H("upload_failed"))}))};!function(){var t=e.Deferred();t.then(function(){return T()}).then(function(){return D()}).then(function(e,t){return P()}).then(function(){return z()}).then(function(){A(function(){U()})}),t.resolve()}(),e(window).resize(c.setDimensions)}}(jQuery),$.fn.richFilemanager=function(e){return this.each(function(){if(void 0==$(this).data("richFilemanager")){var t=new $.richFilemanagerPlugin(this,e);$(this).data("richFilemanager",t)}})},window.location.origin||(window.location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")); | ||
!function(e){e.richFilemanagerPlugin=function(t,i){function r(t,i){if(-1===j.indexOf(i))return!1;if("select"===i&&"folder"===t.type)return!1;if("extract"===i){var r=se(t.attributes.name);return"file"===t.type&&"zip"===r}return"download"===i&&"folder"===t.type?!0===k.options.allowFolderDownload:void 0===t.attributes.capabilities||e.inArray(i,t.attributes.capabilities)>-1}function o(){k.filetree.enabled&&(g.show(),m.splitter({sizeLeft:k.filetree.width,minLeft:k.filetree.minWidth,minRight:200}),E.treeModel.loadNodes(null,!1))}function n(){E.itemsModel.loadList(x)}function s(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||N.param("field_name")||N.param("CKEditor")||N.param("ImperaviElementId")}function a(e){if(!e.attributes.readable)return c.error(H("NOT_ALLOWED_SYSTEM")),!1;"file"===e.type&&E.previewModel.applyObject(e),"folder"!==e.type&&"parent"!==e.type||(E.previewFile(!1),E.itemsModel.loadList(e.id))}function l(e){var t=!E.clipboardModel.enabled(),i={select:{name:H("action_select"),className:"select"},download:{name:H("action_download"),className:"download"},rename:{name:H("action_rename"),className:"rename"},move:{name:H("action_move"),className:"move"},separator1:"-----",copy:{name:H("clipboard_copy"),className:"copy"},cut:{name:H("clipboard_cut"),className:"cut"},delete:{name:H("action_delete"),className:"delete"},extract:{name:H("action_extract"),className:"extract"},copyUrl:{name:H("copy_to_clipboard"),className:"copy-url"}};return r(e,"download")||delete i.download,r(e,"select")&&s()||delete i.select,r(e,"rename")&&!0!==k.options.browseOnly||delete i.rename,r(e,"delete")&&!0!==k.options.browseOnly||delete i.delete,r(e,"extract")&&!0!==k.options.browseOnly||delete i.extract,r(e,"copy")&&!0!==k.options.browseOnly&&!t||delete i.copy,r(e,"move")&&!0!==k.options.browseOnly&&!t||(delete i.cut,delete i.move),i}var d={baseUrl:".",config:{},callbacks:{beforeCreateImageUrl:function(e,t){return t},beforeCreatePreviewUrl:function(e,t){return t},beforeSelectItem:function(e,t){return t},afterSelectItem:function(e,t,i){}}},c=this,u=e(t),p=u.children(".fm-wrapper"),f=p.find(".fm-header"),h=f.find(".fm-uploader"),m=p.children(".fm-splitter"),v=p.children(".fm-footer"),b=m.children(".fm-fileinfo"),g=m.children(".fm-filetree"),w=b.find(".view-items-wrapper"),y=b.find(".fm-preview-wrapper"),M=w.find(".view-items"),C=h.children(".fm-upload"),k=null,x="/",S=null,j=[],_=null,L=null,E=null,I=null,O=null,N=purl(),F=(new Date).getTime();c.settings=e.extend(!0,d,i),c.write=function(t,i){var r=alertify,o=e.extend({},{reset:!0,delay:5e3,logMaxItems:5,logPosition:"bottom right",logContainerClass:"fm-log",logMessageTemplate:null,parent:document.body,onClick:void 0,unique:!1,type:"log"},i);if(o.logClass&&o.unique&&e(".fm-log").children("."+o.logClass).length>0)return r;o.reset&&r.reset(),r.parent(o.parent),r.logDelay(o.delay),r.logMaxItems(o.logMaxItems),r.logPosition(o.logPosition),r.logContainerClass(o.logContainerClass),r.logMessageTemplate(o.logMessageTemplate),r[o.type](t,o.onClick);var n=r.getLogs();return n[n.length-1]},c.error=function(t,i){return c.write(t,e.extend({},{type:"error",delay:1e4},i))},c.warning=function(t,i){return c.write(t,e.extend({},{type:"warning",delay:1e4},i))},c.success=function(t,i){return c.write(t,e.extend({},{type:"success",delay:6e3},i))},c.alert=function(e){alertify.reset().dialogContainerClass("fm-popup").alert(e)},c.confirm=function(e){alertify.reset().dialogWidth(e.width).dialogPersistent(e.persistent).dialogContainerClass("fm-popup").confirm(e.message,e.okBtn,e.cancelBtn)},c.prompt=function(e){alertify.reset().dialogWidth(e.width).dialogPersistent(e.persistent).dialogContainerClass("fm-popup").theme(e.template).prompt(e.message,e.value||"",e.okBtn,e.cancelBtn)},c.dialog=function(e){alertify.reset().dialogWidth(e.width).dialogPersistent(e.persistent).dialogContainerClass("fm-popup").dialog(e.message,e.buttons)},c.setDimensions=function(){var t=p.outerHeight(!0)-p.height(),i=e(window).height()-f.height()-v.height()-t,r=m.width()-m.children(".splitter-bar-vertical").outerWidth()-g.outerWidth();m.height(i),b.width(r)},c.log=function(){k.options.logger&&arguments&&([].unshift.call(arguments,(new Date).getTime()),console.log.apply(this,arguments))};var T=function(){return e.when(q("default"),q("user")).done(function(t,i){var r=t[0],o=i[0];if(void 0!==o&&null!==o&&delete o.version,(k=e.extend({},r,o)).api.connectorUrl)S=k.api.connectorUrl;else{var n=location.origin+location.pathname,s="connectors/"+k.api.lang+"/filemanager."+k.api.lang;se(n).length>0&&(n=n.substring(0,n.lastIndexOf("/")+1)),S=n+s}})},P=function(){return Ce("GET",{mode:"initiate"}).done(function(t){if(t.data){var i=t.data.attributes.config;e.each(i,function(t,i){e.each(i,function(e,i){void 0===k[t]&&(k[t]=[]),k[t][e]=i})}),k.security.readOnly&&(k.options.browseOnly=!0)}X(t)}).fail(function(){c.error("Unable to perform initial request to server.")}).then(function(t){if(t.errors)return e.Deferred().reject()})},D=function(){return I=new B,e.ajax().then(function(){var e=N.param("langCode");if(e)return G(I.buildLangFileUrl(e)).done(function(){I.setLang(e)}).fail(function(){setTimeout(function(){c.error("Given language file ("+I.buildLangFileUrl(e)+") does not exist!")},500)});I.setLang(k.language.default)}).then(function(){return e.ajax({type:"GET",url:I.buildLangFileUrl(I.getLang()),dataType:"json"}).done(function(e){I.setTranslations(e)})})},z=function(){return e.when(V("upload-container"),V("upload-item")).done(function(e,t){var i=e[0],r=t[0];p.append(i).append(r)})},U=function(e){var t=[],i=[];if(t.push("/themes/"+k.options.theme+"/styles/theme.css"),k.viewer.image.lazyLoad&&t.push("/scripts/lazyload/dist/lazyload.min.js"),k.customScrollbar.enabled&&(t.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"),t.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js")),t.push(e),K(t),k.editor.enabled){var r=k.editor.theme;r&&"default"!==r&&i.push("/scripts/CodeMirror/theme/"+r+".css"),i.push("/scripts/CodeMirror/lib/codemirror.css"),i.push("/scripts/CodeMirror/lib/codemirror.js"),i.push("/scripts/CodeMirror/addon/selection/active-line.js"),i.push("/scripts/CodeMirror/addon/display/fullscreen.css"),i.push("/scripts/CodeMirror/addon/display/fullscreen.js")}k.viewer.markdownRenderer.enabled&&(i.push("/styles/fm-markdown.css"),i.push("/scripts/markdown-it/markdown-it.min.js"),i.push("/scripts/markdown-it/default.min.css"),i.push("/scripts/markdown-it/highlight.min.js"),i.push("/scripts/markdown-it/markdown-it-footnote.min.js"),i.push("/scripts/markdown-it/markdown-it-replace-link.min.js")),k.options.browseOnly||(i.push("/scripts/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"),i.push("/scripts/jQuery-File-Upload/js/canvas-to-blob.min.js"),i.push("/scripts/jQuery-File-Upload/js/load-image.all.min.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.iframe-transport.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-process.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-image.js"),i.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-validate.js"),k.upload.multiple&&i.push("/scripts/jQuery-File-Upload/css/dropzone.css")),i.length&&K(i)},A=function(){j=k.options.capabilities||["upload","select","download","rename","copy","move","delete","extract"];var t=[];k.options.fileSorting&&(t=k.options.fileSorting.toLowerCase().split("_")),_=t[0]||"name",L=t[1]||"asc";var i=N.param("exclusiveFolder");i&&(x=ne(x="/"+i+"/"));var r=N.param("expandedFolder");if(r&&(O=ne(O=x+r+"/")),E=new R,ko.applyBindings(E),E.itemsModel.initiateLazyLoad(),E.filterModel.setName(N.param("filter")),ko.bindingHandlers.toggleNodeVisibility={init:function(t,i){var r=i();e(t).toggle(r.isExpanded())},update:function(t,i){var r=i();if(!1===r.isSliding())return!1;!1===r.isExpanded()&&e(t).slideDown(k.filetree.expandSpeed,function(){r.isSliding(!1),r.isExpanded(!0)}),!0===r.isExpanded()&&e(t).slideUp(k.filetree.expandSpeed,function(){r.isSliding(!1),r.isExpanded(!1)})}},ko.bindingHandlers.draggableView={init:function(e,t,i){E.ddModel.makeDraggable(t(),e)}},ko.bindingHandlers.droppableView={init:function(e,t,i){E.ddModel.makeDroppable(t(),e)}},ko.bindingHandlers.draggableTree={init:function(e,t,i){E.ddModel.makeDraggable(t(),e)}},ko.bindingHandlers.droppableTree={init:function(e,t,i){E.ddModel.makeDroppable(t(),e)}},p.mousewheel(function(t){if(!E.ddModel.dragHelper)return!0;var i=null;if((k.customScrollbar.enabled?e([w[0],g[0]]):m.children(".splitter-pane")).each(function(r){var o=e(this),n=o.offset().top,s=o.offset().left;if(t.offsetY>=n&&t.offsetY<=n+o.height()&&t.offsetX>=s&&t.offsetX<=s+o.width())return i=o,!1}),null===i)return!1;if(k.customScrollbar.enabled){var r=i.find(".mCSB_scrollTools_vertical"),o=1===t.deltaY?"+":"-";r.is(":visible")&&i.mCustomScrollbar("scrollTo",[o+"=250",0],{scrollInertia:500,scrollEasing:"easeOut",callbacks:!0})}else if(i[0].scrollHeight>i[0].clientHeight){var n=i.scrollTop()-200*t.deltaY;E.ddModel.isScrolling=!0,n=n<0?0:n,i.stop().animate({scrollTop:n},100,"linear",function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0})}}),M.selectable({filter:"li:not(.directory-parent), tbody > tr:not(.directory-parent)",cancel:".directory-parent, thead",disabled:!k.manager.selection.enabled,appendTo:M,start:function(e,t){Ie(),E.itemsModel.isSelecting(!0)},stop:function(e,t){E.itemsModel.isSelecting(!1)},selected:function(e,t){ko.dataFor(t.selected).selected(!0)},unselected:function(e,t){ko.dataFor(t.unselected).selected(!1)}}),b.contextMenu({selector:".view-items",zIndex:10,build:function(e,t){var i={createFolder:{name:H("create_folder"),className:"create-folder"},paste:{name:H("clipboard_paste"),className:"paste",disabled:function(e,t){return E.clipboardModel.isEmpty()}}};return E.clipboardModel.enabled()&&!0!==k.options.browseOnly||delete i.paste,{appendTo:".fm-container",items:i,reposition:!1,callback:function(e,t){switch(e){case"createFolder":E.headerModel.createFolder();break;case"paste":E.clipboardModel.paste()}}}}}),k.extras.extra_js)for(var s=0;s<k.extras.extra_js.length;s++)e.ajax({type:"GET",url:k.extras.extra_js[s],dataType:"script",async:k.extras.extra_js_async});if(N.param("CKEditorCleanUpFuncNum")&&(E.headerModel.closeButton(!0),E.headerModel.closeButtonOnClick=function(){parent.CKEDITOR.tools.callFunction(N.param("CKEditorCleanUpFuncNum"))}),o(),n(),Ke(),k.customScrollbar.enabled&&(g.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onScrollStart:function(){E.ddModel.isScrolling=!0},onScroll:function(){E.ddModel.isScrolling=!1}},axis:"yx"}),y.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0,updateOnSelectorChange:".fm-preview-viewer"}}),w.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0,updateOnSelectorChange:".grid, .list"},callbacks:{onScrollStart:function(){E.itemsModel.continiousSelection()||(this.yStartPosition=this.mcs.top,this.yStartTime=(new Date).getTime()),E.ddModel.isScrolling=!0},onScroll:function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0},whileScrolling:function(){if(k.manager.selection.enabled){var e=(new Date).getTime()-this.yStartTime;!E.itemsModel.continiousSelection()&&e>400&&(this.yStartPosition=this.mcs.top),E.itemsModel.isSelecting()&&E.itemsModel.continiousSelection(!0);var t=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);M.selectable("repositionCssHelper",t,0)}E.itemsModel.lazyLoad&&E.itemsModel.lazyLoad.handleScroll()}},axis:"y",alwaysShowScrollbar:0})),document.documentElement.setAttribute("data-useragent",navigator.userAgent),k.options.logger){var a=(new Date).getTime()-F;console.log("Total execution time : "+a+" ms")}u.find(".fm-loading-wrap").fadeOut(800,function(){c.setDimensions()}),c.setDimensions()},B=function(){var e=null,t={},i=c.settings.baseUrl+"/languages/";this.buildLangFileUrl=function(e){return i+e+".json"},this.setLang=function(t){e=t},this.getLang=function(){return e},this.setTranslations=function(e){t=e},this.getTranslations=function(){return t},this.translate=function(e){return t[e]}},R=function(){function t(e){return(!k.manager.selection.enabled||!k.manager.selection.useCtrlKey||!0!==e.ctrlKey)&&(!k.manager.dblClickOpen||"click"!==e.type)}var i=this;this.config=ko.observable(k),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(k.manager.defaultViewMode),this.currentPath=ko.observable(x),this.browseOnly=ko.observable(k.options.browseOnly),this.previewModel=ko.observable(null),this.currentLang=I.getLang(),this.lg=I.getTranslations(),this.previewFile.subscribe(function(e){e||(i.previewModel.closeEditor(),i.itemsModel.descriptivePanel.rdo().id===i.previewModel.rdo().id&&i.itemsModel.descriptivePanel.render(i.previewModel.viewer.content()))}),this.addItem=function(e,t){var r=E.treeModel.findByParam("id",t);if(r){var o=E.treeModel.createNode(e);E.treeModel.addNodes(r,o)}E.currentPath()===t&&i.itemsModel.addNew(e)},this.removeItem=function(e){var t=E.treeModel.findByParam("id",e.id);t&&t.remove();var r=i.itemsModel.findByParam("id",e.id);r&&r.remove()},this.fetchSelectedItems=function(e){var t,r;if(e===n.name)return i.itemsModel.getSelected();if(e===o.name)return i.treeModel.getSelected();if(!e)return t=i.treeModel.getSelected(),(r=i.itemsModel.getSelected()).length>0?r:t;throw new Error("Unknown item type.")},this.fetchSelectedObjects=function(t){var r=[];return e.each(i.fetchSelectedItems(t.constructor.name),function(e,t){r.push(t.rdo)}),r};var o=function(t){var r=this;this.id=t.id,this.rdo=t,this.cdo={isFolder:"folder"===t.type,extension:"file"===t.type?se(t.id):null,dimensions:t.attributes.width?t.attributes.width+"x"+t.attributes.height:null,cssItemClass:"folder"===t.type?"directory":"file",hiddenByType:!1,hiddenBySearch:!1},this.visible=ko.observable(!0),this.nodeTitle=ko.observable(t.attributes.name),this.children=ko.observableArray([]),this.parentNode=ko.observable(null),this.isSliding=ko.observable(!1),this.isLoading=ko.observable(!1),this.isLoaded=ko.observable(!1),this.isExpanded=ko.observable(!1),this.selected=ko.observable(!1),this.dragHovered=ko.observable(!1),this.level=ko.observable(0),this.isFirstNode=ko.observable(!1),this.isLastNode=ko.observable(!1),this.nodeTitle.subscribe(function(e){r.rdo.attributes.name=e}),this.children.subscribe(function(e){i.treeModel.arrangeNode(r)}),this.isLoaded.subscribe(function(e){r.isLoading(!e)}),this.selected.subscribe(function(e){e?(null!==i.treeModel.selectedNode()&&i.treeModel.selectedNode().selected(!1),i.treeModel.selectedNode(r),i.itemsModel.unselectItems()):i.treeModel.selectedNode(null)}),this.switchNode=function(e){return!!e.cdo.isFolder&&(e.rdo.attributes.readable?void(e.isLoaded()?i.treeModel.toggleNode(e):r.openNode(e)):(c.error(H("NOT_ALLOWED_SYSTEM")),!1))},this.mouseDown=function(e,t){e.selected(!0)},this.nodeClick=function(e,t){k.manager.dblClickOpen||r.openNode(e)},this.nodeDblClick=function(e,t){k.manager.dblClickOpen&&r.openNode(e)},this.openNode=function(t,r){if("file"===t.rdo.type&&a(t.rdo),"folder"===t.rdo.type)if(!t.isLoaded()||t.isExpanded()&&k.filetree.reloadOnClick)i.treeModel.loadNodes(t,!0),a(t.rdo);else{i.treeModel.toggleNode(t),E.currentPath(t.id),E.breadcrumbsModel.splitCurrent();var o=[];e.each(t.children(),function(e,t){o.push(t.rdo)}),i.itemsModel.setList(o)}},this.remove=function(){r.parentNode().children.remove(r)},this.isRoot=function(){return r.level()===i.treeModel.treeData.id},this.title=ko.pureComputed(function(){return k.options.showTitleAttr?this.rdo.id:null},this),this.itemClass=ko.pureComputed(function(){var e=[];return this.selected()&&k.manager.selection.enabled&&e.push("ui-selected"),this.dragHovered()&&e.push(i.ddModel.hoveredCssClass),e.join(" ")},this),this.iconClass=ko.pureComputed(function(){var e,t=["ico"];return!0===this.cdo.isFolder?(e="ico_folder",!0===this.isLoading()?t.push("loading"):(t.push("folder"),this.rdo.attributes.readable?(this.isExpanded()||!this.isExpanded()&&this.isSliding())&&t.push("open"):t.push("lock"))):(e="ico_file",this.rdo.attributes.readable?t.push("ext",this.cdo.extension):t.push("file","lock")),e+" "+t.join("_")},this),this.switcherClass=ko.pureComputed(function(){var e=[];if(k.filetree.showLine?0===this.level()&&this.isFirstNode()&&this.isLastNode()?e.push("root"):0===this.level()&&this.isFirstNode()?e.push("roots"):this.isLastNode()?e.push("bottom"):e.push("center"):e.push("noline"),this.cdo.isFolder){var t=this.isExpanded()||!this.isExpanded()&&this.isSliding();e.push(t?"open":"close")}else e.push("docu");return e.join("_")},this),this.clusterClass=ko.pureComputed(function(){return k.filetree.showLine&&!this.isLastNode()?"line":""},this)},n=function(e){var o=k.viewer.image.thumbMaxWidth;e.attributes.width&&e.attributes.width<o&&(o=e.attributes.width),this.id=e.id,this.rdo=e,this.cdo={isFolder:"folder"===e.type,sizeFormatted:$(e.attributes.size),extension:"file"===e.type?se(e.id):null,dimensions:e.attributes.width?e.attributes.width+"x"+e.attributes.height:null,cssItemClass:"folder"===e.type?"directory":"file",imageUrl:Se(e,!0,!0),previewWidth:o,hiddenByType:!1,hiddenBySearch:!1},this.visible=ko.observable(!0),this.selected=ko.observable(!1),this.dragHovered=ko.observable(!1),this.lazyPreview=k.viewer.image.lazyLoad&&this.cdo.imageUrl,this.selected.subscribe(function(e){e&&null!==i.treeModel.selectedNode()&&i.treeModel.selectedNode().selected(!1)}),this.title=ko.pureComputed(function(){return k.options.showTitleAttr?this.rdo.id:null},this),this.itemClass=ko.pureComputed(function(){var e=[];return this.selected()&&k.manager.selection.enabled&&e.push("ui-selected"),this.dragHovered()&&e.push(i.ddModel.hoveredCssClass),this.cdo.cssItemClass+" "+e.join(" ")},this),this.listIconClass=ko.pureComputed(function(){var e,t=["ico"];return!0===this.cdo.isFolder?(e="ico_folder",t.push("folder"),this.rdo.attributes.readable||t.push("lock")):(e="ico_file",this.rdo.attributes.readable?t.push("ext",this.cdo.extension):t.push("file","lock")),e+" "+t.join("_")},this),this.gridIconClass=ko.pureComputed(function(){var e=[],t=["ico"];return this.cdo.imageUrl||(e.push("grid-icon"),!0===this.cdo.isFolder?(e.push("ico_folder"),t.push("folder"),this.rdo.attributes.readable||t.push("lock")):(e.push("ico_file"),this.rdo.attributes.readable?t.push("ext",this.cdo.extension):t.push("file","lock")),e.push(t.join("_"))),e.join(" ")},this),this.mouseDown=function(e,t){e.selected()||i.itemsModel.unselectItems(t.ctrlKey),i.selectionModel.unselect=e.selected(),e.selected(!0)},this.open=function(e,o){i.selectionModel.unselect&&(o.ctrlKey&&e.selected(!1),!o.ctrlKey&&k.manager.dblClickOpen&&(i.itemsModel.unselectItems(o.ctrlKey),e.selected(!0))),t(o)&&(k.options.quickSelect&&"file"===e.rdo.type&&r(e.rdo,"select")?Oe(e.rdo):a(e.rdo))},this.remove=function(){i.itemsModel.objects.remove(this)}},d=function(){var t,i=this;this.rdo=ko.observable({}),this.content=ko.observable(null),this.renderer=ko.observable(null),this.render=function(e){i.renderer()&&i.renderer().processContent(e)},this.setRenderer=function(e){i.rdo(e),ye(e.attributes.name)?i.renderer(new o):i.renderer(new r)},this.setContainer=function(r){e.each(r,function(){if(e(this).hasClass("fm-renderer-container"))return t=e(this),!1}),i.renderer().processDomElements(t)};var r=function(){this.name="codeMirror",this.interactive=!1;var e=new f;this.processContent=function(t){e.render(t),i.content(t)},this.processDomElements=function(t){if(!e.instance){var r=t.find(".fm-cm-renderer-content")[0],o=se(i.rdo().id);e.createInstance(o,r,{readOnly:"nocursor",styleActiveLine:!1,lineNumbers:!1})}}},o=function(){function r(){t.find("a").each(function(){var t=e(this).attr("href"),i=E.previewModel.editor;if(i.enabled()&&i.isInteractive())e(this).off("click"),e(this).on("click",function(){return!1});else{if(-1!=t.search("://")||re(t,"mailto:"))return;ye(t)&&e(this).on("click",function(e){return Re(t).then(function(e){e.data&&a(e.data)}),!1})}})}this.name="markdown",this.interactive=!0;var o=window.markdownit({html:!0,linkify:!0,typographer:!0,highlight:function(e,t){if(t&&hljs.getLanguage(t))try{return'<pre class="highlight"><code>'+hljs.highlight(t,e,!0).value+"</code></pre>"}catch(e){}return'<pre class="highlight"><code>'+o.utils.escapeHtml(e)+"</code></pre>"},replaceLink:function(e,t){if(-1!=e.search("://")||re(e,"mailto:"))return e;var r=(re(e,"/")?x:le(i.rdo().id))+te(e,"/");if(ye(r))return r;var o=Me("GET",{mode:"readfile",path:r});return ke(o)}}).use(window.markdownitReplaceLink);this.processContent=function(e){var t=o.render(e);i.content(t),r()},this.processDomElements=function(e){}}},f=function(){function t(e){r.enabled(!0),r.instance.setValue(e),setTimeout(function(){r.instance.refresh()},0)}function i(e){var t=[],i="default";k.editor.codeHighlight&&("js"===e&&(t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),i="javascript"),"css"===e&&(t.push("/scripts/CodeMirror/mode/css/css.js"),i="css"),"html"===e&&(t.push("/scripts/CodeMirror/mode/xml/xml.js"),i="text/html"),"xml"===e&&(t.push("/scripts/CodeMirror/mode/xml/xml.js"),i="application/xml"),"php"===e&&(t.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),t.push("/scripts/CodeMirror/mode/xml/xml.js"),t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),t.push("/scripts/CodeMirror/mode/css/css.js"),t.push("/scripts/CodeMirror/mode/clike/clike.js"),t.push("/scripts/CodeMirror/mode/php/php.js"),i="application/x-httpd-php"),"java"===e&&(t.push("/scripts/CodeMirror/mode/clike/clike.js"),i="text/x-java"),"sql"===e&&(t.push("/scripts/CodeMirror/mode/sql/sql.js"),i="text/x-mysql"),"md"===e&&(t.push("/scripts/CodeMirror/addon/mode/overlay.js"),t.push("/scripts/CodeMirror/mode/xml/xml.js"),t.push("/scripts/CodeMirror/mode/markdown/markdown.js"),t.push("/scripts/CodeMirror/mode/gfm/gfm.js"),t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),t.push("/scripts/CodeMirror/mode/css/css.js"),t.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),t.push("/scripts/CodeMirror/mode/clike/clike.js"),t.push("/scripts/CodeMirror/mode/shell/shell.js"),t.push("/scripts/CodeMirror/mode/meta.js"),i="gfm"),"sh"===e&&(t.push("/scripts/CodeMirror/addon/mode/overlay.js"),t.push("/scripts/CodeMirror/mode/markdown/markdown.js"),t.push("/scripts/CodeMirror/mode/gfm/gfm.js"),t.push("/scripts/CodeMirror/mode/javascript/javascript.js"),t.push("/scripts/CodeMirror/mode/css/css.js"),t.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),t.push("/scripts/CodeMirror/mode/clike/clike.js"),t.push("/scripts/CodeMirror/mode/meta.js"),t.push("/scripts/CodeMirror/mode/shell/shell.js"),i="shell")),t.length?(t.push(function(){r.mode(i)}),K(t)):r.mode(i)}var r=this,o=null;this.instance=null,this.enabled=ko.observable(!1),this.content=ko.observable(null),this.mode=ko.observable(null),this.isInteractive=ko.observable(!1),this.mode.subscribe(function(e){e&&(r.instance.setOption("mode",e),o&&(t(o),o=null))}),this.render=function(e){r.mode()?t(e):o=e},this.createInstance=function(t,o,n){var s,a={readOnly:"nocursor",styleActiveLine:!1,viewportMargin:1/0,lineNumbers:k.editor.lineNumbers,lineWrapping:k.editor.lineWrapping,theme:k.editor.theme,matchBrackets:k.editor.matchBrackets,extraKeys:{F11:function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},Esc:function(e){e.getOption("fullScreen")&&e.setOption("fullScreen",!1)}}};(s=CodeMirror.fromTextArea(o,e.extend({},a,n))).on("changes",function(e,t){r.content(e.getValue())}),r.instance=s,i(t)}};this.treeModel=new function(){var t=this;this.selectedNode=ko.observable(null),this.treeData={id:x,level:ko.observable(-1),children:ko.observableArray([])},this.treeData.children.subscribe(function(e){t.arrangeNode(t.treeData)});var r=function(e){if(null!==O){e||(e=t.treeData);var i=t.findByFilter(function(e){return 0===O.indexOf(e.id)},e);i?(k.filetree.expandSpeed=10,t.loadNodes(i,!1)):(O=null,k.filetree.expandSpeed=200)}};this.mapNodes=function(e,i){i||(i=t.treeData),i.id!==t.treeData.id&&e.call(this,i);var r=i.children();if(!r||0===r.length)return null;for(var o=0,n=r.length;o<n;o++)e.call(this,r[o]),t.findByFilter(e,r[o])},this.findByParam=function(e,i,r){if(!r&&(r=t.treeData)[e]===i)return r;var o=r.children();if(!o||0===o.length)return null;for(var n=0,s=o.length;n<s;n++){if(o[n][e]===i)return o[n];var a=t.findByParam(e,i,o[n]);if(a)return a}return null},this.findByFilter=function(e,i){if(!i&&(i=t.treeData,e(i)))return i;var r=i.children();if(!r||0===r.length)return null;for(var o=0,n=r.length;o<n;o++){if(e(r[o]))return r[o];var s=t.findByFilter(e,r[o]);if(s)return s}return null},this.getSelected=function(){var e=[];return t.selectedNode()&&e.push(t.selectedNode()),e},this.loadNodes=function(i,o){var n=i?i.id:t.treeData.id;i&&i.isLoaded(!1),Ce("GET",{mode:"getfolder",path:n}).done(function(n){if(n.data){var s=[];e.each(n.data,function(e,i){var r=t.createNode(i);s.push(r)}),o&&i.children([]),t.addNodes(i,s),i&&(i.isLoaded(!0),t.expandNode(i)),r(i)}X(n)}).fail(Y)},this.createNode=function(e){var t=new o(e);return E.filterModel.filterItem(t),t},this.addNodes=function(i,r){e.isArray(r)||(r=[r]),i||(i=t.treeData),k.filetree.foldersOnly&&(r=e.grep(r,function(e){return e.cdo.isFolder})),e.each(r,function(e,t){t.parentNode(i)});var o=i.children().concat(r);i.children(W(o))},this.expandNode=function(e){return!1===e.isExpanded()&&!0===e.isLoaded()&&(e.isSliding(!0),!0)},this.collapseNode=function(e){return!0===e.isExpanded()&&(e.isSliding(!0),!0)},this.toggleNode=function(e){t.collapseNode(e)||t.expandNode(e)},this.arrangeNode=function(t){var i=t.children().length;e.each(t.children(),function(e,r){r.level(t.level()+1),r.isFirstNode(0===e),r.isLastNode(e===i-1)})},this.nodeRendered=function(t,r){e(t[1]).contextMenu({selector:".file, .directory",zIndex:100,build:function(e,t){return r.selected(!0),{appendTo:".fm-container",items:l(r.rdo),callback:function(e,t){qe(e,t,r.rdo,i.fetchSelectedObjects(r))}}}})},this.actualizeNodeObject=function(i,r,o){var n=new RegExp("^"+r),s=i.rdo.id,a=s.replace(n,o);i.id=a,i.rdo.id=a,i.rdo.attributes.path=i.rdo.attributes.path.replace(new RegExp(s+"$"),a),i.children().length&&e.each(i.children(),function(e,i){t.actualizeNodeObject(i,r,o)})}},this.itemsModel=new function(){var r=this;this.objects=ko.observableArray([]),this.objectsSize=ko.observable(0),this.objectsNumber=ko.observable(0),this.selectedNumber=ko.observable(0),this.listSortField=ko.observable(_),this.listSortOrder=ko.observable(L),this.isSelecting=ko.observable(!1),this.continiousSelection=ko.observable(!1),this.descriptivePanel=new d,this.lazyLoad=null,this.isSelecting.subscribe(function(e){e||r.continiousSelection(!1)}),this.createObject=function(e){var t=new n(e);return E.filterModel.filterItem(t),t},this.addNew=function(t){var o=i.itemsModel.objects();e.isArray(t)||(t=[t]),e.each(t,function(e,t){o.push(r.createObject(t))}),o=W(o),i.itemsModel.objects.valueHasMutated()},this.loadList=function(e){i.loadingView(!0);var t={mode:"getfolder",path:e};N.param("type")&&(t.type=N.param("type")),Ce("GET",t).done(function(t){t.data&&(i.currentPath(e),i.breadcrumbsModel.splitCurrent(),i.itemsModel.setList(t.data),i.itemsModel.lazyLoad&&i.itemsModel.lazyLoad.update()),X(t)}).fail(Y)},this.setList=function(o){var n=[];if(!Z(i.currentPath())&&i.currentPath()!==x){var s=de(i.currentPath()),a={id:s,rdo:{id:s,type:"parent",attributes:{readable:!0,writable:!0}},dragHovered:ko.observable(!1)};a.open=function(e,i){t(i)&&r.loadList(a.id)},a.itemClass=ko.pureComputed(function(){var e=[];return a.dragHovered()&&e.push(i.ddModel.hoveredCssClass),e.join(" ")}),n.push(a)}r.descriptivePanel.content(null),e.each(o,function(e,t){k.manager.renderer.position&&"string"==typeof k.manager.renderer.indexFile&&t.attributes.name.toLowerCase()===k.manager.renderer.indexFile.toLowerCase()&&(r.descriptivePanel.setRenderer(t),Ae(r.descriptivePanel.rdo()).then(function(e){e.data&&r.descriptivePanel.render(e.data.attributes.content)})),n.push(r.createObject(t))}),i.itemsModel.objects(W(n)),i.loadingView(!1)},this.findByParam=function(e,t){return ko.utils.arrayFirst(i.itemsModel.objects(),function(i){return i[e]===t})},this.findByFilter=function(e,t){var i=!t,o=[],n=r.objects();if(!n||0===n.length)return null;for(var s=0,a=n.length;s<a;s++)if(e(n[s])){if(i)return n[s];o.push(n[s])}return i?null:o},this.sortObjects=function(){var e=W(r.objects());r.objects(e)},this.getSelected=function(){var e=r.findByFilter(function(e){return"parent"!==e.rdo.type&&e.selected()},!0);return r.selectedNumber(e.length),e},this.unselectItems=function(t){k.manager.selection.enabled&&k.manager.selection.useCtrlKey&&!0===t||e.each(r.getSelected(),function(e,t){t.selected(!1)})},this.initiateLazyLoad=function(){!0!==k.viewer.image.lazyLoad||r.lazyLoad||(r.lazyLoad=new LazyLoad({container:b[0],callback_load:function(e){c.log("LOADED",e.getAttribute("data-original"))},callback_set:function(e){c.log("SET",e.getAttribute("data-original"))},callback_processed:function(e){c.log("PROCESSED",e+" images left")}}))},this.objects.subscribe(function(t){var o=0,n=0;e.each(t,function(e,t){"parent"!==t.rdo.type&&o++,"file"===t.rdo.type&&(n+=Number(t.rdo.attributes.size))}),r.objectsNumber(o),r.objectsSize($(n)),r.lazyLoad&&setTimeout(function(){r.lazyLoad.update()},50),M.contextMenu({selector:".file, .directory",zIndex:100,build:function(e,t){var r=ko.dataFor(e[0]);return r.selected()||(i.itemsModel.unselectItems(!1),r.selected(!0)),{appendTo:".fm-container",items:l(r.rdo),callback:function(e,t){qe(e,t,r.rdo,i.fetchSelectedObjects(r))}}}})})},this.tableViewModel=new function(){var e=function(e){var t=this;this.column=ko.observable(e),this.order=ko.observable(i.itemsModel.listSortOrder()),this.sortClass=ko.pureComputed(function(){var e;return i.itemsModel.listSortField()===t.column()&&(e="sorted sorted-"+this.order()),e},this),this.sort=function(){var e="asc"===t.order(),r=i.itemsModel.listSortField()===t.column();t.order(r?e?"desc":"asc":i.itemsModel.listSortOrder()),i.itemsModel.listSortField(t.column()),i.itemsModel.listSortOrder(t.order()),i.itemsModel.sortObjects()}};this.thName=new e("name"),this.thType=new e("type"),this.thSize=new e("size"),this.thDimensions=new e("dimensions"),this.thModified=new e("modified")},this.previewModel=new function(){var e=this,t=null;this.rdo=ko.observable({}),this.cdo=ko.observable({}),this.viewer={type:ko.observable("default"),isEditable:ko.observable(!1),url:ko.observable(null),pureUrl:ko.observable(null),options:ko.observable({}),content:ko.observable(null),codeMirror:ko.observable(null)},this.renderer=new d,this.editor=new f,this.rdo.subscribe(function(t){e.cdo({isFolder:"folder"===t.type,sizeFormatted:$(t.attributes.size),extension:"file"===t.type?se(t.id):null,dimensions:t.attributes.width?t.attributes.width+"x"+t.attributes.height:null})}),this.editor.content.subscribe(function(t){e.editor.isInteractive()&&e.renderer.render(t)}),this.applyObject=function(r){t&&t.destroy(),i.previewFile(!1);var o=r.attributes.name,n={interactive:!1},s={type:"default",url:null,options:{}};if(e.rdo(r),pe(o)&&(s.type="image",s.url=Se(r,!1,!0)),he(o)&&!0===k.viewer.audio.enabled&&(s.type="audio",s.url=xe(r,!0)),fe(o)&&!0===k.viewer.video.enabled&&(s.type="video",s.url=xe(r,!0),s.options={width:k.viewer.video.playerWidth,height:k.viewer.video.playerHeight}),me(o)&&!0===k.viewer.onlyoffice.enabled){s.type="onlyoffice";var a=k.viewer.onlyoffice.connectorUrl||c.settings.baseUrl+"/connectors/php/onlyoffice/editor.php";s.url=a+"?path="+encodeURIComponent(r.attributes.path),s.options={width:k.viewer.onlyoffice.editorWidth,height:k.viewer.onlyoffice.editorHeight}}be(o)&&!0===k.viewer.opendoc.enabled&&(s.type="opendoc",s.url=c.settings.baseUrl+"/scripts/ViewerJS/index.html#"+xe(r,!0),s.options={width:k.viewer.opendoc.readerWidth,height:k.viewer.opendoc.readerHeight}),ge(o)&&!0===k.viewer.google.enabled&&(s.type="google",s.url="https://docs.google.com/viewer?url="+encodeURIComponent(xe(r,!1))+"&embedded=true",s.options={width:k.viewer.google.readerWidth,height:k.viewer.google.readerHeight}),ve(o)&&!0===k.viewer.iframe.enabled&&(s.type="iframe",s.url=xe(r,!0),s.options={width:k.viewer.iframe.readerWidth,height:k.viewer.iframe.readerHeight}),(we(o)&&!0===k.viewer.codeMirrorRenderer.enabled||ye(o)&&!0===k.viewer.markdownRenderer.enabled)&&(s.type="renderer",s.options={is_writable:r.attributes.writable},e.renderer.setRenderer(r),n.interactive=e.renderer.renderer().interactive),e.viewer.type(s.type),e.viewer.url(s.url),e.viewer.options(s.options),e.viewer.pureUrl(_e(r)),e.viewer.isEditable(ue(o)&&!0===k.editor.enabled),e.editor.isInteractive(n.interactive),"renderer"===s.type||e.viewer.isEditable()?Ae(r).then(function(t){if(t.data){var r=t.data.attributes.content;e.viewer.content(r),i.previewFile(!0)}}):i.previewFile(!0)},this.afterRender=function(){e.renderer.render(e.viewer.content());var i=y.find(".btn-copy-url")[0];(t=new Clipboard(i)).on("success",function(e){c.success(H("copied"))})},this.initiateEditor=function(t){var i=y.find(".fm-cm-editor-content")[0];e.editor.createInstance(e.cdo().extension,i,{readOnly:!1,styleActiveLine:!0})},this.bindToolbar=function(t){r(e.rdo(),t)&&qe(t,{},e.rdo())},this.previewIconClass=ko.pureComputed(function(){var t=[],i=["ico"];return"default"!==e.viewer.type()&&e.viewer.url()||(t.push("grid-icon"),!0===this.cdo().isFolder?(t.push("ico_folder"),i.push("folder"),this.rdo().attributes.readable||i.push("lock")):(t.push("ico_file"),this.rdo().attributes.readable?i.push("ext",this.cdo().extension):i.push("file","lock")),t.push(i.join("_"))),t.join(" ")},this),this.editFile=function(){var t=e.viewer.content();e.renderer.render(t),e.editor.render(t)},this.saveFile=function(){Be(e.rdo())},this.closeEditor=function(){e.editor.enabled(!1),e.renderer.render(e.viewer.content())},this.buttonVisibility=function(t){switch(t){case"select":return r(e.rdo(),t)&&s();case"move":case"rename":case"delete":case"download":return r(e.rdo(),t)}}},this.headerModel=new function(){this.closeButton=ko.observable(!1),this.langSwitcher=e.isArray(k.language.available)&&k.language.available.length>0,this.closeButtonOnClick=function(){c.log("CLOSE button is clicked")},this.navHome=function(){i.previewFile(!1),i.itemsModel.loadList(x)},this.navLevelUp=function(){var e=i.previewFile()?le(i.previewModel.rdo().id):de(i.currentPath());i.previewFile()&&i.previewFile(!1),e!==i.currentPath()&&i.itemsModel.loadList(e)},this.navRefresh=function(){i.previewFile()?(i.previewFile(!1),i.previewFile(!0)):i.itemsModel.loadList(i.currentPath())},this.displayGrid=function(){i.viewMode("grid"),i.previewFile(!1),i.itemsModel.lazyLoad&&i.itemsModel.lazyLoad.update()},this.displayList=function(){i.viewMode("list"),i.previewFile(!1)},this.switchLang=function(t){var i=t.target.value,r=I.getLang();if(i&&i.toLowerCase()!==r.toLowerCase()){var o,n=window.location.toString(),s=new RegExp("(langCode=)"+r);o=s.test(n)?n.replace(s,"$1"+i):n+(e.isEmptyObject(N.param())?"?":"#")+"langCode="+i,window.location.href=o}},this.createFolder=function(){c.prompt({message:H("prompt_foldername"),value:H("default_foldername"),okBtn:{label:H("create_folder"),autoClose:!1,click:function(e,t){var i=t.getInputValue();i?Ce("GET",{mode:"addfolder",path:E.currentPath(),name:i}).done(function(e){e.data&&(E.addItem(e.data,E.currentPath()),t.closeDialog(),k.options.showConfirmation&&c.success(H("successful_added_folder"))),X(e)}).fail(Y):c.error(H("no_foldername"))}},cancelBtn:{label:H("cancel")}})}},this.summaryModel=new function(){this.files=ko.observable(null),this.folders=ko.observable(null),this.size=ko.observable(null),this.enabled=ko.observable(!1),this.doSummarize=function(){He()}},this.filterModel=new function(){var t=this;this.name=ko.observable(null),this.setName=function(i){i&&k.filter&&e.isArray(k.filter[i])&&t.name(i)},this.getExtensions=function(){return t.name()?k.filter[t.name()]:null},this.filterItem=function(i){if("parent"!==i.rdo.type){var r=t.getExtensions(),o=!i.cdo.hiddenBySearch;if("file"===i.rdo.type&&e.isArray(r)){var n=se(i.id),s=-1!==r.indexOf(n);o=o&&s,i.cdo.hiddenByType=!s}i.visible(o)}},this.filter=function(r){i.searchModel.reset(),t.setName(r),e.each(i.itemsModel.objects(),function(e,i){t.filterItem(i)}),i.treeModel.mapNodes(function(e){t.filterItem(e)}),i.itemsModel.lazyLoad&&i.itemsModel.lazyLoad.update()},this.reset=function(){t.name(null),t.filter(null)}},this.searchModel=new function(){var t=this;this.value=ko.observable(""),this.findAll=function(r,o){t.value(o.target.value),Le(function(){var r=t.value().toLowerCase();e.each(i.itemsModel.objects(),function(e,t){if("parent"!==t.rdo.type&&!t.cdo.hiddenByType){var i=t.rdo.attributes.name,o=0===(i=i.toLowerCase()).indexOf(r);t.cdo.hiddenBySearch=!o,t.visible(o)}})},200)},this.reset=function(r,o){t.value(""),e.each(i.itemsModel.objects(),function(e,t){"parent"!==t.rdo.type&&(t.cdo.hiddenBySearch=!1,t.visible(!t.cdo.hiddenByType))})}},this.clipboardModel=new function(){function e(){r=[],t=null,o.itemsNum(0)}var t=null,r=[],o=this,n=j.indexOf("copy")>-1||j.indexOf("move")>-1;this.itemsNum=ko.observable(0),this.enabled=ko.observable(i.config().clipboard.enabled&&n),this.copy=function(){o.hasCapability("copy")&&(t="copy",r=i.fetchSelectedItems(),o.itemsNum(r.length))},this.cut=function(){o.hasCapability("cut")&&(t="cut",r=i.fetchSelectedItems(),o.itemsNum(r.length))},this.paste=function(){if(o.hasCapability("paste")&&!o.isEmpty())if(null!==t&&0!==r.length){var n=i.currentPath();Ee(r,function(e,i){return"cut"===t?Pe(i,n):"copy"===t?Te(i,n):void 0},e)}else c.warning(H("clipboard_empty"))},this.clear=function(){o.hasCapability("clear")&&!o.isEmpty()&&(e(),c.success(H("clipboard_cleared")))},this.isEmpty=function(){return 0===r.length},this.hasCapability=function(e){if(!o.enabled)return!1;switch(e){case"copy":return j.indexOf("copy")>-1;case"cut":return j.indexOf("move")>-1;default:return!0}}},this.breadcrumbsModel=new function(){var e=this;this.items=ko.observableArray([]),this.add=function(i,r){e.items.push(new t(i,r))},this.splitCurrent=function(){var t=x,r=i.currentPath().replace(new RegExp("^"+x),"").split("/");for(e.items([]),e.add(x,"");r.length>0;){var o=r.shift();o&&(t+=o+"/",e.add(t,o))}};var t=function(e,t){var r=this;this.path=e,this.label=t,this.isRoot=e===x,this.active=e===i.currentPath(),this.itemClass=function(){var e=["nav-item"];return r.isRoot&&e.push("root"),r.active&&e.push("active"),e.join(" ")},this.goto=function(e,t){e.active||i.itemsModel.loadList(e.path)}}},this.ddModel=new function(){function t(t){var i=e.grep(s.items,function(e,i){if("folder"===t.rdo.type||"parent"===t.rdo.type){if(re(t.rdo.id,e.rdo.id))return!0;if(t.rdo.id===ce(e.rdo.id))return!0}return e.id===t.id});return t.rdo.attributes.writable&&0===i.length}function r(e){null!==s.hoveredItem&&s.hoveredItem.dragHovered(!1),s.hoveredItem=e,e&&e.dragHovered(!0)}function o(e,t){t?e.addClass(a):e.removeClass(a)}var s=this,a="drop-restricted",l=e("#drag-helper-template");this.items=[],this.hoveredItem=null,this.dragHelper=null,this.isScrolling=!1,this.isScrolled=!1,this.hoveredCssClass="drop-hover",this.makeDraggable=function(t,r){"file"!==t.rdo.type&&"folder"!==t.rdo.type||e(r).draggable({distance:3,cursor:"pointer",cursorAt:{left:Math.floor(l.width()/2),bottom:15},scroll:!1,appendTo:p,containment:u,refreshPositions:!1,helper:function(){var e,r;return r=i.fetchSelectedItems(t.constructor.name).length>1?"ico_multiple":"folder"===t.rdo.type?"ico_folder":"ico_file ico_ext_"+se(t.rdo.id),(e=l.children(".drag-helper").clone()).find(".clip").addClass(r),s.dragHelper=e,e},start:function(e,r){s.items=i.fetchSelectedItems(t.constructor.name)},drag:function(t,i){e(this).draggable("option","refreshPositions",s.isScrolling||s.isScrolled),s.isScrolled=!1},stop:function(e,t){s.items=[],s.dragHelper=null}})},this.makeDroppable=function(i,a){"folder"!==i.rdo.type&&"parent"!==i.rdo.type||e(a).droppable({tolerance:"pointer",enableExtendedEvents:i instanceof n,accept:function(e){var t=ko.dataFor(e[0]),i=t?t.rdo.type:null;return"file"===i||"folder"===i},over:function(e,n){setTimeout(function(){r(null),o(n.helper,!1),t(i)||o(n.helper,!0),r(i)},0)},out:function(e,t){r(null),o(t.helper,!1)},drop:function(e,o){if(r(null),!t(i))return!1;Ee(s.items,function(e,t){return Pe(t.rdo,i.id)})}})}},this.selectionModel=new function(){this.unselect=!1}},H=function(e){return I.translate(e)},W=function(e){function t(e){var t,i=_;switch("list"===E.viewMode()&&(i=E.itemsModel.listSortField()),i){case"type":t=e.cdo.extension||"";break;case"size":t=e.rdo.attributes.size;break;case"modified":t=e.rdo.attributes.timestamp;break;case"dimensions":t=e.cdo.dimensions||"";break;default:t=e.rdo.attributes.name}return"string"==typeof t&&(n.cases||(t=t.toLowerCase()),t=t.replace(/\s+/g," ")),t}function i(e,t){for(var i=r(e.toString()),o=r(t.toString()),n=0;i[n]&&o[n];n++)if(i[n]!==o[n]){var s=Number(i[n]),a=Number(o[n]);return s==i[n]&&a==o[n]?s-a:i[n]>o[n]?1:-1}return i.length-o.length}function r(e){for(var t,i,r=[],o=0,n=-1,s=0;t=(i=e.charAt(o++)).charCodeAt(0);){var a=46==t||t>=48&&t<=57;a!==s&&(r[++n]="",s=a),r[n]+=i}return r}var o,n={natural:!0,order:"asc"===("list"===E.viewMode()?E.itemsModel.listSortOrder():L)?1:-1,cases:!1};e.length>0&&"parent"===e[0].rdo.type&&(o=e.shift()),e.sort(function(e,r){var o,s=t(e),a=t(r);return o=s===a?0:void 0===s||void 0===a?0:n.natural&&(isNaN(s)||isNaN(a))?i(s,a):s<a?-1:s>a?1:0,o*=n.order});for(var s=[],a=e.length;a--;)"folder"===e[a].rdo.type&&(s.push(e[a]),e.splice(a,1));"top"!==k.options.folderPosition&&s.reverse();for(var l=0,d=s.length;l<d;l++)"top"===k.options.folderPosition?e.unshift(s[l]):e.push(s[l]);return o&&e.unshift(o),e},G=function(t){return e.ajax({type:"HEAD",url:t})},q=function(t){var i=null;return t=void 0===t?"user":t,i="user"===t?N.param("config")?c.settings.baseUrl+"/config/"+N.param("config"):c.settings.baseUrl+"/config/filemanager.config.json":c.settings.baseUrl+"/config/filemanager.config.default.json",e.ajax({type:"GET",url:i,dataType:"json",cache:!1,error:function(e){c.error("Given config file ("+i+") does not exist!")}})},K=function(e){for(var t=0,i=e.length;t<i;t++)"string"==typeof e[t]&&(e[t]=c.settings.baseUrl+e[t]);toast.apply(this,e)},V=function(t,i){return e.ajax({type:"GET",url:c.settings.baseUrl+"/scripts/templates/"+t+".html",error:Y})},$=function(e,t){if(!e)return"";t=t||!1;for(var i=parseFloat(e),r=parseFloat(t?1e3:1024),o=0,n=[H("unit_bytes"),H("unit_kb"),H("unit_mb"),H("unit_gb")];;){if(i<r)return(i=Math.round(100*i)/100)+" "+n[o];i/=r,o+=1}},Q=function(t){var i;return I.getLang()&&H(t.message)?(i=H(t.message),e.each(t.arguments,function(e,t){i=i.replace("%s",t)})):i=t.message,i},Y=function(e){c.log(e.responseText||e),c.error(H("ERROR_SERVER")),c.error(e.responseText)},X=function(t){t.errors&&(c.log(t.errors),e.each(t.errors,function(e,t){c.error(Q(t)),t.arguments.redirect&&(window.location.href=t.arguments.redirect)}))};!function(e){e.extend({inArrayInsensitive:function(t,i,r){if("string"!=typeof t)return e.inArray.apply(this,arguments);if(i){var o=i.length;for(r=r?r<0?Math.max(0,o+r):r:0,t=t.toLowerCase();r<o;r++)if(r in i&&i[r].toLowerCase()==t)return r}return-1}})}(jQuery);var J=function(t){var i=se(t);if(k.security.extensions.ignoreCase){if("ALLOW_LIST"==k.security.extensions.policy&&-1!==e.inArrayInsensitive(i,k.security.extensions.restrictions))return!0;if("DISALLOW_LIST"==k.security.extensions.policy&&-1===e.inArrayInsensitive(i,k.security.extensions.restrictions))return!0}else{if("ALLOW_LIST"==k.security.extensions.policy&&-1!==e.inArray(i,k.security.extensions.restrictions))return!0;if("DISALLOW_LIST"==k.security.extensions.policy&&-1===e.inArray(i,k.security.extensions.restrictions))return!0}return!1},Z=function(e){return"/"!==e.charAt(e.length-1)},ee=function(e,t){var i=new RegExp("^"+t+"+|"+t+"+$","g");return e.replace(i,"")},te=function(e,t){var i=new RegExp("^"+t+"+","g");return e.replace(i,"")},ie=function(e,t){var i=new RegExp(t+"+$","g");return e.replace(i,"")},re=function(e,t,i){return i=i||0,e.substr(i,t.length)===t},oe=function(t){var i=[];return e.each(t.split("/"),function(e,t){i.push(encodeURIComponent(t))}),i.join("/")},ne=function(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")},se=function(e){return 1===e.split(".").length?"":e.split(".").pop().toLowerCase()},ae=function(e){return-1!==e.lastIndexOf(".")?e.substring(0,e.lastIndexOf(".")):e},le=function(e){return e.lastIndexOf("/")!==e.length-1?e.substr(0,e.lastIndexOf("/")+1):e},de=function(e){return e.split("/").reverse().slice(2).reverse().join("/")+"/"},ce=function(e){return e.substring(0,e.slice(0,-1).lastIndexOf("/"))+"/"},ue=function(t){return-1!==e.inArray(se(t),k.editor.extensions)},pe=function(t){return-1!==e.inArray(se(t),k.viewer.image.extensions)},fe=function(t){return-1!==e.inArray(se(t),k.viewer.video.extensions)},he=function(t){return-1!==e.inArray(se(t),k.viewer.audio.extensions)},me=function(t){return-1!==e.inArray(se(t),k.viewer.onlyoffice.extensions)},ve=function(t){return-1!==e.inArray(se(t),k.viewer.iframe.extensions)},be=function(t){return-1!==e.inArray(se(t),k.viewer.opendoc.extensions)},ge=function(t){return-1!==e.inArray(se(t),k.viewer.google.extensions)},we=function(t){return-1!==e.inArray(se(t),k.viewer.codeMirrorRenderer.extensions)},ye=function(t){return-1!==e.inArray(se(t),k.viewer.markdownRenderer.extensions)},Me=function(t,i){var r,o=k.api.requestParams;if(t=t.toUpperCase(),e.isPlainObject(o)&&(r=o[t],e.isPlainObject(r)&&!e.isEmptyObject(r))){var n=e.extend({},o.MIXED||{},r);"POST"===t&&e.isArray(i)?e.each(n,function(e,t){i.push({name:e,value:t})}):i=e.extend({},i,n)}return i},Ce=function(t,i){return e.ajax({type:t,cache:!1,url:ke(),dataType:"json",data:Me(t,i)})},ke=function(t){var i={time:(new Date).getTime()},r=e.extend({},t||{},i);return S+"?"+e.param(r)},xe=function(e,t){var i,r=e.attributes.path;if(k.viewer.absolutePath&&r)t&&(r=oe(r)),i=je(r,!1);else{var o=Me("GET",{mode:"readfile",path:e.id});i=ke(o)}return i=c.settings.callbacks.beforeCreatePreviewUrl(e,i)},Se=function(e,t,i){var r;if(pe(e.id)&&e.attributes.readable&&(t&&k.viewer.image.showThumbs||!t&&!0===k.viewer.image.enabled)){if(k.viewer.absolutePath&&!t&&e.attributes.path)r=je(oe(e.attributes.path),i);else{var o={path:e.id};"svg"===se(e.id)?o.mode="readfile":(o.mode="getimage",t&&(o.thumbnail="true")),o=Me("GET",o),r=ke(o)}r=c.settings.callbacks.beforeCreateImageUrl(e,r)}return r},je=function(e,t){var i="string"==typeof k.viewer.previewUrl?k.viewer.previewUrl:location.origin;return i=ee(i,"/")+e,t&&(i+="?time="+(new Date).getTime()),i},_e=function(e){function t(e){return k.clipboard.encodeCopyUrl?oe(e):e}if(k.viewer.absolutePath&&e.attributes.path){i=t(e.attributes.path);return je(i,!1)}var i=t(e.id),r="folder"===e.type?"getfolder":"readfile";return S+"?path="+i+"&mode="+r},Le=function(){var e=0;return function(t,i){clearTimeout(e),e=setTimeout(t,i)}}(),Ee=function(t,i,r){var o,n=new function(){this.total=0,this.succeed=0,this.failure=0,this.processed=0,this.getProgress=function(){return Math.round(this.processed/this.total*100)},this.getProgressSucceed=function(){return Math.round(this.succeed/this.total*100)},this.getProgressFailure=function(){return Math.round(this.failure/this.total*100)},this.getMessage=function(){return H("successful_processed").replace("%s",this.succeed).replace("%s",this.total)},this.succeeded=function(){this.succeed++,this.processed++},this.failed=function(){this.failure++,this.processed++},this.isProcessed=function(){return this.processed===this.total}},s=e.Deferred().resolve();n.total=t.length,n.total>1&&(o=c.write(n.getMessage(),{delay:0,logMessageTemplate:function(e){n.getProgress();var t=n.isProcessed()?"striped":"striped animated";return"<div>"+e+'</div><div class="progress"><div class="progress-counter">'+n.getProgress()+'%</div><div class="progress-bar '+t+'"><div class="progress-segment progress-succeed" style="width: '+n.getProgressSucceed()+'%"></div><div class="progress-segment progress-failure" style="width: '+n.getProgressFailure()+'%"></div></div></div>'}})).stick(!0),e.each(t,function(e,t){s=s.then(function(){return i(e,t)}).then(function(e){e&&e.data?n.succeeded():n.failed(),o&&o.setMessage(n.getMessage())})}),s.then(function(){o&&n.isProcessed()&&(o.stick(!1),setTimeout(function(){o.remove()},6e3))}),s.then(function(){"function"==typeof r&&r()})},Ie=function(){document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},Oe=function(e){var t=null,i=xe(e,!0);if(i=c.settings.callbacks.beforeSelectItem(e,i),window.tinyMCEPopup){var r=tinyMCEPopup.getWindowArg("window");return r.document.getElementById(tinyMCEPopup.getWindowArg("input")).value=i,void 0!==r.ImageDialog&&(r.ImageDialog.getImageData&&r.ImageDialog.getImageData(),r.ImageDialog.showPreviewImage&&r.ImageDialog.showPreviewImage(i)),void tinyMCEPopup.close()}if(N.param("field_name")&&(parent.document.getElementById(N.param("field_name")).value=i,void 0!==parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),void 0!==parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),N.param("ImperaviElementId"))if(window.opener);else{var o=N.param("ImperaviElementId"),n=parent.$("#"+o).redactor("core.getObject");n&&(n.modal.close(),n.buffer.set(),pe(e.attributes.name)?n.insert.html('<img src="'+i+'">'):n.insert.html('<a href="'+i+'">'+e.attributes.name+"</a>"))}if(N.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(N.param("CKEditorFuncNum"),i):(parent.CKEDITOR.tools.callFunction(N.param("CKEditorFuncNum"),i),parent.CKEDITOR.tools.callFunction(N.param("CKEditorCleanUpFuncNum")))),window.opener&&"function"==typeof window.opener.SetUrl)if(e.attributes.width){var s=i,a=e.attributes.width,l=e.attributes.height;window.opener.SetUrl(s,a,l)}else window.opener.SetUrl(i);window.opener&&(t=window.opener),window.parent&&window.self!==window.parent&&(t=window.parent),t&&t.postMessage({source:"richfilemanager",preview_url:i},"*"),c.settings.callbacks.afterSelectItem(e,i,t)},Ne=function(e){c.prompt({message:H("new_filename"),value:k.options.allowChangeExtensions?e.attributes.name:ae(e.attributes.name),okBtn:{label:H("action_rename"),autoClose:!1,click:function(t,i){var r=e.id,o=i.getInputValue();if(o){if(!k.options.allowChangeExtensions){var n=se(e.attributes.name);n.length>0&&(o=o+"."+n)}if(Z(r)&&!J(o)){var s="<p>"+H("INVALID_FILE_TYPE")+"</p>";return"ALLOW_LIST"==k.security.extensions.policy&&(s+="<p>"+H("ALLOWED_FILE_TYPE").replace("%s",k.security.extensions.restrictions.join(", "))+".</p>"),"DISALLOW_LIST"==k.security.extensions.policy&&(s+="<p>"+H("DISALLOWED_FILE_TYPE").replace("%s",k.security.extensions.restrictions.join(", "))+".</p>"),void c.error(s)}Ce("GET",{mode:"rename",old:r,new:o}).done(function(e){if(e.data){var t=e.data,o=E.treeModel.findByParam("id",r);if(o&&("folder"===o.rdo.type&&(o.nodeTitle(t.attributes.name),E.treeModel.actualizeNodeObject(o,r,t.id)),"file"===o.rdo.type)){var n=o.parentNode(),s=E.treeModel.createNode(t);o.remove(),n&&E.treeModel.addNodes(n,s)}var a=E.itemsModel.findByParam("id",r);a&&("parent"===a.rdo.type?a.id=t.id:(a.remove(),E.itemsModel.addNew(t))),E.currentPath()===r&&E.itemsModel.loadList(t.id),E.previewFile()&&E.previewModel.rdo().id===r&&E.previewModel.applyObject(t),i.closeDialog(),k.options.showConfirmation&&c.success(H("successful_rename"))}X(e)}).fail(Y)}else c.error(H("new_filename"))}},cancelBtn:{label:H("cancel")}})},Fe=function(e,t){var i=e.length,r=i>1?H("prompt_move_multiple").replace("%s",i):H("prompt_move");c.prompt({message:r,value:E.currentPath(),okBtn:{label:H("action_move"),autoClose:!1,click:function(e,i){var r=i.getInputValue();r?(r=ie(r,"/")+"/",t(r)):c.error(H("prompt_foldername"))}},cancelBtn:{label:H("cancel")},template:{dialogInput:'<input data-alertify-input type="text" value="" /><div class="prompt-info">'+H("help_move")+"</div>"}})},Te=function(e,t){return Ce("GET",{mode:"copy",source:e.id,target:t}).done(function(e){if(e.data){var i=e.data;E.addItem(i,t),alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("successful_copied"))}X(e)}).fail(Y)},Pe=function(e,t){return Ce("GET",{mode:"move",old:e.id,new:t}).done(function(i){if(i.data){var r=i.data;E.removeItem(e),E.addItem(r,t),E.currentPath()===e.id&&E.itemsModel.loadList(r.id),E.previewFile()&&E.previewModel.rdo().id===e.id&&E.previewFile(!1),alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("successful_moved"))}X(i)}).fail(Y)},De=function(e,t){var i=e.length,r=i>1?H("confirm_delete_multiple").replace("%s",i):H("confirm_delete");c.confirm({message:r,okBtn:{label:H("yes"),click:function(e,i){t()}},cancelBtn:{label:H("no")}})},ze=function(e){return Ce("GET",{mode:"delete",path:e}).done(function(e){if(e.data){var t=e.data;if(E.removeItem(t),E.currentPath()===t.id){var i=de(E.currentPath());E.itemsModel.loadList(i)}E.previewFile()&&E.previewModel.rdo().id===t.id&&E.previewFile(!1),k.options.showConfirmation&&c.success(H("successful_delete"))}X(e)}).fail(Y)},Ue=function(t){var i={mode:"download",path:t.id};return Ce("GET",i).done(function(t){t.data&&e.fileDownload(ke(i)),X(t)}).fail(Y)},Ae=function(e){return Ce("GET",{mode:"editfile",path:e.id}).done(function(e){X(e)}).fail(Y)},Be=function(t){var i=e("#fm-js-editor-form").serializeArray();Ce("POST",i).done(function(e){if(e.data){var t=e.data,i=E.previewModel,r=i.editor.content();i.rdo(t),i.viewer.content(r),i.closeEditor();var o=E.itemsModel.createObject(t),n=E.itemsModel.findByParam("id",t.id);E.itemsModel.objects.replace(n,o),c.success(H("successful_edit"))}X(e)}).fail(Y)},Re=function(e){return Ce("GET",{mode:"getfile",path:e}).done(function(e){X(e)}).fail(Y)},He=function(){return Ce("GET",{mode:"summarize"}).done(function(t){if(t.data){var i=t.data.attributes,r=$(i.size,!0);if(i.sizeLimit>0){var o=$(i.sizeLimit,!0),n=100*i.size/i.sizeLimit;r+=" ("+Math.round(100*n)/100+"%) "+H("of")+" "+o}E.summaryModel.files(i.files),E.summaryModel.folders(i.folders),E.summaryModel.size(r),E.summaryModel.enabled(!0);var s=e("#summary-popup").clone().show();E.summaryModel.enabled(!1),c.alert(s[0].outerHTML)}X(t)}).fail(Y)},We=function(e){c.prompt({message:H("prompt_extract"),value:E.currentPath(),okBtn:{label:H("action_extract"),autoClose:!1,click:function(t,i){var r=i.getInputValue();r?(r=ie(r,"/")+"/",Ge(e,r)):c.error(H("prompt_foldername"))}},cancelBtn:{label:H("cancel")}})},Ge=function(t,i){Ce("POST",{mode:"extract",source:t.id,target:i}).done(function(t){t.data&&(e.each(t.data,function(e,t){E.addItem(t,i)}),alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("successful_extracted"))),X(t)}).fail(Y)},qe=function(t,i,r,o){var n=o||[r];switch(t){case"select":Oe(r);break;case"download":e.each(n,function(e,t){Ue(t)});break;case"rename":Ne(r);break;case"move":Fe(n,function(e){Ee(n,function(t,i){return Pe(i,e)})});break;case"delete":De(n,function(){Ee(n,function(e,t){return ze(t.id)})});break;case"extract":We(r);break;case"copy":E.clipboardModel.copy(n);break;case"cut":E.clipboardModel.cut(n);break;case"copyUrl":var s=new Clipboard(i.$selected[0],{text:function(e){return _e(r)}});s.on("success",function(e){c.success(H("copied")),s.destroy()})}},Ke=function(){if(k.options.browseOnly)return!1;k.upload.multiple?C.unbind().click(function(){if(-1===j.indexOf("upload"))return c.error(H("NOT_ALLOWED")),!1;var t=null,i=E.currentPath(),r=tmpl("tmpl-fileupload-container",{folder:H("current_folder")+i,info:H("upload_files_number_limit").replace("%s",k.upload.maxNumberOfFiles)+" "+H("upload_file_size_limit").replace("%s",$(k.upload.fileSizeLimit,!0)),lang:I.getTranslations()});"ALLOW_LIST"==k.security.extensions.policy&&(t=new RegExp("(\\.|\\/)("+k.security.extensions.restrictions.join("|")+")$","i")),c.dialog({message:r,width:"auto",buttons:[{type:"ok",label:H("action_upload"),autoClose:!1,click:function(e,t){n.children(".upload-item").length>0?n.find(".button-start").trigger("click"):c.error(H("upload_choose_file"))}},{label:H("action_select"),closeOnClick:!1,click:function(t,i){e("#fileupload",o).trigger("click")}},{type:"cancel",label:H("close")}]});var o=e(".fm-fileupload-container"),n=e(".dropzone",o),s=e(".dropzone-wrapper",o),a=e("#total-progress",o).children();k.customScrollbar.enabled&&s.mCustomScrollbar({theme:k.customScrollbar.theme,scrollButtons:{enable:k.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){s.find(".mCSB_container").css({"margin-right":s.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){s.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),s.on("click",function(t){(t.target===this||e(t.target).parent()[0]===this||t.target===n[0]||e(t.target).parent().hasClass("default-message"))&&e("#fileupload",o).trigger("click")}),n.on("click",".button-start",function(t){var i=e(this);i.parent().parent().data().submit(),i.remove()}),n.on("click",".button-abort",function(t){var i=e(this).parent().parent().data(),r=i.files[0].context;i.abort(),r.find(".error-message").text(H("upload_aborted")),r.addClass("aborted")}),n.on("click",".button-resume",function(t){function r(i){e.blueimp.fileupload.prototype.options.add.call(e("#fileupload")[0],t,i),i.submit()}var o=e(this).parent().parent().data(),n=o.files[0];if(n.chunkUploaded){var s=i+n.serverName;Re(s).then(function(e){e.data&&(o.uploadedBytes=Number(e.data.attributes.size),o.uploadedBytes||(n.chunkUploaded=void 0),r(o))})}else r(o)}),n.on("click",".button-remove",function(t){var r=e(this),o=r.parent().parent().data().files[0];o.chunkUploaded&&ze(i+o.serverName),r.closest(".upload-item").remove(),l()}),n.on("click",".button-info",function(t){var i=e(this).closest(".upload-item");if(i.hasClass("error")){var r=i.find(".error-message");c.error(r.text())}});var l=function(){n.children(".upload-item").length>0?n.addClass("started"):n.removeClass("started")},d=E.filterModel.getExtensions();d&&e("#fileupload").attr("accept",d.map(function(e){return"."+e}).join()),e("#fileupload",o).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:n,maxChunkSize:k.upload.chunkSize,url:ke(),paramName:"files",singleFileUploads:!0,formData:Me("POST",{mode:"upload",path:i}),maxNumberOfFiles:k.upload.maxNumberOfFiles,acceptFileTypes:t,maxFileSize:k.upload.fileSizeLimit,messages:{maxNumberOfFiles:H("upload_files_number_limit").replace("%s",k.upload.maxNumberOfFiles),acceptFileTypes:H("upload_file_type_invalid"),maxFileSize:H("upload_file_too_big")+" "+H("upload_file_size_limit").replace("%s",$(k.upload.fileSizeLimit,!0))},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(t,i){var r=n.children(".upload-item");e.each(i.files,function(t,o){if(r.length>=k.upload.maxNumberOfFiles)return c.error(H("upload_files_number_limit").replace("%s",k.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;o.formattedSize=$(o.size);var s=e(tmpl("tmpl-upload-item",{file:o,lang:I.getTranslations(),imagesPath:c.settings.baseUrl+"/scripts/jQuery-File-Upload/img"}));o.context=s,s.find(".buttons").data(i),s.appendTo(n)}),l()}).on("fileuploadsend",function(t,i){e.each(i.files,function(e,t){var r=t.context;r.removeClass("added aborted error").addClass("process"),t.chunkUploaded&&i.total===i.uploadedBytes&&r.remove()})}).on("fileuploadfail",function(t,i){e.each(i.files,function(e,t){t.error=H("upload_failed"),t.context.removeClass("added process").addClass("error")})}).on("fileuploaddone",function(t,i){var r=i.result;e.each(i.files,function(e,t){var i=t.context;r&&r.errors?(i.removeClass("added process").addClass("error"),i.find(".error-message").text(Q(r.errors[0])),i.find(".button-start").remove()):i.remove()})}).on("fileuploadalways",function(t,i){var r=i.result;e.each(i.files,function(e,t){if(r&&r.data&&r.data[e]){var i=r.data[e];E.removeItem(i),E.addItem(i,E.currentPath())}});var o=n.children(".upload-item");0===o.filter(".added").length&&0===o.filter(".process").length&&(0===o.length&&(alertify.clearDialogs(),k.options.showConfirmation&&c.success(H("upload_successful_files"))),o.filter(".error").length&&c.error(H("upload_partially")+"<br>"+H("upload_failed_details"))),l()}).on("fileuploadchunkdone",function(t,i){var r=i.result;e.each(i.files,function(e,t){if(r.data&&r.data[e]){var i=r.data[e];E.removeItem(i),E.addItem(i,E.currentPath()),t.serverName=i.attributes.name,t.chunkUploaded=1}})}).on("fileuploadprocessalways",function(t,i){e.each(i.files,function(e,t){var i=t.context;void 0!==i&&(t.preview&&(i.find(".image").append(t.preview),i.find(".preview").removeClass("file-preview").addClass("image-preview")),t.error&&(i.removeClass("added process").addClass("error"),i.find(".error-message").text(t.error),i.find(".button-start").remove()))})}).on("fileuploadprogress",function(t,i){e.each(i.files,function(e,t){var r=t.context,o=parseInt(i.loaded/i.total*100,10);r.find(".progress-bar").css("width",o+"%")})}).on("fileuploadprogressall",function(e,t){var i=parseInt(t.loaded/t.total*100,10);a.css("width",i+"%")})}):(C.unbind().click(function(){if(-1===j.indexOf("upload"))return c.error(H("NOT_ALLOWED")),!1;e("#newfile").trigger("click")}),h.fileupload({autoUpload:!0,dataType:"json",url:ke(),paramName:"files",maxChunkSize:k.upload.chunkSize}).on("fileuploadadd",function(e,t){C.data(t)}).on("fileuploadsubmit",function(e,t){t.formData=Me("POST",{mode:"upload",path:E.currentPath()}),C.addClass("loading").prop("disabled",!0),C.children("span").text(H("loading_data"))}).on("fileuploadalways",function(e,t){C.removeData().removeClass("loading").prop("disabled",!1),C.children("span").text(H("action_upload"));var i=t.result;if(i&&i.errors&&c.error(H("upload_failed")+"<br>"+Q(i.errors[0])),i&&i.data){var r=i.data[0];E.removeItem(r),E.addItem(r,E.currentPath()),k.options.showConfirmation&&c.success(H("upload_successful_file"))}}).on("fileuploadchunkdone",function(e,t){var i=t.result;if(i.data&&i.data[0]){var r=i.data[0];E.removeItem(r),E.addItem(r,E.currentPath())}}).on("fileuploadfail",function(e,t){c.error(H("upload_failed"))}))};!function(){var t=e.Deferred();t.then(function(){return T()}).then(function(){return D()}).then(function(e,t){return P()}).then(function(){return z()}).then(function(){U(function(){A()})}),t.resolve()}(),e(window).resize(c.setDimensions)}}(jQuery),$.fn.richFilemanager=function(e){return this.each(function(){if(void 0==$(this).data("richFilemanager")){var t=new $.richFilemanagerPlugin(this,e);$(this).data("richFilemanager",t)}})},window.location.origin||(window.location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28125266
1281
273935