jQuery(document).ready(function() {
jQuery(".cdm_responsive_button a").on("click",function(){
if ( jQuery( ".cdm_responsive_button a" ).is( ".dropdown-button" ) ) {
jQuery("#cdm_nav_buttons").addClass("open-cdm-nav"); jQuery(".cdm_responsive_button a").addClass("dropdown-button-open"); jQuery(".cdm_responsive_button a").removeClass("dropdown-button"); }else{
jQuery("#cdm_nav_buttons").removeClass("open-cdm-nav"); jQuery(".cdm_responsive_button a").addClass("dropdown-button"); jQuery(".cdm_responsive_button a").removeClass("dropdown-button-open");
}
return false; });
jQuery(document).bind("click", function(e) { if(!jQuery(e.target).is(".dropdown-button-open") && !jQuery(e.target).is("#search_files") && !jQuery(e.target).is(".open-cdm-nav") ) {
jQuery("#cdm_nav_buttons").removeClass("open-cdm-nav"); jQuery(".cdm_responsive_button a").addClass("dropdown-button"); jQuery(".cdm_responsive_button a").removeClass("dropdown-button-open"); } });
});
function cdm_ajax_search(){
sp_cdm_loading_image(); var cdm_search = ""; cdm_search = jQuery("#search_files").val();
var pid = jQuery.cookie("pid");
if(! pid){ var pid = 0; }
jQuery.get(sp_vars.ajax_url, {action: "cdm_file_list", uid: "1", pid: pid, search: cdm_search}, function(response){ jQuery("#cmd_file_thumbs").html(response).hide().fadeIn(); })
cdm_check_folder_perms(pid); cdm_check_file_perms(pid); }
function sp_cdm_sort(sort,pid){
if(pid != ""){
var pidurl = "&pid=" + pid;
}else{
var pidurl = "&cid=" + pid;
}
jQuery.get(sp_vars.ajax_url, {action: "cdm_file_list", uid: "1", sort: sort}, function(response){ jQuery("#cmd_file_thumbs").html(response).hide().fadeIn(); }) cdm_check_folder_perms(pid); cdm_check_file_perms(pid);
}
function sp_cdm_loading_image(){
jQuery("#cmd_file_thumbs").html('
');
}
function sp_cdm_load_file_manager(){
sp_cdm_loading_image();
jQuery.get(sp_vars.ajax_url, {action: "cdm_file_list", uid: "1"}, function(response){ jQuery("#cmd_file_thumbs").html(response).hide().fadeIn(); })
cdm_ajax_search();
}
jQuery(document).ready( function() {
var pid = jQuery.cookie("pid");
if(pid != 0){ sp_cdm_load_project(pid) }else{ sp_cdm_load_file_manager(); }
});
function sp_cdm_load_project(pid){
sp_cdm_loading_image(); jQuery("#cdm_current_folder").val(pid);
jQuery(".cdm_premium_pid_field").attr("value", pid); jQuery.cookie("pid", pid, { expires: 7 , path:"/" });
if(pid != 0 && jQuery("#cdm_premium_sub_projects").val() != 1){ jQuery(".cdm_add_folder_button").hide();
}else{ jQuery(".cdm_add_folder_button").show();
} cdm_check_folder_perms(pid); cdm_check_file_perms(pid); jQuery("#sub_category_parent").val(pid); jQuery(".cdm_premium_pid_field").val(pid);
jQuery.get(sp_vars.ajax_url, {action: "cdm_file_list", uid: "1", pid: pid}, function(response){ jQuery("#cmd_file_thumbs").html(response).hide().fadeIn(); })
}