/*
	MIT License
 @author		Jason Huck - Core Five Labs
 @author		Simon Georget <simon (at) linea21 (dot) com>
 @copyright	Authors
*/
(function(a){function P(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 q(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 v(c){var g=c.attr("class").replace(/ /g,"_");if(""==g)return"itemOptions";
if(!a("#"+g).length){var d=a("#itemOptions").clone().attr("id",g);c.hasClass("cap_select")||a(".select",d).remove();c.hasClass("cap_download")||a(".download",d).remove();c.hasClass("cap_rename")||a(".rename",d).remove();c.hasClass("cap_move")||a(".move",d).remove();a(".replace",d).remove();c.hasClass("cap_delete")||a(".delete",d).remove();a("#itemOptions").after(d)}return g}a.urlParam=function(a){return(a=(new RegExp("[\\?&]"+a+"=([^&#]*)")).exec(window.location.href))?a[1]:0};var w=function(c){var g=
null;a.ajax({async:!1,url:"user"==("undefined"===typeof c?"user":c)?"./scripts/filemanager.config.js":"./scripts/filemanager.config.js.default",dataType:"json",cache:!1,success:function(a){g=a}});return g},Q=w("default"),f=w(),f=a.extend({},Q,f);if(f.options.logger)var R=(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 d=a.split("/"),d="/"+d[d.length-2]+"/",b=g.indexOf(d);return a+g.substring(b+d.length)};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")&&P("scripts/languages/"+a.urlParam("langCode")+
".js")&&(f.options.culture=a.urlParam("langCode"));var d=[];a.ajax({url:"scripts/languages/"+f.options.culture+".js",async:!1,dataType:"json",success:function(a){d=a}});a.prompt.setDefaults({overlayspeed:"fast",show:"fadeIn",opacity:.4,persistent:!1});var x=function(){var c=53;a.urlParam("CKEditorCleanUpFuncNum")&&(c+=60);c=a(window).height()-a("#uploader").height()-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,d){d="undefined"===typeof d?!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===d){var e=a.split("/");a="/"+e[1]+"/"+e[2]+"/(...)/"+e[e.length-2]+"/"}}return a},A=function(c){"grid"==c?(a("#grid").addClass("ON"),a("#list").removeClass("ON")):(a("#list").addClass("ON"),a("#grid").removeClass("ON"))},B=function(a){var d="",d="\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<d.length;i++)a=a.replace(RegExp(d[i],"g"),e[i]);d=a;f.options.chars_only_latin&&(d=d.replace(/[^_a-zA-Z0-9]/g,""));return d=d.replace(/[_]+/g,"_")},S=function(a){filename="";-1!=a.lastIndexOf(".")?(filename=B(a.substr(0,a.lastIndexOf("."))),filename+="."+a.split(".").pop()):filename=B(a);return filename},
H=function(a){a=parseFloat(a);for(var g=0,f=[d.bytes,d.kb,d.mb,d.gb];;){if(1024>a)return a=Math.round(100*a)/100,a+f[g];a/=1024;g+=1}},I=function(c){a("#fileinfo").html("<h1>"+c+"</h1>");a("#newfile").attr("disabled","disabled");a("#upload").attr("disabled","disabled");a("#newfolder").attr("disabled","disabled")},J=function(c){c=r(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},r=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 d="<video width="+f.videos.videosPlayerWidth+" height="+f.videos.videosPlayerHeight+' src="'+c.Path+'" controls="controls">',d=d+('<img src="'+c.Preview+'" />'),d=d+"</video>";a("#fileinfo img").remove();a("#fileinfo #preview #main-title").before(d)},V=function(d){var g=
'<audio src="'+d.Path+'" controls="controls">',g=g+('<img src="'+d.Preview+'" />'),g=g+"</audio>";a("#fileinfo img").remove();a("#fileinfo #preview #main-title").before(g)},W=function(d){a("#fileinfo").find("td:first-child").each(function(){var g=a(this).attr("data-path"),g=a("#filetree").find('a[data-path="'+g+'"]').parent();"undefined"!==typeof g.css("background-image")&&(a(this).css("background-image",g.css("background-image")),window.clearInterval(d))})},C=function(c){a("#currentpath").val(c);
a("#uploader h1").text(d.current_folder+y(c)).attr("title",y(c,!1)).attr("data-path",c);a("#newfolder").unbind().click(function(){var c=d.default_foldername,f=d.prompt_foldername+' : <input id="fname" name="fname" type="text" value="'+c+'" />',b={};b[d.create_folder]=!0;b[d.cancel]=!1;a.prompt(f,{callback:function(b,f){if(1!=b)return!1;var e=f.children("#fname").val();""!=e?(c=B(e),e=new Date,a.getJSON(k+"?mode=addfolder&path="+a("#currentpath").val()+"&name="+c+"&time="+e.getMilliseconds(),function(b){0==
b.Code?(X(b.Parent,b.Name),m(b.Parent),a("#filetree").find('a[data-path="'+b.Parent+'/"]').click().click()):a.prompt(b.Error)})):a.prompt(d.no_foldername)},buttons:b})})},O=function(c){a("#fileinfo button").each(function(d){0==a(this).find("span").length&&a(this).wrapInner("<span></span>")});if(q(c,"select")){if(a("#fileinfo").find("button#select").click(function(){D(c)}).show(),window.opener||window.tinyMCEPopup)a("#preview img").attr("title",d.select),a("#preview img").click(function(){D(c)}).css("cursor",
"pointer")}else a("#fileinfo").find("button#select").hide();q(c,"rename")?a("#fileinfo").find("button#rename").click(function(){var d=K(c);d.length&&a("#fileinfo > h1").text(d)}).show():a("#fileinfo").find("button#rename").hide();q(c,"move")?a("#fileinfo").find("button#move").click(function(){var d=L(c);d.length&&a("#fileinfo > h1").text(d)}).show():a("#fileinfo").find("button#move").hide();q(c,"replace")?a("#fileinfo").find("button#replace").click(function(){M(c)}).show():a("#fileinfo").find("button#replace").hide();
q(c,"delete")?a("#fileinfo").find("button#delete").click(function(){N(c)&&a("#fileinfo").html("<h1>"+d.select_from_left+"</h1>")}).show():a("#fileinfo").find("button#delete").hide();q(c,"download")?a("#fileinfo").find("button#download").click(function(){window.location=k+"?mode=download&path="+encodeURIComponent(c.Path)}).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:Y,multiFolder:!1,folderCallback:function(a){m(a)},expandedFolder:fullexpandedFolder,after:function(c){a("#filetree").find("li a").each(function(){a(this).contextMenu({menu:v(a(this))},function(d,b,c){b=a(b).attr("data-path");z(d,b)})});1==f.options.searchBox&&(a("#q").liveUpdate("#filetree ul").blur(),a("#search span.q-inactive").html(d.search),a("#search a.q-reset").attr("title",d.search_reset))}},function(a){E(a)})},D=function(c){var g=!1!==f.options.baseUrl?smartPath(baseUrl,c.Path.replace(fileRoot,
"")):baseUrl+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(d.fck_select_integration)},K=function(c){var g="",e=f.security.allowChangeExtensions?c.Filename:T(c.Filename),e=d.new_filename+' : <input id="rname" name="rname" type="text" value="'+e+'" />',b={};b[d.rename]=!0;b[d.cancel]=!1;a.prompt(e,{callback:function(b,e){if(1!=b)return!1;rname=e.children("#rname").val();if(""!=rname){var h=rname;if(!f.security.allowChangeExtensions){var h=S(rname),l=r(c.Filename);0<l.length&&(h=h+"."+l)}if("/"!=
c.Path.charAt(c.Path.length-1)&&!J(h))return h="<p>"+d.INVALID_FILE_TYPE+"</p>","DISALLOW_ALL"==f.security.uploadPolicy&&(h+="<p>"+d.ALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),"ALLOW_ALL"==f.security.uploadPolicy&&(h+="<p>"+d.DISALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),a("#filepath").val(""),a.prompt(h),!1;a.ajax({type:"GET",url:k+"?mode=rename&old="+c.Path+"&new="+h,dataType:"json",async:!1,success:function(b){if(0==b.Code){var e=b["New Path"],
t=b["New Name"],h=b["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();O(c);f.options.showConfirmation&&a.prompt(d.successful_rename)}else a.prompt(b.Error);g=b["New Name"]}})}},buttons:b});return g},M=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,b){g=a("#fileR",
e).val();if(""==g)return!1;if(r(g)!=c["File Type"])return a.prompt(d.ERROR_REPLACING_FILE+" ."+r(c.Filename)),!1;a("#replace").attr("disabled",!0);a("#upload span").addClass("loading").text(d.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>"+d.file_too_big+"</p><p>"+d.file_size_limit+f.upload.fileSizeLimit+" "+d.mb+".</p>"),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(d.upload),
!1},error:function(c,f,b){a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(d.upload);a.prompt(d.ERROR_UPLOADING_FILE)},success:function(c){c=jQuery.parseJSON(a("#uploadresponse").find("textarea").text());0==c.Code?(c=c.Path+"/"+c.Name,E(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(d.successful_replace)):a.prompt(c.Error);a("#replace").removeAttr("disabled");
a("#upload span").removeClass("loading").text(d.upload)}});a("#newfilepath").val(c.Path);a("#fileR").click()},L=function(c){var g="",e=d.move+' : <input id="rname" name="rname" type="text" value="" />',e=e+('<div class="prompt-info">'+d.help_move+"</div>"),b={};b[d.move]=!0;b[d.cancel]=!1;a.prompt(e,{callback:function(b,e){if(1!=b)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);
a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(b){if(0==b.Code){var c=b["New Path"],e=b["New Name"];fullexpandedFolder=c;u();m(c);f.options.showConfirmation&&a.prompt(d.successful_moved)}else a.prompt(b.Error);g=c+e}})}},buttons:b});return g},N=function(c){var g=!1,e=d.confirmation_delete,b={};b[d.yes]=!0;b[d.no]=!1;a.prompt(e,{callback:function(b,e){if(1!=b)return!1;var h=new Date,h=k+"?mode=delete&path="+encodeURIComponent(c.Path)+"&time="+h.getMilliseconds(),l=c.Path.split("/").reverse().slice(1).reverse().join("/")+
"/";a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(b){0==b.Code?(Z(b.Path),b=b.Path.substring(0,b.Path.length-1),b=b.substr(0,b.lastIndexOf("/")+1),a("#uploader h1").text(d.current_folder+y(b)).attr("title",y(b,!1)).attr("data-path",b),g=!0,f.options.showConfirmation&&a.prompt(d.successful_delete),a("#filetree").find('a[data-path="'+l+'/"]').click().click()):(g=!1,a.prompt(b.Error))}})},buttons:b});return g},aa=function(c){isEdited=!1;a("#fileinfo").find("div#tools").append(' <a id="edit-file" href="#" title="'+
d.edit+'"><span>'+d.edit+"</span></a>");a("#edit-file").click(function(){a(this).hide();var g=new Date,g=k+"?mode=editfile&path="+encodeURIComponent(c.Path)+"&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">'+
d.quit_editor+"</button>",e+='<button id="edit-save" class="edition" type="button">'+d.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 b=codeMirrorEditor.getValue();a("textarea#edit-content").val(b);b=a("#edit-form").serializeArray();a.ajax({type:"POST",url:k,dataType:"json",
data:b,async:!1,success:function(b){0==b.Code?(isEdited=!0,a.prompt(d.successful_edit)):(isEdited=!1,a.prompt(b.Error))}})}),codeMirrorEditor=instantiateCodeMirror(r(c.Path),f)):(isEdited=!1,a.prompt(e.Error),a(this).show())}})});return isEdited},Z=function(d){a("#filetree").find('a[data-path="'+d+'"]').parent().fadeOut("slow",function(){a(this).remove()});if(a("#uploader h1").attr("data-path")==d){var f=d.split("/").slice(0,length-2).join("/")+"/";m(f)}"grid"==a("#fileinfo").data("view")?a('#contents img[data-path="'+
d+'"]').parent().parent().fadeOut("slow",function(){a(this).remove()}):a("table#contents").find('td[data-path="'+d+'"]').parent().fadeOut("slow",function(){a(this).remove()});a("#preview").length&&m(d.substr(0,d.lastIndexOf("/")+1))},X=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>',b=a("#filetree").find('a[data-path="'+c+'"]');c!=fileRoot?b.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:v(a(this))},function(b,d,c){d=a(d).attr("data-path");z(b,d)})}));f.options.showConfirmation&&a.prompt(d.successful_added_folder)},G=function(d){d.lastIndexOf("/")==d.length-1?(m(d),a("#filetree").find('a[data-path="'+d+'"]').click()):E(d)},z=function(d,f){var e=new Date;a.getJSON(k+"?mode=getinfo&path="+
f+"&time="+e.getMilliseconds(),function(b){"grid"==a("#fileinfo").data("view")?a("#fileinfo").find('img[data-path="'+b.Path+'"]').parent():a("#fileinfo").find('td[data-path="'+b.Path+'"]').parent();switch(d){case "select":D(b);break;case "download":window.location=k+"?mode=download&path="+b.Path+"&time="+e.getMilliseconds();break;case "rename":K(b);break;case "replace":M(b);break;case "move":L(b);break;case "delete":N(b)}})},E=function(c){var g=c.substr(0,c.lastIndexOf("/")+1);C(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">'+d.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">'+d.select+"</button>");-1!=a.inArray("download",n)&&(e+='<button id="download" name="download" type="button" value="Download">'+d.download+"</button>");-1!=a.inArray("rename",n)&&1!=f.options.browseOnly&&(e+='<button id="rename" name="rename" type="button" value="Rename">'+
d.rename+"</button>");-1!=a.inArray("move",n)&&1!=f.options.browseOnly&&(e+='<button id="move" name="move" type="button" value="Move">'+d.move+"</button>");-1!=a.inArray("delete",n)&&1!=f.options.browseOnly&&(e+='<button id="delete" name="delete" type="button" value="Delete">'+d.del+"</button>");-1!=a.inArray("replace",n)&&1!=f.options.browseOnly&&(e+='<button id="replace" name="replace" type="button" value="Replace">'+d.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)+"&time="+e.getMilliseconds(),function(b){if(0==b.Code){a("#fileinfo").find("h1").text(b.Filename).attr("title",c);a("#fileinfo").find("img").attr("src",
b.Preview);var e;e=-1!=a.inArray(r(b.Filename),f.videos.videosExt)?!0:!1;e&&1==f.videos.showVideoPlayer&&U(b);e=-1!=a.inArray(r(b.Filename),f.audios.audiosExt)?!0:!1;e&&1==f.audios.showAudioPlayer&&V(b);e=-1!=a.inArray(r(b.Filename),f.edit.editExt)?!0:!1;e&&1==f.edit.enabled&&0==b.Protected&&aa(b);e=new Date;var g=!1!==f.options.baseUrl?smartPath(baseUrl,b.Path.replace(fileRoot,"")):baseUrl+b.Path;0==b.Protected&&(a("#fileinfo").find("div#tools").append(' <a id="copy-button" data-clipboard-text="'+
g+'" title="'+d.copy_to_clipboard+'" href="#"><span>'+d.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">'+d.copied+"</span>");a("#copied").delay(500).fadeOut(1E3,function(){a(this).remove()})}));e="";b.Properties.Width&&""!=b.Properties.Width&&(e+="<dt>"+d.dimensions+"</dt><dd>"+b.Properties.Width+"x"+b.Properties.Height+"</dd>");b.Properties["Date Created"]&&
""!=b.Properties["Date Created"]&&(e+="<dt>"+d.created+"</dt><dd>"+b.Properties["Date Created"]+"</dd>");b.Properties["Date Modified"]&&""!=b.Properties["Date Modified"]&&(e+="<dt>"+d.modified+"</dt><dd>"+b.Properties["Date Modified"]+"</dd>");if(b.Properties.Size||0==parseInt(b.Properties.Size))e+="<dt>"+d.size+"</dt><dd>"+H(b.Properties.Size)+"</dd>";a("#fileinfo").find("dl").html(e);O(b)}else a.prompt(b.Error)})},m=function(c){C(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)+"&mode=getfolder&showThumbs="+f.options.showThumbs+"&time="+g.getMilliseconds();a.urlParam("type")&&(c+="&type="+a.urlParam("type"));a.getJSON(c,function(c){var b="";if("-1"==c.Code)I(c.Error);else{x();if(c){var g=0,p=0;if("grid"==a("#fileinfo").data("view")){b+='<ul id="contents" class="grid">';for(key in c){g++;var h=
c[key].Properties,l="";for(cap in n)q(c[key],n[cap])&&(l+=" cap_"+n[cap]);var F=64,k=h.Width;1<k&&k<F&&(F=k);f.options.showTitleAttr?title=' title="'+c[key].Path+'"':title="";b+='<li class="'+l+'"'+title+'"><div class="clip"><img src="'+c[key].Preview+'" width="'+F+'" alt="'+c[key].Path+'" data-path="'+c[key].Path+'" /></div><p>'+c[key].Filename+"</p>";h.Width&&""!=h.Width&&(b+='<span class="meta dimensions">'+h.Width+"x"+h.Height+"</span>");h.Size&&""!=h.Size&&(b+='<span class="meta size">'+h.Size+
"</span>");h.Size&&""!=h.Size&&(p+=h.Size);h["Date Created"]&&""!=h["Date Created"]&&(b+='<span class="meta created">'+h["Date Created"]+"</span>");h["Date Modified"]&&""!=h["Date Modified"]&&(b+='<span class="meta modified">'+h["Date Modified"]+"</span>");b+="</li>"}b+="</ul>"}else{b=b+'<table id="contents" class="list">'+('<thead><tr><th class="headerSortDown"><span>'+d.name+"</span></th><th><span>"+d.dimensions+"</span></th><th><span>"+d.size+"</span></th><th><span>"+d.modified+"</span></th></tr></thead>");
b+="<tbody>";for(key in c){g++;h=c[key].Properties;l="";f.options.showTitleAttr?title=' title="'+c[key].Path+'"':title="";for(cap in n)q(c[key],n[cap])&&(l+=" cap_"+n[cap]);b+='<tr class="'+l+'">';b+='<td data-path="'+c[key].Path+'"'+title+'">'+c[key].Filename+"</td>";b=h.Width&&""!=h.Width?b+("<td>"+h.Width+"x"+h.Height+"</td>"):b+"<td></td>";h.Size&&""!=h.Size?(b+='<td><abbr title="'+h.Size+'">'+H(h.Size)+"</abbr></td>",p+=h.Size):b+="<td></td>";b=h["Date Modified"]&&""!=h["Date Modified"]?b+("<td>"+
h["Date Modified"]+"</td>"):b+"<td></td>";b+="</tr>"}b+="</tbody>";b+="</table>"}}else b+="<h1>"+d.could_not_retrieve_folder+"</h1>";0<a("#fileinfo .mCSB_container").length?a("#fileinfo .mCSB_container").html(b):a("#fileinfo").html(b);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");G(b)}).each(function(){a(this).contextMenu({menu:v(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");G(b)}).each(function(){a(this).contextMenu({menu:v(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(){W(m)},300)}}})},Y=function(c,g){var e=
new Date,e=k+"?path="+encodeURIComponent(c)+"&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)I(a.Error);else{if(a){c+='<ul class="jqueryFileTree" style="display: none;">';for(key in a){var e="";for(cap in n)q(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>"+d.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",d.support_fm+" ["+d.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"),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> '+d.items+" - "+d.size+' : <span id="items-size"></span> '+d.mb);1==f.options.autoload&&(a("#upload").append(d.upload),
a("#newfolder").append(d.new_folder),a("#grid").attr("title",d.grid_view),a("#list").attr("title",d.list_view),a("#fileinfo h1").append(d.select_from_left),a('#itemOptions a[href$="#select"]').append(d.select),a('#itemOptions a[href$="#download"]').append(d.download),a('#itemOptions a[href$="#rename"]').append(d.rename),a('#itemOptions a[href$="#move"]').append(d.move),a('#itemOptions a[href$="#replace"]').append(d.replace),a('#itemOptions a[href$="#delete"]').append(d.del));a.urlParam("CKEditorCleanUpFuncNum")&&
(a("body").append('<button id="close-btn" type="button">'+d.close+"</button>"),a("#close-btn").click(function(){parent.CKEDITOR.tools.callFunction(a.urlParam("CKEditorCleanUpFuncNum"))}));a("#browse").append("+");a("#browse").attr("title",d.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);A(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 d=a("#fileinfo").data("view");a("#fileinfo").data("view",d);a("#filetree").find('a[data-path="'+b+'"]').click();m(parent)}});
a("#grid").click(function(){A("grid");a("#fileinfo").data("view","grid");m(a("#currentpath").val())});a("#list").click(function(){A("list");a("#fileinfo").data("view","list");m(a("#currentpath").val())});C(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>'+
d.upload+"</span></button> "),a("#upload").unbind().click(function(){var b='<div id="dropzone-container"><h2>'+d.current_folder+a("#uploader h1").attr("title")+'</h2><div id="multiple-uploads" class="dropzone"></div>',b=b+'<div id="total-progress"><div data-dz-uploadprogress="" style="width:0%;" class="progress-bar"></div></div>'+('<div class="prompt-info">'+d.dz_dictMaxFilesExceeded.replace("%s",f.upload.number)+d.file_size_limit+f.upload.fileSizeLimit+" "+d.mb+".</div>"),b=b+('<button id="process-upload">'+
d.upload+"</button></div>");error_flag=!1;var c=a("#currentpath").val(),e="auto"!=f.upload.fileSizeLimit?f.upload.fileSizeLimit:256,g="DISALLOW_ALL"==f.security.uploadPolicy?"."+f.security.uploadRestrictions.join(",."):null;if("images"==a.urlParam("type").toString().toLowerCase()||f.upload.imagesOnly)g="."+f.images.imagesExt.join(",.");var l={};l[d.close]=!1;a.prompt(b,{buttons:l});a("div#multiple-uploads").dropzone({paramName:"newfile",url:k,maxFilesize:e,maxFiles:f.upload.number,addRemoveLinks:!0,
parallelUploads:f.upload.number,dictCancelUpload:d.cancel,dictRemoveFile:d.del,dictMaxFilesExceeded:d.dz_dictMaxFilesExceeded.replace("%s",f.upload.number),dictDefaultMessage:d.dz_dictDefaultMessage,dictInvalidFileType:d.dz_dictInvalidFileType,dictFileTooBig:d.file_too_big+" "+d.file_size_limit+f.upload.fileSizeLimit+" "+d.mb,acceptedFiles:g,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,d){d.append("mode","add");d.append("currentpath",c)},success:function(b,d){a("#uploadresponse").empty().html(d);var e=jQuery.parseJSON(a("#uploadresponse").find("textarea").text());0==e.Code?this.removeFile(b):(m(c),a("#filetree").find('a[data-path="'+c+'"]').click(),a.prompt(e.Error),error_flag=!0)},complete:function(b){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(c),c==fileRoot&&u(),a("#filetree").find('a[data-path="'+c+'"]').click().click(),f.options.showConfirmation&&a.prompt(d.successful_added_file))}})})):(a("#uploader").attr("action",k),a("#uploader").ajaxForm({target:"#uploadresponse",beforeSubmit:function(b,c,e){if(""==a("#newfile",c).val())return!1;if(!J(a("#newfile",c).val()))return c="<p>"+d.INVALID_FILE_TYPE+"</p>","DISALLOW_ALL"==f.security.uploadPolicy&&(c+="<p>"+d.ALLOWED_FILE_TYPE+
f.security.uploadRestrictions.join(", ")+".</p>"),"ALLOW_ALL"==f.security.uploadPolicy&&(c+="<p>"+d.DISALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),a("#filepath").val(""),a.prompt(c),!1;a("#upload").attr("disabled",!0);a("#upload span").addClass("loading").text(d.loading_data);if("images"==a.urlParam("type").toString().toLowerCase()){b=a("#newfile",c).val().toLowerCase().split(".");e=!1;for(key in f.images.imagesExt)f.images.imagesExt[key]==b[b.length-1]&&(e=!0);if(!1===e)return a.prompt(d.UPLOAD_IMAGES_ONLY),
a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(d.upload),!1}if("undefined"!==typeof FileReader&&"auto"!=typeof f.upload.fileSizeLimit&&a("#newfile",c).get(0).files[0].size>1048576*f.upload.fileSizeLimit)return a.prompt("<p>"+d.file_too_big+"</p><p>"+d.file_size_limit+f.upload.fileSizeLimit+" "+d.mb+".</p>"),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(d.upload),!1},error:function(b,c,e){a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(d.upload);
a.prompt(d.ERROR_UPLOADING_FILE)},success:function(b){b=jQuery.parseJSON(a("#uploadresponse").find("textarea").text());if(0==b.Code){var c=b.Path,e=b.Name,g=r(e),l=a("#filetree").find('a[data-path="'+c+'"]'),k=l.parent(),e='<li class="file ext_'+g+'"><a data-path="'+c+e+'" href="#" class="">'+e+"</a></li>";k.find("ul").size()?(k.find("ul").prepend(e),l.click().click()):(k=a("#filetree").find("ul.jqueryFileTree"),k.prepend(e),u());m(c);f.options.showConfirmation&&a.prompt(d.successful_added_file);
a("#filepath, #newfile").val("");a.browser.msie&&a("#newfile").replaceWith(a("#newfile").clone(!0));a("#filetree").find('a[data-path="'+b.Path+'/"]').click().click()}else a.prompt(b.Error);a("#upload").removeAttr("disabled");a("#upload span").removeClass("loading").text(d.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:200});
G(fileRoot+expandedFolder)});document.documentElement.setAttribute("data-useragent",navigator.userAgent);f.options.logger&&(w=(new Date).getTime()-R,console.log("Total execution time : "+w+" ms"));a(window).load(function(){x()})})(jQuery);
