source: sandbox/2.5.1-expresso1/expressoMail1_2/js/abas.js @ 7885

Revision 7885, 23.7 KB checked in by thiago, 11 years ago (diff)

Ticket #3331 - Quase tudo pronto, apenas alguns detalhes no arquivamento.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1var BordersArray = new Array();
2BordersArray[0] = new setBorderAttributes(0);
3var countBorders = 0;
4var partMsgs = new Array();
5var msgAttachments = new Array();
6var uidsSave = new Array();
7var zebraDiscardEventDialog = false;
8var saveBorderError = new Array();
9
10function setBorderAttributes(ID)
11{
12        this.border_id = "border_id_"+ID;
13        this.sequence = ID;
14}
15
16
17function alternate_border(ID)
18{
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 ){
41            var search_win = document.getElementById( 'window_QuickCatalogSearch' );
42            if(search_win){
43                search_win.style.visibility = 'hidden';
44            }
45            win.close( );
46        }
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') {
131                 numBox = ID;
132         }
133         else {
134             if (ID.match("search_"))
135             {
136                 if (ID.match("search_local_msg"))
137                 {
138                         var p = ID.search(/[0-9]/);
139                         numBox =  ID.substr(p);
140                 }
141                 else
142                 {
143                         numBox = ID.substr(7);
144                 }
145             }
146         }
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;
157}
158
159function create_border(borderTitle, id_value, search)
160{
161        borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' );
162    borderTitle = html_entities(borderTitle);   
163        var resize = false;
164        resize = resize_borders();
165        if (!resize){
166            var str_continue = '';
167            var bolContinue = true;
168                        str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one');
169            if (preferences.auto_close_first_tab == 1){
170                var children = Element('border_tr').childNodes;
171                var bolDelete = true;
172                for (var i=0; i<children.length; i++) {
173                    if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
174                    {
175                        bolDelete = true;
176                        var num_child = children[i].id.toString().substr(10);
177                        alternate_border(num_child);
178                        if (editTest(num_child)){
179                            bolDelete = false;
180                        }
181                        if (bolDelete || bolContinue){
182                                                        str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab');
183                                                        var confirmacao = confirm(str_fechar);
184                            if(confirmacao){
185                            bolContinue = false;
186                            delete_border(num_child, 'false');
187                            break;
188                                                        }else{
189                                                                return 'maximo';
190                        }
191                    }
192                }
193            }
194            }else{                     
195                alert(get_lang('Reached maximum tab limit') + str_continue );
196                return 'maximo';
197            }
198        }
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                        }
206        }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.alt = ' ';
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'>" +
270                                borderTitle +
271                            "</div>\n\
272                            <div style='float:right;'>\n\
273                                <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " +
274                            "</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                                                        $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "green");
290                                                        over = $(this);
291                                                        $(this).addClass("folder-over");
292                                                        if(($(this)[0] != $(this).parent().find(".head_folder")[0]))
293                                                                if($(this).prev()[0])
294                                                                        if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){
295                                                                                setTimeout(function(){
296                                                                                        if(over.hasClass("folder-over"))
297                                                                                                over.prev().trigger("click");
298                                                                                }, 500);
299                                                                               
300                                                                        }
301                                                        //$("#content_folders").stop().scrollTo($(this), {axis:'y', margin:true, offset:-50, duration:400});
302                                                },
303                                                out : function(a,b){
304                                                        //RETIRA BORDA EM VOLTA DA PASTA
305                                                        $(b.helper).find(".draggin-folder,.draggin-mail").css("color", "");
306                                                        $(this).removeClass("folder-over");
307                                                },
308                                                //accept: ".draggin_mail",
309                                                drop : function(event, ui){
310                                                        $(this).css("border", "");
311                                                        if($(this).parent().attr('id') == undefined){
312                                                                var folder_to = 'INBOX';
313                                                                var to_folder_title = get_lang("Inbox");
314                                                        }else{
315                                                                var folder_to = $(this).parent().attr('id');
316                                                                var to_folder_title = $(this).attr('title');
317                                                        }               
318                                                        var folder_to_move = ui.draggable.parent().attr('id');
319                                                        var border_id = ui.draggable.find("input[type=hidden]").attr("name");
320                                                        if(folder_to_move == "border_tr"){
321                                                                var id_msg = border_id.split("_")[0];
322                                                                folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder());
323                                                                move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true);
324                                                                return refresh();
325                                                        }
326                                                }
327                                        });
328                                }
329                        },
330                        stop :function(){
331                                $('.upper, .lower').hide();
332                                $(".shared-folders").parent().find(".folder").droppable("destroy");
333                        },
334                        helper: function(event){
335                                if(     borderTitle.length > 18 )
336                                        return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>");
337                                else
338                                        return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>");
339                        },
340                        delay: 150,
341                        cursorAt: {top: 5, left: 56},
342                        refreshPositions: true ,
343                        containment: "#divAppbox"
344                });
345        }
346                //_dragArea.makeDragged(td, id_value,td.value);
347
348        BordersArray[BordersArray.length] = new setBorderAttributes(ID);
349
350        var div = document.createElement("DIV");
351        div.id = "content_id_" + ID;
352        div.className = "conteudo";
353        div.style.display='';
354
355        div.style.overflow = "hidden";
356
357        Element("exmail_main_body").insertBefore(div,Element("footer_menu"));       
358        if (!is_ie)
359                resizeWindow();
360        alternate_border(ID);
361    uidsSave[ID] = [];
362    saveBorderError[ID] = false;
363        return ID;
364}
365
366function resize_borders()
367{
368        var numBorders = count_borders();
369
370        if (numBorders > 8)
371                return false;
372
373        return redim_borders(numBorders+1);
374}
375
376function count_borders()
377{
378        var numBorders = 0;
379        var children = Element('border_tr').childNodes;
380        for (var i=0; i<children.length; i++) {
381            if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
382                numBorders++;
383        }
384
385        return numBorders;
386}
387
388function redim_borders(numBorders)
389{
390        var children = Element('border_tr').childNodes;
391        var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30;
392        var newWidthTD = (clientWidth/numBorders)-6;
393        newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD);
394        children = Element('border_tr').childNodes;
395        for (var i=0; i<children.length; i++) {
396                if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){
397                        $(children[i]).css("width", newWidthTD);
398                        $(children[i]).find('div:first').css("width", newWidthTD);
399                        set_border_caption(children[i].id, children[i].title, newWidthTD);
400                }
401        }
402        return newWidthTD;
403}
404
405
406
407
408function set_border_caption(border_id, title, border_width)
409{
410        var border = document.getElementById(border_id);
411        if (border_width == null)
412        {
413            border_width = border.clientWidth;
414        }
415        var caption = "";
416    if (border != null){
417                Element("font_"+border.id).style.width = (border_width - 35)+'px';
418                Element("font_"+border.id).innerHTML = title;
419        }
420        return(title);
421}
422
423
424function draftTests(ID, msg_sent){
425        if( openTab.toPreserve[ID] = false)
426        {
427            close_delete(ID, msg_sent);
428            delete(openTab.type[ID]);
429        }   
430        else 
431        {
432             var msg = 'Existem alterações não salvas na mensagem.';
433             var buttons = ['Descartar alterações', 'Salvar e fechar' ,'Cancelar'];
434             var width = 371;
435             if($('#fileupload_msg'+ID).find('.in-progress').length)
436             {
437                 msg = 'Existem anexos sendo enviados para o servidor.';
438                 buttons = ['Descartar alterações e anexos', 'Salvar estado atual fechar', 'Continuar editando'];
439                 width = 560;
440             }
441             zebraDiscardEventDialog = true;
442             window.setTimeout(function() {
443                $.Zebra_Dialog(msg, {
444                            'type':     'question',
445                            'overlay_opacity': '0.5',
446                                                        'custom_class': 'custom-zebra-filter',
447                            'buttons':  buttons,
448                            'width' : width,
449                            'onClose':  function(clicked) {
450                                                                        if(clicked == 'Cancelar'){
451                                                                                if (RichTextEditor.plain[id] != true)
452                                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                 
453                                                                                else 
454                                                                                        $('#body_'+ID).focus();
455                                                                        }
456                                    if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) {
457                                        if (openTab.imapBox[ID] && !openTab.toPreserve[ID])
458                                            openTab.toPreserve[ID] = false;
459
460                                        delete(openTab.type[ID]);
461                                        close_delete(ID, msg_sent);
462                                       
463                                    }
464                                    else if(clicked == 'Salvar e fechar' || clicked == 'Salvar estado atual fechar')
465                                    {
466                                        save_msg(ID);
467                                        openTab.toPreserve[ID] = false;
468                                   
469                                        close_delete(ID, msg_sent);
470                                        delete(openTab.type[ID]);
471                                    }   
472                                    else{
473
474                                        Element("border_id_"+ID).onclick = function () {alternate_border(ID);};
475                                        var setFocus = function(ID){
476                                                        if ($.trim($("#to_"+ID).val()) == "")
477                                                                $("#to_"+ID).focus();
478                                                        else if ($("#tr_cc_"+ID).css('display') != 'none' && $.trim($("#cc_"+ID).val()) == "")
479                                                                $("#cc_"+ID).focus();
480                                                        else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "")
481                                                                $("#cco_"+ID).focus();         
482                                                        else if ($.trim($("#subject_"+ID).val()) == "")
483                                                                $("#subject_"+ID).focus();
484                                                        else{
485                                                                if (RichTextEditor.plain[id] != true)
486                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                 
487                                                                else 
488                                                                        $('#body_'+ID).focus();
489                                                        }
490                                                }
491                                                setFocus(ID); 
492                                    }
493                                    window.setTimeout(function() {
494                                            zebraDiscardEventDialog = false;
495                                    }, 500);
496                            }})}, 300);   
497        }
498       
499}
500
501function editTest(ID){
502    var body = document.getElementById('body_'+ ID);
503        var content = $('#content_id_'+ ID);
504    if (body)
505    {
506        var save_link = content.find(".save");
507        if (openTab.toPreserve[ID] == undefined)
508                openTab.toPreserve[ID] = false;
509        if (((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on')) && (save_link.onclick != ''))
510        {
511            return true;
512        }
513    }
514    return false;
515}
516
517function delete_border(ID, msg_sent)
518{
519    var borderElem = Element("border_id_" + ID);
520    if (borderElem){
521        borderElem.onclick = null;
522    }else{
523        return false;
524    }
525
526    if($("#content_id_"+currentTab+" textarea[name=input_to]").length ){
527        if($("#content_id_"+currentTab+" .save").is(':disabled') ) {
528             close_delete(ID, msg_sent);
529        } else if( $("#content_id_"+currentTab+" .save").is(':enabled') ) {
530             return(draftTests(ID, msg_sent));
531        }
532    } else {
533        close_delete(ID, msg_sent);
534    }
535
536    delete(openTab.type[ID]);
537    //refresh();
538    return true;
539     
540    /*var bolExecuteClose = true;
541        var borderElem = Element("border_id_" + ID);
542        if (borderElem){
543            borderElem.onclick = null; // It's avoid a FF3 bug
544        }else{
545            return false;
546        }
547        if (msg_sent == 'false')
548        {
549            if (editTest(ID)){
550                bolExecuteClose = false;
551                if(zebraDiscardEventDialog === false)
552                    return(draftTests(ID, msg_sent));
553            }
554        }
555   
556       
557        if (bolExecuteClose)
558        {
559            close_delete(ID, msg_sent);
560                }
561                delete(openTab.type[ID]);
562        return true;*/
563         
564}
565
566function close_delete(ID, msg_sent)
567{
568        openTab.toPreserve[ID] = false;
569        // Limpa o autosave
570            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null )
571            {
572                autoSaveControl.status[ID] = null;
573                clearInterval(autoSaveControl.timer[ID]);
574            }
575        ////////////////////////////////
576       
577        hold_session = false;
578        if (exist_className(Element('border_id_'+ID),'menu-sel'))
579        {
580                if (BordersArray[BordersArray.length-2].sequence == ID)
581                        this.alternate_border(0);
582                else
583                        this.alternate_border(BordersArray[BordersArray.length-2].sequence);
584        }
585
586        // Remove TD, title
587        border = Element('border_id_' + ID);
588        border.parentNode.removeChild(border);
589        var j=0;
590        var new_BordersArray = new Array();
591        for (i=0;i<BordersArray.length;i++)
592                if (document.getElementById(BordersArray[i].border_id) != null){
593                        new_BordersArray[j] = BordersArray[i];
594                        j++;
595                }
596        if(j == 1)
597                Element("footer_menu").style.display = '';
598        BordersArray = new_BordersArray;
599
600        // Remove Div Content
601        content = Element('content_id_' + ID);
602        content.parentNode.removeChild(content);
603        if(is_webkit)
604                resizeWindow();
605        RichTextEditor.destroy( 'body_'+ID );
606        delete msgAttachments[ID];
607        //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba
608            var isPartMsg = false;
609                        if(!parseInt(id2))
610                                return;
611            var id2 = ID.replace('_r','');
612            for(var ii = 0; ii < partMsgs.length; ii++)
613               if(partMsgs[ii] == id2){           
614                  isPartMsg = true;
615                  partMsgs[ii] = null;
616               }     
617
618            if(isPartMsg === true){
619                var handler_delete_msg = function(){};
620                cExecute ("$this.imap_functions.delete_msgs&folder=INBOX"+cyrus_delimiter+trashfolder+"&msgs_number="+id2,handler_delete_msg);
621            }
622        ///////////////////////////////////////////////////////////////////////////////////
623       
624        return true;
625}
626
627function getTabPrefix() { // define o prefixo para os checkboxes das mensagens
628        if (typeof(currentTab)!='number')
629                return currentTab+"_";
630        else
631                return "";
632}
633
634function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha
635        var p = row_id.search("_s");
636        if (p>0)
637                return row_id.substr(0,p);
638        else
639                return row_id;
640}
641
642function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab
643        if (typeof(tab_id)=='number') {
644                return tab_id;
645        }
646        else {
647                var p = tab_id.search(/[0-9]/);
648                return tab_id.substr(p);
649        }
650}
651
652function addAttachment(ID, att)
653{
654    if(typeof(msgAttachments[ID]) == 'undefined')
655            msgAttachments[ID] = [];
656
657        msgAttachments[ID].push(att);
658}
659
660function delAttachment(ID, att)
661{
662   
663    if(msgAttachments[ID] == undefined) return;
664    var len = msgAttachments[ID].length;
665    for(var i = 0; i < len; i++)
666    {
667        if(msgAttachments[ID][i] == att)
668        {
669            delete msgAttachments[ID][i];
670            break;
671        }
672    } 
673}
674
675function listAttachment(ID)
676{
677    var imap     = new Array();
678    var archiver = new Array();
679   
680    if(typeof msgAttachments[ID] == "undefined"){
681        return "";
682    }
683
684    $.each(msgAttachments[ID], function(i, each){
685       
686        if(typeof($.parseJSON(each).folder) == "undefined")  return false;
687       
688       if($.parseJSON(each).folder.indexOf("local_messages_") != -1){
689            archiver.push($.parseJSON(each));
690       } else {
691            imap.push(each);
692       }
693    });
694
695    context = {
696        "imap" : imap,
697        "archiver" : archiver
698    };
699
700   return (typeof(msgAttachments[ID]) == 'undefined') ? '' : context;
701}
702
Note: See TracBrowser for help on using the repository browser.