var init_tree = 0; var selected; var over; var cp_tree1; var cp_tree2; var cp_tree3; var mail_archive_url; 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'); change_folder(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); } } }); }).filter('.followup-messages').click(function(event, ui) { search_emails("UNDELETED KEYWORD \"$Followupflagged\""); }).end().end(); refreshTreeview(); $('.upper').droppable( { over: function(event, ui) { $('#content_folders').autoscroll( { direction: 'up', step: 150, scroll: true }); }, out: function(event, ui) { $('#content_folders').autoscroll('destroy'); } }); $('.lower').droppable( { over: function(event, ui) { $('#content_folders').autoscroll( { direction: 'down', step: 150, scroll: true }); }, out: function(event, ui) { $('#content_folders').autoscroll('destroy'); } }); folders_html.find('[id="' + selected + '"]').children().addClass("selected"); $(".folder") .not(".head_folder") .not(".shared-folders") .not(".shared-folders + ul .folder") .parent() .find(".folder") .not(".head_folder,.inbox,.drafts,.sent,.spam,.trash") .draggable( { // DRAG DE PASTAS start: function() { $(this).css("color", "gray"); $('.upper, .lower').show(); $(".lower").css("top", ($("#content_folders").height() - 18) + $("#content_folders").offset().top); }, stop: function() { $(this).css("color", ""); $('.upper, .lower').hide(); }, revert: "invalid", helper: function(event) { if($.trim(($(this).text().split("["))[0]).length > 18) return $(DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', { texto: (($(this).text().split("["))[0]).substring(0, 18) + "...", type: "folder" })); return $(DataLayer.render('../prototype/modules/mail/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") }); $(".folder") .not(".head_folder") .not(".shared-folders") .parent() .find(".folder") .not(".head_folder,.inbox,.drafts,.sent,.spam,.trash") .end() .droppable( { //DROP DE PASTAS over: function(a, b) { //INICIO : SE A PASTA CONTER FILHAS EXPANDE $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); 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(a, b) { //RETIRA BORDA EM VOLTA DA PASTA $(b.helper).find(".draggin-folder,.draggin-mail").css("color", ""); $(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 = get_lang("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); //Correção para realinhamento da grid de mensagens no navegador Chrome. if(is_webkit) { var table = $('#table_box'); $('#divScrollMain_0').html(''); $('#divScrollMain_0').html(table); $(".ui-draggable-dragging").remove(); } return; } //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; } // 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; } // SE O DROP VIER DA LISTA DE PASTAS else { if($(ui.draggable[0]).parent().find("input").val() == "localFolder" && $(this).parents("li").find("input").first().val() != "localFolder") { return write_msg(get_lang("It isn't possible to send a folder by Archiver to My folders")); } else if(!$(ui.draggable[0]).parent().find("input").val() && $(this).parents("li").find("input").first().val() == "localFolder") { return write_msg(get_lang("It isn't possible to send a folder by My folders to Archiver")); } var folder_to_exist = folder_to_move.split(cyrus_delimiter); folder_to_exist = folder_to + cyrus_delimiter + 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 write_msg(get_lang("Thie folder is already in this place")); } // VALIDA SE O USUARIO ESTA TENTANDO MOVER A PASTA ABERTA NO momentO if(folder_to_move == get_current_folder()) { return write_msg(get_lang("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 write_msg(get_lang("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 write_msg(get_lang("It's not possible to move this folder to its subfolders!")); } if($('[id="' + folder_to_exist + '"]').length) { return write_msg(get_lang("Can not move this folder to this location, because the target has already a folder with this name")); } $(this).addClass("folders-loading"); if($(this).parents("li").find("input").first().val() == "localFolder") { var idFolder = $(this).parent().attr("id").split("_")[2]; expresso_mail_archive.moveFolder(idFolder, folder_to_move.split("_")[2]); cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); } else { $.ajax( { url: "controller.php?" + $.param( { action: "$this.imap_functions.move_folder", folder_to_move: folder_to_move, folder_to: folder_to }), success: function(data) { cExecute("$this.imap_functions.get_folders_list&onload=true", force_update_menu); data = connector.unserialize(data); if(data == "Permission denied") { write_msg(get_lang("Permission denied")); } else if(data) { write_msg(get_lang("The folder was successfully moved")); } else { write_msg(get_lang("ERROR moving your folder.")); } } }); } } } }); $(".folder") .not(".shared-folders, .followup-messages") .parent() .find(".folder") .not($('#message-attach-dialog').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") && !($(this).next().hasClass("local-connect"))) { /*se houver a classe local-connect, não adiciona o botão de conectar*/ var folder_ = $(this); var folder_name; var shared = { head: false, valid: false }; if(folder_.parent().attr('id')) { folder_name = folder_.parent().attr('id').split(cyrus_delimiter); folder_name = folder_name[folder_name.length - 1]; shared.valid = folder_.parent().attr('id').search("user"+cyrus_delimiter) == 0 ? true : false; } else folder_name = "Root"; if(shared.valid) { shared.head = folder_.parent().attr('id').split(cyrus_delimiter).length == 2 ? true : false; var folder_name_parts = folder_.parent().attr('id').split(cyrus_delimiter); var acls = shared_acls[folder_name_parts[0] + cyrus_delimiter + folder_name_parts[1]]; } html = DataLayer.render("../prototype/modules/mail/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 write_msg(get_lang("It's not possible rename this folder, because it is being used in the moment!")); } if($(this).parents(".closed:first").find("span.selected").length) { return write_msg(get_lang("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() != "") { /* Verifica se existe caracteres especiais no nome da pasta ou se existe "local_" * em parte do nome (palavra reservada para pastas locais) */ if($(this).val().match(/[\`\~\^\<\>\|\\\"\!\@\#\$\%\&\*\+\(\)\[\]\{\}\?;:]/gi) || $(this).val().indexOf("local_") != -1) { return write_msg(get_lang("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"); write_msg(get_lang("Mailbox already exists")); return draw_new_tree_folder(); } $(".new_folder").parent().addClass("folders-loading"); if($(this).parents("li").first().attr("id").indexOf("local_messages_") != -1) { var idFolder = $(this).parents("li").first().attr("id").split("_")[2]; expresso_mail_archive.renameFolder(idFolder, new_name); cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); } else { $.ajax( { url: "controller.php?action=$this.imap_functions.ren_mailbox", type: "POST", data: "current=" + folder_id + "&rename=" + new_name, success: function(data) { data = connector.unserialize(data); if(data == "Permission denied") { $(".folders-loading").removeClass("folders-loading"); cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); return write_msg(get_lang("Permission denied")); } write_msg(get_lang("The folder was successfully rename")); cExecute("$this.imap_functions.get_folders_list&onload=true", force_update_menu); } }); } } else { $(".new_folder").focusout(); } } 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 write_msg(get_lang("Delete/move subfolders first")); } if($(this).parents(".closed:first").find("span.selected").length) { $(this).parents(".closed:first").find(".folder").removeClass("folders-loading"); return write_msg(get_lang("It's not possible delete this folder, because it is being used in the moment!")); } var folder_span = $(this); var confirm_text = get_lang("Do you wish to exclude the folder "); $.Zebra_Dialog(confirm_text + folder_name, { 'type': 'question', 'overlay_opacity': '0.5', 'custom_class': 'custom-zebra-filter', 'buttons': [get_lang('Yes'), get_lang('No')], 'onClose': function(caption) { if(caption == get_lang('Yes')) { if(folder_span.parents("li").find("input").first().val() == "localFolder") { var idFolder = folder_span.parents("li").first().attr("id").split("_")[2]; expresso_mail_archive.deleteFolder(idFolder, folder_name); cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); } else { $.ajax( { url: "controller.php?action=$this.imap_functions.delete_mailbox", type: "POST", data: "del_past=" + folder_id, success: function(data) { data = connector.unserialize(data); if(data == "Mailbox does not exist") { $(".folders-loading").removeClass("folders-loading"); return write_msg(get_lang("Mailbox does not exist")); } else if(data == "Permission denied") { $(".folders-loading").removeClass("folders-loading"); cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); return write_msg(get_lang("Permission denied")); } write_msg(get_lang("The folder %1 was successfully removed", folder_name)); cExecute("$this.imap_functions.get_folders_list&onload=true", force_update_menu); } }); } } else { folder_span.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("li:first"); 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 }); } var existsIdenticalFolder = false; selected_li.find(".new_folder").Watermark("Nova Pasta").focus().keydown(function(event) { event.stopPropagation(); existsIdenticalFolder = false; var ok = false; var makeChildren = function(auxNameFolder, father) { if(auxNameFolder.length == 0) return true; if(auxNameFolder[0] == "") { auxNameFolder.shift(); makeChildren(auxNameFolder, father); return true; } if(ok == false) { expresso_mail_archive.createFolder((father ? father : "inbox"), auxNameFolder[0]); } expresso_mail_archive.getFoldersList(father); for(var ii = 0; ii < expresso_mail_archive.folders.length; ii++) { if(auxNameFolder[0] == expresso_mail_archive.folders[ii].name) { auxNameFolder.shift(); save = expresso_mail_archive.folders; expresso_mail_archive.createFolder(expresso_mail_archive.folders[ii].id, auxNameFolder[0]); expresso_mail_archive.folders = save; ok = true; makeChildren(auxNameFolder, expresso_mail_archive.folders[ii].id); return true; } } } if(event.keyCode == 13) { /* Verifica se existe caracteres especiais no nome da pasta ou se existe "local_" * em parte do nome (palavra reservada para pastas locais) */ if($(this).val().match(/[\`\~\^\<\>\|\\\"\!\@\#\$\%\&\*\+\(\)\[\]\{\}\?;:]/gi) || $(this).val().indexOf("local_") != -1) { return write_msg(get_lang("cannot create folder. try other folder name")); } if($(this).parents("li").find("input[type=hidden]").val() == "localFolder") { $(".new_folder").parent().addClass("folders-loading"); var folderName = $(this).val(); var folder = (folderName != "" ? folderName : get_lang("New Folder")); var father = typeof(selected_li.attr('id')) != "undefined" ? selected_li.attr('id').split("_")[2] : "home"; $(this).parents(".treeview:first").find("li").each(function() { var eachFolder = $(this).find("span:first").text().trim(); if(folder == eachFolder) { existsIdenticalFolder = true; return false; } }); if(existsIdenticalFolder) { event.stopPropagation(); write_msg(get_lang("Mailbox already exists")); draw_new_tree_folder(); return false; } if(folderName.indexOf("/") != -1) { auxNameFolder = folderName.split("/"); makeChildren(auxNameFolder, father); } else { var folder = (folderName != "" ? folderName : get_lang("New Folder")); create_new_local_folder((selected_li.attr('id') ? selected_li.attr('id') : "inbox"), folder); } cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); } else { if($('[id="' + (selected_li.attr('id') ? selected_li.attr('id') : "INBOX") + cyrus_delimiter + $(this).val() + '"]').length) { $(".folders-loading").removeClass("folders-loading"); write_msg(get_lang("Mailbox already exists")); return draw_new_tree_folder(); } $(".new_folder").parent().addClass("folders-loading"); create_new_folder(($(this).val() != "" ? $(this).val() : get_lang("New Folder")), (selected_li.attr('id') ? selected_li.attr('id') : "INBOX")); } } else if(event.keyCode == 27) { draw_new_tree_folder(); } }).focusout(function() { if(!existsIdenticalFolder) { draw_new_tree_folder(); } }); }).end().find(".float-menu-export").click(function() { var name_box = $(this).parents("li:first").attr("id"); var name_folder = name_box.split(cyrus_delimiter)[name_box.split(cyrus_delimiter).length - 1]; var hand_export = function(data) { clean_msg(); if(!data) { write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')) } else if(data["empty_folder"] || data == "empty_folder") { write_msg(get_lang("The selected folder is empty.")); } else download_attachments(null, null, data, null, null, name_folder + '.zip'); } if($(this).parents("li:first").find("input[type=hidden]:first").val() == "localFolder") { expresso_mail_archive.listMessages(name_box.split("_")[2]); var msgsArchive = expresso_mail_archive.messageslisted; buildExportArchiver(msgsArchive, name_box); } else { cExecute("$this.exporteml.export_all", hand_export, "folder=" + name_box); } write_msg(get_lang('You must wait while the messages will be exported...'), true); }); //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(); }); $("#new_m") .html($('.selected .message_unseen_count:first .folder_unseen').html() ? $('.selected .message_unseen_count:first .folder_unseen').html() : "0") .css("color", "red"); }