| | |
| | | | RoundCube Webmail Client Script | |
| | | | | |
| | | | This file is part of the RoundCube Webmail client | |
| | | | Copyright (C) 2005-2008, RoundCube Dev, - Switzerland | |
| | | | Copyright (C) 2005-2009, RoundCube Dev, - Switzerland | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | +-----------------------------------------------------------------------+ |
| | |
| | | this.message_list.addEventListener('dblclick', function(o){ p.msglist_dbl_click(o); }); |
| | | this.message_list.addEventListener('keypress', function(o){ p.msglist_keypress(o); }); |
| | | this.message_list.addEventListener('select', function(o){ p.msglist_select(o); }); |
| | | this.message_list.addEventListener('dragstart', function(o){ p.drag_active = true; if (p.preview_timer) clearTimeout(p.preview_timer); }); |
| | | this.message_list.addEventListener('dragstart', function(o){ p.drag_start(o); }); |
| | | this.message_list.addEventListener('dragmove', function(o, e){ p.drag_move(e); }); |
| | | this.message_list.addEventListener('dragend', function(o){ p.drag_active = false; }); |
| | | |
| | |
| | | } |
| | | if (this.env.drafts_mailbox) |
| | | this.enable_command('savedraft', true); |
| | | |
| | | document.onmouseup = function(e){ return p.doc_mouse_up(e); }; |
| | | } |
| | | |
| | | if (this.env.messagecount) |
| | |
| | | this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, {multiselect:true, draggable:true, keyboard:true}); |
| | | this.contact_list.addEventListener('keypress', function(o){ p.contactlist_keypress(o); }); |
| | | this.contact_list.addEventListener('select', function(o){ p.contactlist_select(o); }); |
| | | this.contact_list.addEventListener('dragstart', function(o){ p.drag_active = true; }); |
| | | this.contact_list.addEventListener('dragstart', function(o){ p.drag_start(o); }); |
| | | this.contact_list.addEventListener('dragmove', function(o, e){ p.drag_move(e); }); |
| | | this.contact_list.addEventListener('dragend', function(o){ p.drag_active = false; }); |
| | | this.contact_list.init(); |
| | |
| | | this.start_keepalive = function() |
| | | { |
| | | if (this.env.keep_alive && !this.env.framed && this.task=='mail' && this.gui_objects.mailboxlist) |
| | | this._int = setInterval(function(){ ref.check_for_recent(); }, this.env.keep_alive * 1000); |
| | | this._int = setInterval(function(){ ref.check_for_recent(false); }, this.env.keep_alive * 1000); |
| | | else if (this.env.keep_alive && !this.env.framed && this.task!='login') |
| | | this._int = setInterval(function(){ ref.send_keep_alive(); }, this.env.keep_alive * 1000); |
| | | } |
| | |
| | | break; |
| | | |
| | | case 'checkmail': |
| | | this.check_for_recent(); |
| | | this.check_for_recent(true); |
| | | break; |
| | | |
| | | case 'compose': |
| | |
| | | } |
| | | |
| | | // handle mouse release when dragging |
| | | if (this.drag_active && model) { |
| | | for (var k in model) { |
| | | if ((li = this.get_folder_li(k)) && rcube_mouse_is_over(e, li.firstChild) && this.check_droptarget(k)) { |
| | | this.set_classname(li, 'droptarget', false); |
| | | this.command('moveto', model[k].id); |
| | | break; |
| | | } |
| | | } |
| | | if (this.drag_active && model && this.env.last_folder_target) { |
| | | this.set_classname(this.get_folder_li(this.env.last_folder_target), 'droptarget', false); |
| | | this.command('moveto', model[this.env.last_folder_target].id); |
| | | this.env.last_folder_target = null; |
| | | } |
| | | }; |
| | | |
| | | this.drag_move = function(e) |
| | | this.drag_start = function(list) |
| | | { |
| | | var li; |
| | | var model = this.task == 'mail' ? this.env.mailboxes : this.env.address_sources; |
| | | |
| | | this.drag_active = true; |
| | | if (this.preview_timer) |
| | | clearTimeout(this.preview_timer); |
| | | |
| | | if (this.gui_objects.folderlist && model) { |
| | | // save folderlist and folders location/sizes for droptarget calculation in drag_move() |
| | | if (this.gui_objects.folderlist && model) |
| | | { |
| | | var li, pos, list, height; |
| | | list = rcube_find_object(this.task == 'mail' ? 'mailboxlist' : 'directorylist'); |
| | | pos = rcube_get_object_pos(list); |
| | | this.env.folderlist_coords = {x1:pos.x, y1:pos.y, x2:pos.x + list.offsetWidth, y2:pos.y + list.offsetHeight}; |
| | | |
| | | this.env.folder_coords = new Array(); |
| | | for (var k in model) { |
| | | if (li = this.get_folder_li(k)) |
| | | this.set_classname(li, 'droptarget', (rcube_mouse_is_over(e, li.firstChild) && this.check_droptarget(k))); |
| | | { |
| | | pos = rcube_get_object_pos(li.firstChild); |
| | | // only visible folders |
| | | if (height = li.firstChild.offsetHeight) |
| | | this.env.folder_coords[k] = {x1:pos.x, y1:pos.y, x2:pos.x + li.firstChild.offsetWidth, y2:pos.y + height}; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | this.drag_move = function(e) |
| | | { |
| | | if (this.gui_objects.folderlist && this.env.folder_coords) |
| | | { |
| | | var li, pos, mouse; |
| | | mouse = rcube_event.get_mouse_pos(e); |
| | | pos = this.env.folderlist_coords; |
| | | |
| | | // if mouse pointer is outside of folderlist |
| | | if (mouse.x < pos.x1 || mouse.x >= pos.x2 |
| | | || mouse.y < pos.y1 || mouse.y >= pos.y2) |
| | | { |
| | | if (this.env.last_folder_target) { |
| | | this.set_classname(this.get_folder_li(this.env.last_folder_target), 'droptarget', false); |
| | | this.env.last_folder_target = null; |
| | | } |
| | | return; |
| | | } |
| | | |
| | | // over the folders |
| | | for (var k in this.env.folder_coords) |
| | | { |
| | | pos = this.env.folder_coords[k]; |
| | | if (this.check_droptarget(k) && ((mouse.x >= pos.x1) && (mouse.x < pos.x2) |
| | | && (mouse.y >= pos.y1) && (mouse.y < pos.y2))) |
| | | { |
| | | this.set_classname(this.get_folder_li(k), 'droptarget', true); |
| | | this.env.last_folder_target = k; |
| | | } |
| | | else |
| | | this.set_classname(this.get_folder_li(k), 'droptarget', false); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | this.collapse_folder = function(id) |
| | | { |
| | |
| | | ul.style.display = ''; |
| | | this.set_classname(div, 'collapsed', false); |
| | | this.set_classname(div, 'expanded', true); |
| | | var reg = new RegExp('&'+escape(id)+'&'); |
| | | var reg = new RegExp('&'+urlencode(id)+'&'); |
| | | this.set_env('collapsed_folders', this.env.collapsed_folders.replace(reg, '')); |
| | | } |
| | | else |
| | |
| | | ul.style.display = 'none'; |
| | | this.set_classname(div, 'expanded', false); |
| | | this.set_classname(div, 'collapsed', true); |
| | | this.set_env('collapsed_folders', this.env.collapsed_folders+'&'+escape(id)+'&'); |
| | | |
| | | this.set_env('collapsed_folders', this.env.collapsed_folders+'&'+urlencode(id)+'&'); |
| | | |
| | | // select parent folder if one of its childs is currently selected |
| | | if (this.env.mailbox.indexOf(id + this.env.delimiter) == 0) |
| | | this.command('list', id); |
| | |
| | | li.nextSibling.getElementsByTagName("ul")[0].style.display = ''; |
| | | } |
| | | |
| | | this.http_post('save-pref', '_name=collapsed_folders&_value='+escape(this.env.collapsed_folders)); |
| | | this.http_post('save-pref', '_name=collapsed_folders&_value='+urlencode(this.env.collapsed_folders)); |
| | | this.set_unread_count_display(id, false); |
| | | } |
| | | } |
| | |
| | | |
| | | if (rows[uid].flagged && this.env.flaggedicon) |
| | | icn_src = this.env.flaggedicon; |
| | | else if (this.env.unflaggedicon) |
| | | else if (!rows[uid].flagged && this.env.unflaggedicon) |
| | | icn_src = this.env.unflaggedicon; |
| | | |
| | | if (rows[uid].flagged_icon && icn_src) |
| | |
| | | if (this.env.signatures) |
| | | { |
| | | // Append the signature as a div within the body |
| | | var sigElem = editor.dom.get("_rc_sig"); |
| | | var sigElem = editor.dom.get('_rc_sig'); |
| | | var newsig = ''; |
| | | var htmlsig = true; |
| | | |
| | | |
| | | if (!sigElem) |
| | | { |
| | | sigElem = editor.getDoc().createElement("div"); |
| | | sigElem.setAttribute("id", "_rc_sig"); |
| | | // add empty line before signature on IE |
| | | if (bw.ie) |
| | | editor.getBody().appendChild(editor.getDoc().createElement('br')); |
| | | |
| | | sigElem = editor.getDoc().createElement('div'); |
| | | sigElem.setAttribute('id', '_rc_sig'); |
| | | editor.getBody().appendChild(sigElem); |
| | | } |
| | | |
| | |
| | | |
| | | this.ksearch_value = q; |
| | | |
| | | this.display_message('searching', 'loading', true); |
| | | this.display_message(this.get_label('searching'), 'loading', true); |
| | | this.http_post('autocomplete', '_search='+q); |
| | | }; |
| | | |
| | |
| | | this.ksearch_display_results = function (a_results, a_result_ids, c) |
| | | { |
| | | // display search results |
| | | if (c && a_results.length) { |
| | | if (c && a_results.length && this.ksearch_input) { |
| | | var p, ul, li; |
| | | |
| | | // create results pane if not present |
| | |
| | | // add each result line to list |
| | | for (i=0; i<a_results.length; i++) { |
| | | li = document.createElement('LI'); |
| | | li.innerHTML = a_results[i].replace(/</, '<').replace(/>/, '>').replace(new RegExp('('+this.ksearch_value+')', 'ig'), '<b>$1</b>'); |
| | | li.innerHTML = a_results[i].replace(new RegExp('('+this.ksearch_value+')', 'ig'), '##$1%%').replace(/</g, '<').replace(/>/g, '>').replace(/##([^%]+)%%/g, '<b>$1</b>'); |
| | | li.onmouseover = function(){ ref.ksearch_select(this); }; |
| | | li.onclick = function(){ ref.ksearch_click(this) }; |
| | | li.onmouseup = function(){ ref.ksearch_click(this) }; |
| | | li._rcm_id = a_result_ids[i]; |
| | | ul.appendChild(li); |
| | | } |
| | |
| | | } |
| | | else if (col == 'subject' && this.message_list) |
| | | this.message_list.subject_col = n+1; |
| | | else if (col == 'flag' && this.env.unflaggedicon) |
| | | { |
| | | cell.innerHTML = '<img src="'+this.env.unflaggedicon+'" alt="" />'; |
| | | } |
| | | } |
| | | }; |
| | | |
| | |
| | | { |
| | | if (flags.flagged && this.env.flaggedicon) |
| | | col.innerHTML = '<img src="'+this.env.flaggedicon+'" alt="" />'; |
| | | else if(this.env.unflaggedicon) |
| | | else if(!flags.flagged && this.env.unflaggedicon) |
| | | col.innerHTML = '<img src="'+this.env.unflaggedicon+'" alt="" />'; |
| | | } |
| | | else if (c=='attachment') |
| | | col.innerHTML = attachment && this.env.attachmenticon ? '<img src="'+this.env.attachmenticon+'" alt="" />' : ''; |
| | | col.innerHTML = attachment && this.env.attachmenticon ? '<img src="'+this.env.attachmenticon+'" alt="" />' : ' '; |
| | | else |
| | | col.innerHTML = cols[c]; |
| | | |
| | |
| | | }; |
| | | |
| | | // send periodic request to check for recent messages |
| | | this.check_for_recent = function() |
| | | this.check_for_recent = function(setbusy) |
| | | { |
| | | if (this.busy) |
| | | return; |
| | | |
| | | this.set_busy(true, 'checkingmail'); |
| | | if (setbusy) |
| | | this.set_busy(true, 'checkingmail'); |
| | | |
| | | this.http_request('check-recent', (this.env.search_request ? '_search='+this.env.search_request+'&' : '') + '_t='+(new Date().getTime()), true); |
| | | }; |
| | | |