Ignore:
Timestamp:
10/08/13 16:20:46 (11 years ago)
Author:
douglas
Message:

Ticket #0000 - Copiadas as alterações do Trunk. Versão final 2.5.1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/expressoMail1_2/js/abas.js

    r8125 r8232  
    1010function setBorderAttributes(ID) 
    1111{ 
    12         this.border_id = "border_id_"+ID; 
    13         this.sequence = ID;  
     12    this.border_id = "border_id_"+ID; 
     13    this.sequence = ID;  
    1414} 
    1515 
     
    1717function alternate_border(ID) 
    1818{ 
    19         msg_selected = false;//Controle da seleção de mensagens 
    20         if(isNaN(ID)) 
    21                 if(preferences.use_shortcuts == "1") 
    22                         select_msg((ID.split("_"))[0]); 
    23         if( document.getElementById("div_menu_c3") != null ) 
    24         { 
    25                 //div que contém divs de paginação de todas abas de listagem possíveis (listagem de pasta e listagem de pesquisa) 
    26                 var node = document.getElementById("div_menu_c3").firstChild; 
    27                 //Se for diferente da aba de listagem, remove a paginação 
    28                 if(currentTab != 0){ 
    29                         //Enquanto node for true (retorna false se não houver mais elementos) 
    30                         while ( node ) { 
    31                                 node.style.display = "none"; 
    32                                 node = node.nextSibling; 
    33                         } 
    34                 } 
    35                  
    36                 if( document.getElementById("span_paging"+ID) != null ) 
    37                         document.getElementById("span_paging"+ID).style.display = "block"; 
    38         } 
    39          
    40         if ( typeof win == 'object' && win.close && win.close.constructor == Function ){ 
     19    
     20 
     21    msg_selected = false;//Controle da seleção de mensagens 
     22    if(isNaN(ID)) 
     23        if(preferences.use_shortcuts == "1") 
     24            select_msg((ID.split("_"))[0]); 
     25    if( document.getElementById("div_menu_c3") != null ) 
     26    { 
     27        //div que contém divs de paginação de todas abas de listagem possíveis (listagem de pasta e listagem de pesquisa) 
     28        var node = document.getElementById("div_menu_c3").firstChild; 
     29        //Se for diferente da aba de listagem, remove a paginação 
     30        if(currentTab != 0){ 
     31            //Enquanto node for true (retorna false se não houver mais elementos) 
     32            while ( node ) { 
     33                node.style.display = "none"; 
     34                node = node.nextSibling; 
     35            } 
     36        } 
     37         
     38        if( document.getElementById("span_paging"+ID) != null ) 
     39            document.getElementById("span_paging"+ID).style.display = "block"; 
     40    } 
     41     
     42    if ( typeof win == 'object' && win.close && win.close.constructor == Function ){ 
    4143            var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 
    4244            if(search_win){ 
     
    4547            win.close( ); 
    4648        } 
    47                  
    48         if (! Element('border_id_'+ID)) 
    49                 return false; // Not possible to alternate 
    50         show_hide_span_paging(ID); 
    51         spanD = Element("span_D"); 
    52         if (spanD) 
    53                 spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none'); 
    54  
    55         var footer_menu = Element("footer_menu");        
    56         var aba = Element('border_id_'+ID); 
    57         if (footer_menu != null) { 
    58                 footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none'); 
    59                 var alternate_menu = document.getElementById('localOption'); 
    60                  
    61                 if(alternate_menu != null && alternate_menu != 'undefined'){ //Quando Carregado o expresso mail 
    62                         if(openTab.imapBox[ID]!= null && openTab.imapBox[ID]!= 'undefined' ){ //Quando abrir uma Nova Mensagem 
    63                                 if((openTab.imapBox[ID].indexOf("local_") >= 0)){                                                
    64                                                 alternate_menu.title = get_lang("Unarchive"); 
    65                                                 alternate_menu.removeAttribute("onclick"); 
    66                                                 if(!is_ie) 
    67                                                         alternate_menu.setAttribute("onclick",  'expresso_local_messages.unarchive_msgs(\''+openTab.imapBox[ID]+'\', null)'); 
    68                                                 else{ 
    69                                                         alternate_menu.onclick = function(){ 
    70                                                                 expresso_local_messages.unarchive_msgs(openTab.imapBox[ID], null); 
    71                                                         } 
    72                                                 } 
    73                                                 alternate_menu.innerHTML = get_lang("Unarchive"); 
    74                                                  
    75                                         }else{ 
    76                                                 alternate_menu.title = get_lang("Archive"); 
    77                                                 alternate_menu.removeAttribute("onclick"); 
    78                                                 if(!is_ie) 
    79                                                         alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)');               
    80                                                 else{ 
    81                                                         alternate_menu.onclick = function(){ 
    82                                                                 archive_msgs(openTab.imapBox[ID], null); 
    83                                                         }        
    84                                                 } 
    85                                                 alternate_menu.innerHTML = get_lang("Archive"); 
    86                                         } 
    87                                          
    88                         } 
    89                 } 
    90                  
    91                 if((aba.id.indexOf("_r") < 0) && (aba.id.indexOf("_0") < 0) && (aba.id.indexOf("id_search_") < 0) && (aba.id.indexOf("_s") < 0)){ 
    92                         spanD.style.display = 'none'; 
    93                         footer_menu.style.display = 'none';                      
    94                 } 
    95         } 
    96  
    97  
    98         var len = BordersArray.length; 
    99         for (var i=0; i < len; i++) 
    100         { 
    101                 m = document.getElementById(BordersArray[i].border_id); 
    102                 if ((m)&&(m.className == 'menu-sel')) 
    103                 { 
    104                         m.className = 'menu'; 
    105                         c = document.getElementById("content_id_"+BordersArray[i].sequence); 
    106                         c.style.display = 'none'; 
    107                         if(Element("font_border_id_"+BordersArray[i].sequence)) 
    108                                 Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu';     
    109  
    110                 } 
    111         } 
    112  
    113         m = Element("border_id_"+ID); 
    114         if (m) 
    115                 m.className = 'menu-sel'; 
    116         if(Element("font_border_id_" + ID)) 
    117                 Element("font_border_id_" + ID).className = 'font-menu-sel'; 
    118         var c = Element("content_id_"+ID) 
    119         if (c) 
    120                 c.style.display = ''; 
    121  
    122  
    123         // hide the DropDrowContact, if necessary 
    124         window_DropDownContacts = Element('tipDiv'); 
    125         if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){ 
    126                 window_DropDownContacts.style.visibility = 'hidden'; 
    127         } 
    128  
    129         numBox = getNumBoxFromTabId(ID); 
    130         if (typeof(ID)=='number') { 
     49         
     50    if (! Element('border_id_'+ID)) 
     51        return false; // Not possible to alternate 
     52    show_hide_span_paging(ID); 
     53    spanD = Element("span_D"); 
     54    if (spanD) 
     55        spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none'); 
     56 
     57    var footer_menu = Element("footer_menu");    
     58    var aba = Element('border_id_'+ID); 
     59    if (footer_menu != null) { 
     60        footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none'); 
     61        var alternate_menu = document.getElementById('localOption'); 
     62         
     63        if(alternate_menu != null && alternate_menu != 'undefined'){ //Quando Carregado o expresso mail 
     64            if(openTab.imapBox[ID]!= null && openTab.imapBox[ID]!= 'undefined' ){ //Quando abrir uma Nova Mensagem 
     65                if((openTab.imapBox[ID].indexOf("local_") >= 0)){                        
     66                        alternate_menu.title = get_lang("Unarchive"); 
     67                        alternate_menu.removeAttribute("onclick"); 
     68                        if(!is_ie) 
     69                            alternate_menu.setAttribute("onclick",  'expresso_local_messages.unarchive_msgs(\''+openTab.imapBox[ID]+'\', null)'); 
     70                        else{ 
     71                            alternate_menu.onclick = function(){ 
     72                                expresso_local_messages.unarchive_msgs(openTab.imapBox[ID], null); 
     73                            } 
     74                        } 
     75                        alternate_menu.innerHTML = get_lang("Unarchive"); 
     76                         
     77                    }else{ 
     78                        alternate_menu.title = get_lang("Archive"); 
     79                        alternate_menu.removeAttribute("onclick"); 
     80                        if(!is_ie) 
     81                            alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)');       
     82                        else{ 
     83                            alternate_menu.onclick = function(){ 
     84                                archive_msgs(openTab.imapBox[ID], null); 
     85                            }    
     86                        } 
     87                        alternate_menu.innerHTML = get_lang("Archive"); 
     88                    } 
     89                     
     90            } 
     91        } 
     92         
     93        if((aba.id.indexOf("_r") < 0) && (aba.id.indexOf("_0") < 0) && (aba.id.indexOf("id_search_") < 0) && (aba.id.indexOf("_s") < 0)){ 
     94            spanD.style.display = 'none'; 
     95            footer_menu.style.display = 'none';          
     96        } 
     97    } 
     98 
     99 
     100    var len = BordersArray.length; 
     101    for (var i=0; i < len; i++) 
     102    { 
     103        m = document.getElementById(BordersArray[i].border_id); 
     104        if ((m)&&(m.className == 'menu-sel')) 
     105        { 
     106            m.className = 'menu'; 
     107            c = document.getElementById("content_id_"+BordersArray[i].sequence); 
     108            c.style.display = 'none'; 
     109            if(Element("font_border_id_"+BordersArray[i].sequence)) 
     110                Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu';     
     111 
     112        } 
     113    } 
     114 
     115    m = Element("border_id_"+ID); 
     116    if (m) 
     117        m.className = 'menu-sel'; 
     118    if(Element("font_border_id_" + ID)) 
     119        Element("font_border_id_" + ID).className = 'font-menu-sel'; 
     120    var c = Element("content_id_"+ID) 
     121    if (c) 
     122        c.style.display = ''; 
     123 
     124 
     125    // hide the DropDrowContact, if necessary 
     126    window_DropDownContacts = Element('tipDiv'); 
     127    if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){ 
     128        window_DropDownContacts.style.visibility = 'hidden'; 
     129    } 
     130 
     131    numBox = getNumBoxFromTabId(ID); 
     132    if (typeof(ID)=='number') { 
    131133                 numBox = ID; 
    132134         } 
     
    145147             } 
    146148         } 
    147         currentTab=ID; 
    148         if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){  
    149             document.getElementById('to_'+ID).focus();  
    150         } 
    151         if (ID == 0){  
    152                 updateSelectedMsgs(); 
    153         } 
    154         RichTextEditor.setEditable(ID); 
    155         resizeWindow(); 
    156         return ID; 
     149    currentTab=ID; 
     150    if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){  
     151        document.getElementById('to_'+ID).focus();  
     152    } 
     153    if (ID == 0){  
     154        updateSelectedMsgs(); 
     155    } 
     156    RichTextEditor.setEditable(ID); 
     157    resizeWindow(); 
     158 
     159    return ID; 
    157160} 
    158161 
    159162function create_border(borderTitle, id_value, search) 
    160163{ 
    161         borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); 
     164    borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); 
    162165    borderTitle = html_entities(borderTitle);     
    163         var resize = false; 
     166    var resize = false; 
    164167        resize = resize_borders(); 
    165168        if (!resize){ 
    166169            var str_continue = ''; 
    167170            var bolContinue = true; 
    168                         str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); 
     171            str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); 
    169172            if (preferences.auto_close_first_tab == 1){ 
    170173                var children = Element('border_tr').childNodes; 
     
    180183                        } 
    181184                        if (bolDelete || bolContinue){ 
    182                                                         str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); 
    183                                                         var confirmacao = confirm(str_fechar); 
     185                            str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); 
     186                            var confirmacao = confirm(str_fechar); 
    184187                            if(confirmacao){ 
    185188                            bolContinue = false; 
    186189                            delete_border(num_child, 'false'); 
    187190                            break; 
    188                                                         }else{ 
    189                                                                 return 'maximo'; 
     191                            }else{ 
     192                                return 'maximo'; 
    190193                        } 
    191194                    } 
    192195                } 
    193196            } 
    194             }else{                       
     197            }else{           
    195198                alert(get_lang('Reached maximum tab limit') + str_continue ); 
    196199                return 'maximo'; 
    197200            } 
    198201        } 
    199          
    200         if (! id_value){ // Is new message? 
    201                 var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1; 
    202                         if(isNaN(ID)){ 
    203                                 var aux = BordersArray[(BordersArray.length-1)].sequence.split("_"); 
    204                                 ID = parseInt(aux[1]) + 1; 
    205                         } 
     202     
     203    if (! id_value){ // Is new message? 
     204        var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1; 
     205            if(isNaN(ID)){ 
     206                var aux = BordersArray[(BordersArray.length-1)].sequence.split("_"); 
     207                ID = parseInt(aux[1]) + 1; 
     208            } 
    206209        }else 
    207         { 
    208                 if (Element("border_id_"+id_value)) // It's opened already! 
    209                         return alternate_border(id_value); 
    210                  
    211                 var ID = id_value; 
    212                 if(isNaN(ID) && ID.indexOf("search_local") >= 0){ 
    213                         if(current_folder.indexOf("local") >= 0) 
    214                                 openTab.imapBox[ID] = current_folder; 
    215                         else 
    216                                 openTab.imapBox[ID] = 'local_search'; 
    217                 }else if(isNaN(ID) && ID.indexOf("search_") >= 0){ 
    218                         if(current_folder.indexOf("local") < 0) 
    219                                 openTab.imapBox[ID] = current_folder; 
    220                         else 
    221                                 openTab.imapBox[ID] = 'search'; 
    222                 }else if( (currentTab != 0) && isNaN(currentTab) && (currentTab.indexOf("search") >= 0) && (ID.indexOf("msg") < 0) ) { 
    223                         var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); 
    224                         ID_TR = ID.toString().substr(0,ID.toString().indexOf("_r")); 
    225                         var tr = Element(ID_TR) ? Element(ID_TR) : Element(ID_TR+"_s"+id_border); 
    226                         openTab.imapBox[ID] = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); 
    227                 }else 
    228                         openTab.imapBox[ID] = current_folder; 
    229         } 
    230         td = document.createElement("TD"); 
    231         td.id="border_id_" + ID; 
    232         if(resize)  
    233         { 
    234                 td.setAttribute("width", parseInt(resize)+"px"); 
    235                 td.style.width = parseInt(resize)+"px"; 
    236         } 
    237         else 
    238                 td.setAttribute("width", "200px"); 
    239  
    240         td.setAttribute("align", "right"); 
    241         td.onclick = function(){alternate_border(ID);resizeWindow()}; 
    242         td.setAttribute("noWrap","true"); 
    243         td.setAttribute("role",get_current_folder()); 
    244         td.title = borderTitle; 
    245         borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : " "      ; 
    246         td.value = borderTitle; 
    247         if (borderTitle.length > 21) 
    248                 borderTitle = borderTitle.substring(0,21) + "..."; 
    249  
    250         if ( resize ) 
    251                 borderTitle = borderTitle.substring(0, resize*0.08); 
    252          
    253         var cc = search; 
    254         if(!cc){ 
    255                 if(isNaN(ID)){ 
    256                         var is_local = ID.match('.*_local_.*'); 
    257                         if(!is_local) 
    258                                 cc = document.getElementById("em_message_search").value; 
    259                         else{ 
    260                                 if (currentTab == 0) 
    261                                         cc = ""; 
    262                                 else 
    263                                         cc = document.getElementsByName(currentTab)[0].value; 
    264                         } 
    265                 }else{ 
    266                         cc =""; 
    267                 } 
    268         } 
    269         td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" + 
     210    { 
     211        if (Element("border_id_"+id_value)) // It's opened already! 
     212            return alternate_border(id_value); 
     213         
     214        var ID = id_value; 
     215        if(isNaN(ID) && ID.indexOf("search_local") >= 0){ 
     216            if(current_folder.indexOf("local") >= 0) 
     217                openTab.imapBox[ID] = current_folder; 
     218            else 
     219                openTab.imapBox[ID] = 'local_search'; 
     220        }else if(isNaN(ID) && ID.indexOf("search_") >= 0){ 
     221            if(current_folder.indexOf("local") < 0) 
     222                openTab.imapBox[ID] = current_folder; 
     223            else 
     224                openTab.imapBox[ID] = 'search'; 
     225        }else if( (currentTab != 0) && isNaN(currentTab) && (currentTab.indexOf("search") >= 0) && (ID.indexOf("msg") < 0) ) { 
     226            var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); 
     227            ID_TR = ID.toString().substr(0,ID.toString().indexOf("_r")); 
     228            var tr = Element(ID_TR) ? Element(ID_TR) : Element(ID_TR+"_s"+id_border); 
     229            openTab.imapBox[ID] = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); 
     230        }else 
     231            openTab.imapBox[ID] = current_folder; 
     232    } 
     233    td = document.createElement("TD"); 
     234    td.id="border_id_" + ID; 
     235    if(resize)  
     236    { 
     237        td.setAttribute("width", parseInt(resize)+"px"); 
     238        td.style.width = parseInt(resize)+"px"; 
     239    } 
     240    else 
     241        td.setAttribute("width", "200px"); 
     242 
     243    td.setAttribute("align", "right"); 
     244    td.onclick = function(){alternate_border(ID);resizeWindow()}; 
     245    td.setAttribute("noWrap","true"); 
     246    td.setAttribute("role",get_current_folder()); 
     247    td.title = borderTitle; 
     248    borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : " "  ; 
     249    td.value = borderTitle; 
     250    if (borderTitle.length > 21) 
     251        borderTitle = borderTitle.substring(0,21) + "..."; 
     252 
     253    if ( resize ) 
     254        borderTitle = borderTitle.substring(0, resize*0.08); 
     255     
     256    var cc = search; 
     257    if(!cc){ 
     258        if(isNaN(ID)){ 
     259            var is_local = ID.match('.*_local_.*'); 
     260            if(!is_local) 
     261                cc = document.getElementById("em_message_search").value; 
     262            else{ 
     263                if (currentTab == 0) 
     264                    cc = ""; 
     265                else 
     266                    cc = document.getElementsByName(currentTab)[0].value; 
     267            } 
     268        }else{ 
     269            cc =""; 
     270        } 
     271    } 
     272    td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" + 
    270273                                borderTitle + 
    271274                            "</div>\n\ 
     
    273276                                <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " + 
    274277                            "</div>\n\ " +  
    275                                                         "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>";               
    276         bb = document.getElementById("border_blank"); 
    277         parent_bb = bb.parentNode; //Pego o tbody 
    278         parent_bb.insertBefore(td, bb); 
    279  
    280         if((typeof(id_value) == 'string') && id_value.match(/_r/)){ 
    281                 $(td).draggable({ 
    282                         start : function(){ 
    283                                 $('.upper, .lower').show(); 
    284                         $(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top); 
    285                                 if($(".shared-folders").length){ 
    286                                         $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ 
    287                                                 over : function(a, b){                                           
    288                                                         //SETA BORDA EM VOLTA DA PASTA 
    289                                                         over = $(this); 
    290                                                         $(this).addClass("folder-over"); 
    291                                                         if(($(this)[0] != $(this).parent().find(".head_folder")[0])) 
    292                                                                 if($(this).prev()[0]) 
    293                                                                         if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ 
    294                                                                                 setTimeout(function(){ 
    295                                                                                         if(over.hasClass("folder-over")) 
    296                                                                                                 over.prev().trigger("click"); 
    297                                                                                 }, 500); 
    298                                                                                  
    299                                                                         } 
    300                                                         //$("#content_folders").stop().scrollTo($(this), {axis:'y', margin:true, offset:-50, duration:400}); 
    301                                                 }, 
    302                                                 out : function(){ 
    303                                                         //RETIRA BORDA EM VOLTA DA PASTA 
    304                                                         $(this).removeClass("folder-over"); 
    305                                                 }, 
    306                                                 //accept: ".draggin_mail", 
    307                                                 drop : function(event, ui){ 
    308                                                         $(this).css("border", "0"); 
    309                                                         if($(this).parent().attr('id') == undefined){ 
    310                                                                 var folder_to = 'INBOX'; 
    311                                                                 var to_folder_title = get_lang("Inbox"); 
    312                                                         }else{ 
    313                                                                 var folder_to = $(this).parent().attr('id'); 
    314                                                                 var to_folder_title = $(this).attr('title'); 
    315                                                         }                
    316                                                         var folder_to_move = ui.draggable.parent().attr('id'); 
    317                                                         var border_id = ui.draggable.find("input[type=hidden]").attr("name"); 
    318                                                         if(folder_to_move == "border_tr"){ 
    319                                                                 var id_msg = border_id.split("_")[0]; 
    320                                                                 folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); 
    321                                                                 move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true); 
    322                                                                 return refresh(); 
    323                                                         } 
    324                                                 } 
    325                                         }); 
    326                                 } 
    327                         }, 
    328                         stop :function(){ 
    329                                 $('.upper, .lower').hide(); 
    330                                 $(".shared-folders").parent().find(".folder").droppable("destroy"); 
    331                         }, 
    332                         helper: function(event){ 
    333                                 if(     borderTitle.length > 18 ) 
    334                                         return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>"); 
    335                                 else 
    336                                         return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>"); 
    337                         }, 
    338                         delay: 150, 
    339                         cursorAt: {top: 5, left: 56}, 
    340                         refreshPositions: true , 
    341                         containment: "#divAppbox" 
    342                 }); 
    343         } 
    344                 //_dragArea.makeDragged(td, id_value,td.value); 
    345  
    346         BordersArray[BordersArray.length] = new setBorderAttributes(ID); 
    347  
    348         var div = document.createElement("DIV"); 
    349         div.id = "content_id_" + ID; 
    350         div.className = "conteudo"; 
    351         div.style.display=''; 
    352  
    353         div.style.overflow = "hidden"; 
    354  
    355         Element("exmail_main_body").insertBefore(div,Element("footer_menu"));        
    356         if (!is_ie) 
    357                 resizeWindow(); 
    358         alternate_border(ID); 
     278                            "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>";       
     279    bb = document.getElementById("border_blank"); 
     280    parent_bb = bb.parentNode; //Pego o tbody 
     281    parent_bb.insertBefore(td, bb); 
     282 
     283    if((typeof(id_value) == 'string') && id_value.match(/_r/)){ 
     284        $(td).draggable({ 
     285            start : function(){ 
     286                $('.upper, .lower').show(); 
     287                $(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top); 
     288                /* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável,   
     289                ou seja, nem de leitura (2), nem de lista de mensagens (0):*/  
     290                var current_tab_type = openTab.type[currentTab];  
     291                if (current_tab_type != 0 && current_tab_type != 2){  
     292                    var dropzone = $("#fileupload_msg" + currentTab + "_droopzone");  
     293                    dropzone.show();  
     294                    dropzone.prev().hide();  
     295                    dropzone.droppable({  
     296                        over: function (event, ui){  
     297                            dropzone.addClass('hover in');  
     298                            $(ui.helper).find(".draggin-folder,.draggin-mail").css("color", "green");  
     299                        },  
     300                        out: function (event, ui) {  
     301                            dropzone.removeClass('hover in');  
     302                            $(ui.helper).find(".draggin-folder,.draggin-mail").css("color", "");  
     303                        },  
     304                        drop: function (event, ui) {  
     305                            var border_id = ui.draggable.find("input[type=hidden]").attr("name");  
     306                            var id_msg = border_id.split("_")[0];  
     307                            var folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder());  
     308                            attach_message(folder, id_msg); /* Anexa a mensagem especificada (por folder e id_msg)  
     309                                                               na mensagem sendo criada.*/  
     310                        }  
     311                    });  
     312                }  
     313                if($(".shared-folders").length){ 
     314                    $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ 
     315                        over : function(a, b){                       
     316                            //SETA BORDA EM VOLTA DA PASTA 
     317                            $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "green"); 
     318                            over = $(this); 
     319                            $(this).addClass("folder-over"); 
     320                            if(($(this)[0] != $(this).parent().find(".head_folder")[0])) 
     321                                if($(this).prev()[0]) 
     322                                    if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ 
     323                                        setTimeout(function(){ 
     324                                            if(over.hasClass("folder-over")) 
     325                                                over.prev().trigger("click"); 
     326                                        }, 500); 
     327                                         
     328                                    } 
     329                            //$("#content_folders").stop().scrollTo($(this), {axis:'y', margin:true, offset:-50, duration:400}); 
     330                        }, 
     331                        out : function(a,b){ 
     332                            //RETIRA BORDA EM VOLTA DA PASTA 
     333                            $(b.helper).find(".draggin-folder,.draggin-mail").css("color", ""); 
     334                            $(this).removeClass("folder-over"); 
     335                        }, 
     336                        //accept: ".draggin_mail", 
     337                        drop : function(event, ui){ 
     338                            $(this).css("border", "0"); 
     339                            if($(this).parent().attr('id') == undefined){ 
     340                                var folder_to = 'INBOX'; 
     341                                var to_folder_title = get_lang("Inbox"); 
     342                            }else{ 
     343                                var folder_to = $(this).parent().attr('id'); 
     344                                var to_folder_title = $(this).attr('title'); 
     345                            }        
     346                            var folder_to_move = ui.draggable.parent().attr('id'); 
     347                            var border_id = ui.draggable.find("input[type=hidden]").attr("name"); 
     348                            if(folder_to_move == "border_tr"){ 
     349                                var id_msg = border_id.split("_")[0]; 
     350                                folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder()); 
     351                                move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true); 
     352                                return refresh(); 
     353                            } 
     354                        } 
     355                    }); 
     356                } 
     357            }, 
     358            stop :function(){ 
     359                $('.upper, .lower').hide(); 
     360                $(".shared-folders").parent().find(".folder").droppable("destroy"); 
     361                /* Habilitar anexar mensagem por drag-and-drop, se a aba atual for editável,   
     362                ou seja, nem de leitura (2), nem de lista de mensagens (0):*/  
     363                var current_tab_type = openTab.type[currentTab];  
     364                if (current_tab_type != 0 && current_tab_type != 2){  
     365                    var dropzone = $("#fileupload_msg" + currentTab + "_droopzone");  
     366                    dropzone.hide();  
     367                    dropzone.prev().show();  
     368                }  
     369            }, 
     370            helper: function(event){ 
     371                if( borderTitle.length > 18 ) 
     372                    return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>"); 
     373                else 
     374                    return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>"); 
     375            }, 
     376            delay: 150, 
     377            cursorAt: {top: 5, left: 56}, 
     378            refreshPositions: true , 
     379            containment: "#divAppbox" 
     380        }); 
     381    } 
     382        //_dragArea.makeDragged(td, id_value,td.value); 
     383 
     384    BordersArray[BordersArray.length] = new setBorderAttributes(ID); 
     385 
     386    var div = document.createElement("DIV"); 
     387    div.id = "content_id_" + ID; 
     388    div.className = "conteudo"; 
     389    div.style.display=''; 
     390 
     391    div.style.overflow = "hidden"; 
     392 
     393    Element("exmail_main_body").insertBefore(div,Element("footer_menu"));        
     394    if (!is_ie) 
     395        resizeWindow(); 
     396    alternate_border(ID); 
    359397    uidsSave[ID] = []; 
    360398    saveBorderError[ID] = false; 
    361         return ID; 
     399    return ID; 
    362400} 
    363401 
    364402function resize_borders() 
    365403{ 
    366         var numBorders = count_borders(); 
    367  
    368         if (numBorders > 8) 
    369                 return false; 
    370  
    371         return redim_borders(numBorders+1); 
     404    var numBorders = count_borders(); 
     405 
     406    if (numBorders > 8) 
     407        return false; 
     408 
     409    return redim_borders(numBorders+1); 
    372410} 
    373411 
    374412function count_borders() 
    375413{ 
    376         var numBorders = 0; 
    377         var children = Element('border_tr').childNodes; 
    378         for (var i=0; i<children.length; i++) { 
    379             if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) 
    380                 numBorders++; 
    381         } 
    382  
    383         return numBorders; 
     414    var numBorders = 0; 
     415    var children = Element('border_tr').childNodes; 
     416    for (var i=0; i<children.length; i++) { 
     417        if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) 
     418        numBorders++; 
     419    } 
     420 
     421    return numBorders; 
    384422} 
    385423 
    386424function redim_borders(numBorders) 
    387425{ 
    388         var children = Element('border_tr').childNodes; 
    389         var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30; 
    390         var newWidthTD = (clientWidth/numBorders)-6; 
    391         newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD); 
    392         children = Element('border_tr').childNodes; 
    393         for (var i=0; i<children.length; i++) { 
    394                 if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){ 
    395                         $(children[i]).css("width", newWidthTD); 
    396                         $(children[i]).find('div:first').css("width", newWidthTD); 
    397                         set_border_caption(children[i].id, children[i].title, newWidthTD); 
    398                 } 
    399         } 
    400         return newWidthTD; 
     426    var children = Element('border_tr').childNodes; 
     427    var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30; 
     428    var newWidthTD = (clientWidth/numBorders)-6; 
     429    newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD); 
     430    children = Element('border_tr').childNodes; 
     431    for (var i=0; i<children.length; i++) { 
     432        if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){ 
     433            $(children[i]).css("width", newWidthTD); 
     434            $(children[i]).find('div:first').css("width", newWidthTD); 
     435            set_border_caption(children[i].id, children[i].title, newWidthTD); 
     436        } 
     437    } 
     438    return newWidthTD; 
    401439} 
    402440 
     
    411449            border_width = border.clientWidth; 
    412450        } 
    413         var caption = ""; 
     451    var caption = ""; 
    414452    if (border != null){ 
    415                 Element("font_"+border.id).style.width = (border_width - 35)+'px'; 
    416                 Element("font_"+border.id).innerHTML = title; 
    417         } 
    418         return(title); 
     453        Element("font_"+border.id).style.width = (border_width - 35)+'px'; 
     454        Element("font_"+border.id).innerHTML = title; 
     455    } 
     456    return(title); 
    419457} 
    420458 
     
    442480                            'type':     'question', 
    443481                            'overlay_opacity': '0.5', 
    444                                                         'custom_class': 'custom-zebra-filter', 
     482                            'custom_class': 'custom-zebra-filter', 
    445483                            'buttons':  buttons, 
    446484                            'width' : width, 
    447485                            'onClose':  function(clicked) { 
    448                                                                         if(clicked == 'Cancelar'){ 
    449                                                                                 if (RichTextEditor.plain[id] != true)  
    450                                                                                         setTimeout("RichTextEditor.focus("+ID+")",100);                   
    451                                                                                 else   
    452                                                                                         $('#body_'+ID).focus();  
    453                                                                         } 
     486                                    if(clicked == 'Cancelar'){ 
     487                                        if (RichTextEditor.plain[id] != true)  
     488                                            setTimeout("RichTextEditor.focus("+ID+")",100);                   
     489                                        else   
     490                                            $('#body_'+ID).focus();  
     491                                    } 
    454492                                    if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) { 
    455493                                        if (openTab.imapBox[ID] && !openTab.toPreserve[ID]) 
     
    477515                                                                $("#cc_"+ID).focus(); 
    478516                                                        else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "") 
    479                                                                 $("#cco_"+ID).focus();           
     517                                                                $("#cco_"+ID).focus();       
    480518                                                        else if ($.trim($("#subject_"+ID).val()) == "") 
    481519                                                                $("#subject_"+ID).focus(); 
     
    494532                            }})}, 300);     
    495533        } 
    496          
     534     
    497535} 
    498536 
    499537function editTest(ID){ 
    500538    var body = document.getElementById('body_'+ ID); 
    501         var content = $('#content_id_'+ ID); 
     539    var content = $('#content_id_'+ ID); 
    502540    if (body) 
    503541    { 
     
    522560    } 
    523561 
    524     if($("#content_id_"+currentTab+" textarea[name=input_to]").length ){ 
    525         if($("#content_id_"+currentTab+" .save").is(':disabled') ) { 
     562    if($("#content_id_"+ID+" textarea[name=input_to]").length ){ 
     563        if($("#content_id_"+ID+" .save").is(':disabled') ) { 
    526564             close_delete(ID, msg_sent); 
    527         } else if( $("#content_id_"+currentTab+" .save").is(':enabled') ) { 
     565        } else if( $("#content_id_"+ID+" .save").is(':enabled') ) { 
    528566             return(draftTests(ID, msg_sent)); 
    529567        } 
     
    537575      
    538576    /*var bolExecuteClose = true; 
    539         var borderElem = Element("border_id_" + ID); 
    540         if (borderElem){ 
     577    var borderElem = Element("border_id_" + ID); 
     578    if (borderElem){ 
    541579            borderElem.onclick = null; // It's avoid a FF3 bug 
    542580        }else{ 
    543581            return false; 
    544582        } 
    545         if (msg_sent == 'false') 
    546         { 
     583    if (msg_sent == 'false') 
     584    { 
    547585            if (editTest(ID)){ 
    548586                bolExecuteClose = false; 
     
    550588                    return(draftTests(ID, msg_sent)); 
    551589            } 
    552         } 
     590    } 
    553591     
    554592         
     
    556594        { 
    557595            close_delete(ID, msg_sent); 
    558                 } 
    559                 delete(openTab.type[ID]); 
     596        } 
     597        delete(openTab.type[ID]); 
    560598        return true;*/ 
    561599          
     
    564602function close_delete(ID, msg_sent) 
    565603{ 
    566         openTab.toPreserve[ID] = false; 
     604    openTab.toPreserve[ID] = false; 
    567605        // Limpa o autosave 
    568606            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null ) 
     
    573611        //////////////////////////////// 
    574612         
    575         hold_session = false; 
    576         if (exist_className(Element('border_id_'+ID),'menu-sel')) 
    577         { 
    578                 if (BordersArray[BordersArray.length-2].sequence == ID) 
    579                         this.alternate_border(0); 
    580                 else 
    581                         this.alternate_border(BordersArray[BordersArray.length-2].sequence); 
    582         } 
    583  
    584         // Remove TD, title 
    585         border = Element('border_id_' + ID); 
    586         border.parentNode.removeChild(border); 
    587         var j=0; 
    588         var new_BordersArray = new Array(); 
    589         for (i=0;i<BordersArray.length;i++) 
    590                 if (document.getElementById(BordersArray[i].border_id) != null){ 
    591                         new_BordersArray[j] = BordersArray[i]; 
    592                         j++; 
    593                 } 
    594         if(j == 1) 
    595                 Element("footer_menu").style.display = ''; 
    596         BordersArray = new_BordersArray; 
    597  
    598         // Remove Div Content 
    599         content = Element('content_id_' + ID); 
    600         content.parentNode.removeChild(content); 
    601         if(is_webkit) 
    602                 resizeWindow(); 
    603         RichTextEditor.destroy( 'body_'+ID ); 
     613    hold_session = false; 
     614    if (exist_className(Element('border_id_'+ID),'menu-sel')) 
     615    { 
     616        if (BordersArray[BordersArray.length-2].sequence == ID) 
     617            this.alternate_border(0); 
     618        else 
     619            this.alternate_border(BordersArray[BordersArray.length-2].sequence); 
     620    } 
     621 
     622    // Remove TD, title 
     623    border = Element('border_id_' + ID); 
     624    border.parentNode.removeChild(border); 
     625    var j=0; 
     626    var new_BordersArray = new Array(); 
     627    for (i=0;i<BordersArray.length;i++) 
     628        if (document.getElementById(BordersArray[i].border_id) != null){ 
     629            new_BordersArray[j] = BordersArray[i]; 
     630            j++; 
     631        } 
     632    if(j == 1) 
     633        Element("footer_menu").style.display = ''; 
     634    BordersArray = new_BordersArray; 
     635 
     636    // Remove Div Content 
     637    content = Element('content_id_' + ID); 
     638    content.parentNode.removeChild(content); 
     639    if(is_webkit) 
     640        resizeWindow(); 
     641    RichTextEditor.destroy( 'body_'+ID ); 
    604642        delete msgAttachments[ID]; 
    605643        //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba 
    606644            var isPartMsg = false; 
    607                         if(!parseInt(id2)) 
    608                                 return; 
     645            if(!parseInt(id2)) 
     646                return; 
    609647            var id2 = ID.replace('_r',''); 
    610648            for(var ii = 0; ii < partMsgs.length; ii++) 
     
    620658        /////////////////////////////////////////////////////////////////////////////////// 
    621659         
    622         return true; 
     660    return true; 
    623661} 
    624662 
    625663function getTabPrefix() { // define o prefixo para os checkboxes das mensagens 
    626         if (typeof(currentTab)!='number') 
    627                 return currentTab+"_"; 
    628         else 
    629                 return ""; 
     664    if (typeof(currentTab)!='number') 
     665        return currentTab+"_"; 
     666    else 
     667        return ""; 
    630668} 
    631669 
    632670function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha 
    633         var p = row_id.search("_s"); 
    634         if (p>0) 
    635                 return row_id.substr(0,p); 
    636         else 
    637                 return row_id; 
     671    var p = row_id.search("_s"); 
     672    if (p>0) 
     673        return row_id.substr(0,p); 
     674    else 
     675        return row_id; 
    638676} 
    639677 
    640678function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab 
    641         if (typeof(tab_id)=='number') { 
    642                 return tab_id; 
    643         } 
    644         else { 
    645                 var p = tab_id.search(/[0-9]/); 
    646                 return tab_id.substr(p); 
    647         } 
     679    if (typeof(tab_id)=='number') { 
     680        return tab_id; 
     681    } 
     682    else { 
     683        var p = tab_id.search(/[0-9]/); 
     684        return tab_id.substr(p); 
     685    } 
    648686} 
    649687 
     
    673711function listAttachment(ID) 
    674712{ 
    675    return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]);  
    676 } 
    677  
     713    return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]); 
     714} 
Note: See TracChangeset for help on using the changeset viewer.