diff --git a/src/Module.php b/src/Module.php index f7b45ef..d12d1d4 100644 --- a/src/Module.php +++ b/src/Module.php @@ -72,5 +72,8 @@ public function init() { if (!is_dir(Yii::getAlias($this->uploadFolder))) { mkdir(Yii::getAlias($this->uploadFolder), 0777, true); } + if(!Yii::$app->cache->exists('roxy_last_order')) { + Yii::$app->cache->set('roxy_last_folder', Yii::getAlias($this->uploadFolder)); + } } } diff --git a/src/web/js/roxy.js b/src/web/js/roxy.js index dfd5c4d..cc10078 100644 --- a/src/web/js/roxy.js +++ b/src/web/js/roxy.js @@ -279,7 +279,7 @@ $(document).on("change", "input#uploadform-file", function() { $(document).on("click", '.btn-roxymce-close', function() { var win = (window.opener ? window.opener : window.parent); win.tinyMCE.activeEditor.windowManager.close(); - closeDialog(getUrlParam('dialog')); + closeDialog(getUrlParam('fancybox')); }); /** * Event selected file roxymce @@ -298,7 +298,7 @@ $(document).on("click", '.btn-roxymce-select', function() { } } win.tinyMCE.activeEditor.windowManager.close(); - closeDialog(getUrlParam('dialog')); + closeDialog(getUrlParam('fancybox')); }); /** * Event search files diff --git a/src/web/js/roxy.min.js b/src/web/js/roxy.min.js index f25434e..9ef449d 100644 --- a/src/web/js/roxy.min.js +++ b/src/web/js/roxy.min.js @@ -1,4 +1,4 @@ /** * Created by phuon on 11/4/2016. */ -function showFileList(a){var b="";$(".file-list-item").html(""),$("#txtSearch").val(""),current_url=a,$.ajax({type:"GET",cache:!1,dataType:"json",url:a,success:function(a){if(0==a.error){$.each(a.content,function(a,c){$("button[data-name='thumb_view']").hasClass("btn-primary")?(b+='
',b+='
',b+='
'+c.name+"
",b+='
'+c.size+"
",b+="
",b+="
",b+="",$(".sort-actions").hide()):(b+='
'+c.name+"
",b+='
'+c.size+"
",b+='
'+c.date+"
",b+="
",b+="",$(".sort-actions").show())}),""==b&&(b=msg_empty_directory);var c=$(".file-list-item");c.html(b),$("img.lazy").lazyload({container:c,effect:"fadeIn"})}else alert(a.message),$(".file-list-item").html(msg_empty_directory)},error:function(){alert(msg_somethings_went_wrong),$(".file-list-item").html(msg_empty_directory)}})}function showFolderList(a){var b=$(".folder-list");return $.ajax({type:"GET",cache:!1,dataType:"json",url:a,success:function(a){if(0==a.error){b.treeview({data:a.content,preventUnselect:!0});var c=b.treeview("getNodes",node_id);$("#folder-rename").find("input[name='folder']").val(c.path).parent().find("input[name='name']").val(c.text)}else alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}}),b}function getUrlParam(a,b){var c="";if(b||(b=self.location.href),b.indexOf("?")>-1){b=b.substr(b.indexOf("?")+1),b=b.split("&");for(var d=0;d=0&&(f=f.split("?")[1]);var g=decodeURIComponent(e[1]);c.push({name:f,value:g})}return c}function progress(a){if(a.lengthComputable){var b=a.total,c=a.loaded,d=Math.round(100*c/b);$(".progress-bar").css({width:d+"%"}).html(d+"%"),d>=100&&setTimeout(function(){$(".progress").fadeOut("normal",function(){$(".progress-bar").css({width:"0%"}).html("0%")})},1e3)}}function reloadTreeview(a){node_id=a.nodeId,$("#folder-rename").find("input[name='folder']").val(a.path).parent().find("input[name='name']").val(a.text),$("#folder-create").find("input[name='folder']").val(a.path),$("#uploadform-file").attr("data-url",url_file_upload+"?folder="+a.path).attr("data-href",a.href),$("#txtSearch").val(""),reloadActionButton()}function reloadActionButton(){$(".first-row button,.first-row a").attr("disabled","disabled");var a=$(".btn-file-preview");a.removeAttr("href").attr("title",a.text());var b=$(".btn-file-download");b.removeAttr("href").attr("title",b.text()),$(".btn-roxymce-select").attr("disabled","disabled")}function closeDialog(a){switch(a){case"fancybox":parent.$.fancybox.close(),$.fancybox.close();break;case"modal":break;case"colorbox":break;case"iframe":}}var node_id=0,folder_list=$(".folder-list"),current_url="",file_cut,file_copy,target=null;$(document).on("ready",function(){showFolderList(folder_list.data("url")),showFileList($(".file-list").data("url")),$("a#single_image").fancybox()}),$(document).on("submit","form",function(a){return a.preventDefault(),!1}),$(document).on("nodeSelected",".folder-list",function(a,b){reloadTreeview(b),showFileList(b.href)}),$(document).on("click","[data-action='switch_view']",function(){$("[data-action='switch_view']").removeClass("btn-primary"),$(this).addClass("btn-primary"),$(".file-body").removeClass("thumb_view list_view").addClass($(this).data("name")),$(".first-row button,.first-row a").attr("disabled","disabled"),$(".btn-file-preview").removeAttr("href"),$(".btn-roxymce-select").attr("disabled","disabled"),$("#txtSearch").val(""),showFileList(current_url)}),$(document).on("click",".file-list-item .thumb,.file-list-item .list",function(){var a=$(this);$(".file-list-item .thumb, .file-list-item .list").removeClass("selected"),a.addClass("selected"),$(".first-row button,.first-row a").removeAttr("disabled"),$(".btn-file-download").attr("href",a.data("url")).attr("target","_blank"),$(".btn-file-preview").attr("href",a.data("url")).attr("title",a.data("title")).fancybox({type:1==a.data("image")?"image":"iframe",padding:5,fitToView:!0,autoSize:!0});var b=folder_list.treeview("getSelected"),c=$("#file-rename");c.find("input[name='file']").val(a.data("title")),c.find("input[name='name']").val(a.data("title")),c.find("input[name='folder']").val(b[0].path),$(".btn-roxymce-select").removeAttr("disabled")}),$(document).on("click","#folder-create .btn-submit",function(){var a=folder_list.treeview("getSelected");if(0!=a.length){var b=$(this),c=b.closest(".modal").find("form");$.ajax({type:"GET",cache:!1,data:c.serializeArray(),url:c.attr("action"),dataType:"json",success:function(b){if(0==b.error){var c=$("#folder-create");c.modal("hide"),c.find("input[name='name']").val("");var d={text:b.data.text,href:b.data.href,path:b.data.path,icon:"glyphicon glyphicon-folder-close",selectedIcon:"glyphicon glyphicon-folder-open"};folder_list.treeview("addNode",[d,a])}else alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})}else alert(msg_please_select_one_folder),$("#folder-create").modal("hide");return!1}),$(document).on("click","#folder-rename .btn-submit",function(){var a=folder_list.treeview("getSelected");if(0!=a.length){var b=$(this),c=b.closest(".modal").find("form");$.ajax({type:"GET",cache:!1,data:c.serializeArray(),url:c.attr("action"),dataType:"json",success:function(b){if(0==b.error){$("#folder-rename").modal("hide");var c={text:b.data.text,href:b.data.href,path:b.data.path,icon:"glyphicon glyphicon-folder-close",selectedIcon:"glyphicon glyphicon-folder-open"};folder_list.treeview("updateNode",[a,c]).treeview("selectNode",[c,{silent:!0}]),reloadTreeview(c)}else alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})}else alert(msg_please_select_one_folder),$("#folder-rename").modal("hide");return!1}),$(document).on("click","#file-rename .btn-submit",function(){var a=$(this),b=a.closest(".modal").find("form");return $.ajax({type:"GET",cache:!1,data:b.serializeArray(),url:b.attr("action"),dataType:"json",success:function(a){if(0==a.error){var b=$("#file-rename");b.find("input[name='file']").val(a.data.name),b.modal("hide"),$(".file-list-item").find(".selected").find(".file-name").find("span").text(a.data.name)}else alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}}),!1}),$(document).on("click",".btn-folder-remove",function(){var a=folder_list.treeview("getSelected"),b=folder_list.treeview("getParents",a)[0],c=confirm(msg_are_you_sure);c&&$.ajax({type:"GET",cache:!1,url:url_folder_remove+"?folder="+a[0].path,dataType:"json",success:function(c){0==c.error?(folder_list.treeview("removeNode",[a,{silent:!0}]).treeview("selectNode",[b,{silent:!0}]),current_url=b.href,reloadTreeview(b),showFileList(current_url)):alert(c.message)},error:function(){alert(msg_somethings_went_wrong)}})}),$(document).on("click",".btn-file-remove",function(){var a=confirm(msg_are_you_sure),b=folder_list.treeview("getSelected"),c=$(".btn-file-preview").attr("title");a&&$.ajax({type:"GET",cache:!1,url:url_file_remove+"?folder="+b[0].path+"&file="+c,dataType:"json",success:function(a){if(0==a.error){var b=$(".file-list-item").find(".selected");b.hasClass("list")?b.fadeOut("normal",function(){$(this).remove()}):b.parent().fadeOut("normal",function(){$(this).remove()})}else alert(a.message);reloadActionButton()},error:function(){alert(msg_somethings_went_wrong),reloadActionButton()}})}),$(document).on("change","input#uploadform-file",function(){$(".progress").show();var a=$(this),b=a.prop("files"),c=new FormData;$.each(b,function(a,b){c.append("UploadForm[file][]",b)}),$.ajax({type:"POST",url:a.attr("data-url"),cache:!1,data:c,xhr:function(){var a=$.ajaxSettings.xhr();return a.upload&&a.upload.addEventListener("progress",progress,!1),a},dataType:"json",processData:!1,contentType:!1,success:function(b){0==b.error?($(".image-list").append(b.html),showFileList(a.attr("data-href"))):alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})}),$(document).on("click",".btn-roxymce-close",function(){var a=window.opener?window.opener:window.parent;a.tinyMCE.activeEditor.windowManager.close(),closeDialog(getUrlParam("dialog"))}),$(document).on("click",".btn-roxymce-select",function(){var a=window.opener?window.opener:window.parent,b=$(".file-list-item").find(".selected"),c=a.document.getElementById(getUrlParam("input"));c.value=b.attr("data-url"),"undefined"!=typeof a.ImageDialog&&(a.ImageDialog.getImageData&&a.ImageDialog.getImageData(),a.ImageDialog.showPreviewImage()&&a.ImageDialog.showPreviewImage(b.attr("data-url"))),a.tinyMCE.activeEditor.windowManager.close(),closeDialog(getUrlParam("dialog"))}),$(document).on("keyup","#txtSearch",function(){var a=$(this).val(),b=$(".file-list-item .item");b.show(),$.each(b,function(b,c){var d=$(c).find(".file-name span").text();if(d.indexOf(a)<0)$(c).hide();else{var e=new RegExp(a,"g");d=d.replace(e,''+a+""),$(c).find(".file-name span").html(d)}})}),$(document).on("click",'[rel="order"]',function(){$('[rel="order"]').removeClass("sorted");var a=$(this).attr("data-order"),b=2,c=!1,d=folder_list.treeview("getSelected");switch("desc"==$(this).attr("data-sort")?($(this).addClass("sorted").attr("data-sort","asc"),a+="_asc"):($(this).addClass("sorted").attr("data-sort","desc"),a+="_desc"),a){case"date_asc":b=1;break;case"date_desc":b=2;break;case"name_asc":b=3;break;case"name_desc":b=4;break;case"size_asc":b=5;break;case"size_desc":b=6;break;default:b=2}var e=d[0].href;$.each(parseQuery(e),function(a,b){"sort"==a&&(c=a+"="+b)}),c?e=d[0].href.replace(c,"sort="+b):e+="&sort="+b,showFileList(e)}),$(".file-list-item")[0].oncontextmenu=function(a){target=$(a.target);var b=target.closest(".item");if(b.length>0)b.find(".list, .thumb").trigger("click");else{target.closest(".file-list-item").find(".list, .thumb").removeClass("selected"),$(".first-row button,.first-row a").attr("disabled","disabled");var c=$(".btn-file-preview");c.removeAttr("href").attr("title",c.text());var d=$(".btn-file-download");d.removeAttr("href").attr("title",d.text()),$(".btn-roxymce-select").attr("disabled","disabled")}return!1},$.contextMenu({selector:".file-list-item",items:{preview:{name:msg_preview,icon:"fa-search",callback:function(){$(".btn-file-preview").trigger("click")},disabled:function(){return 0==target.closest(".item").length}},download:{name:msg_download,icon:"fa-download",callback:function(){$(".btn-file-download").trigger("click")},disabled:function(){return 0==target.closest(".item").length}},separator:{type:"cm_separator"},cut:{name:msg_cut,icon:"fa-cut",callback:function(){var a=folder_list.treeview("getSelected"),b=$(".btn-file-preview").attr("title");$.ajax({type:"get",cache:!1,dataType:"json",url:url_file_cut+"?folder="+a[0].path+"&file="+b,success:function(a){0==a.error?(file_copy=!1,file_cut=!0):alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}})},disabled:function(){return 0==target.closest(".item").length}},copy:{name:msg_copy,icon:"fa-copy",callback:function(){var a=folder_list.treeview("getSelected"),b=$(".btn-file-preview").attr("title");$.ajax({type:"get",cache:!1,dataType:"json",url:url_file_copy+"?folder="+a[0].path+"&file="+b,success:function(a){0==a.error?(file_cut=!1,file_copy=!0):alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}})},disabled:function(){return 0==target.closest(".item").length}},paste:{name:msg_paste,icon:"fa-clipboard",callback:function(){var a=folder_list.treeview("getSelected");$(".btn-file-preview").attr("title");$.ajax({type:"get",cache:!1,dataType:"json",url:url_file_paste+"?folder="+a[0].path,success:function(b){0==b.error?(file_copy=!1,file_cut=!1,showFileList(a[0].href)):alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})},disabled:function(){return!file_copy&&!file_cut}},rename:{name:msg_rename,icon:"fa-pencil",callback:function(){$(".btn-file-rename").trigger("click")},disabled:function(){return 0==target.closest(".item").length}},remove:{name:msg_delete,icon:"fa-trash",callback:function(){$(".btn-file-remove").trigger("click")},disabled:function(){return 0==target.closest(".item").length}}}}); \ No newline at end of file +function showFileList(a){var b="";$(".file-list-item").html(""),$("#txtSearch").val(""),current_url=a,$.ajax({type:"GET",cache:!1,dataType:"json",url:a,success:function(a){if(0==a.error){$.each(a.content,function(a,c){$("button[data-name='thumb_view']").hasClass("btn-primary")?(b+='
',b+='
',b+='
'+c.name+"
",b+='
'+c.size+"
",b+="
",b+="
",b+="",$(".sort-actions").hide()):(b+='
'+c.name+"
",b+='
'+c.size+"
",b+='
'+c.date+"
",b+="
",b+="",$(".sort-actions").show())}),""==b&&(b=msg_empty_directory);var c=$(".file-list-item");c.html(b),$("img.lazy").lazyload({container:c,effect:"fadeIn"})}else alert(a.message),$(".file-list-item").html(msg_empty_directory)},error:function(){alert(msg_somethings_went_wrong),$(".file-list-item").html(msg_empty_directory)}})}function showFolderList(a){var b=$(".folder-list");return $.ajax({type:"GET",cache:!1,dataType:"json",url:a,success:function(a){if(0==a.error){b.treeview({data:a.content,preventUnselect:!0});var c=b.treeview("getNodes",node_id);$("#folder-rename").find("input[name='folder']").val(c.path).parent().find("input[name='name']").val(c.text)}else alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}}),b}function getUrlParam(a,b){var c="";if(b||(b=self.location.href),b.indexOf("?")>-1){b=b.substr(b.indexOf("?")+1),b=b.split("&");for(var d=0;d=0&&(f=f.split("?")[1]);var g=decodeURIComponent(e[1]);c.push({name:f,value:g})}return c}function progress(a){if(a.lengthComputable){var b=a.total,c=a.loaded,d=Math.round(100*c/b);$(".progress-bar").css({width:d+"%"}).html(d+"%"),d>=100&&setTimeout(function(){$(".progress").fadeOut("normal",function(){$(".progress-bar").css({width:"0%"}).html("0%")})},1e3)}}function reloadTreeview(a){node_id=a.nodeId,$("#folder-rename").find("input[name='folder']").val(a.path).parent().find("input[name='name']").val(a.text),$("#folder-create").find("input[name='folder']").val(a.path),$("#uploadform-file").attr("data-url",url_file_upload+"?folder="+a.path).attr("data-href",a.href),$("#txtSearch").val(""),reloadActionButton()}function reloadActionButton(){$(".first-row button,.first-row a").attr("disabled","disabled");var a=$(".btn-file-preview");a.removeAttr("href").attr("title",a.text());var b=$(".btn-file-download");b.removeAttr("href").attr("title",b.text()),$(".btn-roxymce-select").attr("disabled","disabled")}function closeDialog(a){switch(a){case"fancybox":parent.$.fancybox.close(),$.fancybox.close();break;case"modal":break;case"colorbox":break;case"iframe":}}var node_id=0,folder_list=$(".folder-list"),current_url="",file_cut,file_copy,target=null;$(document).on("ready",function(){showFolderList(folder_list.data("url")),showFileList($(".file-list").data("url")),$("a#single_image").fancybox()}),$(document).on("submit","form",function(a){return a.preventDefault(),!1}),$(document).on("nodeSelected",".folder-list",function(a,b){reloadTreeview(b),showFileList(b.href)}),$(document).on("click","[data-action='switch_view']",function(){$("[data-action='switch_view']").removeClass("btn-primary"),$(this).addClass("btn-primary"),$(".file-body").removeClass("thumb_view list_view").addClass($(this).data("name")),$(".first-row button,.first-row a").attr("disabled","disabled"),$(".btn-file-preview").removeAttr("href"),$(".btn-roxymce-select").attr("disabled","disabled"),$("#txtSearch").val(""),showFileList(current_url)}),$(document).on("click",".file-list-item .thumb,.file-list-item .list",function(){var a=$(this);$(".file-list-item .thumb, .file-list-item .list").removeClass("selected"),a.addClass("selected"),$(".first-row button,.first-row a").removeAttr("disabled"),$(".btn-file-download").attr("href",a.data("url")).attr("target","_blank"),$(".btn-file-preview").attr("href",a.data("url")).attr("title",a.data("title")).fancybox({type:1==a.data("image")?"image":"iframe",padding:5,fitToView:!0,autoSize:!0});var b=folder_list.treeview("getSelected"),c=$("#file-rename");c.find("input[name='file']").val(a.data("title")),c.find("input[name='name']").val(a.data("title")),c.find("input[name='folder']").val(b[0].path),$(".btn-roxymce-select").removeAttr("disabled")}),$(document).on("click","#folder-create .btn-submit",function(){var a=folder_list.treeview("getSelected");if(0!=a.length){var b=$(this),c=b.closest(".modal").find("form");$.ajax({type:"GET",cache:!1,data:c.serializeArray(),url:c.attr("action"),dataType:"json",success:function(b){if(0==b.error){var c=$("#folder-create");c.modal("hide"),c.find("input[name='name']").val("");var d={text:b.data.text,href:b.data.href,path:b.data.path,icon:"glyphicon glyphicon-folder-close",selectedIcon:"glyphicon glyphicon-folder-open"};folder_list.treeview("addNode",[d,a])}else alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})}else alert(msg_please_select_one_folder),$("#folder-create").modal("hide");return!1}),$(document).on("click","#folder-rename .btn-submit",function(){var a=folder_list.treeview("getSelected");if(0!=a.length){var b=$(this),c=b.closest(".modal").find("form");$.ajax({type:"GET",cache:!1,data:c.serializeArray(),url:c.attr("action"),dataType:"json",success:function(b){if(0==b.error){$("#folder-rename").modal("hide");var c={text:b.data.text,href:b.data.href,path:b.data.path,icon:"glyphicon glyphicon-folder-close",selectedIcon:"glyphicon glyphicon-folder-open"};folder_list.treeview("updateNode",[a,c]).treeview("selectNode",[c,{silent:!0}]),reloadTreeview(c)}else alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})}else alert(msg_please_select_one_folder),$("#folder-rename").modal("hide");return!1}),$(document).on("click","#file-rename .btn-submit",function(){var a=$(this),b=a.closest(".modal").find("form");return $.ajax({type:"GET",cache:!1,data:b.serializeArray(),url:b.attr("action"),dataType:"json",success:function(a){if(0==a.error){var b=$("#file-rename");b.find("input[name='file']").val(a.data.name),b.modal("hide"),$(".file-list-item").find(".selected").find(".file-name").find("span").text(a.data.name)}else alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}}),!1}),$(document).on("click",".btn-folder-remove",function(){var a=folder_list.treeview("getSelected"),b=folder_list.treeview("getParents",a)[0],c=confirm(msg_are_you_sure);c&&$.ajax({type:"GET",cache:!1,url:url_folder_remove+"?folder="+a[0].path,dataType:"json",success:function(c){0==c.error?(folder_list.treeview("removeNode",[a,{silent:!0}]).treeview("selectNode",[b,{silent:!0}]),current_url=b.href,reloadTreeview(b),showFileList(current_url)):alert(c.message)},error:function(){alert(msg_somethings_went_wrong)}})}),$(document).on("click",".btn-file-remove",function(){var a=confirm(msg_are_you_sure),b=folder_list.treeview("getSelected"),c=$(".btn-file-preview").attr("title");a&&$.ajax({type:"GET",cache:!1,url:url_file_remove+"?folder="+b[0].path+"&file="+c,dataType:"json",success:function(a){if(0==a.error){var b=$(".file-list-item").find(".selected");b.hasClass("list")?b.fadeOut("normal",function(){$(this).remove()}):b.parent().fadeOut("normal",function(){$(this).remove()})}else alert(a.message);reloadActionButton()},error:function(){alert(msg_somethings_went_wrong),reloadActionButton()}})}),$(document).on("change","input#uploadform-file",function(){$(".progress").show();var a=$(this),b=a.prop("files"),c=new FormData;$.each(b,function(a,b){c.append("UploadForm[file][]",b)}),$.ajax({type:"POST",url:a.attr("data-url"),cache:!1,data:c,xhr:function(){var a=$.ajaxSettings.xhr();return a.upload&&a.upload.addEventListener("progress",progress,!1),a},dataType:"json",processData:!1,contentType:!1,success:function(b){0==b.error?($(".image-list").append(b.html),showFileList(a.attr("data-href"))):alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})}),$(document).on("click",".btn-roxymce-close",function(){var a=window.opener?window.opener:window.parent;a.tinyMCE.activeEditor.windowManager.close(),closeDialog(getUrlParam("fancybox"))}),$(document).on("click",".btn-roxymce-select",function(){var a=window.opener?window.opener:window.parent,b=$(".file-list-item").find(".selected"),c=a.document.getElementById(getUrlParam("input"));c.value=b.attr("data-url"),"undefined"!=typeof a.ImageDialog&&(a.ImageDialog.getImageData&&a.ImageDialog.getImageData(),a.ImageDialog.showPreviewImage()&&a.ImageDialog.showPreviewImage(b.attr("data-url"))),a.tinyMCE.activeEditor.windowManager.close(),closeDialog(getUrlParam("fancybox"))}),$(document).on("keyup","#txtSearch",function(){var a=$(this).val(),b=$(".file-list-item .item");b.show(),$.each(b,function(b,c){var d=$(c).find(".file-name span").text();if(d.indexOf(a)<0)$(c).hide();else{var e=new RegExp(a,"g");d=d.replace(e,''+a+""),$(c).find(".file-name span").html(d)}})}),$(document).on("click",'[rel="order"]',function(){$('[rel="order"]').removeClass("sorted");var a=$(this).attr("data-order"),b=2,c=!1,d=folder_list.treeview("getSelected");switch("desc"==$(this).attr("data-sort")?($(this).addClass("sorted").attr("data-sort","asc"),a+="_asc"):($(this).addClass("sorted").attr("data-sort","desc"),a+="_desc"),a){case"date_asc":b=1;break;case"date_desc":b=2;break;case"name_asc":b=3;break;case"name_desc":b=4;break;case"size_asc":b=5;break;case"size_desc":b=6;break;default:b=2}var e=d[0].href;$.each(parseQuery(e),function(a,b){"sort"==a&&(c=a+"="+b)}),c?e=d[0].href.replace(c,"sort="+b):e+="&sort="+b,showFileList(e)}),$(".file-list-item")[0].oncontextmenu=function(a){target=$(a.target);var b=target.closest(".item");if(b.length>0)b.find(".list, .thumb").trigger("click");else{target.closest(".file-list-item").find(".list, .thumb").removeClass("selected"),$(".first-row button,.first-row a").attr("disabled","disabled");var c=$(".btn-file-preview");c.removeAttr("href").attr("title",c.text());var d=$(".btn-file-download");d.removeAttr("href").attr("title",d.text()),$(".btn-roxymce-select").attr("disabled","disabled")}return!1},$.contextMenu({selector:".file-list-item",items:{preview:{name:msg_preview,icon:"fa-search",callback:function(){$(".btn-file-preview").trigger("click")},disabled:function(){return 0==target.closest(".item").length}},download:{name:msg_download,icon:"fa-download",callback:function(){$(".btn-file-download").trigger("click")},disabled:function(){return 0==target.closest(".item").length}},separator:{type:"cm_separator"},cut:{name:msg_cut,icon:"fa-cut",callback:function(){var a=folder_list.treeview("getSelected"),b=$(".btn-file-preview").attr("title");$.ajax({type:"get",cache:!1,dataType:"json",url:url_file_cut+"?folder="+a[0].path+"&file="+b,success:function(a){0==a.error?(file_copy=!1,file_cut=!0):alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}})},disabled:function(){return 0==target.closest(".item").length}},copy:{name:msg_copy,icon:"fa-copy",callback:function(){var a=folder_list.treeview("getSelected"),b=$(".btn-file-preview").attr("title");$.ajax({type:"get",cache:!1,dataType:"json",url:url_file_copy+"?folder="+a[0].path+"&file="+b,success:function(a){0==a.error?(file_cut=!1,file_copy=!0):alert(a.message)},error:function(){alert(msg_somethings_went_wrong)}})},disabled:function(){return 0==target.closest(".item").length}},paste:{name:msg_paste,icon:"fa-clipboard",callback:function(){var a=folder_list.treeview("getSelected");$(".btn-file-preview").attr("title");$.ajax({type:"get",cache:!1,dataType:"json",url:url_file_paste+"?folder="+a[0].path,success:function(b){0==b.error?(file_copy=!1,file_cut=!1,showFileList(a[0].href)):alert(b.message)},error:function(){alert(msg_somethings_went_wrong)}})},disabled:function(){return!file_copy&&!file_cut}},rename:{name:msg_rename,icon:"fa-pencil",callback:function(){$(".btn-file-rename").trigger("click")},disabled:function(){return 0==target.closest(".item").length}},remove:{name:msg_delete,icon:"fa-trash",callback:function(){$(".btn-file-remove").trigger("click")},disabled:function(){return 0==target.closest(".item").length}}}}); \ No newline at end of file