From 15d35b0456aac8c65cd0f0fb79e0fe258e32b89f Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 18 Dec 2017 12:40:38 +0200 Subject: [PATCH] can handle application/json content type upon "download" operation #270 --- scripts/filemanager.js | 7 ++++--- scripts/filemanager.min.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/filemanager.js b/scripts/filemanager.js index e5c76766..63a5edf1 100644 --- a/scripts/filemanager.js +++ b/scripts/filemanager.js @@ -4136,10 +4136,11 @@ $.richFilemanagerPlugin = function(element, pluginOptions) $.fileDownload(buildConnectorUrl(queryParams), { failCallback: function (responseHtml, url, error) { - var responseJSON = $.parseJSON(responseHtml); + var message = $(responseHtml).text(); + var messageJSON = $.parseJSON(message); - if ($.isPlainObject(responseJSON) && responseJSON.errors) { - handleJsonErrors(responseJSON.errors); + if ($.isPlainObject(messageJSON) && messageJSON.errors) { + handleJsonErrors(messageJSON.errors); } } }); diff --git a/scripts/filemanager.min.js b/scripts/filemanager.min.js index 97da8c40..cd98acf3 100644 --- a/scripts/filemanager.min.js +++ b/scripts/filemanager.min.js @@ -1 +1 @@ -!function(e){e.richFilemanagerPlugin=function(t,i){function r(e){return j.indexOf(e)>-1}function n(t,i){if(!r(i))return!1;if("select"===i&&"folder"===t.type)return!1;if("extract"===i){var n=ce(t.attributes.name);return"file"===t.type&&"zip"===n}return"download"===i&&"folder"===t.type?!0===C.options.allowFolderDownload:void 0===t.attributes.capabilities||e.inArray(i,t.attributes.capabilities)>-1}function o(){C.filetree.enabled&&(g.show(),m.splitter({sizeLeft:C.filetree.width,minLeft:C.filetree.minWidth,minRight:200}))}function s(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||F.param("field_name")||F.param("CKEditor")||F.param("ImperaviElementId")}function a(e){if(!e.attributes.readable)return c.error(G("NOT_ALLOWED_SYSTEM")),!1;"file"===e.type&&E.previewModel.applyObject(e),"folder"!==e.type&&"parent"!==e.type||(E.previewFile(!1),E.itemsModel.loadDataList(e.id))}function l(e){var t=!E.clipboardModel.enabled(),i={select:{name:G("action_select"),className:"select"},download:{name:G("action_download"),className:"download"},rename:{name:G("action_rename"),className:"rename"},move:{name:G("action_move"),className:"move"},separator1:"-----",copy:{name:G("clipboard_copy"),className:"copy"},cut:{name:G("clipboard_cut"),className:"cut"},delete:{name:G("action_delete"),className:"delete"},extract:{name:G("action_extract"),className:"extract"},copyUrl:{name:G("copy_to_clipboard"),className:"copy-url"}};return n(e,"download")||delete i.download,n(e,"select")&&s()||delete i.select,n(e,"rename")&&!0!==C.options.browseOnly||delete i.rename,n(e,"delete")&&!0!==C.options.browseOnly||delete i.delete,n(e,"extract")&&!0!==C.options.browseOnly||delete i.extract,n(e,"copy")&&!0!==C.options.browseOnly&&!t||delete i.copy,n(e,"move")&&!0!==C.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){},beforeSetRequestParams:function(e,t){return t},beforeSendRequest:function(e,t){return!0}}},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"),k=w.find(".view-items"),M=h.children(".fm-upload"),C=null,x="/",S=null,j=[],L=null,_=null,E=null,O=null,I=null,N=null,T=null,F=purl(),P=(new Date).getTime();c.settings=e.extend(!0,d,i),c.write=function(t,i){var r=alertify,n=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(n.logClass&&n.unique&&e(".fm-log").children("."+n.logClass).length>0)return r;n.reset&&r.reset(),r.parent(n.parent),r.logDelay(n.delay),r.logMaxItems(n.logMaxItems),r.logPosition(n.logPosition),r.logContainerClass(n.logContainerClass),r.logMessageTemplate(n.logMessageTemplate),r[n.type](t,n.onClick);var o=r.getLogs();return o[o.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.console=function(){C.options.logger&&arguments&&([].unshift.call(arguments,(new Date).getTime()),console.log.apply(this,arguments))};var D=function(){return e.when($("default"),$("user")).done(function(t,i){var r=t[0],n=i[0];if(void 0!==n&&null!==n&&delete n.version,(C=e.extend({},r,n)).api.connectorUrl)S=C.api.connectorUrl;else{var o=location.origin+location.pathname,s="connectors/"+C.api.lang+"/filemanager."+C.api.lang;ce(o).length>0&&(o=o.substring(0,o.lastIndexOf("/")+1)),S=o+s}})},z=function(){return Se("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){if(null===i)return!0;void 0===C[t]&&(C[t]=[]),C[t][e]=i})}),C.security.readOnly&&(C.options.browseOnly=!0)}}).fail(function(){c.error("Unable to perform initial request to server.")}).then(function(t){if(t.errors)return e.Deferred().reject()})},A=function(){return O=new H,e.ajax().then(function(){var e=F.param("langCode");if(e)return V(O.buildLangFileUrl(e)).done(function(){O.setLang(e)}).fail(function(){setTimeout(function(){c.error("Given language file ("+O.buildLangFileUrl(e)+") does not exist!")},500)});O.setLang(C.language.default)}).then(function(){return e.ajax({type:"GET",url:O.buildLangFileUrl(O.getLang()),dataType:"json"}).done(function(e){O.setTranslations(e)})}).then(function(){var t=O.getLang().substr(0,2);return e.when(e.get("/scripts/cldrjs/cldr-dates/"+t+"/ca-gregorian.json"),e.get("/scripts/cldrjs/cldr-numbers/"+t+"/numbers.json"),e.get("/scripts/cldrjs/cldr-core/supplemental/likelySubtags.json"),e.get("/scripts/cldrjs/cldr-core/supplemental/timeData.json"),e.get("/scripts/cldrjs/cldr-core/supplemental/weekData.json")).fail(function(){c.error('CLDR files for "'+t+'" language do not exist!')}).then(function(){return[].slice.apply(arguments,[0]).map(function(e){return e[0]})}).then(Globalize.load).then(function(){I=Globalize(t)})})},U=function(){return e.when(Y("upload-container"),Y("upload-item")).done(function(e,t){var i=e[0],r=t[0];p.append(i).append(r)})},B=function(e){var t=[],i=[];if(t.push("/themes/"+C.options.theme+"/styles/theme.css"),C.viewer.image.lazyLoad&&t.push("/scripts/lazyload/dist/lazyload.min.js"),C.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),Q(t),C.editor.enabled){var r=C.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")}C.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")),C.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"),C.upload.multiple&&i.push("/scripts/jQuery-File-Upload/css/dropzone.css")),i.length&&Q(i)},R=function(){N=new W,j=C.options.capabilities||["upload","select","download","rename","copy","move","delete","extract","createFolder"];var t=[];C.options.fileSorting&&(t=C.options.fileSorting.toLowerCase().split("_")),L=t[0]||"name",_=t[1]||"asc";var i=F.param("exclusiveFolder");i&&(x=de(x="/"+i+"/"));var n=F.param("expandedFolder");if(n&&(T=de(T=x+n+"/")),E=new q,ko.applyBindings(E),E.itemsModel.initiateLazyLoad(),E.filterModel.setName(F.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(C.filetree.expandSpeed,function(){r.isSliding(!1),r.isExpanded(!0)}),!0===r.isExpanded()&&e(t).slideUp(C.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((C.customScrollbar.enabled?e([w[0],g[0]]):m.children(".splitter-pane")).each(function(r){var n=e(this),o=n.offset().top,s=n.offset().left;if(t.offsetY>=o&&t.offsetY<=o+n.height()&&t.offsetX>=s&&t.offsetX<=s+n.width())return i=n,!1}),null===i)return!1;if(C.customScrollbar.enabled){var r=i.find(".mCSB_scrollTools_vertical"),n=1===t.deltaY?"+":"-";r.is(":visible")&&i.mCustomScrollbar("scrollTo",[n+"=250",0],{scrollInertia:500,scrollEasing:"easeOut",callbacks:!0})}else if(i[0].scrollHeight>i[0].clientHeight){var o=i.scrollTop()-200*t.deltaY;E.ddModel.isScrolling=!0,o=o<0?0:o,i.stop().animate({scrollTop:o},100,"linear",function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0})}}),k.selectable({filter:"li:not(.directory-parent), tbody > tr:not(.directory-parent)",cancel:".directory-parent, thead",disabled:!C.manager.selection.enabled,appendTo:k,start:function(e,t){Ne(),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(t,i){var n={createFolder:{name:G("create_folder"),className:"create-folder"},paste:{name:G("clipboard_paste"),className:"paste",disabled:function(e,t){return E.clipboardModel.isEmpty()}}};return E.clipboardModel.enabled()&&!0!==C.options.browseOnly||delete n.paste,r("createFolder")&&!0!==C.options.browseOnly||delete n.createFolder,!e.isEmptyObject(n)&&{appendTo:".fm-container",items:n,reposition:!1,callback:function(e,t){switch(e){case"createFolder":E.headerModel.createFolder();break;case"paste":E.clipboardModel.paste()}}}}}),C.extras.extra_js)for(var s=0;s400&&(this.yStartPosition=this.mcs.top),E.itemsModel.isSelecting()&&E.itemsModel.continiousSelection(!0);var t=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);k.selectable("repositionCssHelper",t,0)}E.itemsModel.lazyLoad&&E.itemsModel.lazyLoad.handleScroll()}},axis:"y",alwaysShowScrollbar:0})),document.documentElement.setAttribute("data-useragent",navigator.userAgent),C.options.logger){var a=(new Date).getTime()-P;console.log("Total execution time : "+a+" ms")}u.find(".fm-loading-wrap").fadeOut(800,function(){c.setDimensions()}),c.setDimensions()},H=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]}},W=function(){var e={},t=this;this.push=function(i,r,n){t.removeTimer(i),e[i]=setTimeout(r,n)},this.getTimer=function(t){return e[t]},this.removeTimer=function(t){e[t]&&(clearTimeout(e[t]),delete e[t])}},q=function(){function t(e){return(!C.manager.selection.enabled||!C.manager.selection.useCtrlKey||!0!==e.ctrlKey)&&(!C.manager.dblClickOpen||"click"!==e.type)}var i=this;this.config=ko.observable(C),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(C.manager.defaultViewMode),this.currentPath=ko.observable(x),this.browseOnly=ko.observable(C.options.browseOnly),this.previewModel=ko.observable(null),this.currentLang=O.getLang(),this.lg=O.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.isCapable=function(e){return r(e)},this.addElements=function(e,t,r){i.treeModel.addNodes(e,t,r),i.currentPath()===t&&i.itemsModel.addItems(e,t,r)},this.removeElement=function(e){var t=i.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===f.name)return i.itemsModel.getSelected();if(e===d.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(){this.beforeLoad=function(e){},this.afterLoad=function(e,t){}},d=function(t){var r=this;this.id=t.id,this.rdo=t,this.cdo={isFolder:"folder"===t.type,extension:"file"===t.type?ce(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(G("NOT_ALLOWED_SYSTEM")),!1))},this.mouseDown=function(e,t){e.selected(!0)},this.nodeClick=function(e,t){C.manager.dblClickOpen||r.openNode(e)},this.nodeDblClick=function(e,t){C.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()&&C.filetree.reloadOnClick)i.treeModel.loadDataNode(t,!0);else{i.treeModel.toggleNode(t);var n=[];e.each(t.children(),function(e,t){n.push(t.rdo)}),i.itemsModel.addItems(n,t.id,!0)}},this.remove=function(){r.parentNode().children.remove(r)},this.isRoot=function(){return r.level()===i.treeModel.treeData.id},this.title=ko.pureComputed(function(){return C.options.showTitleAttr?this.rdo.id:null},this),this.itemClass=ko.pureComputed(function(){var e=[];return this.selected()&&C.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(C.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 C.filetree.showLine&&!this.isLastNode()?"line":""},this)},f=function(e){var r=C.viewer.image.thumbMaxWidth;e.attributes.width&&e.attributes.width'+hljs.highlight(t,e,!0).value+""}catch(e){}return'
'+n.utils.escapeHtml(e)+"
"},replaceLink:function(e,t){if(-1!=e.search("://")||ae(e,"mailto:"))return e;var i=(ae(e,"/")?x:pe(r.rdo().id))+oe(e,"/");if(Ce(i))return i;var n=xe("GET",{mode:"readfile",path:i});return je(n)}}).use(window.markdownitReplaceLink);this.processContent=function(e){var i=n.render(e);r.content(i),t()},this.processDomElements=function(e){}}},v=function(){function t(e){r.enabled(!0),r.instance.setValue(e),setTimeout(function(){r.instance.refresh()},0)}function i(e){var t=[],i="default";C.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)}),Q(t)):r.mode(i)}var r=this,n=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),n&&(t(n),n=null))}),this.render=function(e){r.mode()?t(e):n=e},this.createInstance=function(t,n,o){var s,a={readOnly:"nocursor",styleActiveLine:!1,viewportMargin:1/0,lineNumbers:C.editor.lineNumbers,lineWrapping:C.editor.lineWrapping,theme:C.editor.theme,matchBrackets:C.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(n,e.extend({},a,o))).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!==T){e||(e=t.treeData);var i=t.findByFilter(function(e){return 0===T.indexOf(e.id)},e);i?(C.filetree.expandSpeed=10,t.loadDataNode(i,!0)):(T=null,C.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 n=0,o=r.length;n0,this.closeButtonOnClick=function(){c.console("CLOSE button is clicked")},this.navHome=function(){i.previewFile(!1),i.itemsModel.loadDataList(x)},this.navLevelUp=function(){var e=i.previewFile()?pe(i.previewModel.rdo().id):fe(i.currentPath());i.previewFile()&&i.previewFile(!1),e!==i.currentPath()&&i.itemsModel.loadDataList(e)},this.navRefresh=function(){i.previewFile()?(i.previewFile(!1),i.previewFile(!0)):i.itemsModel.loadDataList(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=O.getLang();if(i&&i.toLowerCase()!==r.toLowerCase()){var n,o=window.location.toString(),s=new RegExp("(langCode=)"+r);n=s.test(o)?o.replace(s,"$1"+i):o+(e.isEmptyObject(F.param())?"?":"#")+"langCode="+i,window.location.href=n}},this.createFolder=function(){if(!r("createFolder"))return c.error(G("NOT_ALLOWED")),!1;c.prompt({message:G("prompt_foldername"),value:G("default_foldername"),okBtn:{label:G("create_folder"),autoClose:!1,click:function(e,t){var i=t.getInputValue();i?Se("GET",{mode:"addfolder",path:E.currentPath(),name:i}).done(function(e){e.data&&(E.addElements(e.data,E.currentPath()),t.closeDialog(),C.options.showConfirmation&&c.success(G("successful_added_folder")))}).fail(te):c.error(G("no_foldername"))}},cancelBtn:{label:G("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(){Ke()}},this.filterModel=new function(){var t=this;this.name=ko.observable(null),this.setName=function(i){i&&C.filter&&e.isArray(C.filter[i])&&t.name(i)},this.getExtensions=function(){return t.name()?C.filter[t.name()]:null},this.filterItem=function(i){var r=t.getExtensions(),n=!i.cdo.hiddenBySearch;if(i.cdo.hiddenByType=!1,"file"===i.rdo.type&&e.isArray(r)){var o=ce(i.id),s=-1!==r.indexOf(o);n=n&&s,i.cdo.hiddenByType=!s}i.visible(n)},this.filter=function(r){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(){function t(){a?N.push("search",function(){r()},C.search.typingDelay):r()}function r(){var t=o.value(),r=C.search.caseSensitive?t:t.toLowerCase();if(""!==t)if(C.search.recursive){var a=i.currentPath();new h(a).setPreloader(i.itemsModel.getPreloader()).setDataHandler(function(t,n){var o=[];C.search.caseSensitive?e.each(t,function(e,t){0===t.attributes.name.indexOf(r)&&o.push(t)}):o=t;var s=i.itemsModel.createItems(o);i.itemsModel.setItemsList(s)}).load(function(){return qe(a,t)})}else e.each(i.itemsModel.objects(),function(e,t){var i=t.rdo.attributes.name;C.search.caseSensitive||(i=i.toLowerCase());var n=0===i.indexOf(r),o=!t.cdo.hiddenByType;o=o&&n,t.cdo.hiddenBySearch=!n,t.visible(o)});else t!==s?n():c.warning(G("search_string_empty"))}function n(){o.clearInput(),C.search.recursive?i.itemsModel.loadDataList(i.currentPath()):e.each(i.itemsModel.objects(),function(e,t){t.cdo.hiddenBySearch=!1,t.visible(!t.cdo.hiddenByType)})}var o=this,s="",a=!!C.search.typingDelay;this.value=ko.observable(""),this.value.subscribe(function(e){s=e},null,"beforeChange"),this.inputKeyUp=function(e,i){var r=i.which||i.keyCode,n=[16,17,18,27,37,38,39,40];if(a){if(n.indexOf(r)>-1)return;o.value(i.target.value)}(a||13===r)&&t()},this.seekItems=function(e,i){t()},this.reset=function(e,t){n()},this.clearInput=function(){o.value(""),s=o.value(),N.removeTimer("search")}},this.clipboardModel=new function(){function e(){n=[],t=null,o.itemsNum(0)}var t=null,n=[],o=this,s=r("copy")&&r("move");this.itemsNum=ko.observable(0),this.enabled=ko.observable(i.config().clipboard.enabled&&s),this.copy=function(){o.hasCapability("copy")&&(t="copy",n=i.fetchSelectedItems(),o.itemsNum(n.length))},this.cut=function(){o.hasCapability("cut")&&(t="cut",n=i.fetchSelectedItems(),o.itemsNum(n.length))},this.paste=function(){var r=i.currentPath();o.hasCapability("paste")&&!o.isEmpty()&&(null!==t&&0!==n.length?Ie(n,function(e,i){return"cut"===t?ze(i,r):"copy"===t?De(i,r):void 0},e):c.warning(G("clipboard_empty")))},this.clear=function(){o.hasCapability("clear")&&!o.isEmpty()&&(e(),c.success(G("clipboard_cleared")))},this.isEmpty=function(){return 0===n.length},this.hasCapability=function(e){if(!o.enabled)return!1;switch(e){case"copy":return r("copy");case"cut":return r("move");default:return!0}}},this.breadcrumbsModel=new function(){var e=this;this.items=ko.observableArray([]),this.clean=function(){e.items([]),e.add(x,"")},this.add=function(i,r){e.items.push(new t(i,r))},this.splitPath=function(t){var i=x,r=t.replace(new RegExp("^"+x),"").split("/");for(e.clean();r.length>0;){var n=r.shift();n&&(i+=n+"/",e.add(i,n))}},this.splitCurrent=function(){e.splitPath(i.currentPath())},this.getLabel=ko.pureComputed(function(){return G(i.searchModel.value()?"search_results":"current_folder")+": "},this);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.loadDataList(e.path)}}},this.ddModel=new function(){function t(t){var i=e.grep(o.items,function(e,i){if("folder"===t.rdo.type||"parent"===t.rdo.type){if(ae(t.rdo.id,e.rdo.id))return!0;if(t.rdo.id===he(e.rdo.id))return!0}return e.id===t.id});return t.rdo.attributes.writable&&0===i.length}function r(e){null!==o.hoveredItem&&o.hoveredItem.dragHovered(!1),o.hoveredItem=e,e&&e.dragHovered(!0)}function n(e,t){t?e.addClass(s):e.removeClass(s)}var o=this,s="drop-restricted",a=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(a.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_"+ce(t.rdo.id),(e=a.children(".drag-helper").clone()).find(".clip").addClass(r),o.dragHelper=e,e},start:function(e,r){o.items=i.fetchSelectedItems(t.constructor.name)},drag:function(t,i){e(this).draggable("option","refreshPositions",o.isScrolling||o.isScrolled),o.isScrolled=!1},stop:function(e,t){o.items=[],o.dragHelper=null}})},this.makeDroppable=function(i,s){"folder"!==i.rdo.type&&"parent"!==i.rdo.type||e(s).droppable({tolerance:"pointer",enableExtendedEvents:i instanceof f,accept:function(e){var t=ko.dataFor(e[0]),i=t?t.rdo.type:null;return"file"===i||"folder"===i},over:function(e,o){setTimeout(function(){r(null),n(o.helper,!1),t(i)||n(o.helper,!0),r(i)},0)},out:function(e,t){r(null),n(t.helper,!1)},drop:function(e,n){if(r(null),!t(i))return!1;Ie(o.items,function(e,t){return ze(t.rdo,i.id)})}})}},this.selectionModel=new function(){this.unselect=!1}},G=function(e){return O.translate(e)},K=function(e){function t(e){var t,i=L;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.modified;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()),n=r(t.toString()),o=0;i[o]&&n[o];o++)if(i[o]!==n[o]){var s=Number(i[o]),a=Number(n[o]);return s==i[o]&&a==n[o]?s-a:i[o]>n[o]?1:-1}return i.length-n.length}function r(e){for(var t,i,r=[],n=0,o=-1,s=0;t=(i=e.charAt(n++)).charCodeAt(0);){var a=46==t||t>=48&&t<=57;a!==s&&(r[++o]="",s=a),r[o]+=i}return r}var n={natural:!0,order:"asc"===("list"===E.viewMode()?E.itemsModel.listSortOrder():_)?1:-1,cases:!1};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):sa?1:0,o*=n.order});for(var o=[],s=e.length;s--;)"folder"===e[s].rdo.type&&(o.push(e[s]),e.splice(s,1));"top"!==C.options.folderPosition&&o.reverse();for(var a=0,l=o.length;a1&&(n=c.write(o.getMessage(),{delay:0,logMessageTemplate:function(e){o.getProgress();var t=o.isProcessed()?"striped":"striped animated";return"
"+e+'
'+o.getProgress()+'%
'}})).stick(!0),e.each(t,function(e,t){s=s.then(function(){return i(e,t)}).then(function(e){e&&e.data?o.succeeded():o.failed(),n&&n.setMessage(o.getMessage())})}),s.then(function(){n&&o.isProcessed()&&(n.stick(!1),setTimeout(function(){n.remove()},6e3))}),s.then(function(){"function"==typeof r&&r()})},Ne=function(){document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},Te=function(e){var t=null,i=Le(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(F.param("field_name")&&(parent.document.getElementById(F.param("field_name")).value=i,void 0!==parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),void 0!==parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),F.param("ImperaviElementId"))if(window.opener);else{var n=F.param("ImperaviElementId"),o=parent.$("#"+n).redactor("core.getObject");o&&(o.modal.close(),o.buffer.set(),ve(e.attributes.name)?o.insert.html(''):o.insert.html(''+e.attributes.name+""))}if(F.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(F.param("CKEditorFuncNum"),i):(parent.CKEDITOR.tools.callFunction(F.param("CKEditorFuncNum"),i),parent.CKEDITOR.tools.callFunction(F.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)},Fe=function(e){c.prompt({message:G("new_filename"),value:C.options.allowChangeExtensions?e.attributes.name:ue(e.attributes.name),okBtn:{label:G("action_rename"),autoClose:!1,click:function(t,i){var r=e.id,n=i.getInputValue();if(n){if(!C.options.allowChangeExtensions){var o=ce(e.attributes.name);o.length>0&&(n=n+"."+o)}if(re(r)&&!ie(n)){var s="

