From ae7c1e5c7d55eb79056ed5022194dae59514cf1e Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 2 Apr 2017 16:39:42 +0300 Subject: [PATCH] extended drag and drop functionality #133 --- index.html | 2 +- scripts/filemanager.min.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 17878fc5..65f2075e 100644 --- a/index.html +++ b/index.html @@ -415,7 +415,7 @@

- + diff --git a/scripts/filemanager.min.js b/scripts/filemanager.min.js index fa0b05b1..404466bf 100644 --- a/scripts/filemanager.min.js +++ b/scripts/filemanager.min.js @@ -1,2 +1,2 @@ -!function(a){a.richFilemanagerPlugin=function(b,c){function d(b,c){return B.indexOf(c)!==-1&&(("folder"!==b.type||"replace"!==c)&&(("folder"!==b.type||"select"!==c)&&("folder"===b.type&&"download"===c?x.security.allowFolderDownload===!0:"undefined"==typeof b.attributes.capabilities||a.inArray(c,b.attributes.capabilities)>-1)))}function e(){x.filetree.enabled&&(s.show(),p.splitter({sizeLeft:x.filetree.width,minLeft:x.filetree.minWidth,minRight:200}),E.treeModel.loadNodes(null,!1))}function f(){E.itemsModel.loadList(z)}function g(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||G.param("field_name")||G.param("CKEditor")||G.param("ImperaviElementId")}function h(a){return a.attributes.readable?("file"===a.type&&E.previewModel.applyObject(a),void("folder"!==a.type&&"parent"!==a.type||(E.previewFile(!1),E.itemsModel.loadList(a.id)))):(k.error(y.NOT_ALLOWED_SYSTEM),!1)}function i(a){var b=!E.clipboardModel.enabled(),c={select:{name:y.action_select,className:"select"},download:{name:y.action_download,className:"download"},rename:{name:y.action_rename,className:"rename"},move:{name:y.action_move,className:"move"},replace:{name:y.action_replace,className:"replace"},separator1:"-----",copy:{name:y.clipboard_copy,className:"copy"},cut:{name:y.clipboard_cut,className:"cut"},"delete":{name:y.action_delete,className:"delete"}};return d(a,"download")||delete c.download,d(a,"select")&&g()||delete c.select,d(a,"rename")&&x.options.browseOnly!==!0||delete c.rename,d(a,"delete")&&x.options.browseOnly!==!0||delete c["delete"],d(a,"copy")&&x.options.browseOnly!==!0&&!b||delete c.copy,d(a,"move")&&x.options.browseOnly!==!0&&!b||(delete c.cut,delete c.move),delete c.replace,c}var j={baseUrl:".",config:{},callbacks:{beforeCreateImageUrl:function(a,b){return b},beforeCreatePreviewUrl:function(a,b){return b},beforeSelectItem:function(a,b){return b},afterSelectItem:function(a,b,c){}}},k=this,l=a(b),m=l.children(".fm-wrapper"),n=m.find(".fm-header"),o=n.find(".fm-uploader"),p=m.children(".fm-splitter"),q=m.children(".fm-footer"),r=p.children(".fm-fileinfo"),s=p.children(".fm-filetree"),t=r.find(".view-items-wrapper"),u=r.find(".fm-preview-wrapper"),v=t.find(".view-items"),w=o.children(".fm-upload"),x=null,y=null,z="/",A=null,B=[],C=null,D=null,E=null,F=null,G=purl();(new Date).getTime();k.settings=a.extend(!0,j,c),k.log=function(b,c){var d=alertify,e=a.extend({},{reset:!0,delay:5e3,logMaxItems:5,logPosition:"bottom right",logContainerClass:"fm-log",parent:a(".fm-popup").is(":visible")?document.body:r[0],onClick:void 0,unique:!1,type:"log"},c);return e.logClass&&e.unique&&a(".fm-log").children("."+e.logClass).length>0?d:(e.reset&&d.reset(),e.parent&&d.parent(e.parent),d.logDelay(e.delay),d.logMaxItems(e.logMaxItems),d.logPosition(e.logPosition),d.logContainerClass(e.logContainerClass),d[e.type](b,e.onClick),d)},k.error=function(b,c){return k.log(b,a.extend({},{type:"error",delay:1e4},c))},k.warning=function(b,c){return k.log(b,a.extend({},{type:"warning",delay:1e4},c))},k.success=function(b,c){return k.log(b,a.extend({},{type:"success",delay:6e3},c))},k.alert=function(a){alertify.reset().dialogContainerClass("fm-popup").alert(a)},k.confirm=function(a){alertify.reset().dialogWidth(a.width).dialogPersistent(a.persistent).dialogContainerClass("fm-popup").confirm(a.message,a.okBtn,a.cancelBtn)},k.prompt=function(a){alertify.reset().dialogWidth(a.width).dialogPersistent(a.persistent).dialogContainerClass("fm-popup").theme(a.template).prompt(a.message,a.value||"",a.okBtn,a.cancelBtn)},k.dialog=function(a){alertify.reset().dialogWidth(a.width).dialogPersistent(a.persistent).dialogContainerClass("fm-popup").dialog(a.message,a.buttons)},k.setDimensions=function(){var b=m.outerHeight(!0)-m.height(),c=a(window).height()-n.height()-q.height()-b,d=p.width()-p.children(".splitter-bar-vertical").outerWidth()-s.outerWidth();p.height(c),r.width(d)};var H=function(){var b=a.Deferred();b.then(function(){return I()}).then(function(a,b){return J()}).then(function(){return K()}).then(function(){return L()}).then(function(){M(function(){N()})}),b.resolve()},I=function(){return a.when(R("default"),R("user")).done(function(b,c){var d=b[0],e=c[0];if(void 0!==e&&null!==e&&delete e.version,x=a.extend({},d,e),x.api.connectorUrl)A=x.api.connectorUrl;else{var f=location.origin+location.pathname,g="connectors/"+x.api.lang+"/filemanager."+x.api.lang;fa(f).length>0&&(f=f.substring(0,f.lastIndexOf("/")+1)),A=f+g}})},J=function(){return a.ajax({type:"GET",url:ra({mode:"initiate"}),dataType:"json"}).done(function(b){if(b.data){var c=b.data.attributes.config;a.each(c,function(b,c){a.each(c,function(a,c){"undefined"!==x[b]&&"undefined"!==x[b][a]&&(x[b][a]=c)})})}Y(b)}).fail(function(){k.error("Unable to perform initial request to server.")}).then(function(b){if(b.errors)return a.Deferred().reject()})},K=function(){function b(a){return d+a+".json"}var c=G.param("langCode"),d=k.settings.baseUrl+"/languages/";return a.ajax().then(function(){if(c)return Q(b(c)).done(function(){x.options.culture=c}).fail(function(){setTimeout(function(){k.error("Given language file ("+b(c)+") does not exist!")},500)})}).then(function(){return a.ajax({type:"GET",url:b(x.options.culture),dataType:"json"}).done(function(a){y=a})})},L=function(){return a.when(T("upload-container"),T("upload-item")).done(function(a,b){var c=a[0],d=b[0];m.append(c).append(d)})},M=function(a){var b=[],c=[];if(b.push("/themes/"+x.options.theme+"/styles/theme.css"),x.customScrollbar.enabled&&(b.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"),b.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js")),b.push(a),S(b),x.viewer.editable.enabled){var d=x.viewer.editable.theme;d&&"default"!==d&&c.push("/scripts/CodeMirror/theme/"+d+".css"),c.push("/scripts/CodeMirror/lib/codemirror.css"),c.push("/scripts/CodeMirror/lib/codemirror.js"),c.push("/scripts/CodeMirror/addon/selection/active-line.js"),c.push("/scripts/CodeMirror/addon/display/fullscreen.css"),c.push("/scripts/CodeMirror/addon/display/fullscreen.js")}x.viewer.markdownRenderer.enabled&&(c.push("/styles/fm-markdown.css"),c.push("/scripts/markdown-it/markdown-it.min.js"),c.push("/scripts/markdown-it/default.min.css"),c.push("/scripts/markdown-it/highlight.min.js"),c.push("/scripts/markdown-it/markdown-it-footnote.min.js"),c.push("/scripts/markdown-it/markdown-it-replace-link.min.js")),x.options.browseOnly||(c.push("/scripts/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"),c.push("/scripts/jQuery-File-Upload/js/canvas-to-blob.min.js"),c.push("/scripts/jQuery-File-Upload/js/load-image.all.min.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.iframe-transport.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-process.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-image.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-validate.js"),x.upload.multiple&&c.push("/scripts/jQuery-File-Upload/css/dropzone.css")),x.options.charsLatinOnly&&c.push("/scripts/speakingurl/speakingurl.min.js"),c.length&&S(c)},N=function(){B=x.options.capabilities||["upload","select","download","rename","copy","move","delete","replace"];var b=[];x.options.fileSorting&&(b=x.options.fileSorting.toLowerCase().split("_")),C=b[0]||"name",D=b[1]||"asc";var c=G.param("exclusiveFolder");c&&(z="/"+c+"/",z=ea(z));var d=G.param("expandedFolder");if(d&&(F=z+d+"/",F=ea(F)),E=new O,ko.applyBindings(E),ko.bindingHandlers.toggleNodeVisibility={init:function(b,c){var d=c();a(b).toggle(d.isExpanded())},update:function(b,c){var d=c();return d.isSliding()!==!1&&(d.isExpanded()===!1&&a(b).slideDown(x.filetree.expandSpeed,function(){d.isSliding(!1),d.isExpanded(!0)}),void(d.isExpanded()===!0&&a(b).slideUp(x.filetree.expandSpeed,function(){d.isSliding(!1),d.isExpanded(!1)})))}},ko.bindingHandlers.draggableView={init:function(b,c,d){var e=c();"file"!==e.rdo.type&&"folder"!==e.rdo.type||a(b).draggable({distance:3,cursor:"pointer",refreshPositions:!1,helper:function(){var b,c=E.itemsModel.getSelected(),d="drag-helper-"+E.viewMode(),e=a("
",{"class":d});return b=c.length>1?a("#drag-helper-"+E.viewMode()+"-template").clone():a(this).clone(),e.append(b.html())},appendTo:x.customScrollbar.enabled?t.find(".mCustomScrollBox"):r,start:function(a,b){e.selected()||(E.itemsModel.unselectItems(!1),e.selected(!0))},drag:function(b,c){a(this).draggable("option","refreshPositions",E.itemsModel.isScrolling())}})}},ko.bindingHandlers.droppableView={init:function(b,c,d){function e(b,c){var d=a.grep(c,function(a,c){return a.id===b.id});return b.rdo.attributes.writable&&0===d.length}"folder"!==c().rdo.type&&"parent"!==c().rdo.type||a(b).droppable({enableExtendedEvents:!0,accept:function(a){var b=ko.dataFor(a[0]),c=b?b.rdo.type:null;return"file"===c||"folder"===c},over:function(b,c){var d=ko.dataFor(b.target),f=E.itemsModel.getSelected();e(d,f)?a(this).addClass("drop-hover"):c.helper.addClass("drop-restricted")},out:function(b,c){a(this).removeClass("drop-hover"),c.helper.removeClass("drop-restricted")},drop:function(b,c){var d=ko.dataFor(b.target),f=E.itemsModel.getSelected();return a(b.target).removeClass("drop-hover"),!!e(d,f)&&void wa(f,function(a,b){return Da(b.rdo,d.id)})}})}},v.selectable({filter:"li:not(.directory-parent), tbody > tr:not(.directory-parent)",cancel:".directory-parent, thead",disabled:!x.manager.selection.enabled,appendTo:v,start:function(a,b){xa(),E.itemsModel.isSelecting(!0)},stop:function(a,b){E.itemsModel.isSelecting(!1)},selected:function(a,b){var c=ko.dataFor(b.selected);c.selected(!0)},unselected:function(a,b){var c=ko.dataFor(b.unselected);c.selected(!1)}}),ko.bindingHandlers.draggableTree={init:function(b,c,d){var e=c();"file"!==e.rdo.type&&"folder"!==e.rdo.type||a(b).draggable({distance:3,cursor:"pointer",refreshPositions:!1,helper:function(){return a("
  • ").append(a(this).clone())},appendTo:x.customScrollbar.enabled?s.find(".mCustomScrollBox"):s,drag:function(b,c){a(this).draggable("option","refreshPositions",E.treeModel.isScrolling())}})}},ko.bindingHandlers.droppableTree={init:function(b,c,d){"folder"!==c().rdo.type&&"parent"!==c().rdo.type||a(b).droppable({hoverClass:"drop-hover",accept:function(b){if(b.closest("ul").prev("a").is(a(this)))return!1;if(a.contains(b.parent()[0],this))return!1;var c=ko.dataFor(b[0]),d=c?c.rdo.type:null;return"file"===d||"folder"===d},drop:function(a,b){Da(ko.dataFor(b.draggable[0]),ko.dataFor(a.target).id)}})}},r.contextMenu({selector:".view-items",zIndex:10,build:function(a,b){var c={createFolder:{name:y.create_folder,className:"create-folder"},paste:{name:y.clipboard_paste,className:"paste",disabled:function(a,b){return E.clipboardModel.isEmpty()}}};return E.clipboardModel.enabled()&&x.options.browseOnly!==!0||delete c.paste,{appendTo:".fm-container",items:c,reposition:!1,callback:function(a,b){switch(a){case"createFolder":E.headerModel.createFolder();break;case"paste":E.clipboardModel.paste()}}}}}),x.extras.extra_js)for(var g=0;g400&&(this.yStartPosition=this.mcs.top),E.itemsModel.isSelecting()&&E.itemsModel.continiousSelection(!0);var b=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);v.selectable("repositionCssHelper",b,0)}}},axis:"y",alwaysShowScrollbar:0}));var h=document.documentElement;if(h.setAttribute("data-useragent",navigator.userAgent),x.options.logger){(new Date).getTime()}var i=l.find(".fm-loading-wrap");i.fadeOut(800,function(){k.setDimensions()}),k.setDimensions()},O=function(){var b=this;this.config=ko.observable(x),this.lg=ko.observable(y),this.localizeGUI=ko.observable(x.options.localizeGUI),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(x.options.defaultViewMode),this.currentPath=ko.observable(z),this.browseOnly=ko.observable(x.options.browseOnly),this.previewModel=ko.observable(null),this.previewFile.subscribe(function(a){a||(b.previewModel.closeEditor(),b.itemsModel.descriptivePanel.rdo().id===b.previewModel.rdo().id&&b.itemsModel.descriptivePanel.render(b.previewModel.viewer.content()))}),this.addItem=function(a,b){var c=E.treeModel.findByParam("id",b);if(c){var d=E.treeModel.createNode(a);E.treeModel.addNodes(c,d)}E.currentPath()===b&&E.itemsModel.addNew(a)},this.removeItem=function(a){var b=E.treeModel.findByParam("id",a.id);b&&b.remove();var c=E.itemsModel.findByParam("id",a.id);c&&c.remove()};var c=function(){var a=this;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 q,this.editor=new r,this.rdo.subscribe(function(b){a.cdo({isFolder:"folder"===b.type,sizeFormatted:W(b.attributes.size),dimensions:b.attributes.width?b.attributes.width+"x"+b.attributes.height:null})}),this.editor.content.subscribe(function(b){a.editor.isInteractive()&&a.renderer.render(b)}),this.applyObject=function(c){b.previewFile(!1);var d=c.attributes.name,e={interactive:!1},f={type:"default",url:null,options:{}};a.rdo(c),ka(d)&&(f.type="image",f.url=ta(c,!1,!0)),ma(d)&&x.viewer.audio.enabled===!0&&(f.type="audio",f.url=sa(c,!0)),la(d)&&x.viewer.video.enabled===!0&&(f.type="video",f.url=sa(c,!0),f.options={width:x.viewer.video.playerWidth,height:x.viewer.video.playerHeight}),na(d)&&x.viewer.opendoc.enabled===!0&&(f.type="opendoc",f.url=k.settings.baseUrl+"/scripts/ViewerJS/index.html#"+sa(c,!0),f.options={width:x.viewer.opendoc.readerWidth,height:x.viewer.opendoc.readerHeight}),oa(d)&&x.viewer.google.enabled===!0&&(f.type="google",f.url="http://docs.google.com/viewer?url="+encodeURIComponent(sa(c,!1))+"&embedded=true",f.options={width:x.viewer.google.readerWidth,height:x.viewer.google.readerHeight}),(pa(d)&&x.viewer.codeMirrorRenderer.enabled===!0||qa(d)&&x.viewer.markdownRenderer.enabled===!0)&&(f.type="renderer",a.renderer.setRenderer(c),e.interactive=a.renderer.renderer().interactive),a.viewer.type(f.type),a.viewer.url(f.url),a.viewer.options(f.options),a.viewer.pureUrl(ka(d)?ta(c,!1,!1):sa(c,!1)),a.viewer.isEditable(ja(d)&&x.viewer.editable.enabled===!0),a.editor.isInteractive(e.interactive),"renderer"===f.type||a.viewer.isEditable()?Ha(c).then(function(c){if(c.data){var d=c.data.attributes.content;a.viewer.content(d),b.previewFile(!0)}}):b.previewFile(!0)},ZeroClipboard.config({swfPath:k.settings.baseUrl+"/scripts/zeroclipboard/dist/ZeroClipboard.swf"}),this.afterRender=function(){a.renderer.render(a.viewer.content());var b=new ZeroClipboard(u.find(".btn-copy-url")[0]);b.on("ready",function(a){b.on("aftercopy",function(a){k.success(y.copied)})})},this.initiateEditor=function(b){var c=u.find(".fm-cm-editor-content")[0];a.editor.createInstance(a.rdo().attributes.extension,c,{readOnly:!1,styleActiveLine:!0})},this.bindToolbar=function(b){d(a.rdo(),b)&&La(b,a.rdo())},this.previewIconClass=ko.pureComputed(function(){var b=[],c=["ico"];return"default"!==a.viewer.type()&&a.viewer.url()||(b.push("grid-icon"),this.cdo().isFolder===!0?(b.push("ico_folder"),c.push("folder"),this.rdo().attributes.readable||c.push("lock")):(b.push("ico_file"),this.rdo().attributes.readable?c.push("ext",this.rdo().attributes.extension):c.push("file","lock")),b.push(c.join("_"))),b.join(" ")},this),this.editFile=function(){var b=a.viewer.content();a.renderer.render(b),a.editor.render(b)},this.saveFile=function(){Ia(a.rdo())},this.closeEditor=function(){a.editor.enabled(!1),a.renderer.render(a.viewer.content())},this.buttonVisibility=function(b){switch(b){case"select":return d(a.rdo(),b)&&g();case"move":case"rename":case"delete":case"replace":return d(a.rdo(),b)&&x.options.browseOnly!==!0;case"download":return d(a.rdo(),b)}}},e=function(){var b=this;this.isScrolling=ko.observable(!1),this.selecledNode=ko.observable(null),this.treeData={id:z,level:ko.observable(-1),children:ko.observableArray([])},this.treeData.children.subscribe(function(a){b.arrangeNode(b.treeData)});var c=function(a){if(null!==F){a||(a=b.treeData);var c=b.findByFilter(function(a){return 0===F.indexOf(a.id)},a);c?(x.filetree.expandSpeed=10,b.loadNodes(c,!1)):(F=null,x.filetree.expandSpeed=200)}};this.findByParam=function(a,c,d){if(!d&&(d=b.treeData,d[a]===c))return d;var e=d.children();if(!e||0===e.length)return null;for(var f=0,g=e.length;f-1||B.indexOf("move")>-1;this.enabled=ko.observable(b.config().options.clipboard&&f),this.copy=function(){e.hasCapability("copy")&&(d="copy",c=b.itemsModel.getSelected())},this.cut=function(){e.hasCapability("cut")&&(d="cut",c=b.itemsModel.getSelected())},this.paste=function(){if(e.hasCapability("paste")){if(null===d||0===c.length)return void k.warning(y.clipboard_empty);var f=b.currentPath();wa(c,function(a,b){return"cut"===d?Da(b,f):"copy"===d?Ca(b,f):void 0},a)}},this.clear=function(){e.hasCapability("clear")&&(a(),k.success(y.clipboard_cleared))},this.isEmpty=function(){return 0===c.length},this.hasCapability=function(a){if(!e.enabled)return!1;switch(a){case"copy":return B.indexOf("copy")>-1;case"cut":return B.indexOf("move")>-1;default:return!0}}},p=function(){var a=this;this.items=ko.observableArray([]),this.add=function(b,d){a.items.push(new c(b,d))},this.splitCurrent=function(){var c=z,d=b.currentPath(),e=d.replace(new RegExp("^"+z),"").split("/");for(a.items([]),a.add(z,"");e.length>0;){var f=e.shift();f&&(c+=f+"/",a.add(c,f))}};var c=function(a,c){var d=this;this.path=a,this.label=c,this.isRoot=a===z,this.active=a===b.currentPath(),this.itemClass=function(){var a=["nav-item"];return d.isRoot&&a.push("root"),d.active&&a.push("active"),a.join(" ")},this["goto"]=function(a,c){a.active||b.itemsModel.loadList(a.path)}}},q=function(){var b,c=this;this.rdo=ko.observable({}),this.content=ko.observable(null),this.renderer=ko.observable(null),this.render=function(a){c.renderer()&&c.renderer().processContent(a)},this.setRenderer=function(a){c.rdo(a),qa(a.attributes.name)?c.renderer(new e):c.renderer(new d)},this.setContainer=function(d){a.each(d,function(){if(a(this).hasClass("fm-renderer-container"))return b=a(this),!1}),c.renderer().processDomElements(b)};var d=function(){this.name="codeMirror",this.interactive=!1;var a=new r;this.processContent=function(b){a.render(b),c.content(b)},this.processDomElements=function(b){if(!a.instance){var d=b.find(".fm-cm-renderer-content")[0];a.createInstance(c.rdo().attributes.extension,d,{readOnly:"nocursor",styleActiveLine:!1,lineNumbers:!1})}}},e=function(){function d(){b.find("a").each(function(){var b=a(this).attr("href"),c=E.previewModel.editor;if(c.enabled()&&c.isInteractive())a(this).off("click"),a(this).on("click",function(){return!1});else{if(b.search("://")!=-1||ca(b,"mailto:"))return;qa(b)&&a(this).on("click",function(a){return Ja(b).then(function(a){a.data&&h(a.data)}),!1})}})}this.name="markdown",this.interactive=!0;var e=window.markdownit({html:!0,linkify:!0,typographer:!0,highlight:function(a,b){if(b&&hljs.getLanguage(b))try{return'
    '+hljs.highlight(b,a,!0).value+"
    "; -}catch(c){}return'
    '+md.utils.escapeHtml(a)+"
    "},replaceLink:function(a,b){if(a.search("://")!=-1||ca(a,"mailto:"))return a;var d=ca(a,"/")?z:ha(c.rdo().id),e=d+aa(a,"/");return qa(e)?e:ra({mode:"readfile",path:e})}}).use(window.markdownitReplaceLink);this.processContent=function(a){var b=e.render(a);c.content(b),d()},this.processDomElements=function(a){}}},r=function(){function b(a){d.enabled(!0),d.instance.setValue(a),setTimeout(function(){d.instance.refresh()},0)}function c(a){var b=[],c="default";x.viewer.editable.codeHighlight&&("js"===a&&(b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),c="javascript"),"css"===a&&(b.push("/scripts/CodeMirror/mode/css/css.js"),c="css"),"html"===a&&(b.push("/scripts/CodeMirror/mode/xml/xml.js"),c="text/html"),"xml"===a&&(b.push("/scripts/CodeMirror/mode/xml/xml.js"),c="application/xml"),"php"===a&&(b.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/scripts/CodeMirror/mode/xml/xml.js"),b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),b.push("/scripts/CodeMirror/mode/css/css.js"),b.push("/scripts/CodeMirror/mode/clike/clike.js"),b.push("/scripts/CodeMirror/mode/php/php.js"),c="application/x-httpd-php"),"java"===a&&(b.push("/scripts/CodeMirror/mode/clike/clike.js"),c="text/x-java"),"sql"===a&&(b.push("/scripts/CodeMirror/mode/sql/sql.js"),c="text/x-mysql"),"md"===a&&(b.push("/scripts/CodeMirror/addon/mode/overlay.js"),b.push("/scripts/CodeMirror/mode/xml/xml.js"),b.push("/scripts/CodeMirror/mode/markdown/markdown.js"),b.push("/scripts/CodeMirror/mode/gfm/gfm.js"),b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),b.push("/scripts/CodeMirror/mode/css/css.js"),b.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/scripts/CodeMirror/mode/clike/clike.js"),b.push("/scripts/CodeMirror/mode/shell/shell.js"),b.push("/scripts/CodeMirror/mode/meta.js"),c="gfm"),"sh"===a&&(b.push("/scripts/CodeMirror/addon/mode/overlay.js"),b.push("/scripts/CodeMirror/mode/markdown/markdown.js"),b.push("/scripts/CodeMirror/mode/gfm/gfm.js"),b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),b.push("/scripts/CodeMirror/mode/css/css.js"),b.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/scripts/CodeMirror/mode/clike/clike.js"),b.push("/scripts/CodeMirror/mode/meta.js"),b.push("/scripts/CodeMirror/mode/shell/shell.js"),c="shell")),b.length?(b.push(function(){d.mode(c)}),S(b)):d.mode(c)}var d=this,e=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(a){a&&(d.instance.setOption("mode",a),e&&(b(e),e=null))}),this.render=function(a){d.mode()?b(a):e=a},this.createInstance=function(b,e,f){var g,h={readOnly:"nocursor",styleActiveLine:!1,viewportMargin:1/0,lineNumbers:x.viewer.editable.lineNumbers,lineWrapping:x.viewer.editable.lineWrapping,theme:x.viewer.editable.theme,matchBrackets:x.viewer.editable.matchBrackets,extraKeys:{F11:function(a){a.setOption("fullScreen",!a.getOption("fullScreen"))},Esc:function(a){a.getOption("fullScreen")&&a.setOption("fullScreen",!1)}}};g=CodeMirror.fromTextArea(e,a.extend({},h,f)),g.on("changes",function(a,b){d.content(a.getValue())}),d.instance=g,c(b)}};this.treeModel=new e,this.itemsModel=new f,this.tableViewModel=new j,this.previewModel=new c,this.headerModel=new l,this.summaryModel=new m,this.searchModel=new n,this.clipboardModel=new o,this.breadcrumbsModel=new p},P=function(a){function b(a){var b,c=C;switch("list"===E.viewMode()&&(c=E.itemsModel.listSortField()),c){case"type":b=a.rdo.attributes.extension||"";break;case"size":b=a.rdo.attributes.size;break;case"modified":b=a.rdo.attributes.timestamp;break;case"dimensions":b=a.cdo.dimensions||"";break;default:b=a.rdo.attributes.name}return"string"==typeof b&&(f.cases||(b=b.toLowerCase()),b=b.replace(/\s+/g," ")),b}function c(a,b){for(var c=d(a.toString()),e=d(b.toString()),f=0;c[f]&&e[f];f++)if(c[f]!==e[f]){var g=Number(c[f]),h=Number(e[f]);return g==c[f]&&h==e[f]?g-h:c[f]>e[f]?1:-1}return c.length-e.length}function d(a){for(var b,c,d=[],e=0,f=-1,g=0;b=(c=a.charAt(e++)).charCodeAt(0);){var h=46==b||b>=48&&b<=57;h!==g&&(d[++f]="",g=h),d[f]+=c}return d}var e="list"===E.viewMode()?E.itemsModel.listSortOrder():D,f={natural:!0,order:"asc"===e?1:-1,cases:!1};a.sort(function(a,d){if("parent"===a.rdo.type)return-1;var e,g=b(a),h=b(d);return e=g===h?0:void 0===g||void 0===h?0:f.natural&&(isNaN(g)||isNaN(h))?c(g,h):gh?1:0,e*=f.order});for(var g=[],h=a.length;h--;)"folder"===a[h].rdo.type&&(g.push(a[h]),a.splice(h,1));"top"!==x.options.folderPosition&&g.reverse();for(var i=0,j=g.length;i1&&g.then(function(){k.log(y.successful_processed.replace("%s",e).replace("%s",f))}),g.then(function(){"function"==typeof d&&d()})},xa=function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}},ya=function(a){var b=null,c=sa(a,!0);if(c=k.settings.callbacks.beforeSelectItem(a,c),window.tinyMCEPopup){var d=tinyMCEPopup.getWindowArg("window");return d.document.getElementById(tinyMCEPopup.getWindowArg("input")).value=c,"undefined"!=typeof d.ImageDialog&&(d.ImageDialog.getImageData&&d.ImageDialog.getImageData(),d.ImageDialog.showPreviewImage&&d.ImageDialog.showPreviewImage(c)),void tinyMCEPopup.close()}if(G.param("field_name")&&(parent.document.getElementById(G.param("field_name")).value=c,"undefined"!=typeof parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),"undefined"!=typeof parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),G.param("ImperaviElementId"))if(window.opener);else{var e=G.param("ImperaviElementId"),f=parent.$("#"+e).redactor("core.getObject");f&&(f.modal.close(),f.buffer.set(),ka(a.attributes.name)?f.insert.html(''):f.insert.html(''+a.attributes.name+""))}if(G.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(G.param("CKEditorFuncNum"),c):(parent.CKEDITOR.tools.callFunction(G.param("CKEditorFuncNum"),c),parent.CKEDITOR.tools.callFunction(G.param("CKEditorCleanUpFuncNum")))),window.opener&&"function"==typeof window.opener.SetUrl)if(a.attributes.width){var g=c,h=a.attributes.width,i=a.attributes.height;window.opener.SetUrl(g,h,i)}else window.opener.SetUrl(c);window.opener&&(b=window.opener),window.parent&&window.self!==window.parent&&(b=window.parent),b&&b.postMessage({source:"richfilemanager",preview_url:c},"*"),k.settings.callbacks.afterSelectItem(a,c,b)},za=function(b){var c=function(c,d){var e=b.id,f=d.getInputValue();if(!f)return void k.error(y.new_filename);if(!x.security.allowChangeExtensions){f=V(f);var g=fa(b.attributes.name);g.length>0&&(f=f+"."+g)}if($(e)&&!Z(f)){var h="

    "+y.INVALID_FILE_TYPE+"

    ";return"DISALLOW_ALL"==x.upload.policy&&(h+="

    "+y.ALLOWED_FILE_TYPE+x.upload.restrictions.join(", ")+".

    "),"ALLOW_ALL"==x.upload.policy&&(h+="

    "+y.DISALLOWED_FILE_TYPE+x.upload.restrictions.join(", ")+".

    "),a("#filepath").val(""),void k.error(h)}a.ajax({type:"GET",url:ra({mode:"rename",old:e,"new":f}),dataType:"json",success:function(a){if(a.data){var b=a.data,c=E.treeModel.findByParam("id",e);if(c&&("folder"===c.rdo.type&&(c.nodeTitle(b.attributes.name),E.treeModel.actualizeNodeObject(c,e,b.id)),"file"===c.rdo.type)){var f=c.parentNode(),g=E.treeModel.createNode(b);c.remove(),f&&E.treeModel.addNodes(f,g)}var h=E.itemsModel.findByParam("id",e);h&&("parent"===h.rdo.type?h.id=b.id:(h.remove(),E.itemsModel.addNew(b))),E.currentPath()===e&&E.itemsModel.loadList(b.id),E.previewFile()&&E.previewModel.rdo().id===e&&E.previewModel.applyObject(b),d.closeDialog(),x.options.showConfirmation&&k.success(y.successful_rename)}Y(a)},error:X})};k.prompt({message:y.new_filename,value:x.security.allowChangeExtensions?b.attributes.name:ga(b.attributes.name),okBtn:{label:y.action_rename,autoClose:!1,click:c},cancelBtn:{label:y.cancel}})},Aa=function(b){var c=a("#fm-js-preview-toolbar"),d=c.find(":file");"undefined"==typeof c.data("blueimpFileupload")&&c.fileupload({autoUpload:!0,dataType:"json",url:ra(),paramName:x.upload.paramName}).on("fileuploadadd",function(a,c){var d=c.files[0];return fa(d.name)!=b.attributes.extension?(k.error(y.ERROR_REPLACING_FILE+" ."+b.attributes.extension),!1):void c.submit()}).on("fileuploadsubmit",function(a,c){c.formData={mode:"replace",path:b.id},w.addClass("loading").prop("disabled",!0),w.children("span").text(y.loading_data)}).on("fileuploadalways",function(a,b){w.removeData().removeClass("loading").prop("disabled",!1),w.children("span").text(y.action_upload);var c=b.result;if(c&&c.errors&&k.error(y.upload_failed+"
    "+c.errors[0].title),c&&c.data){var d=c.data[0];E.removeItem(d),E.addItem(d,E.currentPath()),E.previewFile()&&E.previewModel.applyObject(d),x.options.showConfirmation&&k.success(y.successful_replace)}}).on("fileuploadchunkdone",function(a,b){var c=b.result;if(c.data&&c.data[0]){var d=c.data[0];E.removeItem(d),E.addItem(d,E.currentPath())}}).on("fileuploadfail",function(a,b){k.error(y.upload_failed)}),d.click()},Ba=function(a,b){var c=function(a,c){var d=c.getInputValue();return d?(d=ba(d,"/")+"/",void b(d)):void k.error(y.prompt_foldername)},d=a.length,e=d>1?y.prompt_move_multiple.replace("%s",d):y.prompt_move;k.prompt({message:e,value:E.currentPath(),okBtn:{label:y.action_move,autoClose:!1,click:c},cancelBtn:{label:y.cancel},template:{dialogInput:'
    '+y.help_move+"
    "}})},Ca=function(b,c){return a.ajax({type:"GET",url:ra({mode:"copy",source:b.id,target:c}),dataType:"json",success:function(a){if(a.data){var b=a.data;E.addItem(b,c),alertify.clearDialogs(),x.options.showConfirmation&&k.success(y.successful_copied)}Y(a)},error:X})},Da=function(b,c){return a.ajax({type:"GET",url:ra({mode:"move",old:b.id,"new":c}),dataType:"json",success:function(a){if(a.data){var d=a.data;E.removeItem(b),E.addItem(d,c),E.currentPath()===b.id&&E.itemsModel.loadList(d.id),E.previewFile()&&E.previewModel.rdo().id===b.id&&E.previewFile(!1),alertify.clearDialogs(),x.options.showConfirmation&&k.success(y.successful_moved)}Y(a)},error:X})},Ea=function(a,b){var c=a.length,d=c>1?y.confirm_delete_multiple.replace("%s",c):y.confirm_delete;k.confirm({message:d,okBtn:{label:y.yes,click:function(a,c){b()}},cancelBtn:{label:y.no}})},Fa=function(b){return a.ajax({type:"GET",url:ra({mode:"delete",path:b}),dataType:"json",success:function(a){if(a.data){var b=a.data;E.removeItem(b),E.previewFile()&&E.previewModel.rdo().id===b.id&&E.previewFile(!1),x.options.showConfirmation&&k.success(y.successful_delete)}Y(a)},error:X})},Ga=function(b){var c={mode:"download",path:b.id};return a.ajax({type:"GET",url:ra(c),dataType:"json",success:function(b){b.data&&a.fileDownload(ra(c)),Y(b)},error:X})},Ha=function(b){return a.ajax({type:"GET",url:ra({mode:"editfile",path:b.id}),dataType:"json",success:function(a){Y(a)},error:X})},Ia=function(b){a.ajax({type:"POST",url:ra(),dataType:"json",data:a("#fm-js-editor-form").serializeArray(),success:function(a){if(a.data){var b=a.data,c=E.previewModel,d=c.editor.content();c.rdo(b),c.viewer.content(d),c.closeEditor();var e=E.itemsModel.createObject(b),f=E.itemsModel.findByParam("id",b.id);E.itemsModel.objects.replace(f,e),k.success(y.successful_edit)}Y(a)},error:X})},Ja=function(b){return a.ajax({type:"GET",url:ra({mode:"getfile",path:b}),dataType:"json",success:function(a){Y(a)},error:X})},Ka=function(){a.ajax({type:"GET",url:ra({mode:"summarize"}),dataType:"json",success:function(b){if(b.data){var c=b.data.attributes,d=W(c.size,!0);if(c.sizeLimit>0){var e=W(c.sizeLimit,!0),f=100*c.size/c.sizeLimit,g=Math.round(100*f)/100;d+=" ("+g+"%) "+y.of+" "+e}E.summaryModel.files(c.files),E.summaryModel.folders(c.folders),E.summaryModel.size(d),E.summaryModel.enabled(!0);var h=a("#summary-popup").clone().show();E.summaryModel.enabled(!1),k.alert(h[0].outerHTML)}Y(b)},error:X})},La=function(b,c,d){var e=d?d:[c];switch(b){case"select":ya(c);break;case"download":a.each(e,function(a,b){Ga(b)});break;case"rename":za(c);break;case"replace":Aa(c);break;case"move":Ba(e,function(a){wa(e,function(b,c){return Da(c,a)})});break;case"delete":Ea(e,function(){wa(e,function(a,b){return Fa(b.id)})});break;case"copy":E.clipboardModel.copy();break;case"cut":E.clipboardModel.cut()}},Ma=function(){return!x.options.browseOnly&&void(x.upload.multiple?(a("#file-input-container").remove(),w.unbind().click(function(){if(B.indexOf("upload")===-1)return k.error(y.NOT_ALLOWED),!1;var b=null,c=E.currentPath(),d=tmpl("tmpl-fileupload-container",{folder:y.current_folder+c,info:y.upload_files_number_limit.replace("%s",x.upload.maxNumberOfFiles)+" "+y.upload_file_size_limit+W(x.upload.fileSizeLimit,!0),lang:y});"DISALLOW_ALL"==x.upload.policy&&(b=new RegExp("(\\.|\\/)("+x.upload.restrictions.join("|")+")$","i")),k.dialog({message:d,width:"auto",buttons:[{type:"ok",label:y.action_upload,autoClose:!1,click:function(a,b){f.children(".upload-item").length>0?f.find(".button-start").trigger("click"):k.error(y.upload_choose_file)}},{label:y.action_select,closeOnClick:!1,click:function(b,c){a("#fileupload",e).trigger("click")}},{type:"cancel",label:y.close}]});var e=a(".fm-fileupload-container"),f=a(".dropzone",e),g=a(".dropzone-wrapper",e),h=a("#total-progress",e).children();x.customScrollbar.enabled&&g.mCustomScrollbar({theme:x.customScrollbar.theme,scrollButtons:{enable:x.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){g.find(".mCSB_container").css({"margin-right":g.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){g.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),g.on("click",function(b){(b.target===this||a(b.target).parent()[0]===this||b.target===f[0]||a(b.target).parent().hasClass("default-message"))&&a("#fileupload",e).trigger("click")}),f.on("click",".button-start",function(b){var c=a(this),d=c.parent().parent(),e=d.data();e.submit(),c.remove()}),f.on("click",".button-abort",function(b){var c=a(this),d=c.parent().parent(),e=d.data(),f=e.files[0].context;e.abort(),f.find(".error-message").text(y.upload_aborted),f.addClass("aborted")}),f.on("click",".button-resume",function(b){function d(c){a.blueimp.fileupload.prototype.options.add.call(a("#fileupload")[0],b,c),c.submit()}var e=a(this),f=e.parent().parent(),g=f.data(),h=g.files[0];if(h.chunkUploaded){var i=c+h.serverName;Ja(i).then(function(a){a.data&&(g.uploadedBytes=Number(a.data.attributes.size),g.uploadedBytes||(h.chunkUploaded=void 0),d(g))})}else d(g)}),f.on("click",".button-remove",function(b){var d=a(this),e=d.parent().parent(),f=e.data(),g=f.files[0];g.chunkUploaded&&Fa(c+g.serverName),d.closest(".upload-item").remove(),i()}),f.on("click",".button-info",function(b){var c=a(this),d=c.closest(".upload-item");if(d.hasClass("error")){var e=d.find(".error-message");k.error(e.text())}});var i=function(){f.children(".upload-item").length>0?f.addClass("started"):f.removeClass("started")};a("#fileupload",e).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:f,maxChunkSize:x.upload.chunkSize,url:ra(),paramName:x.upload.paramName,singleFileUploads:!0,formData:{mode:"upload",path:c},maxNumberOfFiles:x.upload.maxNumberOfFiles,acceptFileTypes:b,maxFileSize:x.upload.fileSizeLimit,messages:{maxNumberOfFiles:y.upload_files_number_limit.replace("%s",x.upload.maxNumberOfFiles),acceptFileTypes:y.upload_file_type_invalid,maxFileSize:y.upload_file_too_big+" "+y.upload_file_size_limit+W(x.upload.fileSizeLimit,!0)},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(b,c){var d=f.children(".upload-item");a.each(c.files,function(b,e){if(d.length>=x.upload.maxNumberOfFiles)return k.error(y.upload_files_number_limit.replace("%s",x.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;e.formattedSize=W(e.size);var g=a(tmpl("tmpl-upload-item",{file:e,lang:y,imagesPath:k.settings.baseUrl+"/scripts/jQuery-File-Upload/img"}));e.context=g,g.find(".buttons").data(c),g.appendTo(f)}),i()}).on("fileuploadsend",function(b,c){a.each(c.files,function(a,b){var d=b.context;d.removeClass("added aborted error").addClass("process"),b.chunkUploaded&&c.total===c.uploadedBytes&&d.remove()})}).on("fileuploadfail",function(b,c){a.each(c.files,function(a,b){b.error=y.upload_failed;var c=b.context;c.removeClass("added process").addClass("error")})}).on("fileuploaddone",function(b,c){var d=c.result;a.each(c.files,function(a,b){var c=b.context;d&&d.errors?(c.removeClass("added process").addClass("error"),c.find(".error-message").text(d.errors[0].title),c.find(".button-start").remove()):c.remove()})}).on("fileuploadalways",function(b,c){var d=c.result;a.each(c.files,function(a,b){if(d&&d.data&&d.data[a]){var c=d.data[a];E.removeItem(c),E.addItem(c,E.currentPath())}});var e=f.children(".upload-item");0===e.filter(".added").length&&0===e.filter(".process").length&&(0===e.length&&(alertify.clearDialogs(),x.options.showConfirmation&&k.success(y.upload_successful_files)),e.filter(".error").length&&k.error(y.upload_partially+"
    "+y.upload_failed_details)),i()}).on("fileuploadchunkdone",function(b,c){var d=c.result;a.each(c.files,function(a,b){if(d.data&&d.data[a]){var c=d.data[a];E.removeItem(c),E.addItem(c,E.currentPath()),b.serverName=c.attributes.name,b.chunkUploaded=1}})}).on("fileuploadprocessalways",function(b,c){a.each(c.files,function(a,b){var c=b.context;"undefined"!=typeof c&&(b.preview&&(c.find(".image").append(b.preview),c.find(".preview").removeClass("file-preview").addClass("image-preview")),b.error&&(c.removeClass("added process").addClass("error"),c.find(".error-message").text(b.error),c.find(".button-start").remove()))})}).on("fileuploadprogress",function(b,c){a.each(c.files,function(a,b){var d=b.context,e=parseInt(c.loaded/c.total*100,10);d.find(".progress-bar").css("width",e+"%")})}).on("fileuploadprogressall",function(a,b){var c=parseInt(b.loaded/b.total*100,10);h.css("width",c+"%")})})):(w.click(function(){if(B.indexOf("upload")===-1)return k.error(y.NOT_ALLOWED),!1;var b=a(this).data();a.isEmptyObject(b)?k.error(y.upload_choose_file):b.submit()}),o.fileupload({autoUpload:!1,dataType:"json",url:ra(),paramName:x.upload.paramName,maxChunkSize:x.upload.chunkSize}).on("fileuploadadd",function(a,b){w.data(b)}).on("fileuploadsubmit",function(a,b){b.formData={mode:"upload",path:E.currentPath()},w.addClass("loading").prop("disabled",!0),w.children("span").text(y.loading_data)}).on("fileuploadalways",function(b,c){a("#filepath").val(""),w.removeData().removeClass("loading").prop("disabled",!1),w.children("span").text(y.action_upload);var d=c.result;if(d&&d.errors&&k.error(y.upload_failed+"
    "+d.errors[0].title),d&&d.data){var e=d.data[0];E.removeItem(e),E.addItem(e,E.currentPath()),x.options.showConfirmation&&k.success(y.upload_successful_file)}}).on("fileuploadchunkdone",function(a,b){var c=b.result;if(c.data&&c.data[0]){var d=c.data[0];E.removeItem(d),E.addItem(d,E.currentPath())}}).on("fileuploadfail",function(a,b){k.error(y.upload_failed)})))};H(),a(window).resize(k.setDimensions)}}(jQuery),$.fn.richFilemanager=function(a){return this.each(function(){if(void 0==$(this).data("richFilemanager")){var b=new $.richFilemanagerPlugin(this,a);$(this).data("richFilemanager",b)}})},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(a){a.richFilemanagerPlugin=function(b,c){function d(b,c){return B.indexOf(c)!==-1&&(("folder"!==b.type||"replace"!==c)&&(("folder"!==b.type||"select"!==c)&&("folder"===b.type&&"download"===c?x.security.allowFolderDownload===!0:"undefined"==typeof b.attributes.capabilities||a.inArray(c,b.attributes.capabilities)>-1)))}function e(){x.filetree.enabled&&(s.show(),p.splitter({sizeLeft:x.filetree.width,minLeft:x.filetree.minWidth,minRight:200}),E.treeModel.loadNodes(null,!1))}function f(){E.itemsModel.loadList(z)}function g(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||G.param("field_name")||G.param("CKEditor")||G.param("ImperaviElementId")}function h(a){return a.attributes.readable?("file"===a.type&&E.previewModel.applyObject(a),void("folder"!==a.type&&"parent"!==a.type||(E.previewFile(!1),E.itemsModel.loadList(a.id)))):(k.error(y.NOT_ALLOWED_SYSTEM),!1)}function i(a){var b=!E.clipboardModel.enabled(),c={select:{name:y.action_select,className:"select"},download:{name:y.action_download,className:"download"},rename:{name:y.action_rename,className:"rename"},move:{name:y.action_move,className:"move"},replace:{name:y.action_replace,className:"replace"},separator1:"-----",copy:{name:y.clipboard_copy,className:"copy"},cut:{name:y.clipboard_cut,className:"cut"},"delete":{name:y.action_delete,className:"delete"}};return d(a,"download")||delete c.download,d(a,"select")&&g()||delete c.select,d(a,"rename")&&x.options.browseOnly!==!0||delete c.rename,d(a,"delete")&&x.options.browseOnly!==!0||delete c["delete"],d(a,"copy")&&x.options.browseOnly!==!0&&!b||delete c.copy,d(a,"move")&&x.options.browseOnly!==!0&&!b||(delete c.cut,delete c.move),delete c.replace,c}var j={baseUrl:".",config:{},callbacks:{beforeCreateImageUrl:function(a,b){return b},beforeCreatePreviewUrl:function(a,b){return b},beforeSelectItem:function(a,b){return b},afterSelectItem:function(a,b,c){}}},k=this,l=a(b),m=l.children(".fm-wrapper"),n=m.find(".fm-header"),o=n.find(".fm-uploader"),p=m.children(".fm-splitter"),q=m.children(".fm-footer"),r=p.children(".fm-fileinfo"),s=p.children(".fm-filetree"),t=r.find(".view-items-wrapper"),u=r.find(".fm-preview-wrapper"),v=t.find(".view-items"),w=o.children(".fm-upload"),x=null,y=null,z="/",A=null,B=[],C=null,D=null,E=null,F=null,G=purl();(new Date).getTime();k.settings=a.extend(!0,j,c),k.log=function(b,c){var d=alertify,e=a.extend({},{reset:!0,delay:5e3,logMaxItems:5,logPosition:"bottom right",logContainerClass:"fm-log",parent:a(".fm-popup").is(":visible")?document.body:r[0],onClick:void 0,unique:!1,type:"log"},c);return e.logClass&&e.unique&&a(".fm-log").children("."+e.logClass).length>0?d:(e.reset&&d.reset(),e.parent&&d.parent(e.parent),d.logDelay(e.delay),d.logMaxItems(e.logMaxItems),d.logPosition(e.logPosition),d.logContainerClass(e.logContainerClass),d[e.type](b,e.onClick),d)},k.error=function(b,c){return k.log(b,a.extend({},{type:"error",delay:1e4},c))},k.warning=function(b,c){return k.log(b,a.extend({},{type:"warning",delay:1e4},c))},k.success=function(b,c){return k.log(b,a.extend({},{type:"success",delay:6e3},c))},k.alert=function(a){alertify.reset().dialogContainerClass("fm-popup").alert(a)},k.confirm=function(a){alertify.reset().dialogWidth(a.width).dialogPersistent(a.persistent).dialogContainerClass("fm-popup").confirm(a.message,a.okBtn,a.cancelBtn)},k.prompt=function(a){alertify.reset().dialogWidth(a.width).dialogPersistent(a.persistent).dialogContainerClass("fm-popup").theme(a.template).prompt(a.message,a.value||"",a.okBtn,a.cancelBtn)},k.dialog=function(a){alertify.reset().dialogWidth(a.width).dialogPersistent(a.persistent).dialogContainerClass("fm-popup").dialog(a.message,a.buttons)},k.setDimensions=function(){var b=m.outerHeight(!0)-m.height(),c=a(window).height()-n.height()-q.height()-b,d=p.width()-p.children(".splitter-bar-vertical").outerWidth()-s.outerWidth();p.height(c),r.width(d)};var H=function(){var b=a.Deferred();b.then(function(){return I()}).then(function(a,b){return J()}).then(function(){return K()}).then(function(){return L()}).then(function(){M(function(){N()})}),b.resolve()},I=function(){return a.when(R("default"),R("user")).done(function(b,c){var d=b[0],e=c[0];if(void 0!==e&&null!==e&&delete e.version,x=a.extend({},d,e),x.api.connectorUrl)A=x.api.connectorUrl;else{var f=location.origin+location.pathname,g="connectors/"+x.api.lang+"/filemanager."+x.api.lang;fa(f).length>0&&(f=f.substring(0,f.lastIndexOf("/")+1)),A=f+g}})},J=function(){return a.ajax({type:"GET",url:sa({mode:"initiate"}),dataType:"json"}).done(function(b){if(b.data){var c=b.data.attributes.config;a.each(c,function(b,c){a.each(c,function(a,c){"undefined"!==x[b]&&"undefined"!==x[b][a]&&(x[b][a]=c)})})}Y(b)}).fail(function(){k.error("Unable to perform initial request to server.")}).then(function(b){if(b.errors)return a.Deferred().reject()})},K=function(){function b(a){return d+a+".json"}var c=G.param("langCode"),d=k.settings.baseUrl+"/languages/";return a.ajax().then(function(){if(c)return Q(b(c)).done(function(){x.options.culture=c}).fail(function(){setTimeout(function(){k.error("Given language file ("+b(c)+") does not exist!")},500)})}).then(function(){return a.ajax({type:"GET",url:b(x.options.culture),dataType:"json"}).done(function(a){y=a})})},L=function(){return a.when(T("upload-container"),T("upload-item")).done(function(a,b){var c=a[0],d=b[0];m.append(c).append(d)})},M=function(a){var b=[],c=[];if(b.push("/themes/"+x.options.theme+"/styles/theme.css"),x.customScrollbar.enabled&&(b.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"),b.push("/scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js")),b.push(a),S(b),x.viewer.editable.enabled){var d=x.viewer.editable.theme;d&&"default"!==d&&c.push("/scripts/CodeMirror/theme/"+d+".css"),c.push("/scripts/CodeMirror/lib/codemirror.css"),c.push("/scripts/CodeMirror/lib/codemirror.js"),c.push("/scripts/CodeMirror/addon/selection/active-line.js"),c.push("/scripts/CodeMirror/addon/display/fullscreen.css"),c.push("/scripts/CodeMirror/addon/display/fullscreen.js")}x.viewer.markdownRenderer.enabled&&(c.push("/styles/fm-markdown.css"),c.push("/scripts/markdown-it/markdown-it.min.js"),c.push("/scripts/markdown-it/default.min.css"),c.push("/scripts/markdown-it/highlight.min.js"),c.push("/scripts/markdown-it/markdown-it-footnote.min.js"),c.push("/scripts/markdown-it/markdown-it-replace-link.min.js")),x.options.browseOnly||(c.push("/scripts/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"),c.push("/scripts/jQuery-File-Upload/js/canvas-to-blob.min.js"),c.push("/scripts/jQuery-File-Upload/js/load-image.all.min.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.iframe-transport.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-process.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-image.js"),c.push("/scripts/jQuery-File-Upload/js/jquery.fileupload-validate.js"),x.upload.multiple&&c.push("/scripts/jQuery-File-Upload/css/dropzone.css")),x.options.charsLatinOnly&&c.push("/scripts/speakingurl/speakingurl.min.js"),c.length&&S(c)},N=function(){B=x.options.capabilities||["upload","select","download","rename","copy","move","delete","replace"];var b=[];x.options.fileSorting&&(b=x.options.fileSorting.toLowerCase().split("_")),C=b[0]||"name",D=b[1]||"asc";var c=G.param("exclusiveFolder");c&&(z="/"+c+"/",z=ea(z));var d=G.param("expandedFolder");if(d&&(F=z+d+"/",F=ea(F)),E=new O,ko.applyBindings(E),ko.bindingHandlers.toggleNodeVisibility={init:function(b,c){var d=c();a(b).toggle(d.isExpanded())},update:function(b,c){var d=c();return d.isSliding()!==!1&&(d.isExpanded()===!1&&a(b).slideDown(x.filetree.expandSpeed,function(){d.isSliding(!1),d.isExpanded(!0)}),void(d.isExpanded()===!0&&a(b).slideUp(x.filetree.expandSpeed,function(){d.isSliding(!1),d.isExpanded(!1)})))}},ko.bindingHandlers.draggableView={init:function(a,b,c){E.ddModel.makeDraggable(b(),a)}},ko.bindingHandlers.droppableView={init:function(a,b,c){E.ddModel.makeDroppable(b(),a)}},ko.bindingHandlers.draggableTree={init:function(a,b,c){E.ddModel.makeDraggable(b(),a)}},ko.bindingHandlers.droppableTree={init:function(a,b,c){E.ddModel.makeDroppable(b(),a)}},m.mousewheel(function(b){if(!E.ddModel.dragHelper)return!1;var c,d=null,e=b.originalEvent.wheelDelta>0||b.originalEvent.detail<0?"+":"-";if(c=x.customScrollbar.enabled?a([t[0],s[0]]):p.children(".splitter-pane"),c.each(function(c){var e=a(this),f=e.offset().top,g=e.offset().left;if(b.offsetY>=f&&b.offsetY<=f+e.height()&&b.offsetX>=g&&b.offsetX<=g+e.width())return d=e,!1}),null===d)return!1;if(x.customScrollbar.enabled){var f=d.find(".mCSB_scrollTools_vertical");f.is(":visible")&&d.mCustomScrollbar("scrollTo",[e+"=250",0],{scrollInertia:500,scrollEasing:"easeOut",callbacks:!0})}else if(d[0].scrollHeight>d[0].clientHeight){var g=d.scrollTop(),h=g-200*b.deltaY;E.ddModel.isScrolling=!0,h=h<0?0:h,d.stop().animate({scrollTop:h},100,"linear",function(){E.ddModel.isScrolling=!1,E.ddModel.isScrolled=!0})}}),v.selectable({filter:"li:not(.directory-parent), tbody > tr:not(.directory-parent)",cancel:".directory-parent, thead",disabled:!x.manager.selection.enabled,appendTo:v,start:function(a,b){ya(),E.itemsModel.isSelecting(!0)},stop:function(a,b){E.itemsModel.isSelecting(!1)},selected:function(a,b){var c=ko.dataFor(b.selected);c.selected(!0)},unselected:function(a,b){var c=ko.dataFor(b.unselected);c.selected(!1)}}),r.contextMenu({selector:".view-items",zIndex:10,build:function(a,b){var c={createFolder:{name:y.create_folder,className:"create-folder"},paste:{name:y.clipboard_paste,className:"paste",disabled:function(a,b){return E.clipboardModel.isEmpty()}}};return E.clipboardModel.enabled()&&x.options.browseOnly!==!0||delete c.paste,{appendTo:".fm-container",items:c,reposition:!1,callback:function(a,b){switch(a){case"createFolder":E.headerModel.createFolder();break;case"paste":E.clipboardModel.paste()}}}}}),x.extras.extra_js)for(var g=0;g400&&(this.yStartPosition=this.mcs.top),E.itemsModel.isSelecting()&&E.itemsModel.continiousSelection(!0);var b=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);v.selectable("repositionCssHelper",b,0)}}},axis:"y",alwaysShowScrollbar:0}));var h=document.documentElement;if(h.setAttribute("data-useragent",navigator.userAgent),x.options.logger){(new Date).getTime()}var i=l.find(".fm-loading-wrap");i.fadeOut(800,function(){k.setDimensions()}),k.setDimensions()},O=function(){var b=this;this.config=ko.observable(x),this.lg=ko.observable(y),this.localizeGUI=ko.observable(x.options.localizeGUI),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(x.options.defaultViewMode),this.currentPath=ko.observable(z),this.browseOnly=ko.observable(x.options.browseOnly),this.previewModel=ko.observable(null),this.previewFile.subscribe(function(a){a||(b.previewModel.closeEditor(),b.itemsModel.descriptivePanel.rdo().id===b.previewModel.rdo().id&&b.itemsModel.descriptivePanel.render(b.previewModel.viewer.content()))}),this.addItem=function(a,b){var c=E.treeModel.findByParam("id",b);if(c){var d=E.treeModel.createNode(a);E.treeModel.addNodes(c,d)}E.currentPath()===b&&E.itemsModel.addNew(a)},this.removeItem=function(a){var b=E.treeModel.findByParam("id",a.id);b&&b.remove();var c=E.itemsModel.findByParam("id",a.id);c&&c.remove()};var c=function(){var a=this;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 s,this.editor=new t,this.rdo.subscribe(function(b){a.cdo({isFolder:"folder"===b.type,sizeFormatted:W(b.attributes.size),dimensions:b.attributes.width?b.attributes.width+"x"+b.attributes.height:null})}),this.editor.content.subscribe(function(b){a.editor.isInteractive()&&a.renderer.render(b)}),this.applyObject=function(c){b.previewFile(!1);var d=c.attributes.name,e={interactive:!1},f={type:"default",url:null,options:{}};a.rdo(c),la(d)&&(f.type="image",f.url=ua(c,!1,!0)),na(d)&&x.viewer.audio.enabled===!0&&(f.type="audio",f.url=ta(c,!0)),ma(d)&&x.viewer.video.enabled===!0&&(f.type="video",f.url=ta(c,!0),f.options={width:x.viewer.video.playerWidth,height:x.viewer.video.playerHeight}),oa(d)&&x.viewer.opendoc.enabled===!0&&(f.type="opendoc",f.url=k.settings.baseUrl+"/scripts/ViewerJS/index.html#"+ta(c,!0),f.options={width:x.viewer.opendoc.readerWidth,height:x.viewer.opendoc.readerHeight}),pa(d)&&x.viewer.google.enabled===!0&&(f.type="google",f.url="http://docs.google.com/viewer?url="+encodeURIComponent(ta(c,!1))+"&embedded=true",f.options={width:x.viewer.google.readerWidth,height:x.viewer.google.readerHeight}),(qa(d)&&x.viewer.codeMirrorRenderer.enabled===!0||ra(d)&&x.viewer.markdownRenderer.enabled===!0)&&(f.type="renderer",a.renderer.setRenderer(c),e.interactive=a.renderer.renderer().interactive),a.viewer.type(f.type),a.viewer.url(f.url),a.viewer.options(f.options),a.viewer.pureUrl(la(d)?ua(c,!1,!1):ta(c,!1)),a.viewer.isEditable(ka(d)&&x.viewer.editable.enabled===!0),a.editor.isInteractive(e.interactive),"renderer"===f.type||a.viewer.isEditable()?Ia(c).then(function(c){if(c.data){var d=c.data.attributes.content;a.viewer.content(d),b.previewFile(!0)}}):b.previewFile(!0)},ZeroClipboard.config({swfPath:k.settings.baseUrl+"/scripts/zeroclipboard/dist/ZeroClipboard.swf"}),this.afterRender=function(){a.renderer.render(a.viewer.content());var b=new ZeroClipboard(u.find(".btn-copy-url")[0]);b.on("ready",function(a){b.on("aftercopy",function(a){k.success(y.copied)})})},this.initiateEditor=function(b){var c=u.find(".fm-cm-editor-content")[0];a.editor.createInstance(a.rdo().attributes.extension,c,{readOnly:!1,styleActiveLine:!0})},this.bindToolbar=function(b){d(a.rdo(),b)&&Ma(b,a.rdo())},this.previewIconClass=ko.pureComputed(function(){var b=[],c=["ico"];return"default"!==a.viewer.type()&&a.viewer.url()||(b.push("grid-icon"),this.cdo().isFolder===!0?(b.push("ico_folder"),c.push("folder"),this.rdo().attributes.readable||c.push("lock")):(b.push("ico_file"),this.rdo().attributes.readable?c.push("ext",this.rdo().attributes.extension):c.push("file","lock")),b.push(c.join("_"))),b.join(" ")},this),this.editFile=function(){var b=a.viewer.content();a.renderer.render(b),a.editor.render(b)},this.saveFile=function(){Ja(a.rdo())},this.closeEditor=function(){a.editor.enabled(!1),a.renderer.render(a.viewer.content())},this.buttonVisibility=function(b){switch(b){case"select":return d(a.rdo(),b)&&g();case"move":case"rename":case"delete":case"replace":return d(a.rdo(),b)&&x.options.browseOnly!==!0;case"download":return d(a.rdo(),b)}}},e=function(){var c=this;this.selectedNode=ko.observable(null),this.treeData={id:z,level:ko.observable(-1),children:ko.observableArray([])},this.treeData.children.subscribe(function(a){c.arrangeNode(c.treeData)});var d=function(a){if(null!==F){a||(a=c.treeData);var b=c.findByFilter(function(a){return 0===F.indexOf(a.id)},a);b?(x.filetree.expandSpeed=10,c.loadNodes(b,!1)):(F=null,x.filetree.expandSpeed=200)}};this.findByParam=function(a,b,d){if(!d&&(d=c.treeData,d[a]===b))return d;var e=d.children();if(!e||0===e.length)return null;for(var f=0,g=e.length;f-1||B.indexOf("move")>-1;this.enabled=ko.observable(b.config().options.clipboard&&f),this.copy=function(){e.hasCapability("copy")&&(d="copy",c=b.itemsModel.getSelected())},this.cut=function(){e.hasCapability("cut")&&(d="cut",c=b.itemsModel.getSelected())},this.paste=function(){if(e.hasCapability("paste")){if(null===d||0===c.length)return void k.warning(y.clipboard_empty);var f=b.currentPath();xa(c,function(a,b){return"cut"===d?Ea(b,f):"copy"===d?Da(b,f):void 0},a)}},this.clear=function(){e.hasCapability("clear")&&(a(),k.success(y.clipboard_cleared))},this.isEmpty=function(){return 0===c.length},this.hasCapability=function(a){if(!e.enabled)return!1;switch(a){case"copy":return B.indexOf("copy")>-1;case"cut":return B.indexOf("move")>-1;default:return!0}}},r=function(){var a=this;this.items=ko.observableArray([]),this.add=function(b,d){a.items.push(new c(b,d))},this.splitCurrent=function(){var c=z,d=b.currentPath(),e=d.replace(new RegExp("^"+z),"").split("/");for(a.items([]),a.add(z,"");e.length>0;){var f=e.shift();f&&(c+=f+"/",a.add(c,f))}};var c=function(a,c){var d=this;this.path=a,this.label=c,this.isRoot=a===z,this.active=a===b.currentPath(),this.itemClass=function(){var a=["nav-item"];return d.isRoot&&a.push("root"),d.active&&a.push("active"),a.join(" ")},this["goto"]=function(a,c){a.active||b.itemsModel.loadList(a.path)}}},s=function(){var b,c=this;this.rdo=ko.observable({}),this.content=ko.observable(null),this.renderer=ko.observable(null),this.render=function(a){c.renderer()&&c.renderer().processContent(a)},this.setRenderer=function(a){c.rdo(a),ra(a.attributes.name)?c.renderer(new e):c.renderer(new d)},this.setContainer=function(d){a.each(d,function(){if(a(this).hasClass("fm-renderer-container"))return b=a(this),!1}),c.renderer().processDomElements(b)};var d=function(){this.name="codeMirror",this.interactive=!1;var a=new t;this.processContent=function(b){a.render(b),c.content(b)},this.processDomElements=function(b){if(!a.instance){var d=b.find(".fm-cm-renderer-content")[0];a.createInstance(c.rdo().attributes.extension,d,{readOnly:"nocursor",styleActiveLine:!1,lineNumbers:!1})}}},e=function(){function d(){b.find("a").each(function(){var b=a(this).attr("href"),c=E.previewModel.editor;if(c.enabled()&&c.isInteractive())a(this).off("click"),a(this).on("click",function(){return!1});else{if(b.search("://")!=-1||ca(b,"mailto:"))return;ra(b)&&a(this).on("click",function(a){return Ka(b).then(function(a){a.data&&h(a.data)}),!1})}})}this.name="markdown",this.interactive=!0;var e=window.markdownit({html:!0,linkify:!0,typographer:!0,highlight:function(a,b){if(b&&hljs.getLanguage(b))try{return'
    '+hljs.highlight(b,a,!0).value+"
    "}catch(c){}return'
    '+md.utils.escapeHtml(a)+"
    "},replaceLink:function(a,b){ +if(a.search("://")!=-1||ca(a,"mailto:"))return a;var d=ca(a,"/")?z:ha(c.rdo().id),e=d+aa(a,"/");return ra(e)?e:sa({mode:"readfile",path:e})}}).use(window.markdownitReplaceLink);this.processContent=function(a){var b=e.render(a);c.content(b),d()},this.processDomElements=function(a){}}},t=function(){function b(a){d.enabled(!0),d.instance.setValue(a),setTimeout(function(){d.instance.refresh()},0)}function c(a){var b=[],c="default";x.viewer.editable.codeHighlight&&("js"===a&&(b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),c="javascript"),"css"===a&&(b.push("/scripts/CodeMirror/mode/css/css.js"),c="css"),"html"===a&&(b.push("/scripts/CodeMirror/mode/xml/xml.js"),c="text/html"),"xml"===a&&(b.push("/scripts/CodeMirror/mode/xml/xml.js"),c="application/xml"),"php"===a&&(b.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/scripts/CodeMirror/mode/xml/xml.js"),b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),b.push("/scripts/CodeMirror/mode/css/css.js"),b.push("/scripts/CodeMirror/mode/clike/clike.js"),b.push("/scripts/CodeMirror/mode/php/php.js"),c="application/x-httpd-php"),"java"===a&&(b.push("/scripts/CodeMirror/mode/clike/clike.js"),c="text/x-java"),"sql"===a&&(b.push("/scripts/CodeMirror/mode/sql/sql.js"),c="text/x-mysql"),"md"===a&&(b.push("/scripts/CodeMirror/addon/mode/overlay.js"),b.push("/scripts/CodeMirror/mode/xml/xml.js"),b.push("/scripts/CodeMirror/mode/markdown/markdown.js"),b.push("/scripts/CodeMirror/mode/gfm/gfm.js"),b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),b.push("/scripts/CodeMirror/mode/css/css.js"),b.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/scripts/CodeMirror/mode/clike/clike.js"),b.push("/scripts/CodeMirror/mode/shell/shell.js"),b.push("/scripts/CodeMirror/mode/meta.js"),c="gfm"),"sh"===a&&(b.push("/scripts/CodeMirror/addon/mode/overlay.js"),b.push("/scripts/CodeMirror/mode/markdown/markdown.js"),b.push("/scripts/CodeMirror/mode/gfm/gfm.js"),b.push("/scripts/CodeMirror/mode/javascript/javascript.js"),b.push("/scripts/CodeMirror/mode/css/css.js"),b.push("/scripts/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/scripts/CodeMirror/mode/clike/clike.js"),b.push("/scripts/CodeMirror/mode/meta.js"),b.push("/scripts/CodeMirror/mode/shell/shell.js"),c="shell")),b.length?(b.push(function(){d.mode(c)}),S(b)):d.mode(c)}var d=this,e=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(a){a&&(d.instance.setOption("mode",a),e&&(b(e),e=null))}),this.render=function(a){d.mode()?b(a):e=a},this.createInstance=function(b,e,f){var g,h={readOnly:"nocursor",styleActiveLine:!1,viewportMargin:1/0,lineNumbers:x.viewer.editable.lineNumbers,lineWrapping:x.viewer.editable.lineWrapping,theme:x.viewer.editable.theme,matchBrackets:x.viewer.editable.matchBrackets,extraKeys:{F11:function(a){a.setOption("fullScreen",!a.getOption("fullScreen"))},Esc:function(a){a.getOption("fullScreen")&&a.setOption("fullScreen",!1)}}};g=CodeMirror.fromTextArea(e,a.extend({},h,f)),g.on("changes",function(a,b){d.content(a.getValue())}),d.instance=g,c(b)}},w=function(){function c(b){var c=a.grep(g.items,function(a,c){if("folder"===b.rdo.type||"parent"===b.rdo.type){if(ca(b.rdo.id,a.rdo.id))return!0;if(b.rdo.id===ja(a.rdo.id))return!0}return a.id===b.id});return b.rdo.attributes.writable&&0===c.length}function d(a){if(a.ancestor===b.treeModel)return[E.treeModel.selectedNode()];if(a.ancestor===b.itemsModel)return E.itemsModel.getSelected();throw new Error("Unknown item type.")}function e(a){null!==g.hoveredItem&&g.hoveredItem.dragHovered(!1),g.hoveredItem=a,a&&a.dragHovered(!0)}function f(a,b){b?a.addClass(h):a.removeClass(h)}var g=this,h="drop-restricted",i=a("#drag-helper-template");this.items=[],this.hoveredItem=null,this.dragHelper=null,this.isScrolling=!1,this.isScrolled=!1,this.hoveredCssClass="drop-hover",this.makeDraggable=function(b,c){"file"!==b.rdo.type&&"folder"!==b.rdo.type||a(c).draggable({distance:3,cursor:"pointer",cursorAt:{left:Math.floor(i.width()/2),bottom:15},scroll:!1,appendTo:m,containment:l,refreshPositions:!1,helper:function(){var a,c;return c=d(b).length>1?"ico_multiple":"folder"===b.rdo.type?"ico_folder":"ico_file ico_ext_"+fa(b.rdo.id),a=i.children(".drag-helper").clone(),a.find(".clip").addClass(c),g.dragHelper=a,a},start:function(a,c){g.items=d(b)},drag:function(b,c){a(this).draggable("option","refreshPositions",g.isScrolling||g.isScrolled),g.isScrolled=!1},stop:function(a,b){g.items=[],g.dragHelper=null}})},this.makeDroppable=function(d,h){"folder"!==d.rdo.type&&"parent"!==d.rdo.type||a(h).droppable({tolerance:"pointer",enableExtendedEvents:d.ancestor===b.itemsModel,accept:function(a){var b=ko.dataFor(a[0]),c=b?b.rdo.type:null;return"file"===c||"folder"===c},over:function(a,b){setTimeout(function(){e(null),f(b.helper,!1),c(d)||f(b.helper,!0),e(d)},0)},out:function(a,b){e(null),f(b.helper,!1)},drop:function(a,b){return e(null),!!c(d)&&void xa(g.items,function(a,b){return Ea(b.rdo,d.id)})}})}},A=function(){this.unselect=!1};this.treeModel=new e,this.itemsModel=new f,this.tableViewModel=new j,this.previewModel=new c,this.headerModel=new n,this.summaryModel=new o,this.searchModel=new p,this.clipboardModel=new q,this.breadcrumbsModel=new r,this.ddModel=new w,this.selectionModel=new A},P=function(a){function b(a){var b,c=C;switch("list"===E.viewMode()&&(c=E.itemsModel.listSortField()),c){case"type":b=a.rdo.attributes.extension||"";break;case"size":b=a.rdo.attributes.size;break;case"modified":b=a.rdo.attributes.timestamp;break;case"dimensions":b=a.cdo.dimensions||"";break;default:b=a.rdo.attributes.name}return"string"==typeof b&&(f.cases||(b=b.toLowerCase()),b=b.replace(/\s+/g," ")),b}function c(a,b){for(var c=d(a.toString()),e=d(b.toString()),f=0;c[f]&&e[f];f++)if(c[f]!==e[f]){var g=Number(c[f]),h=Number(e[f]);return g==c[f]&&h==e[f]?g-h:c[f]>e[f]?1:-1}return c.length-e.length}function d(a){for(var b,c,d=[],e=0,f=-1,g=0;b=(c=a.charAt(e++)).charCodeAt(0);){var h=46==b||b>=48&&b<=57;h!==g&&(d[++f]="",g=h),d[f]+=c}return d}var e="list"===E.viewMode()?E.itemsModel.listSortOrder():D,f={natural:!0,order:"asc"===e?1:-1,cases:!1};a.sort(function(a,d){if("parent"===a.rdo.type)return-1;var e,g=b(a),h=b(d);return e=g===h?0:void 0===g||void 0===h?0:f.natural&&(isNaN(g)||isNaN(h))?c(g,h):gh?1:0,e*=f.order});for(var g=[],h=a.length;h--;)"folder"===a[h].rdo.type&&(g.push(a[h]),a.splice(h,1));"top"!==x.options.folderPosition&&g.reverse();for(var i=0,j=g.length;i1&&g.then(function(){k.log(y.successful_processed.replace("%s",e).replace("%s",f))}),g.then(function(){"function"==typeof d&&d()})},ya=function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}},za=function(a){var b=null,c=ta(a,!0);if(c=k.settings.callbacks.beforeSelectItem(a,c),window.tinyMCEPopup){var d=tinyMCEPopup.getWindowArg("window");return d.document.getElementById(tinyMCEPopup.getWindowArg("input")).value=c,"undefined"!=typeof d.ImageDialog&&(d.ImageDialog.getImageData&&d.ImageDialog.getImageData(),d.ImageDialog.showPreviewImage&&d.ImageDialog.showPreviewImage(c)),void tinyMCEPopup.close()}if(G.param("field_name")&&(parent.document.getElementById(G.param("field_name")).value=c,"undefined"!=typeof parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),"undefined"!=typeof parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),G.param("ImperaviElementId"))if(window.opener);else{var e=G.param("ImperaviElementId"),f=parent.$("#"+e).redactor("core.getObject");f&&(f.modal.close(),f.buffer.set(),la(a.attributes.name)?f.insert.html(''):f.insert.html(''+a.attributes.name+""))}if(G.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(G.param("CKEditorFuncNum"),c):(parent.CKEDITOR.tools.callFunction(G.param("CKEditorFuncNum"),c),parent.CKEDITOR.tools.callFunction(G.param("CKEditorCleanUpFuncNum")))),window.opener&&"function"==typeof window.opener.SetUrl)if(a.attributes.width){var g=c,h=a.attributes.width,i=a.attributes.height;window.opener.SetUrl(g,h,i)}else window.opener.SetUrl(c);window.opener&&(b=window.opener),window.parent&&window.self!==window.parent&&(b=window.parent),b&&b.postMessage({source:"richfilemanager",preview_url:c},"*"),k.settings.callbacks.afterSelectItem(a,c,b)},Aa=function(b){var c=function(c,d){var e=b.id,f=d.getInputValue();if(!f)return void k.error(y.new_filename);if(!x.security.allowChangeExtensions){f=V(f);var g=fa(b.attributes.name);g.length>0&&(f=f+"."+g)}if($(e)&&!Z(f)){var h="

    "+y.INVALID_FILE_TYPE+"

    ";return"DISALLOW_ALL"==x.upload.policy&&(h+="

    "+y.ALLOWED_FILE_TYPE+x.upload.restrictions.join(", ")+".

    "),"ALLOW_ALL"==x.upload.policy&&(h+="

    "+y.DISALLOWED_FILE_TYPE+x.upload.restrictions.join(", ")+".

    "),a("#filepath").val(""),void k.error(h)}a.ajax({type:"GET",url:sa({mode:"rename",old:e,"new":f}),dataType:"json",success:function(a){if(a.data){var b=a.data,c=E.treeModel.findByParam("id",e);if(c&&("folder"===c.rdo.type&&(c.nodeTitle(b.attributes.name),E.treeModel.actualizeNodeObject(c,e,b.id)),"file"===c.rdo.type)){var f=c.parentNode(),g=E.treeModel.createNode(b);c.remove(),f&&E.treeModel.addNodes(f,g)}var h=E.itemsModel.findByParam("id",e);h&&("parent"===h.rdo.type?h.id=b.id:(h.remove(),E.itemsModel.addNew(b))),E.currentPath()===e&&E.itemsModel.loadList(b.id),E.previewFile()&&E.previewModel.rdo().id===e&&E.previewModel.applyObject(b),d.closeDialog(),x.options.showConfirmation&&k.success(y.successful_rename)}Y(a)},error:X})};k.prompt({message:y.new_filename,value:x.security.allowChangeExtensions?b.attributes.name:ga(b.attributes.name),okBtn:{label:y.action_rename,autoClose:!1,click:c},cancelBtn:{label:y.cancel}})},Ba=function(b){var c=a("#fm-js-preview-toolbar"),d=c.find(":file");"undefined"==typeof c.data("blueimpFileupload")&&c.fileupload({autoUpload:!0,dataType:"json",url:sa(),paramName:x.upload.paramName}).on("fileuploadadd",function(a,c){var d=c.files[0];return fa(d.name)!=b.attributes.extension?(k.error(y.ERROR_REPLACING_FILE+" ."+b.attributes.extension),!1):void c.submit()}).on("fileuploadsubmit",function(a,c){c.formData={mode:"replace",path:b.id},w.addClass("loading").prop("disabled",!0),w.children("span").text(y.loading_data)}).on("fileuploadalways",function(a,b){w.removeData().removeClass("loading").prop("disabled",!1),w.children("span").text(y.action_upload);var c=b.result;if(c&&c.errors&&k.error(y.upload_failed+"
    "+c.errors[0].title),c&&c.data){var d=c.data[0];E.removeItem(d),E.addItem(d,E.currentPath()),E.previewFile()&&E.previewModel.applyObject(d),x.options.showConfirmation&&k.success(y.successful_replace)}}).on("fileuploadchunkdone",function(a,b){var c=b.result;if(c.data&&c.data[0]){var d=c.data[0];E.removeItem(d),E.addItem(d,E.currentPath())}}).on("fileuploadfail",function(a,b){k.error(y.upload_failed)}),d.click()},Ca=function(a,b){var c=function(a,c){var d=c.getInputValue();return d?(d=ba(d,"/")+"/",void b(d)):void k.error(y.prompt_foldername)},d=a.length,e=d>1?y.prompt_move_multiple.replace("%s",d):y.prompt_move;k.prompt({message:e,value:E.currentPath(),okBtn:{label:y.action_move,autoClose:!1,click:c},cancelBtn:{label:y.cancel},template:{dialogInput:'
    '+y.help_move+"
    "}})},Da=function(b,c){return a.ajax({type:"GET",url:sa({mode:"copy",source:b.id,target:c}),dataType:"json",success:function(a){if(a.data){var b=a.data;E.addItem(b,c),alertify.clearDialogs(),x.options.showConfirmation&&k.success(y.successful_copied)}Y(a)},error:X})},Ea=function(b,c){return a.ajax({type:"GET",url:sa({mode:"move",old:b.id,"new":c}),dataType:"json",success:function(a){if(a.data){var d=a.data;E.removeItem(b),E.addItem(d,c),E.currentPath()===b.id&&E.itemsModel.loadList(d.id),E.previewFile()&&E.previewModel.rdo().id===b.id&&E.previewFile(!1),alertify.clearDialogs(),x.options.showConfirmation&&k.success(y.successful_moved)}Y(a)},error:X})},Fa=function(a,b){var c=a.length,d=c>1?y.confirm_delete_multiple.replace("%s",c):y.confirm_delete;k.confirm({message:d,okBtn:{label:y.yes,click:function(a,c){b()}},cancelBtn:{label:y.no}})},Ga=function(b){return a.ajax({type:"GET",url:sa({mode:"delete",path:b}),dataType:"json",success:function(a){if(a.data){var b=a.data;E.removeItem(b),E.previewFile()&&E.previewModel.rdo().id===b.id&&E.previewFile(!1),x.options.showConfirmation&&k.success(y.successful_delete)}Y(a)},error:X})},Ha=function(b){var c={mode:"download",path:b.id};return a.ajax({type:"GET",url:sa(c),dataType:"json",success:function(b){b.data&&a.fileDownload(sa(c)),Y(b)},error:X})},Ia=function(b){return a.ajax({type:"GET",url:sa({mode:"editfile",path:b.id}),dataType:"json",success:function(a){Y(a)},error:X})},Ja=function(b){a.ajax({type:"POST",url:sa(),dataType:"json",data:a("#fm-js-editor-form").serializeArray(),success:function(a){if(a.data){var b=a.data,c=E.previewModel,d=c.editor.content();c.rdo(b),c.viewer.content(d),c.closeEditor();var e=E.itemsModel.createObject(b),f=E.itemsModel.findByParam("id",b.id);E.itemsModel.objects.replace(f,e),k.success(y.successful_edit)}Y(a)},error:X})},Ka=function(b){return a.ajax({type:"GET",url:sa({mode:"getfile",path:b}),dataType:"json",success:function(a){Y(a)},error:X})},La=function(){a.ajax({type:"GET",url:sa({mode:"summarize"}),dataType:"json",success:function(b){if(b.data){var c=b.data.attributes,d=W(c.size,!0);if(c.sizeLimit>0){var e=W(c.sizeLimit,!0),f=100*c.size/c.sizeLimit,g=Math.round(100*f)/100;d+=" ("+g+"%) "+y.of+" "+e}E.summaryModel.files(c.files),E.summaryModel.folders(c.folders),E.summaryModel.size(d),E.summaryModel.enabled(!0);var h=a("#summary-popup").clone().show();E.summaryModel.enabled(!1),k.alert(h[0].outerHTML)}Y(b)},error:X})},Ma=function(b,c,d){var e=d?d:[c];switch(b){case"select":za(c);break;case"download":a.each(e,function(a,b){Ha(b)});break;case"rename":Aa(c);break;case"replace":Ba(c);break;case"move":Ca(e,function(a){xa(e,function(b,c){return Ea(c,a)})});break;case"delete":Fa(e,function(){xa(e,function(a,b){return Ga(b.id)})});break;case"copy":E.clipboardModel.copy();break;case"cut":E.clipboardModel.cut()}},Na=function(){return!x.options.browseOnly&&void(x.upload.multiple?(a("#file-input-container").remove(),w.unbind().click(function(){if(B.indexOf("upload")===-1)return k.error(y.NOT_ALLOWED),!1;var b=null,c=E.currentPath(),d=tmpl("tmpl-fileupload-container",{folder:y.current_folder+c,info:y.upload_files_number_limit.replace("%s",x.upload.maxNumberOfFiles)+" "+y.upload_file_size_limit+W(x.upload.fileSizeLimit,!0),lang:y});"DISALLOW_ALL"==x.upload.policy&&(b=new RegExp("(\\.|\\/)("+x.upload.restrictions.join("|")+")$","i")),k.dialog({message:d,width:"auto",buttons:[{type:"ok",label:y.action_upload,autoClose:!1,click:function(a,b){f.children(".upload-item").length>0?f.find(".button-start").trigger("click"):k.error(y.upload_choose_file)}},{label:y.action_select,closeOnClick:!1,click:function(b,c){a("#fileupload",e).trigger("click")}},{type:"cancel",label:y.close}]});var e=a(".fm-fileupload-container"),f=a(".dropzone",e),g=a(".dropzone-wrapper",e),h=a("#total-progress",e).children();x.customScrollbar.enabled&&g.mCustomScrollbar({theme:x.customScrollbar.theme,scrollButtons:{enable:x.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){g.find(".mCSB_container").css({"margin-right":g.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){g.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),g.on("click",function(b){(b.target===this||a(b.target).parent()[0]===this||b.target===f[0]||a(b.target).parent().hasClass("default-message"))&&a("#fileupload",e).trigger("click")}),f.on("click",".button-start",function(b){var c=a(this),d=c.parent().parent(),e=d.data();e.submit(),c.remove()}),f.on("click",".button-abort",function(b){var c=a(this),d=c.parent().parent(),e=d.data(),f=e.files[0].context;e.abort(),f.find(".error-message").text(y.upload_aborted),f.addClass("aborted")}),f.on("click",".button-resume",function(b){function d(c){a.blueimp.fileupload.prototype.options.add.call(a("#fileupload")[0],b,c),c.submit()}var e=a(this),f=e.parent().parent(),g=f.data(),h=g.files[0];if(h.chunkUploaded){var i=c+h.serverName;Ka(i).then(function(a){a.data&&(g.uploadedBytes=Number(a.data.attributes.size),g.uploadedBytes||(h.chunkUploaded=void 0),d(g))})}else d(g)}),f.on("click",".button-remove",function(b){var d=a(this),e=d.parent().parent(),f=e.data(),g=f.files[0];g.chunkUploaded&&Ga(c+g.serverName),d.closest(".upload-item").remove(),i()}),f.on("click",".button-info",function(b){var c=a(this),d=c.closest(".upload-item");if(d.hasClass("error")){var e=d.find(".error-message");k.error(e.text())}});var i=function(){f.children(".upload-item").length>0?f.addClass("started"):f.removeClass("started")};a("#fileupload",e).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:f,maxChunkSize:x.upload.chunkSize,url:sa(),paramName:x.upload.paramName,singleFileUploads:!0,formData:{mode:"upload",path:c},maxNumberOfFiles:x.upload.maxNumberOfFiles,acceptFileTypes:b,maxFileSize:x.upload.fileSizeLimit,messages:{maxNumberOfFiles:y.upload_files_number_limit.replace("%s",x.upload.maxNumberOfFiles),acceptFileTypes:y.upload_file_type_invalid,maxFileSize:y.upload_file_too_big+" "+y.upload_file_size_limit+W(x.upload.fileSizeLimit,!0)},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(b,c){var d=f.children(".upload-item");a.each(c.files,function(b,e){if(d.length>=x.upload.maxNumberOfFiles)return k.error(y.upload_files_number_limit.replace("%s",x.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;e.formattedSize=W(e.size);var g=a(tmpl("tmpl-upload-item",{file:e,lang:y,imagesPath:k.settings.baseUrl+"/scripts/jQuery-File-Upload/img"}));e.context=g,g.find(".buttons").data(c),g.appendTo(f)}),i()}).on("fileuploadsend",function(b,c){a.each(c.files,function(a,b){var d=b.context;d.removeClass("added aborted error").addClass("process"),b.chunkUploaded&&c.total===c.uploadedBytes&&d.remove()})}).on("fileuploadfail",function(b,c){a.each(c.files,function(a,b){b.error=y.upload_failed;var c=b.context;c.removeClass("added process").addClass("error")})}).on("fileuploaddone",function(b,c){var d=c.result;a.each(c.files,function(a,b){var c=b.context;d&&d.errors?(c.removeClass("added process").addClass("error"),c.find(".error-message").text(d.errors[0].title),c.find(".button-start").remove()):c.remove()})}).on("fileuploadalways",function(b,c){var d=c.result;a.each(c.files,function(a,b){if(d&&d.data&&d.data[a]){var c=d.data[a];E.removeItem(c),E.addItem(c,E.currentPath())}});var e=f.children(".upload-item");0===e.filter(".added").length&&0===e.filter(".process").length&&(0===e.length&&(alertify.clearDialogs(),x.options.showConfirmation&&k.success(y.upload_successful_files)),e.filter(".error").length&&k.error(y.upload_partially+"
    "+y.upload_failed_details)),i()}).on("fileuploadchunkdone",function(b,c){var d=c.result;a.each(c.files,function(a,b){if(d.data&&d.data[a]){var c=d.data[a];E.removeItem(c),E.addItem(c,E.currentPath()),b.serverName=c.attributes.name,b.chunkUploaded=1}})}).on("fileuploadprocessalways",function(b,c){a.each(c.files,function(a,b){var c=b.context;"undefined"!=typeof c&&(b.preview&&(c.find(".image").append(b.preview),c.find(".preview").removeClass("file-preview").addClass("image-preview")),b.error&&(c.removeClass("added process").addClass("error"),c.find(".error-message").text(b.error),c.find(".button-start").remove()))})}).on("fileuploadprogress",function(b,c){a.each(c.files,function(a,b){var d=b.context,e=parseInt(c.loaded/c.total*100,10);d.find(".progress-bar").css("width",e+"%")})}).on("fileuploadprogressall",function(a,b){var c=parseInt(b.loaded/b.total*100,10);h.css("width",c+"%")})})):(w.click(function(){if(B.indexOf("upload")===-1)return k.error(y.NOT_ALLOWED),!1;var b=a(this).data();a.isEmptyObject(b)?k.error(y.upload_choose_file):b.submit()}),o.fileupload({autoUpload:!1,dataType:"json",url:sa(),paramName:x.upload.paramName,maxChunkSize:x.upload.chunkSize}).on("fileuploadadd",function(a,b){w.data(b)}).on("fileuploadsubmit",function(a,b){b.formData={mode:"upload",path:E.currentPath()},w.addClass("loading").prop("disabled",!0),w.children("span").text(y.loading_data)}).on("fileuploadalways",function(b,c){a("#filepath").val(""),w.removeData().removeClass("loading").prop("disabled",!1),w.children("span").text(y.action_upload);var d=c.result;if(d&&d.errors&&k.error(y.upload_failed+"
    "+d.errors[0].title),d&&d.data){var e=d.data[0];E.removeItem(e),E.addItem(e,E.currentPath()),x.options.showConfirmation&&k.success(y.upload_successful_file)}}).on("fileuploadchunkdone",function(a,b){var c=b.result;if(c.data&&c.data[0]){var d=c.data[0];E.removeItem(d),E.addItem(d,E.currentPath())}}).on("fileuploadfail",function(a,b){k.error(y.upload_failed)})))};H(),a(window).resize(k.setDimensions)}}(jQuery),$.fn.richFilemanager=function(a){return this.each(function(){if(void 0==$(this).data("richFilemanager")){var b=new $.richFilemanagerPlugin(this,a);$(this).data("richFilemanager",b)}})},window.location.origin||(window.location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")); \ No newline at end of file