/********************************************************************************* ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. * ********************************************************************************/ function load_webmail(mid,hasAttachment) { var node = $("row_"+mid); preview_id = mid; if(typeof($('fnt_subject_'+mid)) != "undefined" && $('fnt_subject_'+mid).color=="green") { $('fnt_subject_'+mid).color=""; $('fnt_date_'+mid).color=""; $('fnt_from_'+mid).color=""; } if(node.className == "mailSelected") { var unread = parseInt($(mailbox+"_unread").innerHTML); if(unread != 0) { var curUnread; curUnread = unread -1; if(curUnread == 0) $(mailbox+"_count").style.display="none"; else $(mailbox+"_unread").innerHTML = curUnread; } $("unread_img_"+mid).removeChild($("unread_img_"+mid).firstChild); $("unread_img_"+mid).appendChild(Builder.node('a', {href: 'javascript:;', onclick: 'OpenComposer('+mid+',\'reply\')'}, [Builder.node('img',{src: 'themes/images/openmail.gif', border: '0', width: '12', height: '12'})] )); } node.className='read_email'; //Fix for webmails body display in IE - dartagnanlaf /* new Ajax.Request( 'index.php', {queue: {position: 'end', scope: 'command'}, method: 'post', postBody: 'module=Webmails&action=body&mailid=' + mid + '&mailbox='+mailbox, onComplete: function(response) { document.getElementById("body_area").innerHTML=response.responseText; } } ); */ oiframe = $("email_description"); oiframe.src = 'index.php?module=Webmails&action=body&theme='+theme+'&mailid='+mid+'&mailbox='+mailbox; //$("body_area").appendChild(Builder.node('iframe',{src: 'index.php?module=Webmails&action=body&mailid='+mid+'&mailbox='+mailbox, width: '100%', height: '210', frameborder: '0'},'You must enable iframes')); tmp = document.getElementsByClassName("previewWindow"); for(var i=0;i 0) { $("status").style.display="block"; new Ajax.Request( 'index.php', {queue: {position: 'end', scope: 'command'}, method: 'post', postBody: 'module=Webmails&action=WebmailsAjax&mailbox='+mailbox+'&start='+start+'&command=move_msg&ajax=true&mailid='+nid.join(":")+'&mvbox='+mvmbox, onComplete: function(t) { sh = $("show_msg"); var leftSide = findPosX(sh); var topSide = findPosY(sh); sh.style.left= leftSide + 400+'px'; sh.style.top= topSide + 350 +'px'; sh.innerHTML = "Moving mail(s) from "+mailbox+" folder to "+mvmbox+" folder"; sh.style.display = "block"; sh.classname = "delete_email"; new Effect.Fade(sh,{queue: {position: 'end', scope: 'effect'},duration: '50'}); for(i=0;i0;i--) { if(els[i].type == "checkbox" && els[i].name.indexOf("_")) { if(els[i].checked) { var nid = els[i].name.substr((els[i].name.indexOf("_")+1),els[i].name.length); var mvmbox = $("mailbox_select").value; var row = $("row_"+nid); new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'},duration: '0.5'}); new Ajax.Request( 'index.php', {queue: {position: 'end', scope: 'command'}, method: 'post', postBody: 'module=Webmails&action=WebmailsAjax&file=ListView&mailbox='+gCurrentFolder+'&command=move_msg&ajax=true&mailid='+nid+'&mvbox='+mvmbox, onComplete: function(t) { //alert(t.responseText); } } ); } } } $('mailbox_select').selectedIndex=0; //runEmailCommand('expunge',''); $("status").style.display="none"; }*/ function search_emails() { // TODO: find a way to search in degraded functionality mode. var search_query = $("search_input").value; var search_type = $("search_type").value; window.location = "index.php?module=Webmails&action=index&search=true&search_type="+search_type+"&search_input="+search_query+'&mailbox='+mailbox; } function runEmailCommand(com,id) { command=com; id=id; gselected_mail = ''; if(com == 'delete_msg') { if(!confirm(alert_arr.DELETE+" "+alert_arr.MAIL+" ?")) return; } if(com=="reload") var file="ListViewAjax"; else var file=""; if(move_mail == 1){ var qry_str = "&mvbox="+mvmbox; move_mail = 0; } else qry_str = ""; $("status").style.display="block"; new Ajax.Request( 'index.php', {queue: {position: 'end', scope: 'command'}, method: 'post', postBody: 'module=Webmails&action=WebmailsAjax&start='+start+'&command='+command+'&mailid='+id+'&file='+file+'&mailbox='+mailbox+qry_str+'&search_type='+$("search_type").value+'&search_input='+$("search_input").value, onComplete: function(t) { resp = t.responseText; id=resp; if(resp.match(/ajax failed/)) {return;} switch(command) { case 'reload': $("rssScroll").innerHTML = resp; var unread_count = parseInt($(mailbox+"_tempcount").innerHTML); if(unread_count > 0) { $(mailbox+"_unread").innerHTML = unread_count; } else{ $(mailbox+"_count").innerHTML = ""; } $("nav").innerHTML = $("navTemp").innerHTML; $("box_list").innerHTML = $("temp_boxlist").innerHTML; $("move_pane").innerHTML = $("temp_movepane").innerHTML; $("temp_boxlist").innerHTML = ""; $("temp_movepane").innerHTML = ""; $("navTemp").innerHTML = ''; $(mailbox+"_tempcount").innerHTML = ""; break; case 'expunge': // NOTE: we either have to reload the page or count up from the messages that // are deleted and moved or we introduce a bug from invalid mail ids //window.location = window.location; start = resp; runEmailCommand("reload",0); break; case 'delete_multi_msg': var ids; eval(resp); var rows = ids.split(":"); for(i=0;i"; $("ndeleted_date_"+id).innerHTML = ""+$("ndeleted_date_"+id).innerHTML+""; $("ndeleted_from_"+id).innerHTML = ""+$("ndeleted_from_"+id).innerHTML+""; }, function() { $("deleted_subject_"+id).innerHTML = ""+$("deleted_subject_"+id).innerHTML+""; $("deleted_date_"+id).innerHTML = ""+$("deleted_date_"+id).innerHTML+""; $("deleted_from_"+id).innerHTML = ""+$("deleted_from_"+id).innerHTML+""; } ); try { $("del_link_"+id).innerHTML = 'del'; new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'},duration: '0.5'}); tmp = document.getElementsByClassName("previewWindow"); // tmp[0].style.visibility="hidden"; }catch(g){} if(preview_id == id){ // alert(preview_id + id); $("preview1").style.visibility="hidden"; $("preview2").style.visibility="hidden"; } /*for(var i=0;i"; $("ndeleted_date_"+id).innerHTML = ""+$("ndeleted_date_"+id).innerHTML+""; $("ndeleted_from_"+id).innerHTML = ""+$("ndeleted_from_"+id).innerHTML+""; }, function() { $("deleted_subject_"+id).innerHTML = ""+$("deleted_subject_"+id).innerHTML+""; $("deleted_date_"+id).innerHTML = ""+$("deleted_date_"+id).innerHTML+""; $("deleted_from_"+id).innerHTML = ""+$("deleted_from_"+id).innerHTML+""; } ); $("del_link_"+id).innerHTML = 'del'; new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'},duration: '1.0'}); } if(preview_id == id){ // alert(preview_id + id); $("preview1").style.visibility="hidden"; $("preview2").style.visibility="hidden"; } runEmailCommand("reload",0); break; case 'undelete_msg': id=resp; var node = $("row_"+id); node.className=''; node.style.display = ''; var newhtml = remove(remove(node.innerHTML,''),''); node.innerHTML=newhtml; $("del_link_"+id).innerHTML = 'del'; $("status").style.display="none"; break; case 'clear_flag': var nm = "clear_td_"+id; var el = $(nm); var tmp = el.innerHTML; el.innerHTML =''; el.id = "set_td_"+id; break; case 'set_flag': var nm = "set_td_"+id; var el = $(nm); var tmp = el.innerHTML; el.innerHTML =''; el.id = "clear_td_"+id; break; } $("status").style.display="none"; } } ); } function cal_navigation(box,page){ start = page; mailbox = box; runEmailCommand("reload",0); } function remove(s, t) { /* ** Remove all occurrences of a token in a string ** s string to be processed ** t token to be removed ** returns new string */ i = s.indexOf(t); r = ""; if (i == -1) return s; r += s.substring(0,i) + remove(s.substring(i + t.length), t); return r; } function changeMbox(box) { mailbox=box; start = 0; change_box=1; runEmailCommand("reload",0); //location.href = "index.php?module=Webmails&action=index&mailbox="+box; } // TODO: these two functions should be tied into a mailbox management panel of some kind. // could be a DHTML div with AJAX calls to execute the commands on the mailbox. function show_addfolder() { var fldr = $("folderOpts"); if(fldr.style.display == 'none') $("folderOpts").style.display=""; else $("folderOpts").style.display="none"; } function show_remfolder(mb) { var fldr = $("remove_"+mb); if(typeof(fldr) != "undefined") { if(fldr.style.display == 'none') fldr.style.display=""; else fldr.style.display="none"; } }