filemanager.min.js 34.6 KB
/*
	MIT License
 @author		Jason Huck - Core Five Labs
 @author		Simon Georget <simon (at) linea21 (dot) com>
 @copyright	Authors
*/
(function(a){function I(a){var g=this.window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest;if(!g)throw Error("XMLHttpRequest not supported");g.open("HEAD",a,!1);g.send(null);return 200==g.status?!0:!1}function r(c,g){return"dir"==c["File Type"]&&"replace"==g?!1:"dir"==c["File Type"]&&"download"==g?1==f.security.allowFolderDownload?!0:!1:"undefined"==typeof c.Capabilities?!0:-1<a.inArray(g,c.Capabilities)}function w(c){var g=c.attr("class").replace(/ /g,"_");if(""==g)return"itemOptions";
if(!a("#"+g).length){var b=a("#itemOptions").clone().attr("id",g);c.hasClass("cap_select")||a(".select",b).remove();c.hasClass("cap_download")||a(".download",b).remove();c.hasClass("cap_rename")||a(".rename",b).remove();c.hasClass("cap_move")||a(".move",b).remove();a(".replace",b).remove();c.hasClass("cap_delete")||a(".delete",b).remove();a("#itemOptions").after(b)}return g}a.urlParam=function(a){return(a=(new RegExp("[\\?&]"+a+"=([^&#]*)")).exec(window.location.href))?a[1]:0};var v=function(c){var g=
null;"user"==("undefined"===typeof c?"user":c)?0!=a.urlParam("config")?(c="./scripts/"+a.urlParam("config"),userconfig=a.urlParam("config")):(c="./scripts/filemanager.config.js",userconfig="filemanager.config.js"):c="./scripts/filemanager.config.js.default";a.ajax({async:!1,url:c,dataType:"json",cache:!1,success:function(a){g=a}});return g},R=v("default"),f=v();null!==f&&delete f.version;f=a.extend({},R,f);if(f.options.logger)var A=(new Date).getTime();HEAD_included_files=[];loadCSS=function(c){if(-1==
a.inArray(c,HEAD_included_files)){var g=a("<link rel='stylesheet' type='text/css' href='"+c+"'>");a("head").append(g);HEAD_included_files.push(c)}};loadJS=function(c){if(-1==a.inArray(c,HEAD_included_files)){var g=a("<script type='text/javascript' src='"+c+"'>");a("head").append(g);HEAD_included_files.push(c)}};smartPath=function(a,g){var b=a.split("/"),b="/"+b[b.length-2]+"/",d=g.indexOf(b);rvalue=-1==d?a+g:a+g.substring(d+b.length);f.options.logger&&console.log("url : "+a+" - path : "+g+" - separator : "+
b+" -  pos : "+d+" - returned value : "+rvalue);return rvalue};var k=f.options.fileConnector||"connectors/"+f.options.lang+"/filemanager."+f.options.lang,n=f.options.capabilities||"select download rename move delete replace".split(" ");0!=a.urlParam("langCode")&&(I("scripts/languages/"+a.urlParam("langCode")+".js")?f.options.culture=a.urlParam("langCode"):(v=a.urlParam("langCode").substring(0,2),I("scripts/languages/"+v+".js")&&(f.options.culture=v)));var b=[];a.ajax({url:"scripts/languages/"+f.options.culture+
".js",async:!1,dataType:"json",success:function(a){b=a}});a.prompt.setDefaults({overlayspeed:"fast",show:"fadeIn",opacity:.4,persistent:!1});var x=function(){var c=53,g=a("#uploader");a.urlParam("CKEditorCleanUpFuncNum")&&(c+=60);c=a(window).height()-g.height()-g.offset().top-c;a("#splitter, #filetree, #fileinfo, .vsplitbar").height(c);c=a("#splitter").width()-a("div.vsplitbar").width()-a("#filetree").width();a("#fileinfo").width(c)},y=function(a,g){g="undefined"===typeof g?!0:!1;if(0==f.options.showFullPath){if("function"===
typeof displayPathDecorator)return displayPathDecorator(a.replace(fileRoot,"/"));a=a.replace(fileRoot,"/");if(50<a.length&&!0===g){var b=a.split("/");a="/"+b[1]+"/"+b[2]+"/(...)/"+b[b.length-2]+"/"}}return a},B=function(c){"grid"==c?(a("#grid").addClass("ON"),a("#list").removeClass("ON")):(a("#list").addClass("ON"),a("#grid").removeClass("ON"))},C=function(a){var b="",b="\u0160\u0161\u0110\u0111\u017d\u017e\u010c\u010d\u0106\u0107\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u00c6\u00c7\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf\u00d1\u00d2\u00d3\u00d4\u00d5\u00d6\u0150\u00d8\u00d9\u00da\u00db\u00dc\u00dd\u00de\u00df\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u00e6\u00e7\u00e8\u00e9\u00ea\u00eb\u00ec\u00ed\u00ee\u00ef\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u0151\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fd\u00fe\u00ff\u0154\u0155 '/".split(""),
e="S s Dj dj Z z C c C c A A A A A A A C E E E E I I I I N O O O O O O O U U U U Y B Ss a a a a a a a c e e e e i i i i o n o o o o o o o u u u u y y b y R r _ _ ".split(" ");a=String(a);for(i=0;i<b.length;i++)a=a.replace(RegExp(b[i],"g"),e[i]);b=a;f.options.chars_only_latin&&(b=b.replace(/[^_a-zA-Z0-9]/g,""));return b=b.replace(/[_]+/g,"_")},S=function(a){filename="";-1!=a.lastIndexOf(".")?(filename=C(a.substr(0,a.lastIndexOf("."))),filename+="."+a.split(".").pop()):filename=C(a);return filename},
J=function(a){a=parseFloat(a);for(var g=0,f=[b.bytes,b.kb,b.mb,b.gb];;){if(1024>a)return a=Math.round(100*a)/100,a+f[g];a/=1024;g+=1}},K=function(c){a("#fileinfo").html("<h1>"+c+"</h1>");a("#newfile").attr("disabled","disabled");a("#upload").attr("disabled","disabled");a("#newfolder").attr("disabled","disabled")},L=function(c){c=q(c);return""==c&&1==f.security.allowNoExtension||"DISALLOW_ALL"==f.security.uploadPolicy&&-1!=a.inArray(c,f.security.uploadRestrictions)||"ALLOW_ALL"==f.security.uploadPolicy&&
-1==a.inArray(c,f.security.uploadRestrictions)?!0:!1},q=function(a){return 1==a.split(".").length?"":a.split(".").pop().toLowerCase()},T=function(a){return-1!=a.lastIndexOf(".")?a.substring(0,a.lastIndexOf(".")):a},U=function(c){var b="<video width="+f.videos.videosPlayerWidth+" height="+f.videos.videosPlayerHeight+' src="'+c.Path+'" controls="controls">',b=b+('<img src="'+c.Preview+'" />'),b=b+"</video>";a("#fileinfo img").remove();a("#fileinfo #preview #main-title").before(b)},V=function(c){var b=
'<audio src="'+c.Path+'" controls="controls">',b=b+('<img src="'+c.Preview+'" />'),b=b+"</audio>";a("#fileinfo img").remove();a("#fileinfo #preview #main-title").before(b)},W=function(b){b='<iframe id="fm-pdf-viewer" src = "scripts/ViewerJS/index.html#'+b.Path+'" width="'+f.pdfs.pdfsReaderWidth+'" height="'+f.pdfs.pdfsReaderHeight+'" allowfullscreen webkitallowfullscreen></iframe>';a("#fileinfo img").remove();a("#fileinfo #preview #main-title").before(b)},X=function(b){a("#fileinfo").find("td:first-child").each(function(){var f=
a(this).attr("data-path"),f=a("#filetree").find('a[data-path="'+f+'"]').parent();"undefined"!==typeof f.css("background-image")&&(a(this).css("background-image",f.css("background-image")),window.clearInterval(b))})},D=function(c){a("#currentpath").val(c);a("#uploader h1").text(b.current_folder+y(c)).attr("title",y(c,!1)).attr("data-path",c);a("#newfolder").unbind().click(function(){var c=b.default_foldername,f=b.prompt_foldername+' : <input id="fname" name="fname" type="text" value="'+c+'" />',d=
{};d[b.create_folder]=!0;d[b.cancel]=!1;a.prompt(f,{callback:function(d,f){if(1!=d)return!1;var e=f.children("#fname").val();""!=e?(c=C(e),e=new Date,a.getJSON(k+"?mode=addfolder&path="+a("#currentpath").val()+"&config="+userconfig+"&name="+encodeURIComponent(c)+"&time="+e.getMilliseconds(),function(b){0==b.Code?(Y(b.Parent,b.Name),m(b.Parent),a("#filetree").find('a[data-path="'+b.Parent+'/"]').click().click()):a.prompt(b.Error)})):a.prompt(b.no_foldername)},buttons:d})})},Q=function(c){a("#fileinfo button").each(function(b){0==
a(this).find("span").length&&a(this).wrapInner("<span></span>")});if(r(c,"select")){if(a("#fileinfo").find("button#select").click(function(){E(c)}).show(),window.opener||window.tinyMCEPopup)a("#preview img").attr("title",b.select),a("#preview img").click(function(){E(c)}).css("cursor","pointer")}else a("#fileinfo").find("button#select").hide();r(c,"rename")?a("#fileinfo").find("button#rename").click(function(){var b=M(c);b.length&&a("#fileinfo > h1").text(b)}).show():a("#fileinfo").find("button#rename").hide();
r(c,"move")?a("#fileinfo").find("button#move").click(function(){var b=N(c);b.length&&a("#fileinfo > h1").text(b)}).show():a("#fileinfo").find("button#move").hide();r(c,"replace")?a("#fileinfo").find("button#replace").click(function(){O(c)}).show():a("#fileinfo").find("button#replace").hide();r(c,"delete")?a("#fileinfo").find("button#delete").click(function(){P(c)&&a("#fileinfo").html("<h1>"+b.select_from_left+"</h1>")}).show():a("#fileinfo").find("button#delete").hide();r(c,"download")?a("#fileinfo").find("button#download").click(function(){window.location=
k+"?mode=download&path="+encodeURIComponent(c.Path)+"&config="+userconfig}).show():a("#fileinfo").find("button#download").hide()},u=function(){var c=0<a("#filetree .mCSB_container").length?"#filetree .mCSB_container":"#filetree";a(c).fileTree({root:fileRoot,datafunc:Z,multiFolder:!1,folderCallback:function(a){m(a)},expandedFolder:fullexpandedFolder,after:function(c){a("#filetree").find("li a").each(function(){a(this).contextMenu({menu:w(a(this))},function(b,d,c){d=a(d).attr("data-path");z(b,d)})});
1==f.options.searchBox&&(a("#q").liveUpdate("#filetree ul").blur(),a("#search span.q-inactive").html(b.search),a("#search a.q-reset").attr("title",b.search_reset))}},function(a){F(a)})},E=function(c){var g=!1!==f.options.baseUrl?smartPath(baseUrl,c.Path.replace(fileRoot,"")):c.Path;window.opener||window.tinyMCEPopup||a.urlParam("field_name")||a.urlParam("CKEditorCleanUpFuncNum")||a.urlParam("CKEditor")?window.tinyMCEPopup?(c=tinyMCEPopup.getWindowArg("window"),c.document.getElementById(tinyMCEPopup.getWindowArg("input")).value=
g,"undefined"!=typeof c.ImageDialog&&(c.ImageDialog.getImageData&&c.ImageDialog.getImageData(),c.ImageDialog.showPreviewImage&&c.ImageDialog.showPreviewImage(g)),tinyMCEPopup.close()):(a.urlParam("field_name")?(parent.document.getElementById(a.urlParam("field_name")).value=g,"undefined"!==typeof parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),"undefined"!==typeof parent.$.fn.colorbox&&parent.$.fn.colorbox.close()):a.urlParam("CKEditor")?window.opener?window.opener.CKEDITOR.tools.callFunction(a.urlParam("CKEditorFuncNum"),
g):(parent.CKEDITOR.tools.callFunction(a.urlParam("CKEditorFuncNum"),g),parent.CKEDITOR.tools.callFunction(a.urlParam("CKEditorCleanUpFuncNum"))):""!=c.Properties.Width?window.opener.SetUrl(g,c.Properties.Width,c.Properties.Height):window.opener.SetUrl(g),window.opener&&window.close()):a.prompt(b.fck_select_integration)},M=function(c){var g="",e=f.security.allowChangeExtensions?c.Filename:T(c.Filename),e=b.new_filename+' : <input id="rname" name="rname" type="text" value="'+e+'" />',d={};d[b.rename]=
!0;d[b.cancel]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;rname=e.children("#rname").val();if(""!=rname){var h=rname;if(!f.security.allowChangeExtensions){var h=S(rname),l=q(c.Filename);0<l.length&&(h=h+"."+l)}if("/"!=c.Path.charAt(c.Path.length-1)&&!L(h))return h="<p>"+b.INVALID_FILE_TYPE+"</p>","DISALLOW_ALL"==f.security.uploadPolicy&&(h+="<p>"+b.ALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),"ALLOW_ALL"==f.security.uploadPolicy&&(h+="<p>"+b.DISALLOWED_FILE_TYPE+
f.security.uploadRestrictions.join(", ")+".</p>"),a("#filepath").val(""),a.prompt(h),!1;h=k+"?mode=rename&old="+encodeURIComponent(c.Path)+"&new="+encodeURIComponent(h)+"&config="+userconfig;a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){if(0==d.Code){var e=d["New Path"],t=d["New Name"],h=d["Old Path"],p=a("#filetree").find('a[data-path="'+h+'"]'),l=p.parent().parent().prev("a");p.attr("data-path",e).text(t);0==l.length?u():l.click().click();p=a("#preview h1").attr("title");
"undefined"!=typeof p&&p==h&&a("#preview h1").text(t);"grid"==a("#fileinfo").data("view")?(a('#fileinfo img[data-path="'+h+'"]').parent().next("p").text(t),a('#fileinfo img[data-path="'+h+'"]').attr("data-path",e)):(a('#fileinfo td[data-path="'+h+'"]').text(t),a('#fileinfo td[data-path="'+h+'"]').attr("data-path",e));a("#preview h1").html(t);c.Path=e;c.Filename=t;a("#fileinfo").find("button#rename, button#delete, button#download").unbind();Q(c);f.options.showConfirmation&&a.prompt(b.successful_rename)}else a.prompt(d.Error);
g=d["New Name"]}})}},buttons:d});return g},O=function(c){a("#fileR").bind("change",function(){a(this).closest("form#toolbar").submit()});a("#toolbar").attr("action",k);a("#toolbar").attr("method","post");a("#toolbar").ajaxForm({target:"#uploadresponse",beforeSubmit:function(g,e,d){g=a("#fileR",e).val();if(""==g)return!1;if(q(g)!=c["File Type"])return a.prompt(b.ERROR_REPLACING_FILE+" ."+q(c.Filename)),!1;a("#replace").attr("disabled",!0);a("#upload span").addClass("loading").text(b.loading_data);
if("undefined"!==typeof FileReader&&"auto"!=typeof f.upload.fileSizeLimit&&a("#fileR",e).get(0).files[0].size>1048576*f.upload.fileSizeLimit)return a.prompt("<p>"+b.file_too_big+"</p><p>"+b.file_size_limit+f.upload.fileSizeLimit+" "+b.mb+".</p>"),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload),!1},error:function(c,f,d){a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload);a.prompt(b.ERROR_UPLOADING_FILE)},success:function(c){c=
jQuery.parseJSON(a("#uploadresponse").find("textarea").text());0==c.Code?(c=c.Path+"/"+c.Name,F(c),a("#preview").find("img").hide().fadeIn("slow"),a("ul.jqueryFileTree").find('li a[data-path="'+c+'"]').parent().hide().fadeIn("slow"),f.options.showConfirmation&&a.prompt(b.successful_replace)):a.prompt(c.Error);a("#replace").removeAttr("disabled");a("#upload span").removeClass("loading").text(b.upload)}});a("#newfilepath").val(c.Path);a("#fileR").click()},N=function(c){var g="",e=b.move+' : <input id="rname" name="rname" type="text" value="" />',
e=e+('<div class="prompt-info">'+b.help_move+"</div>"),d={};d[b.move]=!0;d[b.cancel]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;rname=e.children("#rname").val();if(""!=rname){var h=rname,h=k+"?mode=move&old="+encodeURIComponent(c.Path)+"&new="+encodeURIComponent(h)+"&root="+encodeURIComponent(fileRoot)+"&config="+userconfig;a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){if(0==d.Code){var c=d["New Path"],e=d["New Name"];fullexpandedFolder=c;u();m(c);f.options.showConfirmation&&
a.prompt(b.successful_moved)}else a.prompt(d.Error);g=c+e}})}},buttons:d});return g},P=function(c){var g=!1,e=b.confirmation_delete,d={};d[b.yes]=!0;d[b.no]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;var h=new Date,h=k+"?mode=delete&path="+encodeURIComponent(c.Path)+"&time="+h.getMilliseconds()+"&config="+userconfig,l=c.Path.split("/").reverse().slice(1).reverse().join("/")+"/";a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){0==d.Code?(aa(d.Path),d=d.Path.substring(0,
d.Path.length-1),d=d.substr(0,d.lastIndexOf("/")+1),a("#uploader h1").text(b.current_folder+y(d)).attr("title",y(d,!1)).attr("data-path",d),g=!0,f.options.showConfirmation&&a.prompt(b.successful_delete),a("#filetree").find('a[data-path="'+l+'/"]').click().click()):(g=!1,a.prompt(d.Error))}})},buttons:d});return g},ba=function(c){isEdited=!1;a("#fileinfo").find("div#tools").append(' <a id="edit-file" href="#" title="'+b.edit+'"><span>'+b.edit+"</span></a>");a("#edit-file").click(function(){a(this).hide();
var g=new Date,g=k+"?mode=editfile&path="+encodeURIComponent(c.Path)+"&config="+userconfig+"&time="+g.getMilliseconds();a.ajax({type:"GET",url:g,dataType:"json",async:!1,success:function(e){0==e.Code?(e='<form id="edit-form">'+('<textarea id="edit-content" name="content">'+e.Content+"</textarea>"),e=e+'<input type="hidden" name="mode" value="savefile" />'+('<input type="hidden" name="path" value="'+c.Path+'" />'),e+='<button id="edit-cancel" class="edition" type="button">'+b.quit_editor+"</button>",
e+='<button id="edit-save" class="edition" type="button">'+b.save+"</button>",e+="</form>",a("#preview").find("img").hide(),a("#preview").prepend(e).hide().fadeIn(),a("#edit-cancel").click(function(){a("#preview").find("form#edit-form").hide();a("#preview").find("img").fadeIn();a("#edit-file").show()}),a("#edit-save").click(function(){var d=codeMirrorEditor.getValue();a("textarea#edit-content").val(d);d=a("#edit-form").serializeArray();a.ajax({type:"POST",url:k+"?config="+userconfig,dataType:"json",
data:d,async:!1,success:function(d){0==d.Code?(isEdited=!0,a.prompt(b.successful_edit)):(isEdited=!1,a.prompt(d.Error))}})}),codeMirrorEditor=instantiateCodeMirror(q(c.Path),f)):(isEdited=!1,a.prompt(e.Error),a(this).show())}})});return isEdited},aa=function(b){a("#filetree").find('a[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});if(a("#uploader h1").attr("data-path")==b){var f=b.split("/").slice(0,length-2).join("/")+"/";m(f)}"grid"==a("#fileinfo").data("view")?a('#contents img[data-path="'+
b+'"]').parent().parent().fadeOut("slow",function(){a(this).remove()}):a("table#contents").find('td[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});a("#preview").length&&m(b.substr(0,b.lastIndexOf("/")+1))},Y=function(c,g){var e='<li class="directory collapsed"><a data-path="'+c+g+'/" href="#">'+g+'</a><ul class="jqueryFileTree" style="display: block;"></ul></li>',d=a("#filetree").find('a[data-path="'+c+'"]');c!=fileRoot?d.next("ul").prepend(e).prev("a").click().click():
(a("#filetree ul.jqueryFileTree").prepend(e),a("#filetree").find('li a[data-path="'+c+g+'/"]').attr("class","cap_rename cap_delete").click(function(){m(c+g+"/")}).each(function(){a(this).contextMenu({menu:w(a(this))},function(d,b,c){b=a(b).attr("data-path");z(d,b)})}));f.options.showConfirmation&&a.prompt(b.successful_added_folder)},H=function(b){b.lastIndexOf("/")==b.length-1?(m(b),a("#filetree").find('a[data-path="'+b+'"]').click()):F(b)},z=function(b,f){var e=new Date;a.getJSON(k+"?mode=getinfo&path="+
encodeURIComponent(f)+"&config="+userconfig+"&time="+e.getMilliseconds(),function(d){"grid"==a("#fileinfo").data("view")?a("#fileinfo").find('img[data-path="'+d.Path+'"]').parent():a("#fileinfo").find('td[data-path="'+d.Path+'"]').parent();switch(b){case "select":E(d);break;case "download":window.location=k+"?mode=download&path="+d.Path+"&config="+userconfig+"&time="+e.getMilliseconds();break;case "rename":M(d);break;case "replace":O(d);break;case "move":N(d);break;case "delete":P(d)}})},F=function(c){a(".contextMenu").hide();
var g=c.substr(0,c.lastIndexOf("/")+1);D(g);var e;e='<div id="preview"><img /><div id="main-title"><h1></h1><div id="tools"></div></div><dl></dl></div><form id="toolbar">'+('<button id="parentfolder">'+b.parentfolder+"</button>");-1!=a.inArray("select",n)&&(a.urlParam("CKEditor")||window.opener||window.tinyMCEPopup||a.urlParam("field_name"))&&(e+='<button id="select" name="select" type="button" value="Select">'+b.select+"</button>");-1!=a.inArray("download",n)&&(e+='<button id="download" name="download" type="button" value="Download">'+
b.download+"</button>");-1!=a.inArray("rename",n)&&1!=f.options.browseOnly&&(e+='<button id="rename" name="rename" type="button" value="Rename">'+b.rename+"</button>");-1!=a.inArray("move",n)&&1!=f.options.browseOnly&&(e+='<button id="move" name="move" type="button" value="Move">'+b.move+"</button>");-1!=a.inArray("delete",n)&&1!=f.options.browseOnly&&(e+='<button id="delete" name="delete" type="button" value="Delete">'+b.del+"</button>");-1!=a.inArray("replace",n)&&1!=f.options.browseOnly&&(e+='<button id="replace" name="replace" type="button" value="Replace">'+
b.replace+"</button>",e+='<div class="hidden-file-input"><input id="fileR" name="fileR" type="file" /></div>',e+='<input id="mode" name="mode" type="hidden" value="replace" /> ',e+='<input id="newfilepath" name="newfilepath" type="hidden" />');e+="</form>";0<a("#fileinfo .mCSB_container").length?a("#fileinfo .mCSB_container").html(e):a("#fileinfo").html(e);a("#parentfolder").click(function(){m(g)});e=new Date;a.getJSON(k+"?mode=getinfo&path="+encodeURIComponent(c)+"&config="+userconfig+"&time="+e.getMilliseconds(),
function(d){if(0==d.Code){a("#fileinfo").find("h1").text(d.Filename).attr("title",c);a("#fileinfo").find("img").attr("src",d.Preview);var e;e=-1!=a.inArray(q(d.Filename),f.videos.videosExt)?!0:!1;e&&1==f.videos.showVideoPlayer&&U(d);e=-1!=a.inArray(q(d.Filename),f.audios.audiosExt)?!0:!1;e&&1==f.audios.showAudioPlayer&&V(d);e=-1!=a.inArray(q(d.Filename),f.pdfs.pdfsExt)?!0:!1;e&&1==f.pdfs.showPdfReader&&W(d);e=-1!=a.inArray(q(d.Filename),f.edit.editExt)?!0:!1;e&&1==f.edit.enabled&&0==d.Protected&&
ba(d);e=new Date;var g=!1!==f.options.baseUrl?smartPath(baseUrl,d.Path.replace(fileRoot,"")):d.Path;0==d.Protected&&(a("#fileinfo").find("div#tools").append(' <a id="copy-button" data-clipboard-text="'+g+'" title="'+b.copy_to_clipboard+'" href="#"><span>'+b.copy_to_clipboard+"</span></a>"),loadJS("./scripts/zeroclipboard/copy.js?d"+e.getMilliseconds()),a("#copy-button").click(function(){a("#fileinfo").find("div#tools").append('<span id="copied">'+b.copied+"</span>");a("#copied").delay(500).fadeOut(1E3,
function(){a(this).remove()})}));e="";d.Properties.Width&&""!=d.Properties.Width&&(e+="<dt>"+b.dimensions+"</dt><dd>"+d.Properties.Width+"x"+d.Properties.Height+"</dd>");d.Properties["Date Created"]&&""!=d.Properties["Date Created"]&&(e+="<dt>"+b.created+"</dt><dd>"+d.Properties["Date Created"]+"</dd>");d.Properties["Date Modified"]&&""!=d.Properties["Date Modified"]&&(e+="<dt>"+b.modified+"</dt><dd>"+d.Properties["Date Modified"]+"</dd>");if(d.Properties.Size||0==parseInt(d.Properties.Size))e+="<dt>"+
b.size+"</dt><dd>"+J(d.Properties.Size)+"</dd>";a("#fileinfo").find("dl").html(e);Q(d)}else a.prompt(d.Error)})},m=function(c){D(c);var g='<img id="activity" src="themes/'+f.options.theme+'/images/wait30trans.gif" width="30" height="30" />';0<a("#fileinfo .mCSB_container").length?a("#fileinfo .mCSB_container").html(g):a("#fileinfo").html(g);a("#loading-wrap").fadeOut(800);g=new Date;c=k+"?path="+encodeURIComponent(c)+"&config="+userconfig+"&mode=getfolder&showThumbs="+f.options.showThumbs+"&time="+
g.getMilliseconds();a.urlParam("type")&&(c+="&type="+a.urlParam("type"));a.getJSON(c,function(c){var d="";if("-1"==c.Code)K(c.Error);else{x();if(c){var g=0,p=0;if("grid"==a("#fileinfo").data("view")){d+='<ul id="contents" class="grid">';for(key in c){g++;var h=c[key].Properties,l="";for(cap in n)r(c[key],n[cap])&&(l+=" cap_"+n[cap]);var G=64,k=h.Width;1<k&&k<G&&(G=k);f.options.showTitleAttr?title=' title="'+c[key].Path+'"':title="";d+='<li class="'+l+'"'+title+'"><div class="clip"><img src="'+c[key].Preview+
'" width="'+G+'" alt="'+c[key].Path+'" data-path="'+c[key].Path+'" /></div><p>'+c[key].Filename+"</p>";h.Width&&""!=h.Width&&(d+='<span class="meta dimensions">'+h.Width+"x"+h.Height+"</span>");h.Size&&""!=h.Size&&(d+='<span class="meta size">'+h.Size+"</span>");h.Size&&""!=h.Size&&(p+=h.Size);h["Date Created"]&&""!=h["Date Created"]&&(d+='<span class="meta created">'+h["Date Created"]+"</span>");h["Date Modified"]&&""!=h["Date Modified"]&&(d+='<span class="meta modified">'+h["Date Modified"]+"</span>");
d+="</li>"}d+="</ul>"}else{d=d+'<table id="contents" class="list">'+('<thead><tr><th class="headerSortDown"><span>'+b.name+"</span></th><th><span>"+b.dimensions+"</span></th><th><span>"+b.size+"</span></th><th><span>"+b.modified+"</span></th></tr></thead>");d+="<tbody>";for(key in c){g++;h=c[key].Properties;l="";f.options.showTitleAttr?title=' title="'+c[key].Path+'"':title="";for(cap in n)r(c[key],n[cap])&&(l+=" cap_"+n[cap]);d+='<tr class="'+l+'">';d+='<td data-path="'+c[key].Path+'"'+title+'">'+
c[key].Filename+"</td>";d=h.Width&&""!=h.Width?d+("<td>"+h.Width+"x"+h.Height+"</td>"):d+"<td></td>";h.Size&&""!=h.Size?(d+='<td><abbr title="'+h.Size+'">'+J(h.Size)+"</abbr></td>",p+=h.Size):d+="<td></td>";d=h["Date Modified"]&&""!=h["Date Modified"]?d+("<td>"+h["Date Modified"]+"</td>"):d+"<td></td>";d+="</tr>"}d+="</tbody>";d+="</table>"}}else d+="<h1>"+b.could_not_retrieve_folder+"</h1>";0<a("#fileinfo .mCSB_container").length?a("#fileinfo .mCSB_container").html(d):a("#fileinfo").html(d);a("#items-counter").text(g);
a("#items-size").text(Math.round(p/1024/1024*100)/100);if("grid"==a("#fileinfo").data("view"))a("#fileinfo").find("#contents li").click(function(){var b=a(this).find("img").attr("data-path");H(b)}).each(function(){a(this).contextMenu({menu:w(a(this))},function(b,d,c){d=a(d).find("img").attr("data-path");z(b,d)})});else{a("#fileinfo tbody tr").click(function(){var b=a("td:first-child",this).attr("data-path");H(b)}).each(function(){a(this).contextMenu({menu:w(a(this))},function(b,d,c){d=a("td:first-child",
d).attr("data-path");z(b,d)})});a("#fileinfo").find("table").tablesorter({textExtraction:function(b){return a(b).find("abbr").size()?a(b).find("abbr").attr("title"):b.innerHTML}});var m=setInterval(function(){X(m)},300)}}})},Z=function(c,g){var e=new Date,e=k+"?path="+encodeURIComponent(c)+"&config="+userconfig+"&mode=getfolder&showThumbs="+f.options.showThumbs+"&time="+e.getMilliseconds();a.urlParam("type")&&(e+="&type="+a.urlParam("type"));a.getJSON(e,function(a){var c="";if("-1"==a.Code)K(a.Error);
else{if(a){c+='<ul class="jqueryFileTree" style="display: none;">';for(key in a){var e="";for(cap in n)r(a[key],n[cap])&&(e+=" cap_"+n[cap]);if("dir"==a[key]["File Type"])var h=0==a[key].Protected?"":" directory-locked",c=c+('<li class="directory collapsed'+h+'"><a href="#" class="'+e+'" data-path="'+a[key].Path+'">'+a[key].Filename+"</a></li>");else f.options.listFiles&&(h=0==a[key].Protected?"":" file-locked",c+='<li class="file ext_'+a[key]["File Type"].toLowerCase()+h+'"><a href="#" class="'+
e+'" data-path="'+a[key].Path+'">'+a[key].Filename+"</a></li>")}c+="</ul>"}else c+="<h1>"+b.could_not_retrieve_folder+"</h1>";g(c)}})};a(function(){if(f.extras.extra_js)for(var c=0;c<f.extras.extra_js.length;c++)a.ajax({url:f.extras.extra_js[c],dataType:"script",async:f.extras.extra_js_async});a("#link-to-project").attr("href",f.url).attr("target","_blank").attr("title",b.support_fm+" ["+b.version+" : "+f.version+"]");a("div.version").html(f.version);loadCSS("./themes/"+f.options.theme+"/styles/filemanager.css");
a.ajax({url:"./themes/"+f.options.theme+"/styles/ie.css",async:!1,success:function(b){a("head").append(b)}});loadJS("./scripts/zeroclipboard/dist/ZeroClipboard.js");f.edit.enabled&&(loadCSS("./scripts/CodeMirror/lib/codemirror.css"),loadCSS("./scripts/CodeMirror/theme/"+f.edit.theme+".css"),loadJS("./scripts/CodeMirror/lib/codemirror.js"),loadJS("./scripts/CodeMirror/addon/selection/active-line.js"),loadCSS("./scripts/CodeMirror/addon/display/fullscreen.css"),loadJS("./scripts/CodeMirror/addon/display/fullscreen.js"),
loadJS("./scripts/CodeMirror/dynamic-mode.js"));f.options.fileRoot?(fileRoot=f.options.serverRoot?"/"+f.options.fileRoot:f.options.fileRoot,fileRoot=fileRoot.replace(/\/\//g,"/")):fileRoot="/"+document.location.pathname.substring(1,document.location.pathname.lastIndexOf("/")+1)+"userfiles/";baseUrl=!1===f.options.baseUrl?window.location.protocol+"//"+window.location.host:f.options.baseUrl;0!=a.urlParam("exclusiveFolder")&&(fileRoot+=a.urlParam("exclusiveFolder"),"/"!=fileRoot.charAt(fileRoot.length-
1)&&(fileRoot+="/"),fileRoot=fileRoot.replace(/\/\//g,"/"));0!=a.urlParam("expandedFolder")?(expandedFolder=a.urlParam("expandedFolder"),fullexpandedFolder=fileRoot+expandedFolder):(expandedFolder="",fullexpandedFolder=null);a("#folder-info").html('<span id="items-counter"></span> '+b.items+" - "+b.size+' : <span id="items-size"></span> '+b.mb);1==f.options.autoload&&(a("#upload").append(b.upload),a("#newfolder").append(b.new_folder),a("#grid").attr("title",b.grid_view),a("#list").attr("title",b.list_view),
a("#fileinfo h1").append(b.select_from_left),a('#itemOptions a[href$="#select"]').append(b.select),a('#itemOptions a[href$="#download"]').append(b.download),a('#itemOptions a[href$="#rename"]').append(b.rename),a('#itemOptions a[href$="#move"]').append(b.move),a('#itemOptions a[href$="#replace"]').append(b.replace),a('#itemOptions a[href$="#delete"]').append(b.del));a.urlParam("CKEditorCleanUpFuncNum")&&(a("body").append('<button id="close-btn" type="button">'+b.close+"</button>"),a("#close-btn").click(function(){parent.CKEDITOR.tools.callFunction(a.urlParam("CKEditorCleanUpFuncNum"))}));
a("#browse").append("+");a("#browse").attr("title",b.browse);a("#newfile").change(function(){a("#filepath").val(a(this).val().replace(/.+[\\\/]/,""))});!0===f.options.searchBox?loadJS("./scripts/filemanager.liveSearch.min.js"):a("#search").remove();a("button").wrapInner("<span></span>");a("#fileinfo").data("view",f.options.defaultViewMode);B(f.options.defaultViewMode);a("#home").click(function(){var b=a("#fileinfo").data("view");a("#fileinfo").data("view",b);a("#filetree ul.jqueryFileTree > li.expanded > a").trigger("click");
m(fileRoot)});a("#level-up").click(function(){var b=a("#uploader h1").attr("data-path");if(b!=fileRoot){parent=b.substring(0,b.slice(0,-1).lastIndexOf("/"))+"/";var c=a("#fileinfo").data("view");a("#fileinfo").data("view",c);a("#filetree").find('a[data-path="'+b+'"]').click();m(parent)}});a("#grid").click(function(){B("grid");a("#fileinfo").data("view","grid");m(a("#currentpath").val())});a("#list").click(function(){B("list");a("#fileinfo").data("view","list");m(a("#currentpath").val())});D(fileRoot);
f.upload.multiple?(loadCSS("./scripts/dropzone/downloads/css/dropzone.css"),loadJS("./scripts/dropzone/downloads/dropzone.js"),Dropzone.autoDiscover=!1,a("#file-input-container").remove(),a("#upload").remove(),a("#newfolder").before('<button value="Upload" type="button" name="upload" id="upload" class="em"><span>'+b.upload+"</span></button> "),a("#upload").unbind().click(function(){var c='<div id="dropzone-container"><h2>'+b.current_folder+a("#uploader h1").attr("title")+'</h2><div id="multiple-uploads" class="dropzone"></div>',
c=c+'<div id="total-progress"><div data-dz-uploadprogress="" style="width:0%;" class="progress-bar"></div></div>'+('<div class="prompt-info">'+b.dz_dictMaxFilesExceeded.replace("%s",f.upload.number)+b.file_size_limit+f.upload.fileSizeLimit+" "+b.mb+".</div>"),c=c+('<button id="process-upload">'+b.upload+"</button></div>");error_flag=!1;var e=a("#currentpath").val(),g="auto"!=f.upload.fileSizeLimit?f.upload.fileSizeLimit:256,h="DISALLOW_ALL"==f.security.uploadPolicy?"."+f.security.uploadRestrictions.join(",."):
null;if("images"==a.urlParam("type").toString().toLowerCase()||f.upload.imagesOnly)h="."+f.images.imagesExt.join(",.");var l={};l[b.close]=!1;a.prompt(c,{buttons:l});a("div#multiple-uploads").dropzone({paramName:"newfile",url:k+"?config="+userconfig,maxFilesize:g,maxFiles:f.upload.number,addRemoveLinks:!0,parallelUploads:f.upload.number,dictCancelUpload:b.cancel,dictRemoveFile:b.del,dictMaxFilesExceeded:b.dz_dictMaxFilesExceeded.replace("%s",f.upload.number),dictDefaultMessage:b.dz_dictDefaultMessage,
dictInvalidFileType:b.dz_dictInvalidFileType,dictFileTooBig:b.file_too_big+" "+b.file_size_limit+f.upload.fileSizeLimit+" "+b.mb,acceptedFiles:h,autoProcessQueue:!1,init:function(){var b=this;a("#process-upload").click(function(){b.processQueue()})},totaluploadprogress:function(b){a("#total-progress .progress-bar").css("width",b+"%")},sending:function(a,b,c){c.append("mode","add");c.append("currentpath",e)},success:function(b,c){a("#uploadresponse").empty().html(c);var d=jQuery.parseJSON(a("#uploadresponse").find("textarea").text());
0==d.Code?this.removeFile(b):(m(e),a("#filetree").find('a[data-path="'+e+'"]').click(),a.prompt(d.Error),error_flag=!0)},complete:function(c){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&(a("#total-progress .progress-bar").css("width","0%"),0===this.getRejectedFiles().length&&!1===error_flag&&setTimeout(function(){a.prompt.close()},800),m(e),e==fileRoot&&u(),a("#filetree").find('a[data-path="'+e+'"]').click().click(),f.options.showConfirmation&&a.prompt(b.successful_added_file))}})})):
(a("#uploader").attr("action",k+"?config="+userconfig),a("#uploader").ajaxForm({target:"#uploadresponse",beforeSubmit:function(c,e,g){if(""==a("#newfile",e).val())return!1;if(!L(a("#newfile",e).val()))return e="<p>"+b.INVALID_FILE_TYPE+"</p>","DISALLOW_ALL"==f.security.uploadPolicy&&(e+="<p>"+b.ALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),"ALLOW_ALL"==f.security.uploadPolicy&&(e+="<p>"+b.DISALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),a("#filepath").val(""),
a.prompt(e),!1;a("#upload").attr("disabled",!0);a("#upload span").addClass("loading").text(b.loading_data);if("images"==a.urlParam("type").toString().toLowerCase()){c=a("#newfile",e).val().toLowerCase().split(".");g=!1;for(key in f.images.imagesExt)f.images.imagesExt[key]==c[c.length-1]&&(g=!0);if(!1===g)return a.prompt(b.UPLOAD_IMAGES_ONLY),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload),!1}if("undefined"!==typeof FileReader&&"auto"!=typeof f.upload.fileSizeLimit&&
a("#newfile",e).get(0).files[0].size>1048576*f.upload.fileSizeLimit)return a.prompt("<p>"+b.file_too_big+"</p><p>"+b.file_size_limit+f.upload.fileSizeLimit+" "+b.mb+".</p>"),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload),!1},error:function(c,f,e){a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload);a.prompt(b.ERROR_UPLOADING_FILE)},success:function(c){c=jQuery.parseJSON(a("#uploadresponse").find("textarea").text());if(0==c.Code){var e=
c.Path,g=c.Name,h=q(g),l=a("#filetree").find('a[data-path="'+e+'"]'),k=l.parent(),g='<li class="file ext_'+h+'"><a data-path="'+e+g+'" href="#" class="">'+g+"</a></li>";k.find("ul").size()?(k.find("ul").prepend(g),l.click().click()):(k=a("#filetree").find("ul.jqueryFileTree"),k.prepend(g),u());m(e);f.options.showConfirmation&&a.prompt(b.successful_added_file);a("#filepath, #newfile").val("");a.browser.msie&&a("#newfile").replaceWith(a("#newfile").clone(!0));a("#filetree").find('a[data-path="'+c.Path+
'/"]').click().click()}else a.prompt(c.Error);a("#upload").removeAttr("disabled");a("#upload span").removeClass("loading").text(b.upload);a("#filepath").val("")}}));if(f.customScrollbar.enabled){loadCSS("./scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css");loadJS("./scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js");var g=void 0!=f.customScrollbar.theme?f.customScrollbar.theme:"inset-2-dark",e=void 0!=f.customScrollbar.button?f.customScrollbar.button:!0;a(window).load(function(){a("#filetree").append('<div style="height:3000px"></div>');
a("#filetree").mCustomScrollbar({theme:g,scrollButtons:{enable:e},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},callbacks:{onInit:function(){u()}},axis:"yx"});a("#fileinfo").mCustomScrollbar({theme:g,scrollButtons:{enable:e},advanced:{autoExpandHorizontalScroll:!0,updateOnContentResize:!0},axis:"y",alwaysShowScrollbar:1})})}else u();window.opener||window.tinyMCEPopup||a.urlParam("field_name")||a('#itemOptions a[href$="#select"]').remove();1==f.options.browseOnly&&(a("#file-input-container").remove(),
a("#upload").remove(),a("#newfolder").remove(),a("#toolbar").remove("#rename"),a(".contextMenu .rename").remove(),a(".contextMenu .move").remove(),a(".contextMenu .replace").remove(),a(".contextMenu .delete").remove());x();a(window).resize(x);a("#splitter").splitter({sizeLeft:f.options.splitterMinWidth,minLeft:f.options.splitterMinWidth,minRight:200});H(fileRoot+expandedFolder)});document.documentElement.setAttribute("data-useragent",navigator.userAgent);f.options.logger&&(A=(new Date).getTime()-
A,console.log("Total execution time : "+A+" ms"));a(window).load(function(){x()})})(jQuery);$(window).load(function(){$("#fileinfo").css({left:$("#splitter .vsplitbar").width()+$("#filetree").width()})});