"+G("INVALID_FILE_TYPE")+"

";return"ALLOW_LIST"===C.security.extensions.policy&&(s+="

"+G("ALLOWED_FILE_TYPE").replace("%s",C.security.extensions.restrictions.join(", "))+".

"),"DISALLOW_LIST"===C.security.extensions.policy&&(s+="

"+G("DISALLOWED_FILE_TYPE").replace("%s",C.security.extensions.restrictions.join(", "))+".

"),void c.error(s)}Se("GET",{mode:"rename",old:r,new:n}).done(function(e){if(e.data){var t=e.data,n=E.treeModel.findByParam("id",r);if(n&&("folder"===n.rdo.type&&(n.nodeTitle(t.attributes.name),E.treeModel.actualizeNodeObject(n,r,t.id)),"file"===n.rdo.type)){var o=n.parentNode(),s=E.treeModel.createNode(t);n.remove(),o&&E.treeModel.appendNodes(o,s)}var a=E.itemsModel.parentItem();if(a&&a.id===r)E.itemsModel.parentItem().id=t.id;else{var l=E.itemsModel.findByParam("id",r);if(l){l.remove();var d=E.itemsModel.createItem(t);E.itemsModel.appendItems(d)}}E.currentPath()===r&&E.itemsModel.loadDataList(t.id),E.previewFile()&&E.previewModel.rdo().id===r&&E.previewModel.applyObject(t),i.closeDialog(),C.options.showConfirmation&&c.success(G("successful_rename"))}}).fail(te)}else c.error(G("new_filename"))}},cancelBtn:{label:G("cancel")}})},Pe=function(e,t){var i=e.length,r=i>1?G("prompt_move_multiple").replace("%s",i):G("prompt_move");c.prompt({message:r,value:E.currentPath(),okBtn:{label:G("action_move"),autoClose:!1,click:function(e,i){var r=i.getInputValue();r?(r=se(r,"/")+"/",t(r)):c.error(G("prompt_foldername"))}},cancelBtn:{label:G("cancel")},template:{dialogInput:'
'+G("help_move")+"
"}})},De=function(e,t){return Se("GET",{mode:"copy",source:e.id,target:t}).done(function(e){if(e.data){var i=e.data;E.addElements(i,t),alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("successful_copied"))}}).fail(te)},ze=function(e,t){return Se("GET",{mode:"move",old:e.id,new:t}).done(function(i){if(i.data){var r=i.data;E.removeElement(e),E.addElements(r,t),E.currentPath()===e.id&&E.itemsModel.loadDataList(r.id),E.previewFile()&&E.previewModel.rdo().id===e.id&&E.previewFile(!1),alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("successful_moved"))}}).fail(te)},Ae=function(e,t){var i=e.length,r=i>1?G("confirm_delete_multiple").replace("%s",i):G("confirm_delete");c.confirm({message:r,okBtn:{label:G("yes"),click:function(e,i){t()}},cancelBtn:{label:G("no")}})},Ue=function(e){return Se("GET",{mode:"delete",path:e}).done(function(e){if(e.data){var t=e.data;if(E.removeElement(t),"folder"===t.type&&ae(E.currentPath(),t.id)){var i=fe(t.id);E.itemsModel.loadDataList(i)}E.previewFile()&&E.previewModel.rdo().id===t.id&&E.previewFile(!1),C.options.showConfirmation&&c.success(G("successful_delete"))}}).fail(te)},Be=function(t){var i={mode:"download",path:t.id};e.fileDownload(je(i),{failCallback:function(t,i,r){var n=e.parseJSON(t);e.isPlainObject(n)&&n.errors&&ee(n.errors)}})},Re=function(t){var i=e("#fm-js-editor-form").serializeArray();Se("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 n=E.itemsModel.createItem(t),o=E.itemsModel.findByParam("id",t.id);E.itemsModel.objects.replace(o,n),c.success(G("successful_edit"))}}).fail(te)},He=function(e){return Se("GET",{mode:"readfile",path:e.id},"text").fail(te)},We=function(e){return Se("GET",{mode:"readfolder",path:e}).fail(te)},qe=function(e,t){return Se("GET",{mode:"seekfolder",path:e,string:t}).fail(te)},Ge=function(e){return Se("GET",{mode:"getinfo",path:e}).fail(te)},Ke=function(){return Se("GET",{mode:"summarize"}).done(function(t){if(t.data){var i=t.data.attributes,r=J(i.size,!0);if(i.sizeLimit>0){var n=J(i.sizeLimit,!0),o=100*i.size/i.sizeLimit;r+=" ("+Math.round(100*o)/100+"%) "+G("of")+" "+n}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)}}).fail(te)},Ve=function(e){c.prompt({message:G("prompt_extract"),value:E.currentPath(),okBtn:{label:G("action_extract"),autoClose:!1,click:function(t,i){var r=i.getInputValue();r?(r=se(r,"/")+"/",$e(e,r)):c.error(G("prompt_foldername"))}},cancelBtn:{label:G("cancel")}})},$e=function(e,t){Se("POST",{mode:"extract",source:e.id,target:t}).done(function(e){e.data&&(E.addElements(e.data,t),alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("successful_extracted")))}).fail(te)},Qe=function(t,i,r,n){var o=n||[r];switch(t){case"select":Te(r);break;case"download":e.each(o,function(e,t){Be(t)});break;case"rename":Fe(r);break;case"move":Pe(o,function(e){Ie(o,function(t,i){return ze(i,e)})});break;case"delete":Ae(o,function(){Ie(o,function(e,t){return Ue(t.id)})});break;case"extract":Ve(r);break;case"copy":E.clipboardModel.copy(o);break;case"cut":E.clipboardModel.cut(o);break;case"copyUrl":var s=new Clipboard(i.$selected[0],{text:function(e){return Oe(r)}});s.on("success",function(e){c.success(G("copied")),s.destroy()})}},Ye=function(){if(C.options.browseOnly)return!1;C.upload.multiple?M.unbind().click(function(){if(!r("upload"))return c.error(G("NOT_ALLOWED")),!1;var t=null,i=E.currentPath(),n=tmpl("tmpl-fileupload-container",{folder:G("current_folder")+i,info:G("upload_files_number_limit").replace("%s",C.upload.maxNumberOfFiles)+" "+G("upload_file_size_limit").replace("%s",J(C.upload.fileSizeLimit,!0)),lang:O.getTranslations()});"ALLOW_LIST"===C.security.extensions.policy&&(t=new RegExp("(\\.|\\/)("+C.security.extensions.restrictions.join("|")+")$","i")),c.dialog({message:n,width:"auto",buttons:[{type:"ok",label:G("action_upload"),autoClose:!1,click:function(e,t){s.children(".upload-item").length>0?s.find(".button-start").trigger("click"):c.error(G("upload_choose_file"))}},{label:G("action_select"),closeOnClick:!1,click:function(t,i){e("#fileupload",o).trigger("click")}},{type:"cancel",label:G("close")}]});var o=e(".fm-fileupload-container"),s=e(".dropzone",o),a=e(".dropzone-wrapper",o),l=e("#total-progress",o).children();C.customScrollbar.enabled&&a.mCustomScrollbar({theme:C.customScrollbar.theme,scrollButtons:{enable:C.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){a.find(".mCSB_container").css({"margin-right":a.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){a.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),a.on("click",function(t){(t.target===this||e(t.target).parent()[0]===this||t.target===s[0]||e(t.target).parent().hasClass("default-message"))&&e("#fileupload",o).trigger("click")}),s.on("click",".button-start",function(t){var i=e(this);i.parent().parent().data().submit(),i.remove()}),s.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(G("upload_aborted")),r.addClass("aborted")}),s.on("click",".button-resume",function(t){function r(i){e.blueimp.fileupload.prototype.options.add.call(e("#fileupload")[0],t,i),i.submit()}var n=e(this).parent().parent().data(),o=n.files[0];if(o.chunkUploaded){var s=i+o.serverName;Ge(s).then(function(e){e.data&&(n.uploadedBytes=Number(e.data.attributes.size),n.uploadedBytes||(o.chunkUploaded=void 0),r(n))})}else r(n)}),s.on("click",".button-remove",function(t){var r=e(this),n=r.parent().parent().data().files[0];n.chunkUploaded&&Ue(i+n.serverName),r.closest(".upload-item").remove(),d()}),s.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 d=function(){s.children(".upload-item").length>0?s.addClass("started"):s.removeClass("started")},u=E.filterModel.getExtensions();u&&e("#fileupload").attr("accept",u.map(function(e){return"."+e}).join()),e("#fileupload",o).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:s,maxChunkSize:C.upload.chunkSize,url:je(),paramName:"files",singleFileUploads:!0,formData:xe("POST",{mode:"upload",path:i}),maxNumberOfFiles:C.upload.maxNumberOfFiles,acceptFileTypes:t,maxFileSize:C.upload.fileSizeLimit,messages:{maxNumberOfFiles:G("upload_files_number_limit").replace("%s",C.upload.maxNumberOfFiles),acceptFileTypes:G("upload_file_type_invalid"),maxFileSize:G("upload_file_too_big")+" "+G("upload_file_size_limit").replace("%s",J(C.upload.fileSizeLimit,!0))},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(t,i){var r=s.children(".upload-item");e.each(i.files,function(t,n){if(r.length>=C.upload.maxNumberOfFiles)return c.error(G("upload_files_number_limit").replace("%s",C.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;n.formattedSize=J(n.size);var o=e(tmpl("tmpl-upload-item",{file:n,lang:O.getTranslations(),imagesPath:c.settings.baseUrl+"/scripts/jQuery-File-Upload/img"}));n.context=o,o.find(".buttons").data(i),o.appendTo(s)}),d()}).on("fileuploadsend",function(t,i){if(!1===c.settings.callbacks.beforeSendRequest(i.type,i.formData))return e.each(i.files,function(e,t){var i=t.context;i.find(".error-message").text(G("NOT_ALLOWED")),i.removeClass("added process").addClass("error")}),!1;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=G("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(Z(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.removeElement(i),E.addElements(i,E.currentPath())}});var n=s.children(".upload-item");0===n.filter(".added").length&&0===n.filter(".process").length&&(0===n.length&&(alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("upload_successful_files"))),n.filter(".error").length&&c.error(G("upload_partially")+"
"+G("upload_failed_details"))),d()}).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.removeElement(i),E.addElements(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,n=parseInt(i.loaded/i.total*100,10);r.find(".progress-bar").css("width",n+"%")})}).on("fileuploadprogressall",function(e,t){var i=parseInt(t.loaded/t.total*100,10);l.css("width",i+"%")})}):(M.unbind().click(function(){if(!r("upload"))return c.error(G("NOT_ALLOWED")),!1;e("#newfile").trigger("click")}),h.fileupload({autoUpload:!0,dataType:"json",url:je(),paramName:"files",maxChunkSize:C.upload.chunkSize}).on("fileuploadadd",function(e,t){M.data(t)}).on("fileuploadsubmit",function(e,t){t.formData=xe("POST",{mode:"upload",path:E.currentPath()}),M.addClass("loading").prop("disabled",!0),M.children("span").text(G("loading_data"))}).on("fileuploadsend",function(e,t){if(!1===c.settings.callbacks.beforeSendRequest(t.type,t.formData))return c.error(G("NOT_ALLOWED")),!1}).on("fileuploadalways",function(e,t){M.removeData().removeClass("loading").prop("disabled",!1),M.children("span").text(G("action_upload"));var i=t.result;if(i&&i.errors&&c.error(G("upload_failed")+"
"+Z(i.errors[0])),i&&i.data){var r=i.data[0];E.removeElement(r),E.addElements(r,E.currentPath()),C.options.showConfirmation&&c.success(G("upload_successful_file"))}}).on("fileuploadchunkdone",function(e,t){var i=t.result;if(i.data&&i.data[0]){var r=i.data[0];E.removeElement(r),E.addElements(r,E.currentPath())}}).on("fileuploadfail",function(e,t){c.error(G("upload_failed"))}))};!function(){var t=e.Deferred();t.then(function(){return D()}).then(function(){return A()}).then(function(e,t){return z()}).then(function(){return U()}).then(function(){B(function(){R()})}),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:"")); \ No newline at end of file +!function(e){e.richFilemanagerPlugin=function(t,i){function r(e){return j.indexOf(e)>-1}function n(t,i){if(!r(i))return!1;if("select"===i&&"folder"===t.type)return!1;if("extract"===i){var n=ce(t.attributes.name);return"file"===t.type&&"zip"===n}return"download"===i&&"folder"===t.type?!0===C.options.allowFolderDownload:void 0===t.attributes.capabilities||e.inArray(i,t.attributes.capabilities)>-1}function o(){C.filetree.enabled&&(g.show(),m.splitter({sizeLeft:C.filetree.width,minLeft:C.filetree.minWidth,minRight:200}))}function s(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||F.param("field_name")||F.param("CKEditor")||F.param("ImperaviElementId")}function a(e){if(!e.attributes.readable)return c.error(G("NOT_ALLOWED_SYSTEM")),!1;"file"===e.type&&E.previewModel.applyObject(e),"folder"!==e.type&&"parent"!==e.type||(E.previewFile(!1),E.itemsModel.loadDataList(e.id))}function l(e){var t=!E.clipboardModel.enabled(),i={select:{name:G("action_select"),className:"select"},download:{name:G("action_download"),className:"download"},rename:{name:G("action_rename"),className:"rename"},move:{name:G("action_move"),className:"move"},separator1:"-----",copy:{name:G("clipboard_copy"),className:"copy"},cut:{name:G("clipboard_cut"),className:"cut"},delete:{name:G("action_delete"),className:"delete"},extract:{name:G("action_extract"),className:"extract"},copyUrl:{name:G("copy_to_clipboard"),className:"copy-url"}};return n(e,"download")||delete i.download,n(e,"select")&&s()||delete i.select,n(e,"rename")&&!0!==C.options.browseOnly||delete i.rename,n(e,"delete")&&!0!==C.options.browseOnly||delete i.delete,n(e,"extract")&&!0!==C.options.browseOnly||delete i.extract,n(e,"copy")&&!0!==C.options.browseOnly&&!t||delete i.copy,n(e,"move")&&!0!==C.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){},beforeSetRequestParams:function(e,t){return t},beforeSendRequest:function(e,t){return!0}}},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"),k=w.find(".view-items"),M=h.children(".fm-upload"),C=null,x="/",S=null,j=[],L=null,_=null,E=null,O=null,I=null,N=null,T=null,F=purl(),P=(new Date).getTime();c.settings=e.extend(!0,d,i),c.write=function(t,i){var r=alertify,n=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(n.logClass&&n.unique&&e(".fm-log").children("."+n.logClass).length>0)return r;n.reset&&r.reset(),r.parent(n.parent),r.logDelay(n.delay),r.logMaxItems(n.logMaxItems),r.logPosition(n.logPosition),r.logContainerClass(n.logContainerClass),r.logMessageTemplate(n.logMessageTemplate),r[n.type](t,n.onClick);var o=r.getLogs();return o[o.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.console=function(){C.options.logger&&arguments&&([].unshift.call(arguments,(new Date).getTime()),console.log.apply(this,arguments))};var D=function(){return e.when($("default"),$("user")).done(function(t,i){var r=t[0],n=i[0];if(void 0!==n&&null!==n&&delete n.version,(C=e.extend({},r,n)).api.connectorUrl)S=C.api.connectorUrl;else{var o=location.origin+location.pathname,s="connectors/"+C.api.lang+"/filemanager."+C.api.lang;ce(o).length>0&&(o=o.substring(0,o.lastIndexOf("/")+1)),S=o+s}})},z=function(){return Se("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){if(null===i)return!0;void 0===C[t]&&(C[t]=[]),C[t][e]=i})}),C.security.readOnly&&(C.options.browseOnly=!0)}}).fail(function(){c.error("Unable to perform initial request to server.")}).then(function(t){if(t.errors)return e.Deferred().reject()})},A=function(){return O=new H,e.ajax().then(function(){var e=F.param("langCode");if(e)return V(O.buildLangFileUrl(e)).done(function(){O.setLang(e)}).fail(function(){setTimeout(function(){c.error("Given language file ("+O.buildLangFileUrl(e)+") does not exist!")},500)});O.setLang(C.language.default)}).then(function(){return e.ajax({type:"GET",url:O.buildLangFileUrl(O.getLang()),dataType:"json"}).done(function(e){O.setTranslations(e)})}).then(function(){var t=O.getLang().substr(0,2);return e.when(e.get("/scripts/cldrjs/cldr-dates/"+t+"/ca-gregorian.json"),e.get("/scripts/cldrjs/cldr-numbers/"+t+"/numbers.json"),e.get("/scripts/cldrjs/cldr-core/supplemental/likelySubtags.json"),e.get("/scripts/cldrjs/cldr-core/supplemental/timeData.json"),e.get("/scripts/cldrjs/cldr-core/supplemental/weekData.json")).fail(function(){c.error('CLDR files for "'+t+'" language do not exist!')}).then(function(){return[].slice.apply(arguments,[0]).map(function(e){return e[0]})}).then(Globalize.load).then(function(){I=Globalize(t)})})},U=function(){return e.when(Y("upload-container"),Y("upload-item")).done(function(e,t){var i=e[0],r=t[0];p.append(i).append(r)})},B=function(e){var t=[],i=[];if(t.push("/themes/"+C.options.theme+"/styles/theme.css"),C.viewer.image.lazyLoad&&t.push("/scripts/lazyload/dist/lazyload.min.js"),C.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),Q(t),C.editor.enabled){var r=C.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")}C.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")),C.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"),C.upload.multiple&&i.push("/scripts/jQuery-File-Upload/css/dropzone.css")),i.length&&Q(i)},R=function(){N=new W,j=C.options.capabilities||["upload","select","download","rename","copy","move","delete","extract","createFolder"];var t=[];C.options.fileSorting&&(t=C.options.fileSorting.toLowerCase().split("_")),L=t[0]||"name",_=t[1]||"asc";var i=F.param("exclusiveFolder");i&&(x=de(x="/"+i+"/"));var n=F.param("expandedFolder");if(n&&(T=de(T=x+n+"/")),E=new q,ko.applyBindings(E),E.itemsModel.initiateLazyLoad(),E.filterModel.setName(F.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(C.filetree.expandSpeed,function(){r.isSliding(!1),r.isExpanded(!0)}),!0===r.isExpanded()&&e(t).slideUp(C.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((C.customScrollbar.enabled?e([w[0],g[0]]):m.children(".splitter-pane")).each(function(r){var n=e(this),o=n.offset().top,s=n.offset().left;if(t.offsetY>=o&&t.offsetY<=o+n.height()&&t.offsetX>=s&&t.offsetX<=s+n.width())return i=n,!1}),null===i)return!1;if(C.customScrollbar.enabled){var r=i.find(".mCSB_scrollTools_vertical"),n=1===t.deltaY?"+":"-";r.is(":visible")&&i.mCustomScrollbar("scrollTo",[n+"=250",0],{scrollInertia:500,scrollEasing:"easeOut",callbacks:!0})}else if(i[0].scrollHeight>i[0].clientHeight){var o=i.scrollTop()-200*t.deltaY;E.ddModel.isScrolling=!0,o=o<0?0:o,i.stop().animate({scrollTop:o},100,"linear",function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0})}}),k.selectable({filter:"li:not(.directory-parent), tbody > tr:not(.directory-parent)",cancel:".directory-parent, thead",disabled:!C.manager.selection.enabled,appendTo:k,start:function(e,t){Ne(),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(t,i){var n={createFolder:{name:G("create_folder"),className:"create-folder"},paste:{name:G("clipboard_paste"),className:"paste",disabled:function(e,t){return E.clipboardModel.isEmpty()}}};return E.clipboardModel.enabled()&&!0!==C.options.browseOnly||delete n.paste,r("createFolder")&&!0!==C.options.browseOnly||delete n.createFolder,!e.isEmptyObject(n)&&{appendTo:".fm-container",items:n,reposition:!1,callback:function(e,t){switch(e){case"createFolder":E.headerModel.createFolder();break;case"paste":E.clipboardModel.paste()}}}}}),C.extras.extra_js)for(var s=0;s400&&(this.yStartPosition=this.mcs.top),E.itemsModel.isSelecting()&&E.itemsModel.continiousSelection(!0);var t=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);k.selectable("repositionCssHelper",t,0)}E.itemsModel.lazyLoad&&E.itemsModel.lazyLoad.handleScroll()}},axis:"y",alwaysShowScrollbar:0})),document.documentElement.setAttribute("data-useragent",navigator.userAgent),C.options.logger){var a=(new Date).getTime()-P;console.log("Total execution time : "+a+" ms")}u.find(".fm-loading-wrap").fadeOut(800,function(){c.setDimensions()}),c.setDimensions()},H=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]}},W=function(){var e={},t=this;this.push=function(i,r,n){t.removeTimer(i),e[i]=setTimeout(r,n)},this.getTimer=function(t){return e[t]},this.removeTimer=function(t){e[t]&&(clearTimeout(e[t]),delete e[t])}},q=function(){function t(e){return(!C.manager.selection.enabled||!C.manager.selection.useCtrlKey||!0!==e.ctrlKey)&&(!C.manager.dblClickOpen||"click"!==e.type)}var i=this;this.config=ko.observable(C),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(C.manager.defaultViewMode),this.currentPath=ko.observable(x),this.browseOnly=ko.observable(C.options.browseOnly),this.previewModel=ko.observable(null),this.currentLang=O.getLang(),this.lg=O.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.isCapable=function(e){return r(e)},this.addElements=function(e,t,r){i.treeModel.addNodes(e,t,r),i.currentPath()===t&&i.itemsModel.addItems(e,t,r)},this.removeElement=function(e){var t=i.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===f.name)return i.itemsModel.getSelected();if(e===d.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(){this.beforeLoad=function(e){},this.afterLoad=function(e,t){}},d=function(t){var r=this;this.id=t.id,this.rdo=t,this.cdo={isFolder:"folder"===t.type,extension:"file"===t.type?ce(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(G("NOT_ALLOWED_SYSTEM")),!1))},this.mouseDown=function(e,t){e.selected(!0)},this.nodeClick=function(e,t){C.manager.dblClickOpen||r.openNode(e)},this.nodeDblClick=function(e,t){C.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()&&C.filetree.reloadOnClick)i.treeModel.loadDataNode(t,!0);else{i.treeModel.toggleNode(t);var n=[];e.each(t.children(),function(e,t){n.push(t.rdo)}),i.itemsModel.addItems(n,t.id,!0)}},this.remove=function(){r.parentNode().children.remove(r)},this.isRoot=function(){return r.level()===i.treeModel.treeData.id},this.title=ko.pureComputed(function(){return C.options.showTitleAttr?this.rdo.id:null},this),this.itemClass=ko.pureComputed(function(){var e=[];return this.selected()&&C.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(C.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 C.filetree.showLine&&!this.isLastNode()?"line":""},this)},f=function(e){var r=C.viewer.image.thumbMaxWidth;e.attributes.width&&e.attributes.width'+hljs.highlight(t,e,!0).value+""}catch(e){}return'
'+n.utils.escapeHtml(e)+"
"},replaceLink:function(e,t){if(-1!=e.search("://")||ae(e,"mailto:"))return e;var i=(ae(e,"/")?x:pe(r.rdo().id))+oe(e,"/");if(Ce(i))return i;var n=xe("GET",{mode:"readfile",path:i});return je(n)}}).use(window.markdownitReplaceLink);this.processContent=function(e){var i=n.render(e);r.content(i),t()},this.processDomElements=function(e){}}},v=function(){function t(e){r.enabled(!0),r.instance.setValue(e),setTimeout(function(){r.instance.refresh()},0)}function i(e){var t=[],i="default";C.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)}),Q(t)):r.mode(i)}var r=this,n=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),n&&(t(n),n=null))}),this.render=function(e){r.mode()?t(e):n=e},this.createInstance=function(t,n,o){var s,a={readOnly:"nocursor",styleActiveLine:!1,viewportMargin:1/0,lineNumbers:C.editor.lineNumbers,lineWrapping:C.editor.lineWrapping,theme:C.editor.theme,matchBrackets:C.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(n,e.extend({},a,o))).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!==T){e||(e=t.treeData);var i=t.findByFilter(function(e){return 0===T.indexOf(e.id)},e);i?(C.filetree.expandSpeed=10,t.loadDataNode(i,!0)):(T=null,C.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 n=0,o=r.length;n0,this.closeButtonOnClick=function(){c.console("CLOSE button is clicked")},this.navHome=function(){i.previewFile(!1),i.itemsModel.loadDataList(x)},this.navLevelUp=function(){var e=i.previewFile()?pe(i.previewModel.rdo().id):fe(i.currentPath());i.previewFile()&&i.previewFile(!1),e!==i.currentPath()&&i.itemsModel.loadDataList(e)},this.navRefresh=function(){i.previewFile()?(i.previewFile(!1),i.previewFile(!0)):i.itemsModel.loadDataList(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=O.getLang();if(i&&i.toLowerCase()!==r.toLowerCase()){var n,o=window.location.toString(),s=new RegExp("(langCode=)"+r);n=s.test(o)?o.replace(s,"$1"+i):o+(e.isEmptyObject(F.param())?"?":"#")+"langCode="+i,window.location.href=n}},this.createFolder=function(){if(!r("createFolder"))return c.error(G("NOT_ALLOWED")),!1;c.prompt({message:G("prompt_foldername"),value:G("default_foldername"),okBtn:{label:G("create_folder"),autoClose:!1,click:function(e,t){var i=t.getInputValue();i?Se("GET",{mode:"addfolder",path:E.currentPath(),name:i}).done(function(e){e.data&&(E.addElements(e.data,E.currentPath()),t.closeDialog(),C.options.showConfirmation&&c.success(G("successful_added_folder")))}).fail(te):c.error(G("no_foldername"))}},cancelBtn:{label:G("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(){Ke()}},this.filterModel=new function(){var t=this;this.name=ko.observable(null),this.setName=function(i){i&&C.filter&&e.isArray(C.filter[i])&&t.name(i)},this.getExtensions=function(){return t.name()?C.filter[t.name()]:null},this.filterItem=function(i){var r=t.getExtensions(),n=!i.cdo.hiddenBySearch;if(i.cdo.hiddenByType=!1,"file"===i.rdo.type&&e.isArray(r)){var o=ce(i.id),s=-1!==r.indexOf(o);n=n&&s,i.cdo.hiddenByType=!s}i.visible(n)},this.filter=function(r){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(){function t(){a?N.push("search",function(){r()},C.search.typingDelay):r()}function r(){var t=o.value(),r=C.search.caseSensitive?t:t.toLowerCase();if(""!==t)if(C.search.recursive){var a=i.currentPath();new h(a).setPreloader(i.itemsModel.getPreloader()).setDataHandler(function(t,n){var o=[];C.search.caseSensitive?e.each(t,function(e,t){0===t.attributes.name.indexOf(r)&&o.push(t)}):o=t;var s=i.itemsModel.createItems(o);i.itemsModel.setItemsList(s)}).load(function(){return qe(a,t)})}else e.each(i.itemsModel.objects(),function(e,t){var i=t.rdo.attributes.name;C.search.caseSensitive||(i=i.toLowerCase());var n=0===i.indexOf(r),o=!t.cdo.hiddenByType;o=o&&n,t.cdo.hiddenBySearch=!n,t.visible(o)});else t!==s?n():c.warning(G("search_string_empty"))}function n(){o.clearInput(),C.search.recursive?i.itemsModel.loadDataList(i.currentPath()):e.each(i.itemsModel.objects(),function(e,t){t.cdo.hiddenBySearch=!1,t.visible(!t.cdo.hiddenByType)})}var o=this,s="",a=!!C.search.typingDelay;this.value=ko.observable(""),this.value.subscribe(function(e){s=e},null,"beforeChange"),this.inputKeyUp=function(e,i){var r=i.which||i.keyCode,n=[16,17,18,27,37,38,39,40];if(a){if(n.indexOf(r)>-1)return;o.value(i.target.value)}(a||13===r)&&t()},this.seekItems=function(e,i){t()},this.reset=function(e,t){n()},this.clearInput=function(){o.value(""),s=o.value(),N.removeTimer("search")}},this.clipboardModel=new function(){function e(){n=[],t=null,o.itemsNum(0)}var t=null,n=[],o=this,s=r("copy")&&r("move");this.itemsNum=ko.observable(0),this.enabled=ko.observable(i.config().clipboard.enabled&&s),this.copy=function(){o.hasCapability("copy")&&(t="copy",n=i.fetchSelectedItems(),o.itemsNum(n.length))},this.cut=function(){o.hasCapability("cut")&&(t="cut",n=i.fetchSelectedItems(),o.itemsNum(n.length))},this.paste=function(){var r=i.currentPath();o.hasCapability("paste")&&!o.isEmpty()&&(null!==t&&0!==n.length?Ie(n,function(e,i){return"cut"===t?ze(i,r):"copy"===t?De(i,r):void 0},e):c.warning(G("clipboard_empty")))},this.clear=function(){o.hasCapability("clear")&&!o.isEmpty()&&(e(),c.success(G("clipboard_cleared")))},this.isEmpty=function(){return 0===n.length},this.hasCapability=function(e){if(!o.enabled)return!1;switch(e){case"copy":return r("copy");case"cut":return r("move");default:return!0}}},this.breadcrumbsModel=new function(){var e=this;this.items=ko.observableArray([]),this.clean=function(){e.items([]),e.add(x,"")},this.add=function(i,r){e.items.push(new t(i,r))},this.splitPath=function(t){var i=x,r=t.replace(new RegExp("^"+x),"").split("/");for(e.clean();r.length>0;){var n=r.shift();n&&(i+=n+"/",e.add(i,n))}},this.splitCurrent=function(){e.splitPath(i.currentPath())},this.getLabel=ko.pureComputed(function(){return G(i.searchModel.value()?"search_results":"current_folder")+": "},this);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.loadDataList(e.path)}}},this.ddModel=new function(){function t(t){var i=e.grep(o.items,function(e,i){if("folder"===t.rdo.type||"parent"===t.rdo.type){if(ae(t.rdo.id,e.rdo.id))return!0;if(t.rdo.id===he(e.rdo.id))return!0}return e.id===t.id});return t.rdo.attributes.writable&&0===i.length}function r(e){null!==o.hoveredItem&&o.hoveredItem.dragHovered(!1),o.hoveredItem=e,e&&e.dragHovered(!0)}function n(e,t){t?e.addClass(s):e.removeClass(s)}var o=this,s="drop-restricted",a=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(a.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_"+ce(t.rdo.id),(e=a.children(".drag-helper").clone()).find(".clip").addClass(r),o.dragHelper=e,e},start:function(e,r){o.items=i.fetchSelectedItems(t.constructor.name)},drag:function(t,i){e(this).draggable("option","refreshPositions",o.isScrolling||o.isScrolled),o.isScrolled=!1},stop:function(e,t){o.items=[],o.dragHelper=null}})},this.makeDroppable=function(i,s){"folder"!==i.rdo.type&&"parent"!==i.rdo.type||e(s).droppable({tolerance:"pointer",enableExtendedEvents:i instanceof f,accept:function(e){var t=ko.dataFor(e[0]),i=t?t.rdo.type:null;return"file"===i||"folder"===i},over:function(e,o){setTimeout(function(){r(null),n(o.helper,!1),t(i)||n(o.helper,!0),r(i)},0)},out:function(e,t){r(null),n(t.helper,!1)},drop:function(e,n){if(r(null),!t(i))return!1;Ie(o.items,function(e,t){return ze(t.rdo,i.id)})}})}},this.selectionModel=new function(){this.unselect=!1}},G=function(e){return O.translate(e)},K=function(e){function t(e){var t,i=L;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.modified;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()),n=r(t.toString()),o=0;i[o]&&n[o];o++)if(i[o]!==n[o]){var s=Number(i[o]),a=Number(n[o]);return s==i[o]&&a==n[o]?s-a:i[o]>n[o]?1:-1}return i.length-n.length}function r(e){for(var t,i,r=[],n=0,o=-1,s=0;t=(i=e.charAt(n++)).charCodeAt(0);){var a=46==t||t>=48&&t<=57;a!==s&&(r[++o]="",s=a),r[o]+=i}return r}var n={natural:!0,order:"asc"===("list"===E.viewMode()?E.itemsModel.listSortOrder():_)?1:-1,cases:!1};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):sa?1:0,o*=n.order});for(var o=[],s=e.length;s--;)"folder"===e[s].rdo.type&&(o.push(e[s]),e.splice(s,1));"top"!==C.options.folderPosition&&o.reverse();for(var a=0,l=o.length;a1&&(n=c.write(o.getMessage(),{delay:0,logMessageTemplate:function(e){o.getProgress();var t=o.isProcessed()?"striped":"striped animated";return"
"+e+'
'+o.getProgress()+'%
'}})).stick(!0),e.each(t,function(e,t){s=s.then(function(){return i(e,t)}).then(function(e){e&&e.data?o.succeeded():o.failed(),n&&n.setMessage(o.getMessage())})}),s.then(function(){n&&o.isProcessed()&&(n.stick(!1),setTimeout(function(){n.remove()},6e3))}),s.then(function(){"function"==typeof r&&r()})},Ne=function(){document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},Te=function(e){var t=null,i=Le(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(F.param("field_name")&&(parent.document.getElementById(F.param("field_name")).value=i,void 0!==parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),void 0!==parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),F.param("ImperaviElementId"))if(window.opener);else{var n=F.param("ImperaviElementId"),o=parent.$("#"+n).redactor("core.getObject");o&&(o.modal.close(),o.buffer.set(),ve(e.attributes.name)?o.insert.html(''):o.insert.html(''+e.attributes.name+""))}if(F.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(F.param("CKEditorFuncNum"),i):(parent.CKEDITOR.tools.callFunction(F.param("CKEditorFuncNum"),i),parent.CKEDITOR.tools.callFunction(F.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)},Fe=function(e){c.prompt({message:G("new_filename"),value:C.options.allowChangeExtensions?e.attributes.name:ue(e.attributes.name),okBtn:{label:G("action_rename"),autoClose:!1,click:function(t,i){var r=e.id,n=i.getInputValue();if(n){if(!C.options.allowChangeExtensions){var o=ce(e.attributes.name);o.length>0&&(n=n+"."+o)}if(re(r)&&!ie(n)){var s="

"+G("INVALID_FILE_TYPE")+"

";return"ALLOW_LIST"===C.security.extensions.policy&&(s+="

"+G("ALLOWED_FILE_TYPE").replace("%s",C.security.extensions.restrictions.join(", "))+".

"),"DISALLOW_LIST"===C.security.extensions.policy&&(s+="

"+G("DISALLOWED_FILE_TYPE").replace("%s",C.security.extensions.restrictions.join(", "))+".

"),void c.error(s)}Se("GET",{mode:"rename",old:r,new:n}).done(function(e){if(e.data){var t=e.data,n=E.treeModel.findByParam("id",r);if(n&&("folder"===n.rdo.type&&(n.nodeTitle(t.attributes.name),E.treeModel.actualizeNodeObject(n,r,t.id)),"file"===n.rdo.type)){var o=n.parentNode(),s=E.treeModel.createNode(t);n.remove(),o&&E.treeModel.appendNodes(o,s)}var a=E.itemsModel.parentItem();if(a&&a.id===r)E.itemsModel.parentItem().id=t.id;else{var l=E.itemsModel.findByParam("id",r);if(l){l.remove();var d=E.itemsModel.createItem(t);E.itemsModel.appendItems(d)}}E.currentPath()===r&&E.itemsModel.loadDataList(t.id),E.previewFile()&&E.previewModel.rdo().id===r&&E.previewModel.applyObject(t),i.closeDialog(),C.options.showConfirmation&&c.success(G("successful_rename"))}}).fail(te)}else c.error(G("new_filename"))}},cancelBtn:{label:G("cancel")}})},Pe=function(e,t){var i=e.length,r=i>1?G("prompt_move_multiple").replace("%s",i):G("prompt_move");c.prompt({message:r,value:E.currentPath(),okBtn:{label:G("action_move"),autoClose:!1,click:function(e,i){var r=i.getInputValue();r?(r=se(r,"/")+"/",t(r)):c.error(G("prompt_foldername"))}},cancelBtn:{label:G("cancel")},template:{dialogInput:'
'+G("help_move")+"
"}})},De=function(e,t){return Se("GET",{mode:"copy",source:e.id,target:t}).done(function(e){if(e.data){var i=e.data;E.addElements(i,t),alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("successful_copied"))}}).fail(te)},ze=function(e,t){return Se("GET",{mode:"move",old:e.id,new:t}).done(function(i){if(i.data){var r=i.data;E.removeElement(e),E.addElements(r,t),E.currentPath()===e.id&&E.itemsModel.loadDataList(r.id),E.previewFile()&&E.previewModel.rdo().id===e.id&&E.previewFile(!1),alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("successful_moved"))}}).fail(te)},Ae=function(e,t){var i=e.length,r=i>1?G("confirm_delete_multiple").replace("%s",i):G("confirm_delete");c.confirm({message:r,okBtn:{label:G("yes"),click:function(e,i){t()}},cancelBtn:{label:G("no")}})},Ue=function(e){return Se("GET",{mode:"delete",path:e}).done(function(e){if(e.data){var t=e.data;if(E.removeElement(t),"folder"===t.type&&ae(E.currentPath(),t.id)){var i=fe(t.id);E.itemsModel.loadDataList(i)}E.previewFile()&&E.previewModel.rdo().id===t.id&&E.previewFile(!1),C.options.showConfirmation&&c.success(G("successful_delete"))}}).fail(te)},Be=function(t){var i={mode:"download",path:t.id};e.fileDownload(je(i),{failCallback:function(t,i,r){var n=e(t).text(),o=e.parseJSON(n);e.isPlainObject(o)&&o.errors&&ee(o.errors)}})},Re=function(t){var i=e("#fm-js-editor-form").serializeArray();Se("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 n=E.itemsModel.createItem(t),o=E.itemsModel.findByParam("id",t.id);E.itemsModel.objects.replace(o,n),c.success(G("successful_edit"))}}).fail(te)},He=function(e){return Se("GET",{mode:"readfile",path:e.id},"text").fail(te)},We=function(e){return Se("GET",{mode:"readfolder",path:e}).fail(te)},qe=function(e,t){return Se("GET",{mode:"seekfolder",path:e,string:t}).fail(te)},Ge=function(e){return Se("GET",{mode:"getinfo",path:e}).fail(te)},Ke=function(){return Se("GET",{mode:"summarize"}).done(function(t){if(t.data){var i=t.data.attributes,r=J(i.size,!0);if(i.sizeLimit>0){var n=J(i.sizeLimit,!0),o=100*i.size/i.sizeLimit;r+=" ("+Math.round(100*o)/100+"%) "+G("of")+" "+n}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)}}).fail(te)},Ve=function(e){c.prompt({message:G("prompt_extract"),value:E.currentPath(),okBtn:{label:G("action_extract"),autoClose:!1,click:function(t,i){var r=i.getInputValue();r?(r=se(r,"/")+"/",$e(e,r)):c.error(G("prompt_foldername"))}},cancelBtn:{label:G("cancel")}})},$e=function(e,t){Se("POST",{mode:"extract",source:e.id,target:t}).done(function(e){e.data&&(E.addElements(e.data,t),alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("successful_extracted")))}).fail(te)},Qe=function(t,i,r,n){var o=n||[r];switch(t){case"select":Te(r);break;case"download":e.each(o,function(e,t){Be(t)});break;case"rename":Fe(r);break;case"move":Pe(o,function(e){Ie(o,function(t,i){return ze(i,e)})});break;case"delete":Ae(o,function(){Ie(o,function(e,t){return Ue(t.id)})});break;case"extract":Ve(r);break;case"copy":E.clipboardModel.copy(o);break;case"cut":E.clipboardModel.cut(o);break;case"copyUrl":var s=new Clipboard(i.$selected[0],{text:function(e){return Oe(r)}});s.on("success",function(e){c.success(G("copied")),s.destroy()})}},Ye=function(){if(C.options.browseOnly)return!1;C.upload.multiple?M.unbind().click(function(){if(!r("upload"))return c.error(G("NOT_ALLOWED")),!1;var t=null,i=E.currentPath(),n=tmpl("tmpl-fileupload-container",{folder:G("current_folder")+i,info:G("upload_files_number_limit").replace("%s",C.upload.maxNumberOfFiles)+" "+G("upload_file_size_limit").replace("%s",J(C.upload.fileSizeLimit,!0)),lang:O.getTranslations()});"ALLOW_LIST"===C.security.extensions.policy&&(t=new RegExp("(\\.|\\/)("+C.security.extensions.restrictions.join("|")+")$","i")),c.dialog({message:n,width:"auto",buttons:[{type:"ok",label:G("action_upload"),autoClose:!1,click:function(e,t){s.children(".upload-item").length>0?s.find(".button-start").trigger("click"):c.error(G("upload_choose_file"))}},{label:G("action_select"),closeOnClick:!1,click:function(t,i){e("#fileupload",o).trigger("click")}},{type:"cancel",label:G("close")}]});var o=e(".fm-fileupload-container"),s=e(".dropzone",o),a=e(".dropzone-wrapper",o),l=e("#total-progress",o).children();C.customScrollbar.enabled&&a.mCustomScrollbar({theme:C.customScrollbar.theme,scrollButtons:{enable:C.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){a.find(".mCSB_container").css({"margin-right":a.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){a.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),a.on("click",function(t){(t.target===this||e(t.target).parent()[0]===this||t.target===s[0]||e(t.target).parent().hasClass("default-message"))&&e("#fileupload",o).trigger("click")}),s.on("click",".button-start",function(t){var i=e(this);i.parent().parent().data().submit(),i.remove()}),s.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(G("upload_aborted")),r.addClass("aborted")}),s.on("click",".button-resume",function(t){function r(i){e.blueimp.fileupload.prototype.options.add.call(e("#fileupload")[0],t,i),i.submit()}var n=e(this).parent().parent().data(),o=n.files[0];if(o.chunkUploaded){var s=i+o.serverName;Ge(s).then(function(e){e.data&&(n.uploadedBytes=Number(e.data.attributes.size),n.uploadedBytes||(o.chunkUploaded=void 0),r(n))})}else r(n)}),s.on("click",".button-remove",function(t){var r=e(this),n=r.parent().parent().data().files[0];n.chunkUploaded&&Ue(i+n.serverName),r.closest(".upload-item").remove(),d()}),s.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 d=function(){s.children(".upload-item").length>0?s.addClass("started"):s.removeClass("started")},u=E.filterModel.getExtensions();u&&e("#fileupload").attr("accept",u.map(function(e){return"."+e}).join()),e("#fileupload",o).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:s,maxChunkSize:C.upload.chunkSize,url:je(),paramName:"files",singleFileUploads:!0,formData:xe("POST",{mode:"upload",path:i}),maxNumberOfFiles:C.upload.maxNumberOfFiles,acceptFileTypes:t,maxFileSize:C.upload.fileSizeLimit,messages:{maxNumberOfFiles:G("upload_files_number_limit").replace("%s",C.upload.maxNumberOfFiles),acceptFileTypes:G("upload_file_type_invalid"),maxFileSize:G("upload_file_too_big")+" "+G("upload_file_size_limit").replace("%s",J(C.upload.fileSizeLimit,!0))},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(t,i){var r=s.children(".upload-item");e.each(i.files,function(t,n){if(r.length>=C.upload.maxNumberOfFiles)return c.error(G("upload_files_number_limit").replace("%s",C.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;n.formattedSize=J(n.size);var o=e(tmpl("tmpl-upload-item",{file:n,lang:O.getTranslations(),imagesPath:c.settings.baseUrl+"/scripts/jQuery-File-Upload/img"}));n.context=o,o.find(".buttons").data(i),o.appendTo(s)}),d()}).on("fileuploadsend",function(t,i){if(!1===c.settings.callbacks.beforeSendRequest(i.type,i.formData))return e.each(i.files,function(e,t){var i=t.context;i.find(".error-message").text(G("NOT_ALLOWED")),i.removeClass("added process").addClass("error")}),!1;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=G("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(Z(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.removeElement(i),E.addElements(i,E.currentPath())}});var n=s.children(".upload-item");0===n.filter(".added").length&&0===n.filter(".process").length&&(0===n.length&&(alertify.clearDialogs(),C.options.showConfirmation&&c.success(G("upload_successful_files"))),n.filter(".error").length&&c.error(G("upload_partially")+"
"+G("upload_failed_details"))),d()}).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.removeElement(i),E.addElements(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,n=parseInt(i.loaded/i.total*100,10);r.find(".progress-bar").css("width",n+"%")})}).on("fileuploadprogressall",function(e,t){var i=parseInt(t.loaded/t.total*100,10);l.css("width",i+"%")})}):(M.unbind().click(function(){if(!r("upload"))return c.error(G("NOT_ALLOWED")),!1;e("#newfile").trigger("click")}),h.fileupload({autoUpload:!0,dataType:"json",url:je(),paramName:"files",maxChunkSize:C.upload.chunkSize}).on("fileuploadadd",function(e,t){M.data(t)}).on("fileuploadsubmit",function(e,t){t.formData=xe("POST",{mode:"upload",path:E.currentPath()}),M.addClass("loading").prop("disabled",!0),M.children("span").text(G("loading_data"))}).on("fileuploadsend",function(e,t){if(!1===c.settings.callbacks.beforeSendRequest(t.type,t.formData))return c.error(G("NOT_ALLOWED")),!1}).on("fileuploadalways",function(e,t){M.removeData().removeClass("loading").prop("disabled",!1),M.children("span").text(G("action_upload"));var i=t.result;if(i&&i.errors&&c.error(G("upload_failed")+"
"+Z(i.errors[0])),i&&i.data){var r=i.data[0];E.removeElement(r),E.addElements(r,E.currentPath()),C.options.showConfirmation&&c.success(G("upload_successful_file"))}}).on("fileuploadchunkdone",function(e,t){var i=t.result;if(i.data&&i.data[0]){var r=i.data[0];E.removeElement(r),E.addElements(r,E.currentPath())}}).on("fileuploadfail",function(e,t){c.error(G("upload_failed"))}))};!function(){var t=e.Deferred();t.then(function(){return D()}).then(function(){return A()}).then(function(e,t){return z()}).then(function(){return U()}).then(function(){B(function(){R()})}),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:"")); \ No newline at end of file