diff --git a/package.json b/package.json index b4917140..19d41a74 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "uglify-js": "^3.0.27" }, "dependencies": { + "node-sass": "^4.9.0", "sass": "^1.0.0-beta.5.3" } } diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 035eeaf4..a05a1916 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -339,9 +339,12 @@ $.richFilemanagerPlugin = function(element, pluginOptions) } }) .then(function() { + // append query param to prevent caching + var langFileUrl = langModel.buildLangFileUrl(langModel.getLang()) + '?_=' + new Date().getTime(); + return $.ajax({ type: 'GET', - url: langModel.buildLangFileUrl(langModel.getLang()), + url: langFileUrl, dataType: 'json' }).done(function(jsonTrans) { langModel.setTranslations(jsonTrans); diff --git a/src/js/filemanager.min.js b/src/js/filemanager.min.js index d2ed2f96..735cd78f 100644 --- a/src/js/filemanager.min.js +++ b/src/js/filemanager.min.js @@ -1,3 +1,3 @@ -!function(a){a.richFilemanagerPlugin=function(b,c){function d(a){return A.indexOf(a)>-1}function e(b,c){if(!d(c))return!1;if("select"===c&&"folder"===b.type)return!1;if("extract"===c){var e=ka(b.attributes.name);return"file"===b.type&&"zip"===e}return"download"===c&&"folder"===b.type?x.options.allowFolderDownload===!0:"undefined"==typeof b.attributes.capabilities||a.inArray(c,b.attributes.capabilities)>-1}function f(){x.filetree.enabled&&(s.show(),p.splitter({sizeLeft:x.filetree.width,minLeft:x.filetree.minWidth,minRight:200}))}function g(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||I.param("field_name")||I.param("CKEditor")||I.param("ImperaviElementId")}function h(a){return a.attributes.readable?("file"===a.type&&D.previewModel.applyObject(a),void("folder"!==a.type&&"parent"!==a.type||(D.previewFile(!1),D.itemsModel.loadDataList(a.id)))):(k.error(T("NOT_ALLOWED_SYSTEM")),!1)}function i(a){var b=!D.clipboardModel.enabled(),c={select:{name:T("action_select"),className:"select"},download:{name:T("action_download"),className:"download"},rename:{name:T("action_rename"),className:"rename"},move:{name:T("action_move"),className:"move"},separator1:"-----",copy:{name:T("clipboard_copy"),className:"copy"},cut:{name:T("clipboard_cut"),className:"cut"},"delete":{name:T("action_delete"),className:"delete"},extract:{name:T("action_extract"),className:"extract"},copyUrl:{name:T("copy_to_clipboard"),className:"copy-url"}};return e(a,"download")||delete c.download,e(a,"select")&&g()||delete c.select,e(a,"rename")&&x.options.browseOnly!==!0||delete c.rename,e(a,"delete")&&x.options.browseOnly!==!0||delete c["delete"],e(a,"extract")&&x.options.browseOnly!==!0||delete c.extract,e(a,"copy")&&x.options.browseOnly!==!0&&!b||delete c.copy,e(a,"move")&&x.options.browseOnly!==!0&&!b||(delete c.cut,delete c.move),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){},beforeSetRequestParams:function(a,b){return b},beforeSendRequest:function(a,b){return!0}}},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="/",z=null,A=[],B=null,C=null,D=null,E=null,F=null,G=null,H=null,I=purl();(new Date).getTime();k.settings=a.extend(!0,j,c),k.write=function(b,c){var d=alertify,e=a.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"},c);if(e.logClass&&e.unique&&a(".fm-log").children("."+e.logClass).length>0)return d;e.reset&&d.reset(),d.parent(e.parent),d.logDelay(e.delay),d.logMaxItems(e.logMaxItems),d.logPosition(e.logPosition),d.logContainerClass(e.logContainerClass),d.logMessageTemplate(e.logMessageTemplate),d[e.type](b,e.onClick);var f=d.getLogs();return f[f.length-1]},k.error=function(b,c){return k.write(b,a.extend({},{type:"error",delay:1e4},c))},k.warning=function(b,c){return k.write(b,a.extend({},{type:"warning",delay:1e4},c))},k.success=function(b,c){return k.write(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)},k.console=function(){x.options.logger&&arguments&&[].unshift.call(arguments,(new Date).getTime())},k.refreshFolder=function(a){D.loadPath(D.currentPath(),a)},k.loadFolder=function(a,b){a="/"+ea(a,"/")+"/",D.loadPath(a,b)};var J=function(){var b=a.Deferred();b.then(function(){return K()}).then(function(){return M()}).then(function(a,b){return L()}).then(function(){return N()}).then(function(){O(function(){P()})}),b.resolve()},K=function(){return a.when(W("default"),W("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)z=x.api.connectorUrl;else{var f=location.origin+location.pathname,g="connectors/"+x.api.lang+"/filemanager."+x.api.lang;ka(f).length>0&&(f=f.substring(0,f.lastIndexOf("/")+1)),z=f+g}})},L=function(){return za("GET",{mode:"initiate"}).done(function(b){if(b.data){var c=b.data.attributes.config;a.each(c,function(b,c){a.each(c,function(a,c){return null===c||(void 0===x[b]&&(x[b]=[]),void(x[b][a]=c))})}),c.options&&c.options.capabilities&&(x.options.capabilities=c.options.capabilities)}}).fail(function(a){k.error("Unable to perform initial request to server."),ba(a)}).then(function(b){if(b.errors)return a.Deferred().reject()})},M=function(){return E=new Q,a.ajax().then(function(){var a=I.param("langCode");return a?V(E.buildLangFileUrl(a)).done(function(){E.setLang(a)}).fail(function(){setTimeout(function(){k.error("Given language file ("+E.buildLangFileUrl(a)+") does not exist!")},500)}):void E.setLang(x.language["default"])}).then(function(){return a.ajax({type:"GET",url:E.buildLangFileUrl(E.getLang()),dataType:"json"}).done(function(a){E.setTranslations(a)})}).then(function(){var b=E.getLang().substr(0,2),c=k.settings.baseUrl;return a.when(a.get(c+"/libs/cldrjs/cldr-dates/"+b+"/ca-gregorian.json"),a.get(c+"/libs/cldrjs/cldr-numbers/"+b+"/numbers.json"),a.get(c+"/libs/cldrjs/cldr-core/supplemental/likelySubtags.json"),a.get(c+"/libs/cldrjs/cldr-core/supplemental/timeData.json"),a.get(c+"/libs/cldrjs/cldr-core/supplemental/weekData.json")).fail(function(){k.error('CLDR files for "'+b+'" language do not exist!')}).then(function(){return[].slice.apply(arguments,[0]).map(function(a){return a[0]})}).then(Globalize.load).then(function(){F=Globalize(b)})})},N=function(){return a.when(Y("upload-container"),Y("upload-item")).done(function(a,b){var c=a[0],d=b[0];m.append(c).append(d)})},O=function(a){var b=[],c=[];if(b.push("/themes/"+x.options.theme+"/styles/theme.css"),x.viewer.image.lazyLoad&&b.push("/libs/lazyload/dist/lazyload.min.js"),x.customScrollbar.enabled&&(b.push("/libs/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"),b.push("/libs/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js")),b.push(a),X(b),x.editor.enabled){var d=x.editor.theme;d&&"default"!==d&&c.push("/libs/CodeMirror/theme/"+d+".css"),c.push("/libs/CodeMirror/lib/codemirror.css"),c.push("/libs/CodeMirror/lib/codemirror.js"),c.push("/libs/CodeMirror/addon/selection/active-line.js"),c.push("/libs/CodeMirror/addon/display/fullscreen.css"),c.push("/libs/CodeMirror/addon/display/fullscreen.js")}x.viewer.markdownRenderer.enabled&&(c.push("/src/css/fm-markdown.css"),c.push("/libs/markdown-it/markdown-it.min.js"),c.push("/libs/markdown-it/default.min.css"),c.push("/libs/markdown-it/highlight.min.js"),c.push("/libs/markdown-it/markdown-it-footnote.min.js"),c.push("/libs/markdown-it/markdown-it-replace-link.min.js")),x.options.browseOnly||(c.push("/src/js/libs-fileupload.js"),x.upload.multiple&&c.push("/libs/jQuery-File-Upload/css/dropzone.css")),c.length&&X(c)},P=function(){G=new R,A=x.options.capabilities||["upload","select","download","rename","copy","move","delete","extract","createFolder"],x.security.readOnly&&(x.options.browseOnly=!0),x.upload.paramName||(x.upload.paramName="files");var b=[];x.options.fileSorting&&(b=x.options.fileSorting.toLowerCase().split("_")),B=b[0]||"name",C=b[1]||"asc";var c=I.param("exclusiveFolder");c&&(y="/"+c+"/",y=ja(y));var e=I.param("expandedFolder");if(e&&(H=y+e+"/",H=ja(H)),D=new S,ko.applyBindings(D),D.itemsModel.initiateLazyLoad(),D.filterModel.setName(I.param("filter")),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){D.ddModel.makeDraggable(b(),a)}},ko.bindingHandlers.droppableView={init:function(a,b,c){D.ddModel.makeDroppable(b(),a)}},ko.bindingHandlers.draggableTree={init:function(a,b,c){D.ddModel.makeDraggable(b(),a)}},ko.bindingHandlers.droppableTree={init:function(a,b,c){D.ddModel.makeDroppable(b(),a)}},m.mousewheel(function(b){if(!D.ddModel.dragHelper)return!0;var c,d=null;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 e=d.find(".mCSB_scrollTools_vertical"),f=1===b.deltaY?"+":"-";e.is(":visible")&&d.mCustomScrollbar("scrollTo",[f+"=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;D.ddModel.isScrolling=!0,h=h<0?0:h,d.stop().animate({scrollTop:h},100,"linear",function(){D.ddModel.isScrolling=!1,D.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){Ga(),D.itemsModel.isSelecting(!0)},stop:function(a,b){D.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(b,c){var e={createFolder:{name:T("create_folder"),className:"create-folder"},paste:{name:T("clipboard_paste"),className:"paste",disabled:function(a,b){return D.clipboardModel.isEmpty()}}};return D.clipboardModel.enabled()&&x.options.browseOnly!==!0||delete e.paste,d("createFolder")&&x.options.browseOnly!==!0||delete e.createFolder,!a.isEmptyObject(e)&&{appendTo:".fm-container",items:e,reposition:!1,callback:function(a,b){switch(a){case"createFolder":D.headerModel.createFolder();break;case"paste":D.clipboardModel.paste()}}}}}),x.extras.extra_js)for(var g=0;g400&&(this.yStartPosition=this.mcs.top),D.itemsModel.isSelecting()&&D.itemsModel.continiousSelection(!0);var b=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);v.selectable("repositionCssHelper",b,0)}D.itemsModel.lazyLoad&&D.itemsModel.lazyLoad.handleScroll()}},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()},Q=function(){var a=null,b={},c=k.settings.baseUrl+"/languages/";this.buildLangFileUrl=function(a){return c+a+".json"},this.setLang=function(b){a=b},this.getLang=function(){return a},this.setTranslations=function(a){b=a},this.getTranslations=function(){return b},this.translate=function(a){return b[a]}},R=function(){var a={},b=this;this.push=function(c,d,e){b.removeTimer(c),a[c]=setTimeout(d,e)},this.getTimer=function(b){return a[b]},this.removeTimer=function(b){a[b]&&(clearTimeout(a[b]),delete a[b])}},S=function(){function b(a){return(!x.manager.selection.enabled||!x.manager.selection.useCtrlKey||a.ctrlKey!==!0)&&(!x.manager.dblClickOpen||"click"!==a.type)}var c=this;this.config=ko.observable(x),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(x.manager.defaultViewMode),this.currentPath=ko.observable(y),this.browseOnly=ko.observable(x.options.browseOnly),this.previewModel=ko.observable(null),this.currentLang=E.getLang(),this.lg=E.getTranslations(),this.previewFile.subscribe(function(a){a||(c.previewModel.closeEditor(),c.itemsModel.descriptivePanel.rdo().id===c.previewModel.rdo().id&&c.itemsModel.descriptivePanel.render(c.previewModel.viewer.content()))}),this.isCapable=function(a){return d(a)},this.loadPath=function(a,b){var d,e=new s(a);b&&(d=D.treeModel.findByParam("id",a)),d&&e.setPreloader(D.treeModel.getPreloader(d)),e.setPreloader(c.itemsModel.getPreloader()).setDataHandler(function(a,b){d&&D.treeModel.addNodes(a,d,!0),c.itemsModel.addItems(a,b,!0),c.searchModel.clearInput()}).load(function(){return Ra(a)})},this.addElements=function(a,b,d){var e=c.treeModel.findByParam("id",b);e&&c.treeModel.addNodes(a,e,d),c.currentPath()===b&&c.itemsModel.addItems(a,b,d)},this.removeElement=function(a){var b=c.treeModel.findByParam("id",a.id);b&&b.remove();var d=c.itemsModel.findByParam("id",a.id);d&&d.remove()},this.fetchSelectedItems=function(a){var b,d;if(a===q.name)return c.itemsModel.getSelected();if(a===o.name)return c.treeModel.getSelected();if(!a)return b=c.treeModel.getSelected(),d=c.itemsModel.getSelected(),d.length>0?d:b;throw new Error("Unknown item type.")},this.fetchSelectedObjects=function(b){var d=[];return a.each(c.fetchSelectedItems(b.constructor.name),function(a,b){d.push(b.rdo)}),d};var f=function(){this.beforeLoad=function(a){},this.afterLoad=function(a,b){}},j=function(){var a=this,b=null;this.rdo=ko.observable({}),this.cdo=ko.observable({}),this.viewer={type:ko.observable("default"),isEditable:ko.observable(!1),url:ko.observable(null),pureUrl:ko.observable(null),options:ko.observable({}),content:ko.observable(null),codeMirror:ko.observable(null)},this.renderer=new L,this.editor=new M,this.rdo.subscribe(function(b){a.cdo({isFolder:"folder"===b.type,sizeFormatted:Z(b.attributes.size),createdFormatted:$(b.attributes.created),modifiedFormatted:$(b.attributes.modified),extension:"file"===b.type?ka(b.id):null,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(d){b&&b.destroy(),c.previewFile(!1);var e=d.attributes.name,f={interactive:!1},g={type:"default",url:null,options:{}};a.rdo(d),qa(e)&&(g.type="image",g.url=Ca(d,!1,!0)),sa(e)&&x.viewer.audio.enabled===!0&&(g.type="audio",g.url=Ba(d,!0)),ra(e)&&x.viewer.video.enabled===!0&&(g.type="video",g.url=Ba(d,!0),g.options={width:x.viewer.video.playerWidth,height:x.viewer.video.playerHeight}),ua(e)&&x.viewer.opendoc.enabled===!0&&(g.type="opendoc",g.url=k.settings.baseUrl+"/libs/ViewerJS/index.html#"+Ba(d,!0),g.options={width:x.viewer.opendoc.readerWidth,height:x.viewer.opendoc.readerHeight}),va(e)&&x.viewer.google.enabled===!0&&(g.type="google",g.url="https://docs.google.com/viewer?url="+encodeURIComponent(Ba(d,!1))+"&embedded=true",g.options={width:x.viewer.google.readerWidth,height:x.viewer.google.readerHeight}),ta(e)&&x.viewer.iframe.enabled===!0&&(g.type="iframe",g.url=Ba(d,!0),g.options={width:x.viewer.iframe.readerWidth,height:x.viewer.iframe.readerHeight}),(wa(e)&&x.viewer.codeMirrorRenderer.enabled===!0||xa(e)&&x.viewer.markdownRenderer.enabled===!0)&&(g.type="renderer",g.options={is_writable:d.attributes.writable},a.renderer.setRenderer(d),f.interactive=a.renderer.renderer().interactive),a.viewer.type(g.type),a.viewer.url(g.url),a.viewer.options(g.options),a.viewer.pureUrl(Ea(d)),a.viewer.isEditable(pa(e)&&x.editor.enabled===!0),a.editor.isInteractive(f.interactive),"renderer"===g.type||a.viewer.isEditable()?Qa(d).then(function(b){a.viewer.content(b),c.previewFile(!0)}):c.previewFile(!0)},this.afterRender=function(){a.renderer.render(a.viewer.content());var c=u.find(".btn-copy-url")[0];b=new Clipboard(c),b.on("success",function(a){k.success(T("copied"))})},this.initiateEditor=function(b){var c=u.find(".fm-cm-editor-content")[0];a.editor.createInstance(a.cdo().extension,c,{readOnly:!1,styleActiveLine:!0})},this.bindToolbar=function(b){e(a.rdo(),b)&&Xa(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.cdo().extension):c.push("file","lock")),b.push(c.join("_"))),b.join(" ")},this),this.closePreview=function(){c.previewFile(!1)},this.editFile=function(){var b=a.viewer.content();a.renderer.render(b),a.editor.render(b)},this.saveFile=function(){Pa(a.rdo())},this.closeEditor=function(){a.editor.enabled(!1),a.renderer.render(a.viewer.content())},this.buttonVisibility=function(b){switch(b){case"select":return e(a.rdo(),b)&&g();case"move":case"rename":case"delete":case"download":return e(a.rdo(),b)}}},n=function(){function b(a){if(null!==H){a||(a=d.rootNode);var b=d.findByFilter(function(a){return 0===H.indexOf(a.id)},a);b?(x.filetree.expandSpeed=10,d.loadDataNode(b,!1,!0)):(H=null,x.filetree.expandSpeed=200,d.setItemsFromNode(a))}}var d=this;this.selectedNode=ko.observable(null);var e=new o({attributes:{}});e.id=y,e.level=ko.observable(-1),this.rootNode=e,this.mapNodes=function(a,b){b||(b=d.rootNode),b.isRoot()||a.call(this,b);var c=b.children();if(!c||0===c.length)return null;for(var e=0,f=c.length;e0,this.closeButtonOnClick=function(){k.console("CLOSE button is clicked")},this.navHome=function(){c.previewFile(!1),c.itemsModel.loadDataList(y)},this.navLevelUp=function(){var a=c.previewFile()?ma(c.previewModel.rdo().id):na(c.currentPath());c.previewFile()&&c.previewFile(!1),a!==c.currentPath()&&c.itemsModel.loadDataList(a)},this.navRefresh=function(){c.previewFile()?(c.previewFile(!1),c.previewFile(!0)):c.itemsModel.loadDataList(c.currentPath())},this.displayGrid=function(){c.viewMode("grid"),c.previewFile(!1),c.itemsModel.lazyLoad&&c.itemsModel.lazyLoad.update()},this.displayList=function(){c.viewMode("list"),c.previewFile(!1)},this.switchLang=function(b){var c=b.target.value,d=E.getLang();if(c&&c.toLowerCase()!==d.toLowerCase()){var e,f=window.location.toString(),g=new RegExp("(langCode=)"+d);e=g.test(f)?f.replace(g,"$1"+c):f+(a.isEmptyObject(I.param())?"?":"#")+"langCode="+c,window.location.href=e}},this.createFolder=function(){function a(a,b){var c=b.getInputValue();return c?void za("GET",{mode:"addfolder",path:D.currentPath(),name:c}).done(function(a){a.data&&(D.addElements(a.data,D.currentPath()),b.closeDialog(),x.options.showConfirmation&&k.success(T("successful_added_folder")))}).fail(ba):void k.error(T("no_foldername"))}return d("createFolder")?void k.prompt({message:T("prompt_foldername"),value:T("default_foldername"),okBtn:{label:T("create_folder"),autoClose:!1,click:a},cancelBtn:{label:T("cancel")}}):(k.error(T("NOT_ALLOWED")),!1)}},z=function(){this.files=ko.observable(null),this.folders=ko.observable(null),this.size=ko.observable(null),this.enabled=ko.observable(!1),this.doSummarize=function(){Ua()}},A=function(){var b=this;this.name=ko.observable(null),this.setName=function(c){c&&x.filter&&a.isArray(x.filter[c])&&b.name(c)},this.getExtensions=function(){return b.name()?x.filter[b.name()]:null},this.filterItem=function(c){var d=b.getExtensions(),e=!c.cdo.hiddenBySearch;if(c.cdo.hiddenByType=!1,"file"===c.rdo.type&&a.isArray(d)){var f=ka(c.id),g=d.indexOf(f)!==-1;e=e&&g,c.cdo.hiddenByType=!g}c.visible(e)},this.filter=function(d){b.setName(d),a.each(c.itemsModel.objects(),function(a,c){b.filterItem(c)}),c.treeModel.mapNodes(function(a){b.filterItem(a)}),c.itemsModel.lazyLoad&&c.itemsModel.lazyLoad.update()},this.reset=function(){b.name(null),b.filter(null)}},F=function(){function b(){h?G.push("search",function(){d()},x.search.typingDelay):d()}function d(){var b=f.value(),d=x.search.caseSensitive?b:b.toLowerCase();if(""===b)return void(b!==g?e():k.warning(T("search_string_empty")));if(x.search.recursive){var h=c.currentPath(),i=new s(h);i.setPreloader(c.itemsModel.getPreloader()).setDataHandler(function(b,e){var g=[];x.search.caseSensitive?a.each(b,function(a,b){0===b.attributes.name.indexOf(d)&&g.push(b)}):g=b;var h=c.itemsModel.createItems(g);c.itemsModel.setItemsList(h),f.isRendered(!0)}).load(function(){return Sa(h,b)})}else a.each(c.itemsModel.objects(),function(a,b){var c=b.rdo.attributes.name;x.search.caseSensitive||(c=c.toLowerCase());var e=0===c.indexOf(d),f=!b.cdo.hiddenByType;f=f&&e,b.cdo.hiddenBySearch=!e,b.visible(f)}),f.isRendered(!0)}function e(){f.clearInput(),x.search.recursive?c.itemsModel.loadDataList(c.currentPath()):a.each(c.itemsModel.objects(),function(a,b){b.cdo.hiddenBySearch=!1,b.visible(!b.cdo.hiddenByType)})}var f=this,g="",h=!!x.search.typingDelay;this.value=ko.observable(""),this.isRendered=ko.observable(!1),this.value.subscribe(function(a){g=a},null,"beforeChange"),this.inputKeyUp=function(a,c){var d=c.which||c.keyCode,e=[16,17,18,27,37,38,39,40];if(h){if(e.indexOf(d)>-1)return;f.value(c.target.value)}(h||13===d)&&b()},this.seekItems=function(a,c){b()},this.reset=function(a,b){e()},this.clearInput=function(){g="",f.value(""),f.isRendered(!1),G.removeTimer("search")}},J=function(){function a(){e=[],b=null,f.itemsNum(0)}var b=null,e=[],f=this,g=d("copy")&&d("move");this.itemsNum=ko.observable(0),this.enabled=ko.observable(c.config().clipboard.enabled&&g),this.copy=function(){f.hasCapability("copy")&&(b="copy",e=c.fetchSelectedItems(),f.itemsNum(e.length))},this.cut=function(){f.hasCapability("cut")&&(b="cut",e=c.fetchSelectedItems(),f.itemsNum(e.length))},this.paste=function(){var d=c.currentPath();if(f.hasCapability("paste")&&!f.isEmpty())return null===b||0===e.length?void k.warning(T("clipboard_empty")):void Fa(e,function(a,c){return"cut"===b?La(c,d):"copy"===b?Ka(c,d):void 0},a)},this.clear=function(){f.hasCapability("clear")&&!f.isEmpty()&&(a(),k.success(T("clipboard_cleared")))},this.isEmpty=function(){return 0===e.length},this.hasCapability=function(a){if(!f.enabled)return!1;switch(a){case"copy":return d("copy");case"cut":return d("move");default:return!0}}},K=function(){var a=this;this.items=ko.observableArray([]),this.clean=function(){a.items([]),a.add(y,"")},this.add=function(c,d){a.items.push(new b(c,d))},this.splitPath=function(b){var c=y,d=b.replace(new RegExp("^"+y),"").split("/");for(a.clean();d.length>0;){var e=d.shift();e&&(c+=e+"/",a.add(c,e))}},this.splitCurrent=function(){a.splitPath(c.currentPath())},this.getLabel=ko.pureComputed(function(){var a=T(c.searchModel.isRendered()?"search_results":"current_folder");return a+": "},this);var b=function(a,b){var d=this;this.path=a,this.label=b,this.isRoot=a===y,this.active=a===c.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,b){a.active||c.itemsModel.loadDataList(a.path)}}},L=function(){function b(a){return xa(a)?new f:wa(a)?new e:void 0}var c,d=this;this.rdo=ko.observable({}),this.content=ko.observable(null),this.renderer=ko.observable(null),this.render=function(a){d.renderer()&&d.renderer().processContent(a)},this.setRenderer=function(a){d.rdo(a),d.renderer(b(a.attributes.name))},this.setContainer=function(b){a.each(b,function(){if(a(this).hasClass("fm-renderer-container"))return c=a(this),!1}),d.renderer().processDomElements(c)};var e=function(){this.name="codeMirror",this.interactive=!1;var a=new M;this.processContent=function(b){a.render(b),d.content(b)},this.processDomElements=function(b){if(!a.instance){var c=b.find(".fm-cm-renderer-content")[0],e=ka(d.rdo().id);a.createInstance(e,c,{readOnly:"nocursor",styleActiveLine:!1,lineNumbers:!1})}}},f=function(){function b(){c.find("a").each(function(){var b=a(this).attr("href"),c=D.previewModel.editor;if(c.enabled()&&c.isInteractive())a(this).off("click"),a(this).on("click",function(){return!1});else{if(b.search("://")!==-1||ha(b,"mailto:"))return;xa(b)&&a(this).on("click",function(a){return Ta(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'
'+e.utils.escapeHtml(a)+"
"},replaceLink:function(a,b){if(a.search("://")!==-1||ha(a,"mailto:"))return a;var c=ha(a,"/")?y:ma(d.rdo().id),e=c+fa(a,"/");if(xa(e))return e;var f=ya("GET",{mode:"readfile",path:e});return Aa(f)}}).use(window.markdownitReplaceLink);this.processContent=function(a){var c=e.render(a);d.content(c),b()},this.processDomElements=function(a){}}},M=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.editor.codeHighlight&&("js"===a&&(b.push("/libs/CodeMirror/mode/javascript/javascript.js"),c="javascript"),"css"===a&&(b.push("/libs/CodeMirror/mode/css/css.js"),c="css"),"html"===a&&(b.push("/libs/CodeMirror/mode/xml/xml.js"),c="text/html"),"xml"===a&&(b.push("/libs/CodeMirror/mode/xml/xml.js"),c="application/xml"),"php"===a&&(b.push("/libs/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/libs/CodeMirror/mode/xml/xml.js"),b.push("/libs/CodeMirror/mode/javascript/javascript.js"),b.push("/libs/CodeMirror/mode/css/css.js"),b.push("/libs/CodeMirror/mode/clike/clike.js"),b.push("/libs/CodeMirror/mode/php/php.js"),c="application/x-httpd-php"),"java"===a&&(b.push("/libs/CodeMirror/mode/clike/clike.js"),c="text/x-java"),"sql"===a&&(b.push("/libs/CodeMirror/mode/sql/sql.js"),c="text/x-mysql"),"md"===a&&(b.push("/libs/CodeMirror/addon/mode/overlay.js"),b.push("/libs/CodeMirror/mode/xml/xml.js"),b.push("/libs/CodeMirror/mode/markdown/markdown.js"),b.push("/libs/CodeMirror/mode/gfm/gfm.js"),b.push("/libs/CodeMirror/mode/javascript/javascript.js"),b.push("/libs/CodeMirror/mode/css/css.js"),b.push("/libs/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/libs/CodeMirror/mode/clike/clike.js"),b.push("/libs/CodeMirror/mode/shell/shell.js"),b.push("/libs/CodeMirror/mode/meta.js"),c="gfm"),"sh"===a&&(b.push("/libs/CodeMirror/addon/mode/overlay.js"),b.push("/libs/CodeMirror/mode/markdown/markdown.js"),b.push("/libs/CodeMirror/mode/gfm/gfm.js"),b.push("/libs/CodeMirror/mode/javascript/javascript.js"),b.push("/libs/CodeMirror/mode/css/css.js"),b.push("/libs/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/libs/CodeMirror/mode/clike/clike.js"),b.push("/libs/CodeMirror/mode/meta.js"),b.push("/libs/CodeMirror/mode/shell/shell.js"),c="shell")),b.length?(b.push(function(){d.mode(c)}),X(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.editor.lineNumbers,lineWrapping:x.editor.lineWrapping,theme:x.editor.theme,matchBrackets:x.editor.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)}},N=function(){function b(b){var c=a.grep(f.items,function(a,c){if("folder"===b.rdo.type||"parent"===b.rdo.type){if(ha(b.rdo.id,a.rdo.id))return!0;if(b.rdo.id===oa(a.rdo.id))return!0}return a.id===b.id});return b.rdo.attributes.writable&&0===c.length}function d(a){null!==f.hoveredItem&&f.hoveredItem.dragHovered(!1),f.hoveredItem=a,a&&a.dragHovered(!0)}function e(a,b){b?a.addClass(g):a.removeClass(g)}var f=this,g="drop-restricted",h=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,d){"file"!==b.rdo.type&&"folder"!==b.rdo.type||a(d).draggable({distance:3,cursor:"pointer",cursorAt:{left:Math.floor(h.width()/2),bottom:15},scroll:!1,appendTo:m,containment:l,refreshPositions:!1,helper:function(){var a,d;return d=c.fetchSelectedItems(b.constructor.name).length>1?"ico_multiple":"folder"===b.rdo.type?"ico_folder":"ico_file ico_ext_"+ka(b.rdo.id),a=h.children(".drag-helper").clone(),a.find(".clip").addClass(d),f.dragHelper=a,a},start:function(a,d){f.items=c.fetchSelectedItems(b.constructor.name)},drag:function(b,c){a(this).draggable("option","refreshPositions",f.isScrolling||f.isScrolled),f.isScrolled=!1},stop:function(a,b){f.items=[],f.dragHelper=null}})},this.makeDroppable=function(c,g){"folder"!==c.rdo.type&&"parent"!==c.rdo.type||a(g).droppable({tolerance:"pointer",enableExtendedEvents:c instanceof q,accept:function(a){var b=ko.dataFor(a[0]),c=b?b.rdo.type:null;return"file"===c||"folder"===c},over:function(a,f){setTimeout(function(){d(null),e(f.helper,!1),b(c)||e(f.helper,!0),d(c)},0)},out:function(a,b){d(null),e(b.helper,!1)},drop:function(a,e){return d(null),!!b(c)&&void Fa(f.items,function(a,b){return La(b.rdo,c.id)})}})}},O=function(){this.unselect=!1};this.treeModel=new n,this.itemsModel=new p,this.tableViewModel=new t,this.previewModel=new j,this.headerModel=new w,this.summaryModel=new z,this.filterModel=new A,this.searchModel=new F,this.clipboardModel=new J,this.breadcrumbsModel=new K,this.ddModel=new N,this.selectionModel=new O},T=function(a){return E.translate(a)},U=function(a){function b(a){var b,c=B;switch("list"===D.viewMode()&&(c=D.itemsModel.listSortField()),c){case"type":b=a.cdo.extension||"";break;case"size":b=a.rdo.attributes.size;break;case"modified":b=a.rdo.attributes.modified;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"===D.viewMode()?D.itemsModel.listSortOrder():C,f={natural:!0,order:"asc"===e?1:-1,cases:!1};a.sort(function(a,d){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&&(e=k.write(g.getMessage(),{delay:0,logMessageTemplate:function(a){var b=(g.getProgress(),g.isProcessed()?"striped":"striped animated");return"
"+a+'
'+g.getProgress()+'%
'}}),e.stick(!0)),a.each(b,function(a,b){h=h.then(function(){return c(a,b)}).then(function(a){a&&a.data?g.succeeded():g.failed(),e&&e.setMessage(g.getMessage())})}),h.then(function(){e&&g.isProcessed()&&(e.stick(!1),setTimeout(function(){e.remove()},6e3))}),h.then(function(){"function"==typeof d&&d()})},Ga=function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}},Ha=function(a){var b=null,c=Ba(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(I.param("field_name")&&(parent.document.getElementById(I.param("field_name")).value=c,"undefined"!=typeof parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),"undefined"!=typeof parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),I.param("ImperaviElementId"))if(window.opener);else{var e=I.param("ImperaviElementId"),f=parent.$("#"+e).redactor("core.getObject");f&&(f.modal.close(),f.buffer.set(),qa(a.attributes.name)?f.insert.html(''):f.insert.html(''+a.attributes.name+""))}if(I.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(I.param("CKEditorFuncNum"),c):(parent.CKEDITOR.tools.callFunction(I.param("CKEditorFuncNum"),c),parent.CKEDITOR.tools.callFunction(I.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",resourceObject:a,preview_url:c},"*"),k.settings.callbacks.afterSelectItem(a,c,b)},Ia=function(a){var b=function(b,c){var d=a.id,e=c.getInputValue();if(!e)return void k.error(T("new_filename"));if(!x.options.allowChangeExtensions){var f=ka(a.attributes.name);f.length>0&&(e=e+"."+f)}if(da(d)&&!ca(e)){var g="

"+T("INVALID_FILE_TYPE")+"

";return"ALLOW_LIST"===x.security.extensions.policy&&(g+="

"+T("ALLOWED_FILE_TYPE").replace("%s",x.security.extensions.restrictions.join(", "))+".

"),"DISALLOW_LIST"===x.security.extensions.policy&&(g+="

"+T("DISALLOWED_FILE_TYPE").replace("%s",x.security.extensions.restrictions.join(", "))+".

"),void k.error(g)}za("GET",{mode:"rename",old:d,"new":e}).done(function(a){if(a.data){var b=a.data,e=D.treeModel.findByParam("id",d);if(e&&("folder"===e.rdo.type&&(e.nodeTitle(b.attributes.name),D.treeModel.actualizeNodeObject(e,d,b.id)),"file"===e.rdo.type)){var f=e.parentNode(),g=D.treeModel.createNode(b);e.remove(),f&&D.treeModel.appendNodes(f,g)}var h=D.itemsModel.parentItem();if(h&&h.id===d)D.itemsModel.parentItem().id=b.id;else{var i=D.itemsModel.findByParam("id",d);if(i){i.remove();var j=D.itemsModel.createItem(b);D.itemsModel.appendItems(j)}}D.currentPath()===d&&D.itemsModel.loadDataList(b.id),D.previewFile()&&D.previewModel.rdo().id===d&&D.previewModel.applyObject(b),c.closeDialog(),x.options.showConfirmation&&k.success(T("successful_rename"))}}).fail(ba)};k.prompt({message:T("new_filename"),value:x.options.allowChangeExtensions?a.attributes.name:la(a.attributes.name),okBtn:{label:T("action_rename"),autoClose:!1,click:b},cancelBtn:{label:T("cancel")}})},Ja=function(a,b){var c=function(a,c){var d=c.getInputValue();return d?(d=ga(d,"/")+"/",void b(d)):void k.error(T("prompt_foldername"))},d=a.length,e=d>1?T("prompt_move_multiple").replace("%s",d):T("prompt_move");k.prompt({message:e,value:D.currentPath(),okBtn:{label:T("action_move"),autoClose:!1,click:c},cancelBtn:{label:T("cancel")},template:{dialogInput:'
'+T("help_move")+"
"}})},Ka=function(a,b){return za("GET",{mode:"copy",source:a.id,target:b}).done(function(a){if(a.data){var c=a.data;D.addElements(c,b),alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("successful_copied"))}}).fail(ba)},La=function(a,b){return za("GET",{mode:"move",old:a.id,"new":b}).done(function(c){if(c.data){var d=c.data;D.removeElement(a),D.addElements(d,b),D.currentPath()===a.id&&D.itemsModel.loadDataList(d.id),D.previewFile()&&D.previewModel.rdo().id===a.id&&D.previewFile(!1),alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("successful_moved"))}}).fail(ba)},Ma=function(a,b){var c=a.length,d=c>1?T("confirm_delete_multiple").replace("%s",c):T("confirm_delete");k.confirm({message:d,okBtn:{label:T("yes"),click:function(a,c){b()}},cancelBtn:{label:T("no")}})},Na=function(a){return za("GET",{mode:"delete",path:a}).done(function(a){if(a.data){var b=a.data;if(D.removeElement(b),"folder"===b.type&&ha(D.currentPath(),b.id)){var c=na(b.id);D.itemsModel.loadDataList(c)}D.previewFile()&&D.previewModel.rdo().id===b.id&&D.previewFile(!1),x.options.showConfirmation&&k.success(T("successful_delete"))}}).fail(ba)},Oa=function(b){var c={mode:"download",path:b.id};a.fileDownload(Aa(ya("GET",c)),{failCallback:function(b,c,d){var e=a(b).text(),f=a.parseJSON(e);a.isPlainObject(f)&&f.errors&&aa(f.errors)}})},Pa=function(b){var c=a("#fm-js-editor-form").serializeArray();za("POST",c).done(function(a){if(a.data){var b=a.data,c=D.previewModel,d=c.editor.content();c.rdo(b),c.viewer.content(d),c.closeEditor();var e=D.itemsModel.createItem(b),f=D.itemsModel.findByParam("id",b.id);D.itemsModel.objects.replace(f,e),k.success(T("successful_edit"))}}).fail(ba)},Qa=function(a){return za("GET",{mode:"readfile",path:a.id},"text").fail(ba)},Ra=function(a){return za("GET",{mode:"readfolder",path:a}).fail(ba)},Sa=function(a,b){return za("GET",{mode:"seekfolder",path:a,string:b}).fail(ba)},Ta=function(a){return za("GET",{mode:"getinfo",path:a}).fail(ba)},Ua=function(){return za("GET",{mode:"summarize"}).done(function(b){if(b.data){var c=b.data.attributes,d=Z(c.size,!0);if(c.sizeLimit>0){var e=Z(c.sizeLimit,!0),f=100*c.size/c.sizeLimit,g=Math.round(100*f)/100;d+=" ("+g+"%) "+T("of")+" "+e}D.summaryModel.files(c.files),D.summaryModel.folders(c.folders),D.summaryModel.size(d),D.summaryModel.enabled(!0);var h=a("#summary-popup").clone().show();D.summaryModel.enabled(!1),k.alert(h[0].outerHTML)}}).fail(ba)},Va=function(a){var b=function(b,c){var d=c.getInputValue();return d?(d=ga(d,"/")+"/",void Wa(a,d)):void k.error(T("prompt_foldername"))};k.prompt({message:T("prompt_extract"),value:D.currentPath(),okBtn:{label:T("action_extract"),autoClose:!1,click:b},cancelBtn:{label:T("cancel")}})},Wa=function(a,b){za("POST",{mode:"extract",source:a.id,target:b}).done(function(a){a.data&&(D.addElements(a.data,b),alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("successful_extracted")))}).fail(ba)},Xa=function(b,c,d,e){var f=e?e:[d];switch(b){case"select":Ha(d);break;case"download":a.each(f,function(a,b){Oa(b)});break;case"rename":Ia(d);break;case"move":Ja(f,function(a){Fa(f,function(b,c){return La(c,a)})});break;case"delete":Ma(f,function(){Fa(f,function(a,b){return Na(b.id)})});break;case"extract":Va(d);break;case"copy":D.clipboardModel.copy(f);break;case"cut":D.clipboardModel.cut(f);break;case"copyUrl":var g=new Clipboard(c.$selected[0],{text:function(a){return Ea(d)}});g.on("success",function(a){k.success(T("copied")),g.destroy()})}},Ya=function(){return!x.options.browseOnly&&void(x.upload.multiple?w.unbind().click(function(){if(!d("upload"))return k.error(T("NOT_ALLOWED")),!1;var b=null,c=D.currentPath(),e=tmpl("tmpl-fileupload-container",{folder:T("current_folder")+c,info:T("upload_files_number_limit").replace("%s",x.upload.maxNumberOfFiles)+" "+T("upload_file_size_limit").replace("%s",Z(x.upload.fileSizeLimit,!0)),lang:E.getTranslations()});"ALLOW_LIST"===x.security.extensions.policy&&(b=new RegExp("(\\.|\\/)("+x.security.extensions.restrictions.join("|")+")$","i")),k.dialog({message:e,width:"auto",buttons:[{type:"ok",label:T("action_upload"),autoClose:!1,click:function(a,b){g.children(".upload-item").length>0?g.find(".button-start").trigger("click"):k.error(T("upload_choose_file"))}},{label:T("action_select"),closeOnClick:!1,click:function(b,c){a("#fileupload",f).trigger("click")}},{type:"cancel",label:T("close")}]});var f=a(".fm-fileupload-container"),g=a(".dropzone",f),h=a(".dropzone-wrapper",f),i=a("#total-progress",f).children();x.customScrollbar.enabled&&h.mCustomScrollbar({theme:x.customScrollbar.theme,scrollButtons:{enable:x.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){h.find(".mCSB_container").css({"margin-right":h.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){h.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),h.on("click",function(b){(b.target===this||a(b.target).parent()[0]===this||b.target===g[0]||a(b.target).parent().hasClass("default-message"))&&a("#fileupload",f).trigger("click")}),g.on("click",".button-start",function(b){var c=a(this),d=c.parent().parent(),e=d.data();e.submit(),c.remove()}),g.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(T("upload_aborted")),f.addClass("aborted")}),g.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;Ta(i).then(function(a){a.data&&(g.uploadedBytes=Number(a.data.attributes.size),g.uploadedBytes||(h.chunkUploaded=void 0),d(g))})}else d(g)}),g.on("click",".button-remove",function(b){var d=a(this),e=d.parent().parent(),f=e.data(),g=f.files[0];g.chunkUploaded&&Na(c+g.serverName),d.closest(".upload-item").remove(),j()}),g.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 j=function(){g.children(".upload-item").length>0?g.addClass("started"):g.removeClass("started")},l=D.filterModel.getExtensions();l&&a("#fileupload").attr("accept",l.map(function(a){return"."+a}).join()),a("#fileupload",f).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:g,maxChunkSize:x.upload.chunkSize,url:Aa(),paramName:x.upload.paramName,singleFileUploads:!0,formData:ya("POST",{mode:"upload",path:c}),maxNumberOfFiles:x.upload.maxNumberOfFiles,acceptFileTypes:b,maxFileSize:x.upload.fileSizeLimit,messages:{maxNumberOfFiles:T("upload_files_number_limit").replace("%s",x.upload.maxNumberOfFiles),acceptFileTypes:T("upload_file_type_invalid"),maxFileSize:T("upload_file_too_big")+" "+T("upload_file_size_limit").replace("%s",Z(x.upload.fileSizeLimit,!0))},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(b,c){var d=g.children(".upload-item");a.each(c.files,function(b,e){if(d.length>=x.upload.maxNumberOfFiles)return k.error(T("upload_files_number_limit").replace("%s",x.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;e.formattedSize=Z(e.size);var f=a(tmpl("tmpl-upload-item",{file:e,lang:E.getTranslations(),imagesPath:k.settings.baseUrl+"/libs/jQuery-File-Upload/img"}));e.context=f,f.find(".buttons").data(c),f.appendTo(g)}),j()}).on("fileuploadsend",function(b,c){return k.settings.callbacks.beforeSendRequest(c.type,c.formData)===!1?(a.each(c.files,function(a,b){ -var c=b.context;c.find(".error-message").text(T("NOT_ALLOWED")),c.removeClass("added process").addClass("error")}),!1):void 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){var d,e=c.jqXHR;d=a.isPlainObject(e.responseJSON)&&e.responseJSON.errors?_(e.responseJSON.errors[0]):T("upload_failed"),a.each(c.files,function(a,b){var c=b.context;c.removeClass("added process").addClass("error"),c.find(".error-message").text(d),c.find(".button-start").remove()})}).on("fileuploaddone",function(b,c){var d=c.result;a.each(c.files,function(a,b){d&&d.data&&d.data[a]&&b.context.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];D.removeElement(c),D.addElements(c,D.currentPath())}});var e=g.children(".upload-item");0===e.filter(".added").length&&0===e.filter(".process").length&&(0===e.length&&(alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("upload_successful_files"))),e.filter(".error").length&&k.error(T("upload_partially")+"
"+T("upload_failed_details"))),j()}).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];D.removeElement(c),D.addElements(c,D.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);i.css("width",c+"%")})}):(w.unbind().click(function(){return d("upload")?void a("#newfile").trigger("click"):(k.error(T("NOT_ALLOWED")),!1)}),o.fileupload({autoUpload:!0,dataType:"json",url:Aa(),paramName:x.upload.paramName,maxChunkSize:x.upload.chunkSize}).on("fileuploadadd",function(a,b){w.data(b)}).on("fileuploadsubmit",function(a,b){b.formData=ya("POST",{mode:"upload",path:D.currentPath()}),w.addClass("loading").prop("disabled",!0),w.children("span").text(T("loading_data"))}).on("fileuploadsend",function(a,b){if(k.settings.callbacks.beforeSendRequest(b.type,b.formData)===!1)return k.error(T("NOT_ALLOWED")),!1}).on("fileuploadalways",function(a,b){w.removeData().removeClass("loading").prop("disabled",!1),w.children("span").text(T("action_upload"));var c=b.result;if(c&&c.data){var d=c.data[0];D.removeElement(d),D.addElements(d,D.currentPath()),x.options.showConfirmation&&k.success(T("upload_successful_file"))}}).on("fileuploadchunkdone",function(a,b){var c=b.result;if(c.data&&c.data[0]){var d=c.data[0];D.removeElement(d),D.addElements(d,D.currentPath())}}).on("fileuploadfail",function(b,c){var d,e=c.jqXHR;d=a.isPlainObject(e.responseJSON)&&e.responseJSON.errors?_(e.responseJSON.errors[0]):T("upload_failed"),k.error(d)})))};J(),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(a){return A.indexOf(a)>-1}function e(b,c){if(!d(c))return!1;if("select"===c&&"folder"===b.type)return!1;if("extract"===c){var e=ka(b.attributes.name);return"file"===b.type&&"zip"===e}return"download"===c&&"folder"===b.type?x.options.allowFolderDownload===!0:"undefined"==typeof b.attributes.capabilities||a.inArray(c,b.attributes.capabilities)>-1}function f(){x.filetree.enabled&&(s.show(),p.splitter({sizeLeft:x.filetree.width,minLeft:x.filetree.minWidth,minRight:200}))}function g(){return window.opener||window.parent&&window.self!==window.parent||window.tinyMCEPopup||I.param("field_name")||I.param("CKEditor")||I.param("ImperaviElementId")}function h(a){return a.attributes.readable?("file"===a.type&&D.previewModel.applyObject(a),void("folder"!==a.type&&"parent"!==a.type||(D.previewFile(!1),D.itemsModel.loadDataList(a.id)))):(k.error(T("NOT_ALLOWED_SYSTEM")),!1)}function i(a){var b=!D.clipboardModel.enabled(),c={select:{name:T("action_select"),className:"select"},download:{name:T("action_download"),className:"download"},rename:{name:T("action_rename"),className:"rename"},move:{name:T("action_move"),className:"move"},separator1:"-----",copy:{name:T("clipboard_copy"),className:"copy"},cut:{name:T("clipboard_cut"),className:"cut"},"delete":{name:T("action_delete"),className:"delete"},extract:{name:T("action_extract"),className:"extract"},copyUrl:{name:T("copy_to_clipboard"),className:"copy-url"}};return e(a,"download")||delete c.download,e(a,"select")&&g()||delete c.select,e(a,"rename")&&x.options.browseOnly!==!0||delete c.rename,e(a,"delete")&&x.options.browseOnly!==!0||delete c["delete"],e(a,"extract")&&x.options.browseOnly!==!0||delete c.extract,e(a,"copy")&&x.options.browseOnly!==!0&&!b||delete c.copy,e(a,"move")&&x.options.browseOnly!==!0&&!b||(delete c.cut,delete c.move),c}var j={baseUrl:".",configUrl:null,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){},beforeSetRequestParams:function(a,b){return b},beforeSendRequest:function(a,b){return!0}}},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="/",z=null,A=[],B=null,C=null,D=null,E=null,F=null,G=null,H=null,I=purl();(new Date).getTime();k.settings=a.extend(!0,j,c),k.write=function(b,c){var d=alertify,e=a.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"},c);if(e.logClass&&e.unique&&a(".fm-log").children("."+e.logClass).length>0)return d;e.reset&&d.reset(),d.parent(e.parent),d.logDelay(e.delay),d.logMaxItems(e.logMaxItems),d.logPosition(e.logPosition),d.logContainerClass(e.logContainerClass),d.logMessageTemplate(e.logMessageTemplate),d[e.type](b,e.onClick);var f=d.getLogs();return f[f.length-1]},k.error=function(b,c){return k.write(b,a.extend({},{type:"error",delay:1e4},c))},k.warning=function(b,c){return k.write(b,a.extend({},{type:"warning",delay:1e4},c))},k.success=function(b,c){return k.write(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)},k.console=function(){x.options.logger&&arguments&&[].unshift.call(arguments,(new Date).getTime())},k.refreshFolder=function(a){D.loadPath(D.currentPath(),a)},k.loadFolder=function(a,b){a="/"+ea(a,"/")+"/",D.loadPath(a,b)};var J=function(){var b=a.Deferred();b.then(function(){return K()}).then(function(){return M()}).then(function(a,b){return L()}).then(function(){return N()}).then(function(){O(function(){P()})}),b.resolve()},K=function(){return a.when(W("default"),W("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)z=x.api.connectorUrl;else{var f=location.origin+location.pathname,g="connectors/"+x.api.lang+"/filemanager."+x.api.lang;ka(f).length>0&&(f=f.substring(0,f.lastIndexOf("/")+1)),z=f+g}})},L=function(){return za("GET",{mode:"initiate"}).done(function(b){if(b.data){var c=b.data.attributes.config;a.each(c,function(b,c){a.each(c,function(a,c){return null===c||(void 0===x[b]&&(x[b]=[]),void(x[b][a]=c))})}),c.options&&c.options.capabilities&&(x.options.capabilities=c.options.capabilities)}}).fail(function(a){k.error("Unable to perform initial request to server."),ba(a)}).then(function(b){if(b.errors)return a.Deferred().reject()})},M=function(){return E=new Q,a.ajax().then(function(){var a=I.param("langCode");return a?V(E.buildLangFileUrl(a)).done(function(){E.setLang(a)}).fail(function(){setTimeout(function(){k.error("Given language file ("+E.buildLangFileUrl(a)+") does not exist!")},500)}):void E.setLang(x.language["default"])}).then(function(){var b=E.buildLangFileUrl(E.getLang())+"?_="+(new Date).getTime();return a.ajax({type:"GET",url:b,dataType:"json"}).done(function(a){E.setTranslations(a)})}).then(function(){var b=E.getLang().substr(0,2),c=k.settings.baseUrl;return a.when(a.get(c+"/libs/cldrjs/cldr-dates/"+b+"/ca-gregorian.json"),a.get(c+"/libs/cldrjs/cldr-numbers/"+b+"/numbers.json"),a.get(c+"/libs/cldrjs/cldr-core/supplemental/likelySubtags.json"),a.get(c+"/libs/cldrjs/cldr-core/supplemental/timeData.json"),a.get(c+"/libs/cldrjs/cldr-core/supplemental/weekData.json")).fail(function(){k.error('CLDR files for "'+b+'" language do not exist!')}).then(function(){return[].slice.apply(arguments,[0]).map(function(a){return a[0]})}).then(Globalize.load).then(function(){F=Globalize(b)})})},N=function(){return a.when(Y("upload-container"),Y("upload-item")).done(function(a,b){var c=a[0],d=b[0];m.append(c).append(d)})},O=function(a){var b=[],c=[];if(b.push("/themes/"+x.options.theme+"/styles/theme.css"),x.viewer.image.lazyLoad&&b.push("/libs/lazyload/dist/lazyload.min.js"),x.customScrollbar.enabled&&(b.push("/libs/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"),b.push("/libs/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js")),b.push(a),X(b),x.editor.enabled){var d=x.editor.theme;d&&"default"!==d&&c.push("/libs/CodeMirror/theme/"+d+".css"),c.push("/libs/CodeMirror/lib/codemirror.css"),c.push("/libs/CodeMirror/lib/codemirror.js"),c.push("/libs/CodeMirror/addon/selection/active-line.js"),c.push("/libs/CodeMirror/addon/display/fullscreen.css"),c.push("/libs/CodeMirror/addon/display/fullscreen.js")}x.viewer.markdownRenderer.enabled&&(c.push("/src/css/fm-markdown.css"),c.push("/libs/markdown-it/markdown-it.min.js"),c.push("/libs/markdown-it/default.min.css"),c.push("/libs/markdown-it/highlight.min.js"),c.push("/libs/markdown-it/markdown-it-footnote.min.js"),c.push("/libs/markdown-it/markdown-it-replace-link.min.js")),x.options.browseOnly||(c.push("/src/js/libs-fileupload.js"),x.upload.multiple&&c.push("/libs/jQuery-File-Upload/css/dropzone.css")),c.length&&X(c)},P=function(){G=new R,A=x.options.capabilities||["upload","select","download","rename","copy","move","delete","extract","createFolder"],x.security.readOnly&&(x.options.browseOnly=!0),x.upload.paramName||(x.upload.paramName="files");var b=[];x.options.fileSorting&&(b=x.options.fileSorting.toLowerCase().split("_")),B=b[0]||"name",C=b[1]||"asc";var c=I.param("exclusiveFolder");c&&(y="/"+c+"/",y=ja(y));var e=I.param("expandedFolder");if(e&&(H=y+e+"/",H=ja(H)),D=new S,ko.applyBindings(D),D.itemsModel.initiateLazyLoad(),D.filterModel.setName(I.param("filter")),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){D.ddModel.makeDraggable(b(),a)}},ko.bindingHandlers.droppableView={init:function(a,b,c){D.ddModel.makeDroppable(b(),a)}},ko.bindingHandlers.draggableTree={init:function(a,b,c){D.ddModel.makeDraggable(b(),a)}},ko.bindingHandlers.droppableTree={init:function(a,b,c){D.ddModel.makeDroppable(b(),a)}},m.mousewheel(function(b){if(!D.ddModel.dragHelper)return!0;var c,d=null;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 e=d.find(".mCSB_scrollTools_vertical"),f=1===b.deltaY?"+":"-";e.is(":visible")&&d.mCustomScrollbar("scrollTo",[f+"=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;D.ddModel.isScrolling=!0,h=h<0?0:h,d.stop().animate({scrollTop:h},100,"linear",function(){D.ddModel.isScrolling=!1,D.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){Ga(),D.itemsModel.isSelecting(!0)},stop:function(a,b){D.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(b,c){var e={createFolder:{name:T("create_folder"),className:"create-folder"},paste:{name:T("clipboard_paste"),className:"paste",disabled:function(a,b){return D.clipboardModel.isEmpty()}}};return D.clipboardModel.enabled()&&x.options.browseOnly!==!0||delete e.paste,d("createFolder")&&x.options.browseOnly!==!0||delete e.createFolder,!a.isEmptyObject(e)&&{appendTo:".fm-container",items:e,reposition:!1,callback:function(a,b){switch(a){case"createFolder":D.headerModel.createFolder();break;case"paste":D.clipboardModel.paste()}}}}}),x.extras.extra_js)for(var g=0;g400&&(this.yStartPosition=this.mcs.top),D.itemsModel.isSelecting()&&D.itemsModel.continiousSelection(!0);var b=Math.abs(this.mcs.top)-Math.abs(this.yStartPosition);v.selectable("repositionCssHelper",b,0)}D.itemsModel.lazyLoad&&D.itemsModel.lazyLoad.handleScroll()}},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()},Q=function(){var a=null,b={},c=k.settings.baseUrl+"/languages/";this.buildLangFileUrl=function(a){return c+a+".json"},this.setLang=function(b){a=b},this.getLang=function(){return a},this.setTranslations=function(a){b=a},this.getTranslations=function(){return b},this.translate=function(a){return b[a]}},R=function(){var a={},b=this;this.push=function(c,d,e){b.removeTimer(c),a[c]=setTimeout(d,e)},this.getTimer=function(b){return a[b]},this.removeTimer=function(b){a[b]&&(clearTimeout(a[b]),delete a[b])}},S=function(){function b(a){return(!x.manager.selection.enabled||!x.manager.selection.useCtrlKey||a.ctrlKey!==!0)&&(!x.manager.dblClickOpen||"click"!==a.type)}var c=this;this.config=ko.observable(x),this.loadingView=ko.observable(!0),this.previewFile=ko.observable(!1),this.viewMode=ko.observable(x.manager.defaultViewMode),this.currentPath=ko.observable(y),this.browseOnly=ko.observable(x.options.browseOnly),this.previewModel=ko.observable(null),this.currentLang=E.getLang(),this.lg=E.getTranslations(),this.previewFile.subscribe(function(a){a||(c.previewModel.closeEditor(),c.itemsModel.descriptivePanel.rdo().id===c.previewModel.rdo().id&&c.itemsModel.descriptivePanel.render(c.previewModel.viewer.content()))}),this.isCapable=function(a){return d(a)},this.loadPath=function(a,b){var d,e=new s(a);b&&(d=D.treeModel.findByParam("id",a)),d&&e.setPreloader(D.treeModel.getPreloader(d)),e.setPreloader(c.itemsModel.getPreloader()).setDataHandler(function(a,b){d&&D.treeModel.addNodes(a,d,!0),c.itemsModel.addItems(a,b,!0),c.searchModel.clearInput()}).load(function(){return Ra(a)})},this.addElements=function(a,b,d){var e=c.treeModel.findByParam("id",b);e&&c.treeModel.addNodes(a,e,d),c.currentPath()===b&&c.itemsModel.addItems(a,b,d)},this.removeElement=function(a){var b=c.treeModel.findByParam("id",a.id);b&&b.remove();var d=c.itemsModel.findByParam("id",a.id);d&&d.remove()},this.fetchSelectedItems=function(a){var b,d;if(a===q.name)return c.itemsModel.getSelected();if(a===o.name)return c.treeModel.getSelected();if(!a)return b=c.treeModel.getSelected(),d=c.itemsModel.getSelected(),d.length>0?d:b;throw new Error("Unknown item type.")},this.fetchSelectedObjects=function(b){var d=[];return a.each(c.fetchSelectedItems(b.constructor.name),function(a,b){d.push(b.rdo)}),d};var f=function(){this.beforeLoad=function(a){},this.afterLoad=function(a,b){}},j=function(){var a=this,b=null;this.rdo=ko.observable({}),this.cdo=ko.observable({}),this.viewer={type:ko.observable("default"),isEditable:ko.observable(!1),url:ko.observable(null),pureUrl:ko.observable(null),options:ko.observable({}),content:ko.observable(null),codeMirror:ko.observable(null)},this.renderer=new L,this.editor=new M,this.rdo.subscribe(function(b){a.cdo({isFolder:"folder"===b.type,sizeFormatted:Z(b.attributes.size),createdFormatted:$(b.attributes.created),modifiedFormatted:$(b.attributes.modified),extension:"file"===b.type?ka(b.id):null,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(d){b&&b.destroy(),c.previewFile(!1);var e=d.attributes.name,f={interactive:!1},g={type:"default",url:null,options:{}};a.rdo(d),qa(e)&&(g.type="image",g.url=Ca(d,!1,!0)),sa(e)&&x.viewer.audio.enabled===!0&&(g.type="audio",g.url=Ba(d,!0)),ra(e)&&x.viewer.video.enabled===!0&&(g.type="video",g.url=Ba(d,!0),g.options={width:x.viewer.video.playerWidth,height:x.viewer.video.playerHeight}),ua(e)&&x.viewer.opendoc.enabled===!0&&(g.type="opendoc",g.url=k.settings.baseUrl+"/libs/ViewerJS/index.html#"+Ba(d,!0),g.options={width:x.viewer.opendoc.readerWidth,height:x.viewer.opendoc.readerHeight}),va(e)&&x.viewer.google.enabled===!0&&(g.type="google",g.url="https://docs.google.com/viewer?url="+encodeURIComponent(Ba(d,!1))+"&embedded=true",g.options={width:x.viewer.google.readerWidth,height:x.viewer.google.readerHeight}),ta(e)&&x.viewer.iframe.enabled===!0&&(g.type="iframe",g.url=Ba(d,!0),g.options={width:x.viewer.iframe.readerWidth,height:x.viewer.iframe.readerHeight}),(wa(e)&&x.viewer.codeMirrorRenderer.enabled===!0||xa(e)&&x.viewer.markdownRenderer.enabled===!0)&&(g.type="renderer",g.options={is_writable:d.attributes.writable},a.renderer.setRenderer(d),f.interactive=a.renderer.renderer().interactive),a.viewer.type(g.type),a.viewer.url(g.url),a.viewer.options(g.options),a.viewer.pureUrl(Ea(d)),a.viewer.isEditable(pa(e)&&x.editor.enabled===!0),a.editor.isInteractive(f.interactive),"renderer"===g.type||a.viewer.isEditable()?Qa(d).then(function(b){a.viewer.content(b),c.previewFile(!0)}):c.previewFile(!0)},this.afterRender=function(){a.renderer.render(a.viewer.content());var c=u.find(".btn-copy-url")[0];b=new Clipboard(c),b.on("success",function(a){k.success(T("copied"))})},this.initiateEditor=function(b){var c=u.find(".fm-cm-editor-content")[0];a.editor.createInstance(a.cdo().extension,c,{readOnly:!1,styleActiveLine:!0})},this.bindToolbar=function(b){e(a.rdo(),b)&&Xa(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.cdo().extension):c.push("file","lock")),b.push(c.join("_"))),b.join(" ")},this),this.closePreview=function(){c.previewFile(!1)},this.editFile=function(){var b=a.viewer.content();a.renderer.render(b),a.editor.render(b)},this.saveFile=function(){Pa(a.rdo())},this.closeEditor=function(){a.editor.enabled(!1),a.renderer.render(a.viewer.content())},this.buttonVisibility=function(b){switch(b){case"select":return e(a.rdo(),b)&&g();case"move":case"rename":case"delete":case"download":return e(a.rdo(),b)}}},n=function(){function b(a){if(null!==H){a||(a=d.rootNode);var b=d.findByFilter(function(a){return 0===H.indexOf(a.id)},a);b?(x.filetree.expandSpeed=10,d.loadDataNode(b,!1,!0)):(H=null,x.filetree.expandSpeed=200,d.setItemsFromNode(a))}}var d=this;this.selectedNode=ko.observable(null);var e=new o({attributes:{}});e.id=y,e.level=ko.observable(-1),this.rootNode=e,this.mapNodes=function(a,b){b||(b=d.rootNode),b.isRoot()||a.call(this,b);var c=b.children();if(!c||0===c.length)return null;for(var e=0,f=c.length;e0,this.closeButtonOnClick=function(){k.console("CLOSE button is clicked")},this.navHome=function(){c.previewFile(!1),c.itemsModel.loadDataList(y)},this.navLevelUp=function(){var a=c.previewFile()?ma(c.previewModel.rdo().id):na(c.currentPath());c.previewFile()&&c.previewFile(!1),a!==c.currentPath()&&c.itemsModel.loadDataList(a)},this.navRefresh=function(){c.previewFile()?(c.previewFile(!1),c.previewFile(!0)):c.itemsModel.loadDataList(c.currentPath())},this.displayGrid=function(){c.viewMode("grid"),c.previewFile(!1),c.itemsModel.lazyLoad&&c.itemsModel.lazyLoad.update()},this.displayList=function(){c.viewMode("list"),c.previewFile(!1)},this.switchLang=function(b){var c=b.target.value,d=E.getLang();if(c&&c.toLowerCase()!==d.toLowerCase()){var e,f=window.location.toString(),g=new RegExp("(langCode=)"+d);e=g.test(f)?f.replace(g,"$1"+c):f+(a.isEmptyObject(I.param())?"?":"#")+"langCode="+c,window.location.href=e}},this.createFolder=function(){function a(a,b){var c=b.getInputValue();return c?void za("GET",{mode:"addfolder",path:D.currentPath(),name:c}).done(function(a){a.data&&(D.addElements(a.data,D.currentPath()),b.closeDialog(),x.options.showConfirmation&&k.success(T("successful_added_folder")))}).fail(ba):void k.error(T("no_foldername"))}return d("createFolder")?void k.prompt({message:T("prompt_foldername"),value:T("default_foldername"),okBtn:{label:T("create_folder"),autoClose:!1,click:a},cancelBtn:{label:T("cancel")}}):(k.error(T("NOT_ALLOWED")),!1)}},z=function(){this.files=ko.observable(null),this.folders=ko.observable(null),this.size=ko.observable(null),this.enabled=ko.observable(!1),this.doSummarize=function(){Ua()}},A=function(){var b=this;this.name=ko.observable(null),this.setName=function(c){c&&x.filter&&a.isArray(x.filter[c])&&b.name(c)},this.getExtensions=function(){return b.name()?x.filter[b.name()]:null},this.filterItem=function(c){var d=b.getExtensions(),e=!c.cdo.hiddenBySearch;if(c.cdo.hiddenByType=!1,"file"===c.rdo.type&&a.isArray(d)){var f=ka(c.id),g=d.indexOf(f)!==-1;e=e&&g,c.cdo.hiddenByType=!g}c.visible(e)},this.filter=function(d){b.setName(d),a.each(c.itemsModel.objects(),function(a,c){b.filterItem(c)}),c.treeModel.mapNodes(function(a){b.filterItem(a)}),c.itemsModel.lazyLoad&&c.itemsModel.lazyLoad.update()},this.reset=function(){b.name(null),b.filter(null)}},F=function(){function b(){h?G.push("search",function(){d()},x.search.typingDelay):d()}function d(){var b=f.value(),d=x.search.caseSensitive?b:b.toLowerCase();if(""===b)return void(b!==g?e():k.warning(T("search_string_empty")));if(x.search.recursive){var h=c.currentPath(),i=new s(h);i.setPreloader(c.itemsModel.getPreloader()).setDataHandler(function(b,e){var g=[];x.search.caseSensitive?a.each(b,function(a,b){0===b.attributes.name.indexOf(d)&&g.push(b)}):g=b;var h=c.itemsModel.createItems(g);c.itemsModel.setItemsList(h),f.isRendered(!0)}).load(function(){return Sa(h,b)})}else a.each(c.itemsModel.objects(),function(a,b){var c=b.rdo.attributes.name;x.search.caseSensitive||(c=c.toLowerCase());var e=0===c.indexOf(d),f=!b.cdo.hiddenByType;f=f&&e,b.cdo.hiddenBySearch=!e,b.visible(f)}),f.isRendered(!0)}function e(){f.clearInput(),x.search.recursive?c.itemsModel.loadDataList(c.currentPath()):a.each(c.itemsModel.objects(),function(a,b){b.cdo.hiddenBySearch=!1,b.visible(!b.cdo.hiddenByType)})}var f=this,g="",h=!!x.search.typingDelay;this.value=ko.observable(""),this.isRendered=ko.observable(!1),this.value.subscribe(function(a){g=a},null,"beforeChange"),this.inputKeyUp=function(a,c){var d=c.which||c.keyCode,e=[16,17,18,27,37,38,39,40];if(h){if(e.indexOf(d)>-1)return;f.value(c.target.value)}(h||13===d)&&b()},this.seekItems=function(a,c){b()},this.reset=function(a,b){e()},this.clearInput=function(){g="",f.value(""),f.isRendered(!1),G.removeTimer("search")}},J=function(){function a(){e=[],b=null,f.itemsNum(0)}var b=null,e=[],f=this,g=d("copy")&&d("move");this.itemsNum=ko.observable(0),this.enabled=ko.observable(c.config().clipboard.enabled&&g),this.copy=function(){f.hasCapability("copy")&&(b="copy",e=c.fetchSelectedItems(),f.itemsNum(e.length))},this.cut=function(){f.hasCapability("cut")&&(b="cut",e=c.fetchSelectedItems(),f.itemsNum(e.length))},this.paste=function(){var d=c.currentPath();if(f.hasCapability("paste")&&!f.isEmpty())return null===b||0===e.length?void k.warning(T("clipboard_empty")):void Fa(e,function(a,c){return"cut"===b?La(c,d):"copy"===b?Ka(c,d):void 0},a)},this.clear=function(){f.hasCapability("clear")&&!f.isEmpty()&&(a(),k.success(T("clipboard_cleared")))},this.isEmpty=function(){return 0===e.length},this.hasCapability=function(a){if(!f.enabled)return!1;switch(a){case"copy":return d("copy");case"cut":return d("move");default:return!0}}},K=function(){var a=this;this.items=ko.observableArray([]),this.clean=function(){a.items([]),a.add(y,"")},this.add=function(c,d){a.items.push(new b(c,d))},this.splitPath=function(b){var c=y,d=b.replace(new RegExp("^"+y),"").split("/");for(a.clean();d.length>0;){var e=d.shift();e&&(c+=e+"/",a.add(c,e))}},this.splitCurrent=function(){a.splitPath(c.currentPath())},this.getLabel=ko.pureComputed(function(){var a=T(c.searchModel.isRendered()?"search_results":"current_folder");return a+": "},this);var b=function(a,b){var d=this;this.path=a,this.label=b,this.isRoot=a===y,this.active=a===c.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,b){a.active||c.itemsModel.loadDataList(a.path)}}},L=function(){function b(a){return xa(a)?new f:wa(a)?new e:void 0}var c,d=this;this.rdo=ko.observable({}),this.content=ko.observable(null),this.renderer=ko.observable(null),this.render=function(a){d.renderer()&&d.renderer().processContent(a)},this.setRenderer=function(a){d.rdo(a),d.renderer(b(a.attributes.name))},this.setContainer=function(b){a.each(b,function(){if(a(this).hasClass("fm-renderer-container"))return c=a(this),!1}),d.renderer().processDomElements(c)};var e=function(){this.name="codeMirror",this.interactive=!1;var a=new M;this.processContent=function(b){a.render(b),d.content(b)},this.processDomElements=function(b){if(!a.instance){var c=b.find(".fm-cm-renderer-content")[0],e=ka(d.rdo().id);a.createInstance(e,c,{readOnly:"nocursor",styleActiveLine:!1,lineNumbers:!1})}}},f=function(){function b(){c.find("a").each(function(){var b=a(this).attr("href"),c=D.previewModel.editor;if(c.enabled()&&c.isInteractive())a(this).off("click"),a(this).on("click",function(){return!1});else{if(b.search("://")!==-1||ha(b,"mailto:"))return;xa(b)&&a(this).on("click",function(a){return Ta(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'
'+e.utils.escapeHtml(a)+"
"},replaceLink:function(a,b){if(a.search("://")!==-1||ha(a,"mailto:"))return a;var c=ha(a,"/")?y:ma(d.rdo().id),e=c+fa(a,"/");if(xa(e))return e;var f=ya("GET",{mode:"readfile",path:e});return Aa(f)}}).use(window.markdownitReplaceLink);this.processContent=function(a){var c=e.render(a);d.content(c),b()},this.processDomElements=function(a){}}},M=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.editor.codeHighlight&&("js"===a&&(b.push("/libs/CodeMirror/mode/javascript/javascript.js"),c="javascript"),"css"===a&&(b.push("/libs/CodeMirror/mode/css/css.js"),c="css"),"html"===a&&(b.push("/libs/CodeMirror/mode/xml/xml.js"),c="text/html"),"xml"===a&&(b.push("/libs/CodeMirror/mode/xml/xml.js"),c="application/xml"),"php"===a&&(b.push("/libs/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/libs/CodeMirror/mode/xml/xml.js"),b.push("/libs/CodeMirror/mode/javascript/javascript.js"),b.push("/libs/CodeMirror/mode/css/css.js"),b.push("/libs/CodeMirror/mode/clike/clike.js"),b.push("/libs/CodeMirror/mode/php/php.js"),c="application/x-httpd-php"),"java"===a&&(b.push("/libs/CodeMirror/mode/clike/clike.js"),c="text/x-java"),"sql"===a&&(b.push("/libs/CodeMirror/mode/sql/sql.js"),c="text/x-mysql"),"md"===a&&(b.push("/libs/CodeMirror/addon/mode/overlay.js"),b.push("/libs/CodeMirror/mode/xml/xml.js"),b.push("/libs/CodeMirror/mode/markdown/markdown.js"),b.push("/libs/CodeMirror/mode/gfm/gfm.js"),b.push("/libs/CodeMirror/mode/javascript/javascript.js"),b.push("/libs/CodeMirror/mode/css/css.js"),b.push("/libs/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/libs/CodeMirror/mode/clike/clike.js"),b.push("/libs/CodeMirror/mode/shell/shell.js"),b.push("/libs/CodeMirror/mode/meta.js"),c="gfm"),"sh"===a&&(b.push("/libs/CodeMirror/addon/mode/overlay.js"),b.push("/libs/CodeMirror/mode/markdown/markdown.js"),b.push("/libs/CodeMirror/mode/gfm/gfm.js"),b.push("/libs/CodeMirror/mode/javascript/javascript.js"),b.push("/libs/CodeMirror/mode/css/css.js"),b.push("/libs/CodeMirror/mode/htmlmixed/htmlmixed.js"),b.push("/libs/CodeMirror/mode/clike/clike.js"),b.push("/libs/CodeMirror/mode/meta.js"),b.push("/libs/CodeMirror/mode/shell/shell.js"),c="shell")),b.length?(b.push(function(){d.mode(c)}),X(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.editor.lineNumbers,lineWrapping:x.editor.lineWrapping,theme:x.editor.theme,matchBrackets:x.editor.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)}},N=function(){function b(b){var c=a.grep(f.items,function(a,c){if("folder"===b.rdo.type||"parent"===b.rdo.type){if(ha(b.rdo.id,a.rdo.id))return!0;if(b.rdo.id===oa(a.rdo.id))return!0}return a.id===b.id});return b.rdo.attributes.writable&&0===c.length}function d(a){null!==f.hoveredItem&&f.hoveredItem.dragHovered(!1),f.hoveredItem=a,a&&a.dragHovered(!0)}function e(a,b){b?a.addClass(g):a.removeClass(g)}var f=this,g="drop-restricted",h=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,d){"file"!==b.rdo.type&&"folder"!==b.rdo.type||a(d).draggable({distance:3,cursor:"pointer",cursorAt:{left:Math.floor(h.width()/2),bottom:15},scroll:!1,appendTo:m,containment:l,refreshPositions:!1,helper:function(){var a,d;return d=c.fetchSelectedItems(b.constructor.name).length>1?"ico_multiple":"folder"===b.rdo.type?"ico_folder":"ico_file ico_ext_"+ka(b.rdo.id),a=h.children(".drag-helper").clone(),a.find(".clip").addClass(d),f.dragHelper=a,a},start:function(a,d){f.items=c.fetchSelectedItems(b.constructor.name)},drag:function(b,c){a(this).draggable("option","refreshPositions",f.isScrolling||f.isScrolled),f.isScrolled=!1},stop:function(a,b){f.items=[],f.dragHelper=null}})},this.makeDroppable=function(c,g){"folder"!==c.rdo.type&&"parent"!==c.rdo.type||a(g).droppable({tolerance:"pointer",enableExtendedEvents:c instanceof q,accept:function(a){var b=ko.dataFor(a[0]),c=b?b.rdo.type:null;return"file"===c||"folder"===c},over:function(a,f){setTimeout(function(){d(null),e(f.helper,!1),b(c)||e(f.helper,!0),d(c)},0)},out:function(a,b){d(null),e(b.helper,!1)},drop:function(a,e){return d(null),!!b(c)&&void Fa(f.items,function(a,b){return La(b.rdo,c.id)})}})}},O=function(){this.unselect=!1};this.treeModel=new n,this.itemsModel=new p,this.tableViewModel=new t,this.previewModel=new j,this.headerModel=new w,this.summaryModel=new z,this.filterModel=new A,this.searchModel=new F,this.clipboardModel=new J,this.breadcrumbsModel=new K,this.ddModel=new N,this.selectionModel=new O},T=function(a){return E.translate(a)},U=function(a){function b(a){var b,c=B;switch("list"===D.viewMode()&&(c=D.itemsModel.listSortField()),c){case"type":b=a.cdo.extension||"";break;case"size":b=a.rdo.attributes.size;break;case"modified":b=a.rdo.attributes.modified;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"===D.viewMode()?D.itemsModel.listSortOrder():C,f={natural:!0,order:"asc"===e?1:-1,cases:!1};a.sort(function(a,d){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&&(e=k.write(g.getMessage(),{delay:0,logMessageTemplate:function(a){var b=(g.getProgress(),g.isProcessed()?"striped":"striped animated");return"
"+a+'
'+g.getProgress()+'%
'}}),e.stick(!0)),a.each(b,function(a,b){h=h.then(function(){return c(a,b)}).then(function(a){a&&a.data?g.succeeded():g.failed(),e&&e.setMessage(g.getMessage())})}),h.then(function(){e&&g.isProcessed()&&(e.stick(!1),setTimeout(function(){e.remove()},6e3))}),h.then(function(){"function"==typeof d&&d()})},Ga=function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}},Ha=function(a){var b=null,c=Ba(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(I.param("field_name")&&(parent.document.getElementById(I.param("field_name")).value=c,"undefined"!=typeof parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),"undefined"!=typeof parent.$.fn.colorbox&&parent.$.fn.colorbox.close()),I.param("ImperaviElementId"))if(window.opener);else{var e=I.param("ImperaviElementId"),f=parent.$("#"+e).redactor("core.getObject");f&&(f.modal.close(),f.buffer.set(),qa(a.attributes.name)?f.insert.html(''):f.insert.html(''+a.attributes.name+""))}if(I.param("CKEditor")&&(window.opener?window.opener.CKEDITOR.tools.callFunction(I.param("CKEditorFuncNum"),c):(parent.CKEDITOR.tools.callFunction(I.param("CKEditorFuncNum"),c),parent.CKEDITOR.tools.callFunction(I.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",resourceObject:a,preview_url:c},"*"),k.settings.callbacks.afterSelectItem(a,c,b)},Ia=function(a){var b=function(b,c){var d=a.id,e=c.getInputValue();if(!e)return void k.error(T("new_filename"));if(!x.options.allowChangeExtensions){var f=ka(a.attributes.name);f.length>0&&(e=e+"."+f)}if(da(d)&&!ca(e)){var g="

"+T("INVALID_FILE_TYPE")+"

";return"ALLOW_LIST"===x.security.extensions.policy&&(g+="

"+T("ALLOWED_FILE_TYPE").replace("%s",x.security.extensions.restrictions.join(", "))+".

"),"DISALLOW_LIST"===x.security.extensions.policy&&(g+="

"+T("DISALLOWED_FILE_TYPE").replace("%s",x.security.extensions.restrictions.join(", "))+".

"),void k.error(g)}za("GET",{mode:"rename",old:d,"new":e}).done(function(a){if(a.data){var b=a.data,e=D.treeModel.findByParam("id",d);if(e&&("folder"===e.rdo.type&&(e.nodeTitle(b.attributes.name),D.treeModel.actualizeNodeObject(e,d,b.id)),"file"===e.rdo.type)){var f=e.parentNode(),g=D.treeModel.createNode(b);e.remove(),f&&D.treeModel.appendNodes(f,g)}var h=D.itemsModel.parentItem();if(h&&h.id===d)D.itemsModel.parentItem().id=b.id;else{var i=D.itemsModel.findByParam("id",d);if(i){i.remove();var j=D.itemsModel.createItem(b);D.itemsModel.appendItems(j)}}D.currentPath()===d&&D.itemsModel.loadDataList(b.id),D.previewFile()&&D.previewModel.rdo().id===d&&D.previewModel.applyObject(b),c.closeDialog(),x.options.showConfirmation&&k.success(T("successful_rename"))}}).fail(ba)};k.prompt({message:T("new_filename"),value:x.options.allowChangeExtensions?a.attributes.name:la(a.attributes.name),okBtn:{label:T("action_rename"),autoClose:!1,click:b},cancelBtn:{label:T("cancel")}})},Ja=function(a,b){var c=function(a,c){var d=c.getInputValue();return d?(d=ga(d,"/")+"/",void b(d)):void k.error(T("prompt_foldername"))},d=a.length,e=d>1?T("prompt_move_multiple").replace("%s",d):T("prompt_move");k.prompt({message:e,value:D.currentPath(),okBtn:{label:T("action_move"),autoClose:!1,click:c},cancelBtn:{label:T("cancel")},template:{dialogInput:'
'+T("help_move")+"
"}})},Ka=function(a,b){return za("GET",{mode:"copy",source:a.id,target:b}).done(function(a){if(a.data){var c=a.data;D.addElements(c,b),alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("successful_copied"))}}).fail(ba)},La=function(a,b){return za("GET",{mode:"move",old:a.id,"new":b}).done(function(c){if(c.data){var d=c.data;D.removeElement(a),D.addElements(d,b),D.currentPath()===a.id&&D.itemsModel.loadDataList(d.id),D.previewFile()&&D.previewModel.rdo().id===a.id&&D.previewFile(!1),alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("successful_moved"))}}).fail(ba)},Ma=function(a,b){var c=a.length,d=c>1?T("confirm_delete_multiple").replace("%s",c):T("confirm_delete");k.confirm({message:d,okBtn:{label:T("yes"),click:function(a,c){b()}},cancelBtn:{label:T("no")}})},Na=function(a){return za("GET",{mode:"delete",path:a}).done(function(a){if(a.data){var b=a.data;if(D.removeElement(b),"folder"===b.type&&ha(D.currentPath(),b.id)){var c=na(b.id);D.itemsModel.loadDataList(c)}D.previewFile()&&D.previewModel.rdo().id===b.id&&D.previewFile(!1),x.options.showConfirmation&&k.success(T("successful_delete"))}}).fail(ba)},Oa=function(b){var c={mode:"download",path:b.id};a.fileDownload(Aa(ya("GET",c)),{failCallback:function(b,c,d){var e=a(b).text(),f=a.parseJSON(e);a.isPlainObject(f)&&f.errors&&aa(f.errors)}})},Pa=function(b){var c=a("#fm-js-editor-form").serializeArray();za("POST",c).done(function(a){if(a.data){var b=a.data,c=D.previewModel,d=c.editor.content();c.rdo(b),c.viewer.content(d),c.closeEditor();var e=D.itemsModel.createItem(b),f=D.itemsModel.findByParam("id",b.id);D.itemsModel.objects.replace(f,e),k.success(T("successful_edit"))}}).fail(ba)},Qa=function(a){return za("GET",{mode:"readfile",path:a.id},"text").fail(ba)},Ra=function(a){return za("GET",{mode:"readfolder",path:a}).fail(ba)},Sa=function(a,b){return za("GET",{mode:"seekfolder",path:a,string:b}).fail(ba)},Ta=function(a){return za("GET",{mode:"getinfo",path:a}).fail(ba)},Ua=function(){return za("GET",{mode:"summarize"}).done(function(b){if(b.data){var c=b.data.attributes,d=Z(c.size,!0);if(c.sizeLimit>0){var e=Z(c.sizeLimit,!0),f=100*c.size/c.sizeLimit,g=Math.round(100*f)/100;d+=" ("+g+"%) "+T("of")+" "+e}D.summaryModel.files(c.files),D.summaryModel.folders(c.folders),D.summaryModel.size(d),D.summaryModel.enabled(!0);var h=a("#summary-popup").clone().show();D.summaryModel.enabled(!1),k.alert(h[0].outerHTML)}}).fail(ba)},Va=function(a){var b=function(b,c){var d=c.getInputValue();return d?(d=ga(d,"/")+"/",void Wa(a,d)):void k.error(T("prompt_foldername"))};k.prompt({message:T("prompt_extract"),value:D.currentPath(),okBtn:{label:T("action_extract"),autoClose:!1,click:b},cancelBtn:{label:T("cancel")}})},Wa=function(a,b){za("POST",{mode:"extract",source:a.id,target:b}).done(function(a){a.data&&(D.addElements(a.data,b),alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("successful_extracted")))}).fail(ba)},Xa=function(b,c,d,e){var f=e?e:[d];switch(b){case"select":Ha(d);break;case"download":a.each(f,function(a,b){Oa(b)});break;case"rename":Ia(d);break;case"move":Ja(f,function(a){Fa(f,function(b,c){return La(c,a)})});break;case"delete":Ma(f,function(){Fa(f,function(a,b){return Na(b.id)})});break;case"extract":Va(d);break;case"copy":D.clipboardModel.copy(f);break;case"cut":D.clipboardModel.cut(f);break;case"copyUrl":var g=new Clipboard(c.$selected[0],{text:function(a){return Ea(d)}});g.on("success",function(a){k.success(T("copied")),g.destroy()})}},Ya=function(){return!x.options.browseOnly&&void(x.upload.multiple?w.unbind().click(function(){if(!d("upload"))return k.error(T("NOT_ALLOWED")),!1;var b=null,c=D.currentPath(),e=tmpl("tmpl-fileupload-container",{folder:T("current_folder")+c,info:T("upload_files_number_limit").replace("%s",x.upload.maxNumberOfFiles)+" "+T("upload_file_size_limit").replace("%s",Z(x.upload.fileSizeLimit,!0)),lang:E.getTranslations()});"ALLOW_LIST"===x.security.extensions.policy&&(b=new RegExp("(\\.|\\/)("+x.security.extensions.restrictions.join("|")+")$","i")),k.dialog({message:e,width:"auto",buttons:[{type:"ok",label:T("action_upload"),autoClose:!1,click:function(a,b){g.children(".upload-item").length>0?g.find(".button-start").trigger("click"):k.error(T("upload_choose_file"))}},{label:T("action_select"),closeOnClick:!1,click:function(b,c){a("#fileupload",f).trigger("click")}},{type:"cancel",label:T("close")}]});var f=a(".fm-fileupload-container"),g=a(".dropzone",f),h=a(".dropzone-wrapper",f),i=a("#total-progress",f).children();x.customScrollbar.enabled&&h.mCustomScrollbar({theme:x.customScrollbar.theme,scrollButtons:{enable:x.customScrollbar.button},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onOverflowY:function(){h.find(".mCSB_container").css({"margin-right":h.find(".mCSB_scrollTools").width()})},onOverflowYNone:function(){h.find(".mCSB_container").css({"margin-right":"auto"})}},axis:"y"}),h.on("click",function(b){(b.target===this||a(b.target).parent()[0]===this||b.target===g[0]||a(b.target).parent().hasClass("default-message"))&&a("#fileupload",f).trigger("click")}),g.on("click",".button-start",function(b){var c=a(this),d=c.parent().parent(),e=d.data();e.submit(),c.remove()}),g.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(T("upload_aborted")),f.addClass("aborted")}),g.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;Ta(i).then(function(a){a.data&&(g.uploadedBytes=Number(a.data.attributes.size),g.uploadedBytes||(h.chunkUploaded=void 0),d(g))})}else d(g)}),g.on("click",".button-remove",function(b){var d=a(this),e=d.parent().parent(),f=e.data(),g=f.files[0];g.chunkUploaded&&Na(c+g.serverName),d.closest(".upload-item").remove(),j()}),g.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 j=function(){g.children(".upload-item").length>0?g.addClass("started"):g.removeClass("started")},l=D.filterModel.getExtensions();l&&a("#fileupload").attr("accept",l.map(function(a){return"."+a}).join()),a("#fileupload",f).fileupload({autoUpload:!1,sequentialUploads:!0,dataType:"json",dropZone:g,maxChunkSize:x.upload.chunkSize,url:Aa(),paramName:x.upload.paramName,singleFileUploads:!0,formData:ya("POST",{mode:"upload",path:c}),maxNumberOfFiles:x.upload.maxNumberOfFiles,acceptFileTypes:b,maxFileSize:x.upload.fileSizeLimit,messages:{maxNumberOfFiles:T("upload_files_number_limit").replace("%s",x.upload.maxNumberOfFiles),acceptFileTypes:T("upload_file_type_invalid"),maxFileSize:T("upload_file_too_big")+" "+T("upload_file_size_limit").replace("%s",Z(x.upload.fileSizeLimit,!0))},previewMaxHeight:120,previewMaxWidth:120,previewCrop:!0}).on("fileuploadadd",function(b,c){var d=g.children(".upload-item");a.each(c.files,function(b,e){if(d.length>=x.upload.maxNumberOfFiles)return k.error(T("upload_files_number_limit").replace("%s",x.upload.maxNumberOfFiles),{logClass:"fileuploadadd",unique:!0}),!1;e.formattedSize=Z(e.size);var f=a(tmpl("tmpl-upload-item",{file:e,lang:E.getTranslations(),imagesPath:k.settings.baseUrl+"/libs/jQuery-File-Upload/img"}));e.context=f,f.find(".buttons").data(c), +f.appendTo(g)}),j()}).on("fileuploadsend",function(b,c){return k.settings.callbacks.beforeSendRequest(c.type,c.formData)===!1?(a.each(c.files,function(a,b){var c=b.context;c.find(".error-message").text(T("NOT_ALLOWED")),c.removeClass("added process").addClass("error")}),!1):void 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){var d,e=c.jqXHR;d=a.isPlainObject(e.responseJSON)&&e.responseJSON.errors?_(e.responseJSON.errors[0]):T("upload_failed"),a.each(c.files,function(a,b){var c=b.context;c.removeClass("added process").addClass("error"),c.find(".error-message").text(d),c.find(".button-start").remove()})}).on("fileuploaddone",function(b,c){var d=c.result;a.each(c.files,function(a,b){d&&d.data&&d.data[a]&&b.context.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];D.removeElement(c),D.addElements(c,D.currentPath())}});var e=g.children(".upload-item");0===e.filter(".added").length&&0===e.filter(".process").length&&(0===e.length&&(alertify.clearDialogs(),x.options.showConfirmation&&k.success(T("upload_successful_files"))),e.filter(".error").length&&k.error(T("upload_partially")+"
"+T("upload_failed_details"))),j()}).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];D.removeElement(c),D.addElements(c,D.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);i.css("width",c+"%")})}):(w.unbind().click(function(){return d("upload")?void a("#newfile").trigger("click"):(k.error(T("NOT_ALLOWED")),!1)}),o.fileupload({autoUpload:!0,dataType:"json",url:Aa(),paramName:x.upload.paramName,maxChunkSize:x.upload.chunkSize}).on("fileuploadadd",function(a,b){w.data(b)}).on("fileuploadsubmit",function(a,b){b.formData=ya("POST",{mode:"upload",path:D.currentPath()}),w.addClass("loading").prop("disabled",!0),w.children("span").text(T("loading_data"))}).on("fileuploadsend",function(a,b){if(k.settings.callbacks.beforeSendRequest(b.type,b.formData)===!1)return k.error(T("NOT_ALLOWED")),!1}).on("fileuploadalways",function(a,b){w.removeData().removeClass("loading").prop("disabled",!1),w.children("span").text(T("action_upload"));var c=b.result;if(c&&c.data){var d=c.data[0];D.removeElement(d),D.addElements(d,D.currentPath()),x.options.showConfirmation&&k.success(T("upload_successful_file"))}}).on("fileuploadchunkdone",function(a,b){var c=b.result;if(c.data&&c.data[0]){var d=c.data[0];D.removeElement(d),D.addElements(d,D.currentPath())}}).on("fileuploadfail",function(b,c){var d,e=c.jqXHR;d=a.isPlainObject(e.responseJSON)&&e.responseJSON.errors?_(e.responseJSON.errors[0]):T("upload_failed"),k.error(d)})))};J(),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