var init_tree = 0; var selected; var over; var cp_tree1; var cp_tree2; function unorphanize(root, element) { var ok = false; var f = 0; for (var i=0; i .expandable-hitarea, .mainfoldertree > .collapsable-hitarea')){ $('.filetree span.folder.selected').removeClass('selected'); $(target).children('.folder').addClass('selected'); } $(this).addClass("folders-loading"); selected = target.attr('id'); Folder.change(target.attr('id'), child.attr('title')); /*$.ajax({ url : "controller.php?"+ $.param( { action: "$this.imap_functions.get_folders_list", folder: target.attr('id') } ), success : function(data){ data = connector.unserialize(data); if(data) build_quota(data); } });*/ $(".folders-loading").removeClass("folders-loading"); }).filter('.followup-messages').click(function(event, ui){ search_emails("UNDELETED KEYWORD \"$Followupflagged\""); }).end().end(); folders_html.find('[id="'+selected+'"]').children().addClass("selected"); $(".folder").not(".head_folder").not(".shared-folders").parent().find(".folder").not(".head_folder,.inbox,.drafts,.sent,.spam,.trash").draggable({ // DRAG DE PASTAS start : function(){ $(this).css("color", "gray"); }, stop : function(){ $(this).css("color", ""); }, revert: "invalid", helper: function(event){ if($.trim(($(this).text().split("["))[0]).length > 18) return $(DataLayer.render('templates/draggin_box.ejs', {texto : (($(this).text().split("["))[0]).substring(0,18) + "...", type: "folder"})); return $(DataLayer.render('templates/draggin_box.ejs', {texto : (($(this).text().split("["))[0]), type: "folder"})); }, delay: 150, refreshPositions: true, zIndex : 2700, //scroll: true, //scrollSensitivity: 100, //scrollSpeed: 100, containment: "#divAppbox" }).end().droppable({ //DROP DE PASTAS over : function(a, b){ //INICIO : SE A PASTA CONTER FILHAS EXPANDE over = $(this); $(this).addClass("folder-over"); if(($(this)[0] != $(this).parent().find(".head_folder")[0])) if($(this).prev()[0]) if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ setTimeout(function(){ if(over.hasClass("folder-over")) over.prev().trigger("click"); }, 500); } //FIM : SE A PASTA CONTER FILHAS EXPANDE //SETA BORDA EM VOLTA DA PASTA }, out : function(){ //RETIRA BORDA EM VOLTA DA PASTA $(this).removeClass("folder-over"); }, drop : function(event, ui){ $(this).removeClass("folder-over"); if($(this).parent().attr('id') == undefined){ var folder_to = 'INBOX'; var to_folder_title = ("Inbox"); }else{ var folder_to = $(this).parent().attr('id'); var to_folder_title = $(this).attr('title'); } var folder_to_move = ui.draggable.parent().attr('id'); var border_id = ui.draggable.find("input[type=hidden]").attr("name"); // eventnsagens : SE O DROP VIER DA LISTA DE eventNSAGENS : if(folder_to_move == "tbody_box"){ move_msgs2(get_current_folder(), 'selected', 0, folder_to, to_folder_title,true); return refresh(); } //SE FOR DE UMA PESQUISA RAPIDA else if(ui.draggable.parents('[id^="content_id_"]')[0]){ move_search_msgs("content_id_"+border_id, folder_to, to_folder_title); return refresh(); } // eventnsagens : SE O DROP VIER DE UMA ABA ABERTA else if(folder_to_move == "border_tr"){ var id_msg = border_id.split("_")[0]; folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); alternate_border(border_id); move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true); return refresh(); } // SE O DROP VIER DA LISTA DE PASTAS else{ var folder_to_exist = folder_to_move.split(imap_configs.imapDelimiter); folder_to_exist = folder_to+imap_configs.imapDelimiter+folder_to_exist[folder_to_exist.length-1]; //VERIFICA SE EXISTE UMA eventNSAGENS ABERTA NESTA PASTA E NAS SUAS FILHAS if(valid_tabs(ui.draggable.parent().find("li"), folder_to_move)){ return; } //FIM : VERIFICA SE EXISTE UMA eventNSAGENS ABERTA NESTA PASTA E NAS SUAS FILHAS; // VALIDA SE O USUARIO ESTA TENTANDO MOVER A PASTA PARA O eventSMO LOCAL if(folder_to_exist == folder_to_move){ return alert("Thie folder is already in this place"); } // VALIDA SE O USUARIO ESTA TENTANDO MOVER A PASTA ABERTA NO momentO if(folder_to_move == Folder.open){ return alert("It's not possible move this folder, because it is being used in the moment!"); } // VALIDA SE O USUARIO ESTA TENTANDO MOVER UMA PASTA FILHA DA PASTA ABERTA NO momentO if(ui.draggable.parent().find(".selected")[0]){ return alert(("It's not possible move this folder, because its subfolder is being used in the moment!")); } // VALIDA SE O USUARIO ESTA TENTANDO MOVER UMA PASTA PAI PARA DENTRO DE UMA FILHA if(ui.draggable.parent().find('[id="'+folder_to+'"]')[0]){ return alert(("It's not possible to move this folder to its subfolders!")); } if($('[id="'+folder_to_exist+'"]').length){ return alert(("Can not move this folder to this location, because the target has already a folder with this name")); } $(this).addClass("folders-loading"); $.ajax({ url : "../expressoMail1_2/controller.php?"+ $.param( { action: "$this.imap_functions.move_folder", folder_to_move: folder_to_move, folder_to: folder_to } ), success : function(data){ draw_new_tree_folder(); data = connector.unserialize(data); if(data == "Permission denied"){ alert(("Permission denied")); }else if(data){ alert(("The folder was successfully moved")); } else{ alert(("ERROR moving your folder.")); } } }); } } }); $(".folder").not(".shared-folders").parent().find(".folder").hover( function(){ //CASO A LI NÃO TENHA UM eventNU FLUTUANTE AINDA, O eventNU É ADICIONADO! if(!$(this).children(":last").hasClass("float-menu") && !$(this).children(":last").hasClass("new_folder")){ var folder_ = $(this); var folder_name; var shared = { head : false, valid : false }; if(folder_.parent().attr('id')){ folder_name = folder_.parent().attr('id').split(imap_configs.imapDelimiter); folder_name = folder_name[folder_name.length -1]; shared.valid = folder_.parent().attr('id').search("user/") == 0 ? true : false; }else folder_name = "Root"; if(shared.valid){ shared.head = folder_.parent().attr('id').split(imap_configs.imapDelimiter).length == 2 ? true : false; var folder_name_parts = folder_.parent().attr('id').split(imap_configs.imapDelimiter); var acls = shared_acls[folder_name_parts[0]+imap_configs.imapDelimiter+folder_name_parts[1]]; } html = DataLayer.render("/templates/float_folder_menu.ejs", {name_folder : folder_name, flag : shared, acl : acls}); //FUNÇÃO DO eventNU FLUTUANTE EDITAR < BEGIN var esc = false; $(folder_).append(html).find(".float-menu-edit").click(function(){ var folder_id = $(this).parents(".closed:first").attr('id'); var name = $.trim($(this).parents(".closed:first").find("span:first").text().split("[")[0]); if($(this).parents(".closed:first").find("span:first").hasClass("selected")) return alert(("It's not possible rename this folder, because it is being used in the moment!")); if($(this).parents(".closed:first").find(".selected").length) return alert(("It's not possible rename this folder, because its subfolder is being used in the moment!")); if(valid_tabs($(this).parents("li:first").find("li"), folder_id)) return; $(this).parents(".closed:first").find("span:first").empty().append(""); $(".new_folder").focus().keydown(function(event){ event.stopPropagation(); if(event.keyCode == 13){ if($(this).val() != ""){ if($(this).val().match(/[\/\`\~\^\<\>\|\\\"\!\@\#\$\%\&\*\+\(\)\[\]\{\}\?;:]/gi)){ return alert(("cannot create folder. try other folder name")); } var new_name = folder_id.replace(/[a-zA-Z0-9á-úÁ-Ú^\s_-]+$/, $(this).val()); if($('[id="'+new_name+'"]').length){ $(".folders-loading").removeClass("folders-loading"); alert(("Mailbox already exists")); return draw_new_tree_folder(); } $(".new_folder").parent().addClass("folders-loading"); Folder.rename(folder_id,new_name, function(){ draw_new_tree_folder(); }); } }else if( event.keyCode == 27){ draw_new_tree_folder(); } }).focusout(function(){ draw_new_tree_folder(); }).val(name); }) //FUNÇÃO DO eventNU FLUTUANTE EDITAR < END //FUNÇÃO DO eventNU FLUTUANTE EXCLUIR < BEGIN .end().find(".float-menu-remove").click(function(){ var folder_id = $(this).parents(".closed:first").attr('id'); var folder_name = ""+$.trim($(this).parents(".closed:first").find(".folder").text().split("[")[0])+""; if(valid_tabs($(this).parents("li:first").find("li"), folder_id)) return; $(this).parents(".closed:first").find(".folder").addClass("folders-loading"); if($(this).parents(".closed:first").find("ul").length){ $(this).parents(".closed:first").find(".folder").removeClass("folders-loading"); return alert("Delete/move subfolders first"); } if($(this).parents(".closed:first").find(".selected").length){ $(this).parents(".closed:first").find(".folder").removeClass("folders-loading"); return alert("It's not possible delete this folder, because it is being used in the moment!"); } var folder_span = $(this); confirm("Do you wish to exclude the folder "+folder_name,function(confirm){ if(confirm){ Folder.remove(folder_id, function(){ draw_new_tree_folder(); }); }else{ folder_span.parents(".closed:first").find(".folder").removeClass("folders-loading"); return; } }); /* if(!confirm(confirm_text + folder_name)){ $(this).parents(".closed:first").find(".folder").removeClass("folders-loading"); return; } */ }) //FUNÇÃO DO eventNU FLUTUANTE EXCLUIR < END //FUNÇÃO DO eventNU FLUTUANTE NOVA PASTA < BEGIN .end().find(".float-menu-new").click(function(){ $(this).parents(".float-menu").hide(); var selected_li = $(this).parents(".closed:first"); if(selected_li.find("ul:first").length){ var new_folder = $("
  • ").appendTo(selected_li.find("ul:first")); if(selected_li.find(".expandable-hitarea").length){ selected_li.find(".expandable-hitarea").trigger('click'); } selected_li.find("ul:first").treeview({ add: new_folder }); }else if(selected_li.length){ var new_folder = $("").appendTo(selected_li); selected_li.treeview({ add: new_folder }); }else{ selected_li = $(this).parents(".head_folder").parent(); if($(this).parents(".head_folder").parent().find(".expandable-hitarea").length){ $(this).parents(".head_folder").parent().find(".expandable-hitarea").trigger('click'); } var new_folder = $("").appendTo(selected_li); selected_li.treeview({ add: new_folder }); } selected_li.find(".new_folder").Watermark("Nova Pasta").focus().keydown(function(event){ event.stopPropagation(); if(event.keyCode == 13){ if($(this).val().match(/[\`\~\^\<\>\|\\\"\!\@\#\$\%\&\*\+\(\)\[\]\{\}\?;:]/gi)){ return alert(("cannot create folder. try other folder name")); } if($('[id="'+ (selected_li.attr('id')? selected_li.attr('id') : "INBOX") + imap_configs.imapDelimiter + $(this).val()+'"]').length){ $(".folders-loading").removeClass("folders-loading"); alert(("Mailbox already exists")); return draw_new_tree_folder(); } $(".new_folder").parent().addClass("folders-loading"); Folder.create($(this).val(), selected_li.attr('id'), function(){ draw_new_tree_folder(); }); }else if( event.keyCode == 27){ draw_new_tree_folder(); } }).focusout(function(){ draw_new_tree_folder(); }); }).end().find(".float-menu-export").click(function(){ //proxy_mensagens.export_all_messages($(this).parents("li:first").attr("id")) var name_box = $(this).parents("li:first").attr("id"); var name_folder = name_box.split(imap_configs.imapDelimiter)[name_box.split(imap_configs.imapDelimiter).length-1]; var hand_export = function(data){ if(!data){ alert(('Error compressing messages (ZIP). Contact the administrator.')) }else if(data["empty_folder"]){ alert(("The selected folder is empty.")); }else download_attachments(null, null, data, null,null, name_folder +'.zip'); } cExecute("$this.exporteml.export_all",hand_export,"folder="+name_box); alert(('You must wait while the messages will be exported...')); }); //FUNÇÃO DO eventNU FLUTUANTE NOVA PASTA < END } if(!$(".new_folder").length){ $(this).find(".float-menu:first").css("display", ""); } }, function(){ $(this).find(".float-menu:first").hide(); } ); }