source: trunk/expressoMail1_2/js/abas.js @ 7520

Revision 7520, 23.4 KB checked in by thiago, 11 years ago (diff)

Ticket #3186 - Problema ao fechar mensagem que foi editada ou que tenha uma assinatura.

  • 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        td = document.createElement("TD");
228        td.id="border_id_" + ID;
229        if(resize)
230        {
231                td.setAttribute("width", parseInt(resize)+"px");
232                td.style.width = parseInt(resize)+"px";
233        }
234        else
235                td.setAttribute("width", "200px");
236
237        td.setAttribute("align", "right");
238        td.onclick = function(){alternate_border(ID);resizeWindow()};
239        td.setAttribute("noWrap","true");
240    td.alt = ' ';
241    td.title = borderTitle;
242        borderTitle = borderTitle ?  borderTitle : id_value ? get_lang("No Subject") : " "      ;
243        td.value = borderTitle;
244        if (borderTitle.length > 21)
245                borderTitle = borderTitle.substring(0,21) + "...";
246
247        if ( resize )
248                borderTitle = borderTitle.substring(0, resize*0.08);
249       
250        var cc = search;
251        if(!cc){
252                if(isNaN(ID)){
253                        var is_local = ID.match('.*_local_.*');
254                        if(!is_local)
255                                cc = document.getElementById("em_message_search").value;
256                        else{
257                                if (currentTab == 0)
258                                        cc = "";
259                                else
260                                        cc = document.getElementsByName(currentTab)[0].value;
261                        }
262                }else{
263                        cc ="";
264                }
265        }
266        td.innerHTML = "<div><div id='font_border_id_" + ID+"' class='font-menu'>" +
267                                borderTitle +
268                            "</div>\n\
269                            <div style='float:right;'>\n\
270                                <img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + ID + "','false') src='templates/"+template+"/images/close_button.gif'/>\n\ " +
271                            "</div>\n\ " +
272                                                        "<input type=\"hidden\" name=\""+ ID+"\" value=\""+cc+"\"></div>";             
273        bb = document.getElementById("border_blank");
274        parent_bb = bb.parentNode; //Pego o tbody
275        parent_bb.insertBefore(td, bb);
276
277        if((typeof(id_value) == 'string') && id_value.match(/_r/)){
278                $(td).draggable({
279                        start : function(){
280                                if($(".shared-folders").length){
281                                        $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({
282                                                over : function(a, b){                                         
283                                                        //SETA BORDA EM VOLTA DA PASTA
284                                                        over = $(this);
285                                                        $(this).addClass("folder-over");
286                                                        if(($(this)[0] != $(this).parent().find(".head_folder")[0]))
287                                                                if($(this).prev()[0])
288                                                                        if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){
289                                                                                setTimeout(function(){
290                                                                                        if(over.hasClass("folder-over"))
291                                                                                                over.prev().trigger("click");
292                                                                                }, 500);
293                                                                               
294                                                                        }
295                                                },
296                                                out : function(){
297                                                        //RETIRA BORDA EM VOLTA DA PASTA
298                                                        $(this).removeClass("folder-over");
299                                                },
300                                                //accept: ".draggin_mail",
301                                                drop : function(event, ui){
302                                                        $(this).css("border", "");
303                                                        if($(this).parent().attr('id') == undefined){
304                                                                var folder_to = 'INBOX';
305                                                                var to_folder_title = get_lang("Inbox");
306                                                        }else{
307                                                                var folder_to = $(this).parent().attr('id');
308                                                                var to_folder_title = $(this).attr('title');
309                                                        }               
310                                                        var folder_to_move = ui.draggable.parent().attr('id');
311                                                        var border_id = ui.draggable.find("input[type=hidden]").attr("name");
312                                                        if(folder_to_move == "border_tr"){
313                                                                var id_msg = border_id.split("_")[0];
314                                                                folder = $("#input_folder_"+border_id+"_r")[0] ? $("#input_folder_"+border_id+"_r").val() : (openTab.imapBox[border_id] ? openTab.imapBox[border_id]:get_current_folder());
315                                                                move_msgs2(folder, id_msg, border_id, folder_to, to_folder_title,true);
316                                                                return refresh();
317                                                        }
318                                                }
319                                        });
320                                }
321                        },
322                        stop :function(){
323                                $(".shared-folders").parent().find(".folder").droppable("destroy");
324                        },
325                        helper: function(event){
326                                if(     borderTitle.length > 18 )
327                                        return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle.substring(0,18) + "...", type: "messages"})+"</td>");
328                                else
329                                        return $("<td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : borderTitle, type: "messages"})+"</td>");
330                        },
331                        delay: 150,
332                        cursorAt: {top: 5, left: 56},
333                        refreshPositions: true ,
334                        containment: "#divAppbox"
335                });
336        }
337                //_dragArea.makeDragged(td, id_value,td.value);
338
339        BordersArray[BordersArray.length] = new setBorderAttributes(ID);
340
341        var div = document.createElement("DIV");
342        div.id = "content_id_" + ID;
343        div.className = "conteudo";
344        div.style.display='';
345
346        div.style.overflow = "hidden";
347
348        Element("exmail_main_body").insertBefore(div,Element("footer_menu"));       
349        if (!is_ie)
350                resizeWindow();
351        alternate_border(ID);
352    uidsSave[ID] = [];
353    saveBorderError[ID] = false;
354        return ID;
355}
356
357function resize_borders()
358{
359        var numBorders = count_borders();
360
361        if (numBorders > 8)
362                return false;
363
364        return redim_borders(numBorders+1);
365}
366
367function count_borders()
368{
369        var numBorders = 0;
370        var children = Element('border_tr').childNodes;
371        for (var i=0; i<children.length; i++) {
372            if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank'))
373                numBorders++;
374        }
375
376        return numBorders;
377}
378
379function redim_borders(numBorders)
380{
381        var children = Element('border_tr').childNodes;
382        var clientWidth = (window.document.body.clientWidth - findPosX(Element("exmail_main_body"))) - Element("border_id_0").clientWidth - 30;
383        var newWidthTD = (clientWidth/numBorders)-6;
384        newWidthTD = newWidthTD > 200 ? 200 : (newWidthTD < 50 ? 50 : newWidthTD);
385        children = Element('border_tr').childNodes;
386        for (var i=0; i<children.length; i++) {
387                if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')){
388                        $(children[i]).css("width", newWidthTD);
389                        $(children[i]).find('div:first').css("width", newWidthTD);
390                        set_border_caption(children[i].id, children[i].title, newWidthTD);
391                }
392        }
393        return newWidthTD;
394}
395
396
397
398
399function set_border_caption(border_id, title, border_width)
400{
401        var border = document.getElementById(border_id);
402        if (border_width == null)
403        {
404            border_width = border.clientWidth;
405        }
406        var caption = "";
407    if (border != null){
408                Element("font_"+border.id).style.width = (border_width - 35)+'px';
409                Element("font_"+border.id).innerHTML = title;
410        }
411        return(title);
412}
413
414
415function draftTests(ID, msg_sent){
416   
417       
418        if( openTab.toPreserve[ID] = false)
419        {
420            close_delete(ID, msg_sent);
421            delete(openTab.type[ID]);
422        }   
423        else 
424        {
425             var msg = 'Existem alterações não salvas na mensagem.';
426             var buttons = ['Descartar alterações', 'Salvar e fechar' ,'Cancelar'];
427             var width = 371;
428             if($('#fileupload_msg'+ID).find('.in-progress').length)
429             {
430                 msg = 'Existem anexos sendo enviados para o servidor.';
431                 buttons = ['Descartar alterações e anexos', 'Salvar estado atual fechar', 'Continuar editando'];
432                 width = 560;
433             }
434             zebraDiscardEventDialog = true;
435             window.setTimeout(function() {
436                $.Zebra_Dialog(msg, {
437                            'type':     'question',
438                            'overlay_opacity': '0.5',
439                            'buttons':  buttons,
440                            'width' : width,
441                            'onClose':  function(clicked) {
442                                                                        if(clicked == 'Cancelar'){
443                                                                                if (RichTextEditor.plain[id] != true)
444                                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                 
445                                                                                else 
446                                                                                        $('#body_'+ID).focus();
447                                                                        }
448                                    if(clicked == 'Descartar alterações' || clicked == 'Descartar alterações e anexos' ) {
449                                        if (openTab.imapBox[ID] && !openTab.toPreserve[ID])
450                                            openTab.toPreserve[ID] = false;
451
452                                        delete(openTab.type[ID]);
453                                        close_delete(ID, msg_sent);
454                                       
455                                    }
456                                    else if(clicked == 'Salvar e fechar' || clicked == 'Salvar estado atual fechar')
457                                    {
458                                        save_msg(ID);
459                                        openTab.toPreserve[ID] = false;
460                                   
461                                        close_delete(ID, msg_sent);
462                                        delete(openTab.type[ID]);
463                                    }   
464                                    else{
465
466                                        Element("border_id_"+ID).onclick = function () {alternate_border(ID);};
467                                        var setFocus = function(ID){
468                                                        if ($.trim($("#to_"+ID).val()) == "")
469                                                                $("#to_"+ID).focus();
470                                                        else if ($("#tr_cc_"+ID).css('display') != 'none' && $.trim($("#cc_"+ID).val()) == "")
471                                                                $("#cc_"+ID).focus();
472                                                        else if ($("#tr_cco_"+ID).css('display') != 'none' && $.trim($("#cco_"+ID).val()) == "")
473                                                                $("#cco_"+ID).focus();         
474                                                        else if ($.trim($("#subject_"+ID).val()) == "")
475                                                                $("#subject_"+ID).focus();
476                                                        else{
477                                                                if (RichTextEditor.plain[id] != true)
478                                                                        setTimeout("RichTextEditor.focus("+ID+")",100);                 
479                                                                else 
480                                                                        $('#body_'+ID).focus();
481                                                        }
482                                                }
483                                                setFocus(ID); 
484                                    }
485                                    window.setTimeout(function() {
486                                            zebraDiscardEventDialog = false;
487                                    }, 500);
488                            }})}, 300);   
489        }
490       
491}
492
493function editTest(ID){
494    var body = document.getElementById('body_'+ ID);
495        var content = $('#content_id_'+ ID);
496    if (body)
497    {
498        var save_link = content.find(".save");
499        if (openTab.toPreserve[ID] == undefined)
500                openTab.toPreserve[ID] = false;
501        if (((! openTab.toPreserve[ID] && ! ID.toString().match("_r")) || ((body.contentWindow) == 'object' && body.contentWindow.document.designMode.toLowerCase() == 'on')) && (save_link.onclick != ''))
502        {
503            return true;
504        }
505    }
506    return false;
507}
508
509function delete_border(ID, msg_sent)
510{
511
512        /*if($("#border_id_"+ID).attr("title") == get_lang("New Message")){
513                var to = $("#content_id_"+ID).find(".to").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".to").val();
514                var cc = $("#content_id_"+ID).find(".cc").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".cc").val();
515                var cco = $("#content_id_"+ID).find(".cco").parent(".email-area").find("div").length || $("#content_id_"+ID).find(".email-area").find(".cco").val();
516                var subject = $("#content_id_"+ID).find(".subject").val();
517                var auxAttachments = false;
518                var attachments = $("#content_id_"+ID).find("ul.attachments-list").find("li").each(function(){
519                        ($(this).find("p").length > 0) ? auxAttachments = true : auxAttachments;
520                        if(auxAttachments)
521                                return false;
522                });
523                var textArea = RichTextEditor.getData("body_"+ID);
524               
525                if(!to && !cc && !cco && !auxAttachments && subject == "" && textArea == "")
526                {
527            var borderElem = Element("border_id_" + ID);
528                        borderElem.onclick = null;
529                        close_delete(ID, msg_sent);
530                }
531        }
532    */
533    if($("#content_id_"+currentTab+" textarea[name=input_to]").length ){
534        if($("#content_id_"+currentTab+" .save").is(':disabled') ) {
535             close_delete(ID, msg_sent);
536        } else if( $("#content_id_"+currentTab+" .save").is(':enabled') ) {
537             return(draftTests(ID, msg_sent));
538        }
539    } else {
540        close_delete(ID, msg_sent);
541    }
542     
543    /*var bolExecuteClose = true;
544        var borderElem = Element("border_id_" + ID);
545        if (borderElem){
546            borderElem.onclick = null; // It's avoid a FF3 bug
547        }else{
548            return false;
549        }
550        if (msg_sent == 'false')
551        {
552            if (editTest(ID)){
553                bolExecuteClose = false;
554                if(zebraDiscardEventDialog === false)
555                    return(draftTests(ID, msg_sent));
556            }
557        }
558   
559       
560        if (bolExecuteClose)
561        {
562            close_delete(ID, msg_sent);
563                }
564                delete(openTab.type[ID]);
565        return true;*/
566         delete(openTab.type[ID]);
567        return true;
568}
569
570function close_delete(ID, msg_sent)
571{
572        openTab.toPreserve[ID] = false;
573        // Limpa o autosave
574            if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null )
575            {
576                autoSaveControl.status[ID] = null;
577                clearInterval(autoSaveControl.timer[ID]);
578            }
579        ////////////////////////////////
580       
581        hold_session = false;
582        if (exist_className(Element('border_id_'+ID),'menu-sel'))
583        {
584                if (BordersArray[BordersArray.length-2].sequence == ID)
585                        this.alternate_border(0);
586                else
587                        this.alternate_border(BordersArray[BordersArray.length-2].sequence);
588        }
589
590        // Remove TD, title
591        border = Element('border_id_' + ID);
592        border.parentNode.removeChild(border);
593        var j=0;
594        var new_BordersArray = new Array();
595        for (i=0;i<BordersArray.length;i++)
596                if (document.getElementById(BordersArray[i].border_id) != null){
597                        new_BordersArray[j] = BordersArray[i];
598                        j++;
599                }
600        if(j == 1)
601                Element("footer_menu").style.display = '';
602        BordersArray = new_BordersArray;
603
604        // Remove Div Content
605        content = Element('content_id_' + ID);
606        content.parentNode.removeChild(content);
607        if(is_webkit)
608                resizeWindow();
609        RichTextEditor.destroy( 'body_'+ID );
610        delete msgAttachments[ID];
611        //Caso for uma mensagem anexada tem que deletar ela da lixeira apos fechar a aba
612            var isPartMsg = false;
613                        if(!parseInt(id2))
614                                return;
615            var id2 = ID.replace('_r','');
616            for(var ii = 0; ii < partMsgs.length; ii++)
617               if(partMsgs[ii] == id2){           
618                  isPartMsg = true;
619                  partMsgs[ii] = null;
620               }     
621
622            if(isPartMsg === true){
623                var handler_delete_msg = function(){};
624                cExecute ("$this.imap_functions.delete_msgs&folder=INBOX"+cyrus_delimiter+trashfolder+"&msgs_number="+id2,handler_delete_msg);
625            }
626        ///////////////////////////////////////////////////////////////////////////////////
627       
628        return true;
629}
630
631function getTabPrefix() { // define o prefixo para os checkboxes das mensagens
632        if (typeof(currentTab)!='number')
633                return currentTab+"_";
634        else
635                return "";
636}
637
638function getMessageIdFromRowId(row_id) { // extrai o id da mensagem do id da linha
639        var p = row_id.search("_s");
640        if (p>0)
641                return row_id.substr(0,p);
642        else
643                return row_id;
644}
645
646function getNumBoxFromTabId(tab_id) { // extrai o numBox do id da tab
647        if (typeof(tab_id)=='number') {
648                return tab_id;
649        }
650        else {
651                var p = tab_id.search(/[0-9]/);
652                return tab_id.substr(p);
653        }
654}
655
656function addAttachment(ID, att)
657{
658    if(typeof(msgAttachments[ID]) == 'undefined')
659            msgAttachments[ID] = [];
660
661        msgAttachments[ID].push(att);
662}
663
664function delAttachment(ID, att)
665{
666   
667    if(msgAttachments[ID] == undefined) return;
668    var len = msgAttachments[ID].length;
669    for(var i = 0; i < len; i++)
670    {
671        if(msgAttachments[ID][i] == att)
672        {
673            delete msgAttachments[ID][i];
674            break;
675        }
676    } 
677}
678
679function listAttachment(ID)
680{
681   return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]);
682}
683
Note: See TracBrowser for help on using the repository browser.