source: sandbox/expresso-solr/expressoMail1_2/js/abas.js @ 8056

Revision 8056, 23.4 KB checked in by gustavo, 11 years ago (diff)

Ticket #000 - Commit contendo o expresso com solr funcionando corretamente

  • 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                var node = document.getElementById("div_menu_c3").firstChild;
26               
27                while ( node )
28                {
29                        node.style.display = "none";
30                        node = node.nextSibling;
31                }
32               
33                if( document.getElementById("span_paging"+ID) != null )
34                        document.getElementById("span_paging"+ID).style.display = "block";
35        }
36       
37        if ( typeof win == 'object' && win.close && win.close.constructor == Function ){
38            var search_win = document.getElementById( 'window_QuickCatalogSearch' );
39            if(search_win){
40                search_win.style.visibility = 'hidden';
41            }
42            win.close( );
43        }
44               
45        if (! Element('border_id_'+ID))
46                return false; // Not possible to alternate
47        show_hide_span_paging(ID);
48        spanD = Element("span_D");
49        if (spanD)
50                spanD.style.display = (openTab.type[ID] == 0 ? '' : 'none');
51
52        var footer_menu = Element("footer_menu");       
53        var aba = Element('border_id_'+ID);
54        if (footer_menu != null) {
55                footer_menu.style.display = (openTab.type[ID] != 4 ? '' : 'none');
56                var alternate_menu = document.getElementById('localOption');
57               
58                if(alternate_menu != null && alternate_menu != 'undefined'){ //Quando Carregado o expresso mail
59                        if(openTab.imapBox[ID]!= null && openTab.imapBox[ID]!= 'undefined' ){ //Quando abrir uma Nova Mensagem
60                                if((openTab.imapBox[ID].indexOf("local_") >= 0)){                                               
61                                                alternate_menu.title = get_lang("Unarchive");
62                                                alternate_menu.removeAttribute("onclick");
63                                                if(!is_ie)
64                                                        alternate_menu.setAttribute("onclick",  'expresso_local_messages.unarchive_msgs(\''+openTab.imapBox[ID]+'\', null)');
65                                                else{
66                                                        alternate_menu.onclick = function(){
67                                                                expresso_local_messages.unarchive_msgs(openTab.imapBox[ID], null);
68                                                        }
69                                                }
70                                                alternate_menu.innerHTML = get_lang("Unarchive");
71                                               
72                                        }else{
73                                                alternate_menu.title = get_lang("Archive");
74                                                alternate_menu.removeAttribute("onclick");
75                                                if(!is_ie)
76                                                        alternate_menu.setAttribute("onclick", 'archive_msgs(\''+openTab.imapBox[ID]+'\', null)');             
77                                                else{
78                                                        alternate_menu.onclick = function(){
79                                                                archive_msgs(openTab.imapBox[ID], null);
80                                                        }       
81                                                }
82                                                alternate_menu.innerHTML = get_lang("Archive");
83                                        }
84                                       
85                        }
86                }
87               
88                if((aba.id.indexOf("_r") < 0) && (aba.id.indexOf("_0") < 0) && (aba.id.indexOf("id_search_") < 0) && (aba.id.indexOf("_s") < 0)){
89                        spanD.style.display = 'none';
90                        footer_menu.style.display = 'none';                     
91                }
92        }
93
94
95        var len = BordersArray.length;
96        for (var i=0; i < len; i++)
97        {
98                m = document.getElementById(BordersArray[i].border_id);
99                if ((m)&&(m.className == 'menu-sel'))
100                {
101                        m.className = 'menu';
102                        c = document.getElementById("content_id_"+BordersArray[i].sequence);
103                        c.style.display = 'none';
104                        if(Element("font_border_id_"+BordersArray[i].sequence))
105                                Element("font_border_id_"+BordersArray[i].sequence).className = 'font-menu';   
106
107                }
108        }
109
110        m = Element("border_id_"+ID);
111        if (m)
112                m.className = 'menu-sel';
113        if(Element("font_border_id_" + ID))
114                Element("font_border_id_" + ID).className = 'font-menu-sel';
115        var c = Element("content_id_"+ID)
116        if (c)
117                c.style.display = '';
118
119
120        // hide the DropDrowContact, if necessary
121        window_DropDownContacts = Element('tipDiv');
122        if ((window_DropDownContacts)&&(window_DropDownContacts.style.visibility != 'hidden')){
123                window_DropDownContacts.style.visibility = 'hidden';
124        }
125
126        numBox = getNumBoxFromTabId(ID);
127        if (typeof(ID)=='number') {
128                 numBox = ID;
129         }
130         else {
131             if (ID.match("search_"))
132             {
133                 if (ID.match("search_local_msg"))
134                 {
135                         var p = ID.search(/[0-9]/);
136                         numBox =  ID.substr(p);
137                 }
138                 else
139                 {
140                         numBox = ID.substr(7);
141                 }
142             }
143         }
144        currentTab=ID;
145        if( document.getElementById('to_'+ID) && document.getElementById('to_'+ID).type == "textarea"){
146            document.getElementById('to_'+ID).focus();
147        }
148        if (ID == 0){
149                updateSelectedMsgs();
150        }
151        RichTextEditor.setEditable(ID);
152        resizeWindow();
153        return ID;
154}
155
156function create_border(borderTitle, id_value, search)
157{
158        borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' );
159    borderTitle = html_entities(borderTitle);   
160        var resize = false;
161        resize = resize_borders();
162        if (!resize){
163            var str_continue = '';
164            var bolContinue = true;
165                        str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one');
166            if (preferences.auto_close_first_tab == 1){
167                var children = Element('border_tr').childNodes;
168                var bolDelete = true;
169                for (var i=0; i<children.length; i++) {
170                    if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
171                    {
172                        bolDelete = true;
173                        var num_child = children[i].id.toString().substr(10);
174                        alternate_border(num_child);
175                        if (editTest(num_child)){
176                            bolDelete = false;
177                        }
178                        if (bolDelete || bolContinue){
179                                                        str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab');
180                                                        var confirmacao = confirm(str_fechar);
181                            if(confirmacao){
182                            bolContinue = false;
183                            delete_border(num_child, 'false');
184                            break;
185                                                        }else{
186                                                                return 'maximo';
187                        }
188                    }
189                }
190            }
191            }else{                     
192                alert(get_lang('Reached maximum tab limit') + str_continue );
193                return 'maximo';
194            }
195        }
196       
197        if (! id_value){ // Is new message?
198                var ID = parseInt(BordersArray[(BordersArray.length-1)].sequence) + 1;
199                        if(isNaN(ID)){
200                                var aux = BordersArray[(BordersArray.length-1)].sequence.split("_");
201                                ID = parseInt(aux[1]) + 1;
202                        }
203        }else
204        {
205                if (Element("border_id_"+id_value)) // It's opened already!
206                        return alternate_border(id_value);
207               
208                var ID = id_value;
209                if(isNaN(ID) && ID.indexOf("search_local") >= 0){
210                        if(current_folder.indexOf("local") >= 0)
211                                openTab.imapBox[ID] = current_folder;
212                        else
213                                openTab.imapBox[ID] = 'local_search';
214                }else if(isNaN(ID) && ID.indexOf("search_") >= 0){
215                        if(current_folder.indexOf("local") < 0)
216                                openTab.imapBox[ID] = current_folder;
217                        else
218                                openTab.imapBox[ID] = 'search';
219                }else if( (currentTab != 0) && isNaN(currentTab) && (currentTab.indexOf("search") >= 0) && (ID.indexOf("msg") < 0) ) {
220                        var id_border = currentTab.replace(/[a-zA-Z_]+/, "");
221                        ID_TR = ID.toString().substr(0,ID.toString().indexOf("_r"));
222                        var tr = Element(ID_TR) ? Element(ID_TR) : Element(ID_TR+"_s"+id_border);
223                        openTab.imapBox[ID] = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name'));
224                }else
225                        openTab.imapBox[ID] = current_folder;
226        }
227        ID = $.trim(ID);
228        td = document.createElement("TD");
229        td.id="border_id_" + ID;
230        if(resize)
231        {
232                td.setAttribute("width", parseInt(resize)+"px");
233                td.style.width = parseInt(resize)+"px";
234        }
235        else
236                td.setAttribute("width", "200px");
237
238        td.setAttribute("align", "right");
239        td.onclick = function(){alternate_border(ID);resizeWindow()};
240        td.setAttribute("noWrap","true");
241    td.alt = ' ';
242    td.title = borderTitle;
243        borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : " "      ;
244        td.value = borderTitle;
245        if (borderTitle.length > 21)
246                borderTitle = borderTitle.substring(0,21) + "...";
247
248        if ( resize )
249                borderTitle = borderTitle.substring(0, resize*0.08);
250       
251        var cc = search;
252        if(!cc){
253                if(isNaN(ID)){
254                        var is_local = ID.match('.*_local_.*');
255                        if(!is_local)
256                                cc = document.getElementById("em_message_search").value;
257                        else{
258                                if (currentTab == 0)
259                                        cc = "";
260                                else
261                                        cc = document.getElementsByName(currentTab)[0].value;
262                        }
263                }else{
264                        cc ="";
265                }
266        }
267        td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" +
268                                borderTitle +
269                            "</div>\n\
270                            <div style='float:right;'>\n\
271                                <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " +
272                            "</div>\n\ " +
273                                                        "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>";             
274        bb = document.getElementById("border_blank");
275        parent_bb = bb.parentNode; //Pego o tbody
276        parent_bb.insertBefore(td, bb);
277
278        if((typeof(id_value) == 'string') && id_value.match(/_r/)){
279                $(td).draggable({
280                        start : function(){
281                                if($(".shared-folders").length){
282                                        $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({
283                                                over : function(a, b){                                         
284                                                        //SETA BORDA EM VOLTA DA PASTA
285                                                        over = $(this);
286                                                        $(this).addClass("folder-over");
287                                                        if(($(this)[0] != $(this).parent().find(".head_folder")[0]))
288                                                                if($(this).prev()[0])
289                                                                        if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){
290                                                                                setTimeout(function(){
291                                                                                        if(over.hasClass("folder-over"))
292                                                                                                over.prev().trigger("click");
293                                                                                }, 500);
294                                                                               
295                                                                        }
296                                                },
297                                                out : function(){
298                                                        //RETIRA BORDA EM VOLTA DA PASTA
299                                                        $(this).removeClass("folder-over");
300                                                },
301                                                //accept: ".draggin_mail",
302                                                drop : function(event, ui){
303                                                        $(this).css("border", "");
304                                                        if($(this).parent().attr('id') == undefined){
305                                                                var folder_to = 'INBOX';
306                                                                var to_folder_title = get_lang("Inbox");
307                                                        }else{
308                                                                var folder_to = $(this).parent().attr('id');
309                                                                var to_folder_title = $(this).attr('title');
310                                                        }               
311                                                        var folder_to_move = ui.draggable.parent().attr('id');
312                                                        var border_id = ui.draggable.find("input[type=hidden]").attr("name");
313                                                        if(folder_to_move == "border_tr"){
314                                                                var id_msg = border_id.split("_")[0];
315                                                                folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder());
316                                                                move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true);
317                                                                return refresh();
318                                                        }
319                                                }
320                                        });
321                                }
322                        },
323                        stop :function(){
324                                $(".shared-folders").parent().find(".folder").droppable("destroy");
325                        },
326                        helper: function(event){
327                                if(     borderTitle.length > 18 )
328                                        return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>");
329                                else
330                                        return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>");
331                        },
332                        delay: 150,
333                        cursorAt: {top: 5, left: 56},
334                        refreshPositions: true ,
335                        containment: "#divAppbox"
336                });
337        }
338                //_dragArea.makeDragged(td, id_value,td.value);
339
340        BordersArray[BordersArray.length] = new setBorderAttributes(ID);
341
342        var div = document.createElement("DIV");
343        div.id = "content_id_" + ID;
344        div.className = "conteudo";
345        div.style.display='';
346
347        div.style.overflow = "hidden";
348
349        Element("exmail_main_body").insertBefore(div,Element("footer_menu"));       
350        if (!is_ie)
351                resizeWindow();
352        alternate_border(ID);
353    uidsSave[ID] = [];
354    saveBorderError[ID] = false;
355        return ID;
356}
357
358function resize_borders()
359{
360        var numBorders = count_borders();
361
362        if (numBorders > 8)
363                return false;
364
365        return redim_borders(numBorders+1);
366}
367
368function count_borders()
369{
370        var numBorders = 0;
371        var children = Element('border_tr').childNodes;
372        for (var i=0; i<children.length; i++) {
373            if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
374                numBorders++;
375        }
376
377        return numBorders;
378}
379
380function redim_borders(numBorders)
381{
382        var children = Element('border_tr').childNodes;
383        var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30;
384        var newWidthTD = (clientWidth/numBorders)-6;
385        newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD);
386        children = Element('border_tr').childNodes;
387        for (var i=0; i<children.length; i++) {
388                if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){
389                        $(children[i]).css("width", newWidthTD);
390                        $(children[i]).find('div:first').css("width", newWidthTD);
391                        set_border_caption(children[i].id, children[i].title, newWidthTD);
392                }
393        }
394        return newWidthTD;
395}
396
397
398
399
400function set_border_caption(border_id, title, border_width)
401{
402        var border = document.getElementById(border_id);
403        if (border_width == null)
404        {
405            border_width = border.clientWidth;
406        }
407        var caption = "";
408    if (border != null){
409                Element("font_"+border.id).style.width = (border_width - 35)+'px';
410                Element("font_"+border.id).innerHTML = title;
411        }
412        return(title);
413}
414
415
416function draftTests(ID, msg_sent){
417   
418       
419        if( openTab.toPreserve[ID] = false)
420        {
421            close_delete(ID, msg_sent);
422            delete(openTab.type[ID]);
423        }   
424        else 
425        {
426             var msg = 'Existem alterações não salvas na mensagem.';
427             var buttons = ['Descartar alterações', 'Salvar e fechar' ,'Cancelar'];
428             var width = 371;
429             if($('#fileupload_msg'+ID).find('.in-progress').length)
430             {
431                 msg = 'Existem anexos sendo enviados para o servidor.';
432                 buttons = ['Descartar alterações e anexos', 'Salvar estado atual fechar', 'Continuar editando'];
433                 width = 560;
434             }
435             zebraDiscardEventDialog = true;
436             window.setTimeout(function() {
437                $.Zebra_Dialog(msg, {
438                            'type':     'question',
439                            'overlay_opacity': '0.5',
440                            'buttons':  buttons,
441                            'width' : width,
442                            'onClose':  function(clicked) {
443                                                                        if(clicked == 'Cancelar'){
444                                                                                if (RichTextEditor.plain[id] != true)
445                                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                 
446                                                                                else 
447                                                                                        $('#body_'+ID).focus();
448                                                                        }
449                                    if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) {
450                                        if (openTab.imapBox[ID] && !openTab.toPreserve[ID])
451                                            openTab.toPreserve[ID] = false;
452
453                                        delete(openTab.type[ID]);
454                                        close_delete(ID, msg_sent);
455                                       
456                                    }
457                                    else if(clicked == 'Salvar e fechar' || clicked == 'Salvar estado atual fechar')
458                                    {
459                                        save_msg(ID);
460                                        openTab.toPreserve[ID] = false;
461                                   
462                                        close_delete(ID, msg_sent);
463                                        delete(openTab.type[ID]);
464                                    }   
465                                    else{
466
467                                        Element("border_id_"+ID).onclick = function () {alternate_border(ID);};
468                                        var setFocus = function(ID){
469                                                        if ($.trim($("#to_"+ID).val()) == "")
470                                                                $("#to_"+ID).focus();
471                                                        else if ($("#tr_cc_"+ID).css('display') != 'none' && $.trim($("#cc_"+ID).val()) == "")
472                                                                $("#cc_"+ID).focus();
473                                                        else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "")
474                                                                $("#cco_"+ID).focus();         
475                                                        else if ($.trim($("#subject_"+ID).val()) == "")
476                                                                $("#subject_"+ID).focus();
477                                                        else{
478                                                                if (RichTextEditor.plain[id] != true)
479                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                 
480                                                                else 
481                                                                        $('#body_'+ID).focus();
482                                                        }
483                                                }
484                                                setFocus(ID); 
485                                    }
486                                    window.setTimeout(function() {
487                                            zebraDiscardEventDialog = false;
488                                    }, 500);
489                            }})}, 300);   
490        }
491       
492}
493
494function editTest(ID){
495    var body = document.getElementById('body_'+ ID);
496        var content = $('#content_id_'+ ID);
497    if (body)
498    {
499        var save_link = content.find(".save");
500        if (openTab.toPreserve[ID] == undefined)
501                openTab.toPreserve[ID] = false;
502        if (((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on')) && (save_link.onclick != ''))
503        {
504            return true;
505        }
506    }
507    return false;
508}
509
510function delete_border(ID, msg_sent)
511{
512
513        /*if($("#border_id_"+ID).attr("title") == get_lang("New Message")){
514                var to = $("#content_id_"+ID).find(".to").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".to").val();
515                var cc = $("#content_id_"+ID).find(".cc").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".cc").val();
516                var cco = $("#content_id_"+ID).find(".cco").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".cco").val();
517                var subject = $("#content_id_"+ID).find(".subject").val();
518                var auxAttachments = false;
519                var attachments = $("#content_id_"+ID).find("ul.attachments-list").find("li").each(function(){
520                        ($(this).find("p").length > 0) ? auxAttachments = true : auxAttachments;
521                        if(auxAttachments)
522                                return false;
523                });
524                var textArea = RichTextEditor.getData("body_"+ID);
525               
526                if(!to && !cc && !cco && !auxAttachments && subject == "" && textArea == "")
527                {
528            var borderElem = Element("border_id_" + ID);
529                        borderElem.onclick = null;
530                        close_delete(ID, msg_sent);
531                }
532        }
533    */
534    if($("#content_id_"+currentTab+" textarea[name=input_to]").length ){
535        if($("#content_id_"+currentTab+" .save").is(':disabled') ) {
536             close_delete(ID, msg_sent);
537        } else if( $("#content_id_"+currentTab+" .save").is(':enabled') ) {
538             return(draftTests(ID, msg_sent));
539        }
540    } else {
541        close_delete(ID, msg_sent);
542    }
543     
544    /*var bolExecuteClose = true;
545        var borderElem = Element("border_id_" + ID);
546        if (borderElem){
547            borderElem.onclick = null; // It's avoid a FF3 bug
548        }else{
549            return false;
550        }
551        if (msg_sent == 'false')
552        {
553            if (editTest(ID)){
554                bolExecuteClose = false;
555                if(zebraDiscardEventDialog === false)
556                    return(draftTests(ID, msg_sent));
557            }
558        }
559   
560       
561        if (bolExecuteClose)
562        {
563            close_delete(ID, msg_sent);
564                }
565                delete(openTab.type[ID]);
566        return true;*/
567         delete(openTab.type[ID]);
568        return true;
569}
570
571function close_delete(ID, msg_sent)
572{
573        openTab.toPreserve[ID] = false;
574        // Limpa o autosave
575            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null )
576            {
577                autoSaveControl.status[ID] = null;
578                clearInterval(autoSaveControl.timer[ID]);
579            }
580        ////////////////////////////////
581       
582        hold_session = false;
583        if (exist_className(Element('border_id_'+ID),'menu-sel'))
584        {
585                if (BordersArray[BordersArray.length-2].sequence == ID)
586                        this.alternate_border(0);
587                else
588                        this.alternate_border(BordersArray[BordersArray.length-2].sequence);
589        }
590
591        // Remove TD, title
592        border = Element('border_id_' + ID);
593        border.parentNode.removeChild(border);
594        var j=0;
595        var new_BordersArray = new Array();
596        for (i=0;i<BordersArray.length;i++)
597                if (document.getElementById(BordersArray[i].border_id) != null){
598                        new_BordersArray[j] = BordersArray[i];
599                        j++;
600                }
601        if(j == 1)
602                Element("footer_menu").style.display = '';
603        BordersArray = new_BordersArray;
604
605        // Remove Div Content
606        content = Element('content_id_' + ID);
607        content.parentNode.removeChild(content);
608        if(is_webkit)
609                resizeWindow();
610        RichTextEditor.destroy( 'body_'+ID );
611        delete msgAttachments[ID];
612        //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba
613            var isPartMsg = false;
614                        if(!parseInt(id2))
615                                return;
616            var id2 = ID.replace('_r','');
617            for(var ii = 0; ii < partMsgs.length; ii++)
618               if(partMsgs[ii] == id2){           
619                  isPartMsg = true;
620                  partMsgs[ii] = null;
621               }     
622
623            if(isPartMsg === true){
624                var handler_delete_msg = function(){};
625                cExecute ("$this.imap_functions.delete_msgs&folder=INBOX"+cyrus_delimiter+trashfolder+"&msgs_number="+id2,handler_delete_msg);
626            }
627        ///////////////////////////////////////////////////////////////////////////////////
628       
629        return true;
630}
631
632function getTabPrefix() { // define o prefixo para os checkboxes das mensagens
633        if (typeof(currentTab)!='number')
634                return currentTab+"_";
635        else
636                return "";
637}
638
639function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha
640        var p = row_id.search("_s");
641        if (p>0)
642                return row_id.substr(0,p);
643        else
644                return row_id;
645}
646
647function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab
648        if (typeof(tab_id)=='number') {
649                return tab_id;
650        }
651        else {
652                var p = tab_id.search(/[0-9]/);
653                return tab_id.substr(p);
654        }
655}
656
657function addAttachment(ID, att)
658{
659    if(typeof(msgAttachments[ID]) == 'undefined')
660            msgAttachments[ID] = [];
661
662        msgAttachments[ID].push(att);
663}
664
665function delAttachment(ID, att)
666{
667   
668    if(msgAttachments[ID] == undefined) return;
669    var len = msgAttachments[ID].length;
670    for(var i = 0; i < len; i++)
671    {
672        if(msgAttachments[ID][i] == att)
673        {
674            delete msgAttachments[ID][i];
675            break;
676        }
677    } 
678}
679
680function listAttachment(ID)
681{
682   return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]);
683}
684
Note: See TracBrowser for help on using the repository browser.