| | |
| | | this.message_list.addEventListener('select', function(o){ p.msglist_select(o); }); |
| | | 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; }); |
| | | this.message_list.addEventListener('dragend', function(o, e){ p.drag_end(e); }); |
| | | document.onmouseup = function(e){ return p.doc_mouse_up(e); }; |
| | | |
| | | this.message_list.init(); |
| | |
| | | |
| | | if (this.env.action=='show' || this.env.action=='preview') |
| | | { |
| | | this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', 'print', 'load-attachment', 'load-headers', true); |
| | | this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', |
| | | 'open', 'mark', 'viewsource', 'download', 'print', 'load-attachment', 'load-headers', true); |
| | | |
| | | if (this.env.next_uid) |
| | | { |
| | | this.enable_command('nextmessage', true); |
| | |
| | | { |
| | | this.enable_command('previousmessage', true); |
| | | this.enable_command('firstmessage', true); |
| | | } |
| | | |
| | | if (this.env.blockedobjects) |
| | | { |
| | | if (this.gui_objects.remoteobjectsmsg) |
| | | this.gui_objects.remoteobjectsmsg.style.display = 'block'; |
| | | this.enable_command('load-images', 'always-load', true); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | this.enable_command('compose', 'add-contact', false); |
| | | parent.rcmail.show_contentframe(true); |
| | | } |
| | | |
| | | if ((this.env.action=='show' || this.env.action=='preview') && this.env.blockedobjects) |
| | | { |
| | | if (this.gui_objects.remoteobjectsmsg) |
| | | this.gui_objects.remoteobjectsmsg.style.display = 'block'; |
| | | this.enable_command('load-images', 'always-load', true); |
| | | } |
| | | |
| | | if (this.env.action=='compose') |
| | |
| | | this.contact_list.addEventListener('select', function(o){ p.contactlist_select(o); }); |
| | | 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.addEventListener('dragend', function(o, e){ p.drag_end(e); }); |
| | | this.contact_list.init(); |
| | | |
| | | if (this.env.cid) |
| | |
| | | else if (input_subject.val() == '') |
| | | input_subject.focus(); |
| | | else if (input_message) |
| | | this.set_caret2start(input_message); |
| | | input_message.focus(); |
| | | |
| | | // get summary of all field values |
| | | this.compose_field_hash(true); |
| | |
| | | this.init_address_input_events = function(obj) |
| | | { |
| | | var handler = function(e){ return ref.ksearch_keypress(e,this); }; |
| | | obj.bind((bw.safari ? 'keydown' : 'keypress'), handler); |
| | | obj.bind((bw.safari || bw.ie ? 'keydown' : 'keypress'), handler); |
| | | obj.attr('autocomplete', 'off'); |
| | | }; |
| | | |
| | |
| | | return true; |
| | | else if (this.env.permaurl) |
| | | parent.location.href = this.env.permaurl; |
| | | break; |
| | | break; |
| | | |
| | | case 'open': |
| | | var uid; |
| | | if (uid = this.get_single_uid()) |
| | | { |
| | | obj.href = '?_task='+this.env.task+'&_action=show&_mbox='+urlencode(this.env.mailbox)+'&_uid='+uid; |
| | | return true; |
| | | } |
| | | break; |
| | | |
| | | // misc list commands |
| | | case 'list': |
| | |
| | | |
| | | |
| | | case 'sort': |
| | | // get the type of sorting |
| | | var a_sort = props.split('_'); |
| | | var sort_col = a_sort[0]; |
| | | var sort_order = a_sort[1] ? a_sort[1].toUpperCase() : null; |
| | | var sort_order, sort_col = props; |
| | | |
| | | // no sort order specified: toggle |
| | | if (sort_order==null) |
| | | { |
| | | if (this.env.sort_col==sort_col) |
| | | sort_order = this.env.sort_order=='ASC' ? 'DESC' : 'ASC'; |
| | | else |
| | | sort_order = this.env.sort_order; |
| | | } |
| | | |
| | | if (this.env.sort_col==sort_col && this.env.sort_order==sort_order) |
| | | break; |
| | | |
| | | if (this.env.sort_col==sort_col) |
| | | sort_order = this.env.sort_order=='ASC' ? 'DESC' : 'ASC'; |
| | | else |
| | | sort_order = 'ASC'; |
| | | |
| | | // set table header class |
| | | $('#rcm'+this.env.sort_col).removeClass('sorted'+(this.env.sort_order.toUpperCase())); |
| | | $('#rcm'+sort_col).addClass('sorted'+sort_order); |
| | |
| | | tinyMCE.execCommand('mceSpellCheck', true); |
| | | } |
| | | else if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready) { |
| | | this.env.spellcheck.spellCheck(this.env.spellcheck.check_link); |
| | | this.env.spellcheck.spellCheck(); |
| | | this.set_spellcheck_state('checking'); |
| | | } |
| | | break; |
| | |
| | | var uid; |
| | | if (uid = this.get_single_uid()) |
| | | { |
| | | ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+this.env.uid+'&_mbox='+urlencode(this.env.mailbox)); |
| | | ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)); |
| | | if (this.sourcewin) |
| | | window.setTimeout(function(){ ref.sourcewin.focus(); }, 20); |
| | | } |
| | | break; |
| | | |
| | | case 'download': |
| | | var uid; |
| | | if (uid = this.get_single_uid()) |
| | | this.goto_url('viewsource', '&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+'&_save=1'); |
| | | break; |
| | | |
| | | case 'add-contact': |
| | |
| | | |
| | | this.drag_start = function(list) |
| | | { |
| | | this.initialBodyScrollTop = bw.ie ? 0 : window.pageYOffset; |
| | | this.initialMailBoxScrollTop = document.getElementById("mailboxlist-container").scrollTop; |
| | | |
| | | var model = this.task == 'mail' ? this.env.mailboxes : this.env.address_sources; |
| | | |
| | | this.drag_active = true; |
| | |
| | | // save folderlist and folders location/sizes for droptarget calculation in drag_move() |
| | | if (this.gui_objects.folderlist && model) |
| | | { |
| | | this.initialBodyScrollTop = bw.ie ? 0 : window.pageYOffset; |
| | | this.initialListScrollTop = this.gui_objects.folderlist.parentNode.scrollTop; |
| | | |
| | | var li, pos, list, height; |
| | | list = $(this.gui_objects.folderlist); |
| | | pos = list.offset(); |
| | |
| | | } |
| | | }; |
| | | |
| | | this.drag_end = function(e) |
| | | { |
| | | this.drag_active = false; |
| | | |
| | | // over the folders |
| | | if (this.gui_objects.folderlist && this.env.folder_coords) { |
| | | for (var k in this.env.folder_coords) { |
| | | if (k == this.env.last_folder_target) { |
| | | $(this.get_folder_li(k)).removeClass('droptarget'); |
| | | this.env.last_folder_target = null; |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | this.drag_move = function(e) |
| | | { |
| | | if (this.gui_objects.folderlist && this.env.folder_coords) { |
| | | // offsets to compensate for scrolling while dragging a message |
| | | var boffset = bw.ie ? -document.documentElement.scrollTop : this.initialBodyScrollTop; |
| | | var moffset = this.initialMailBoxScrollTop-document.getElementById('mailboxlist-container').scrollTop; |
| | | var moffset = this.initialListScrollTop-this.gui_objects.folderlist.parentNode.scrollTop; |
| | | var toffset = -moffset-boffset; |
| | | |
| | | var li, pos, mouse; |
| | |
| | | if (this.env.mailbox == this.env.drafts_mailbox) |
| | | { |
| | | this.enable_command('reply', 'reply-all', 'forward', false); |
| | | this.enable_command('show', 'print', selected); |
| | | this.enable_command('show', 'print', 'open', 'download', 'viewsource', selected); |
| | | this.enable_command('delete', 'moveto', 'mark', (list.selection.length > 0 ? true : false)); |
| | | } |
| | | else |
| | | { |
| | | this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', selected); |
| | | this.enable_command('show', 'reply', 'reply-all', 'forward', 'print', 'open', 'download', 'viewsource', selected); |
| | | this.enable_command('delete', 'moveto', 'mark', (list.selection.length > 0 ? true : false)); |
| | | } |
| | | |
| | |
| | | this.show_contentframe(false); |
| | | |
| | | // Hide message command buttons until a message is selected |
| | | this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', false); |
| | | this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'viewsource', 'download', false); |
| | | |
| | | this._with_selected_messages('moveto', lock, add_url, (this.env.flag_for_deletion ? false : true)); |
| | | }; |
| | |
| | | |
| | | // exit if no mailbox specified or if selection is empty |
| | | if (!this.env.uid && !selection.length) |
| | | return; |
| | | return; |
| | | |
| | | // if there is a trash mailbox defined and we're not currently in it: |
| | | if (this.env.trash_mailbox && String(this.env.mailbox).toLowerCase() != String(this.env.trash_mailbox).toLowerCase()) |
| | |
| | | else if (!this.env.trash_mailbox && this.env.flag_for_deletion) |
| | | { |
| | | this.mark_message('delete'); |
| | | if(this.env.action=="show") |
| | | this.command('nextmessage','',this); |
| | | if (this.env.action == 'show') |
| | | this.command('nextmessage', '', this); |
| | | else if (selection.length == 1) |
| | | this.message_list.select_next(); |
| | | } |
| | |
| | | // also send search request to get the right messages |
| | | if (this.env.search_request) |
| | | add_url += '&_search='+this.env.search_request; |
| | | |
| | | if (this.env.next_uid) |
| | | add_url += '&_next_uid='+this.env.next_uid; |
| | | |
| | | // send request to server |
| | | this.http_post(action, '_uid='+a_uids.join(',')+'&_mbox='+urlencode(this.env.mailbox)+add_url, lock); |
| | |
| | | this.stop_spellchecking = function() |
| | | { |
| | | if (this.env.spellcheck && !this.spellcheck_ready) { |
| | | exec_event(this.env.spellcheck.check_link, 'click'); |
| | | $(this.env.spellcheck.spell_span).trigger('click'); |
| | | this.set_spellcheck_state('ready'); |
| | | } |
| | | }; |
| | |
| | | // stop spellchecking process |
| | | if (!vis) |
| | | this.stop_spellchecking(); |
| | | |
| | | this.env.spellcheck.check_link.style.visibility = vis ? 'visible' : 'hidden'; |
| | | this.env.spellcheck.switch_lan_pic.style.visibility = vis ? 'visible' : 'hidden'; |
| | | |
| | | $(this.env.spellcheck.spell_container).css('visibility', vis ? 'visible' : 'hidden'); |
| | | } |
| | | }; |
| | | |
| | | this.set_spellcheck_state = function(s) |
| | | { |
| | | this.spellcheck_ready = (s=='check_spelling' || s=='ready'); |
| | | this.spellcheck_ready = (s == 'ready' || s == 'no_error_found'); |
| | | this.enable_command('spellcheck', this.spellcheck_ready); |
| | | }; |
| | | |
| | |
| | | var input_message = $("[name='_message']"); |
| | | var message = input_message.val(); |
| | | var is_html = ($("input[name='_is_html']").val() == '1'); |
| | | var sig, p; |
| | | var sig, p, len; |
| | | |
| | | if (!this.env.identity) |
| | | this.env.identity = id |
| | |
| | | } |
| | | |
| | | message = message.replace(/[\r\n]+$/, ''); |
| | | |
| | | len = message.length; |
| | | |
| | | // add the new signature string |
| | | if (this.env.signatures && this.env.signatures[id]) |
| | | { |
| | |
| | | if (sig.indexOf('-- ')!=0) |
| | | sig = '-- \n'+sig; |
| | | message += '\n\n'+sig; |
| | | if (len) len += 1; |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | input_message.val(message); |
| | | |
| | | // move cursor before the signature |
| | | if (!is_html) |
| | | this.set_caret_pos(input_message.get(0), len); |
| | | |
| | | this.env.identity = id; |
| | | return true; |
| | |
| | | }; |
| | | |
| | | // send remote request to search mail or contacts |
| | | this.qsearch = function(value, addurl) |
| | | this.qsearch = function(value) |
| | | { |
| | | if (value != '') |
| | | { |
| | | if (this.message_list) |
| | | var addurl = ''; |
| | | if (this.message_list) { |
| | | this.message_list.clear(); |
| | | else if (this.contact_list) { |
| | | if (this.env.search_mods) { |
| | | var head_arr = new Array(); |
| | | for (var n in this.env.search_mods) |
| | | head_arr.push(n); |
| | | addurl += '&_headers='+head_arr.join(','); |
| | | } |
| | | } else if (this.contact_list) { |
| | | this.contact_list.clear(true); |
| | | this.show_contentframe(false); |
| | | } |
| | | |
| | | if (this.gui_objects.search_filter) |
| | | addurl = '&_filter=' + this.gui_objects.search_filter.value; |
| | | addurl += '&_filter=' + this.gui_objects.search_filter.value; |
| | | |
| | | // reset vars |
| | | this.env.current_page = 1; |
| | |
| | | q = q.replace(/(^\s+|\s+$)/g, '').toLowerCase(); |
| | | |
| | | // Don't (re-)search if string is empty or if the last results are still active |
| | | if (!q.length || q == this.ksearch_value) |
| | | if (q == this.ksearch_value) |
| | | return; |
| | | |
| | | |
| | | this.ksearch_value = q; |
| | | |
| | | if (!q.length) |
| | | return; |
| | | |
| | | this.display_message(this.get_label('searching'), 'loading', true); |
| | | this.http_post('autocomplete', '_search='+urlencode(q)); |
| | |
| | | this.ksearch_query_results = function(results, search) |
| | | { |
| | | // ignore this outdated search response |
| | | if (search != this.ksearch_value) |
| | | if (this.ksearch_value && search != this.ksearch_value) |
| | | return; |
| | | |
| | | this.hide_message(); |
| | |
| | | if ((target_li = this.get_folder_li(name))) { |
| | | $(target_li).removeClass('unfocused').addClass('selected'); |
| | | } |
| | | |
| | | // trigger event hook |
| | | this.triggerEvent('selectfolder', { folder:name, old:old }); |
| | | } |
| | | }; |
| | | |
| | |
| | | + (flags.unread ? ' unread' : '') |
| | | + (flags.deleted ? ' deleted' : '') |
| | | + (flags.flagged ? ' flagged' : '') |
| | | + (this.message_list.in_selection(uid) ? ' selected' : ''); |
| | | + (this.message_list.in_selection(uid) ? ' selected' : ''); |
| | | |
| | | // for performance use DOM instead of jQuery here |
| | | var row = document.createElement('TR'); |
| | |
| | | } |
| | | |
| | | this.message_list.insert_row(row, attop); |
| | | this.triggerEvent('insertrow', { uid:uid, row:row }); |
| | | |
| | | // remove 'old' row |
| | | if (attop && this.env.pagesize && this.message_list.rowcount > this.env.pagesize) { |
| | |
| | | var rowcount = tbody.rows.length; |
| | | var even = rowcount%2; |
| | | |
| | | var row = $('<tr>').attr('id', 'rcmrow'+cid).addClass('class').addClass(even ? 'even' : 'odd'); |
| | | |
| | | var row = document.createElement('TR'); |
| | | row.id = 'rcmrow'+cid; |
| | | row.className = 'contact '+(even ? 'even' : 'odd'); |
| | | |
| | | if (this.contact_list.in_selection(cid)) |
| | | row.addClass('selected'); |
| | | row.className += ' selected'; |
| | | |
| | | // add each submitted col |
| | | for (var c in cols) { |
| | | col = $('<td>').addClass(String(c).toLowerCase()).html(cols[c]).appendTo(row); |
| | | col = document.createElement('TD'); |
| | | col.className = String(c).toLowerCase(); |
| | | col.innerHTML = cols[c]; |
| | | row.appendChild(col); |
| | | } |
| | | |
| | | this.contact_list.insert_row(row); |
| | | this.triggerEvent('insertrow', { cid:cid, row:row }); |
| | | |
| | | this.enable_command('export', (this.contact_list.rowcount > 0)); |
| | | }; |
| | | |
| | |
| | | } |
| | | |
| | | case 'moveto': |
| | | if (this.env.action == 'show') |
| | | this.command('list'); |
| | | else if (this.message_list) |
| | | if (this.env.action == 'show') { |
| | | // re-enable commands on move/delete error |
| | | this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'viewsource', 'download', true); |
| | | } else if (this.message_list) |
| | | this.message_list.init(); |
| | | break; |
| | | |
| | |
| | | if (this.env.contentframe) |
| | | this.show_contentframe(false); |
| | | // disable commands useless when mailbox is empty |
| | | this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', |
| | | 'print', 'load-attachment', 'purge', 'expunge', 'select-all', 'select-none', 'sort', false); |
| | | this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', |
| | | 'mark', 'viewsource', 'open', 'download', 'print', 'load-attachment', |
| | | 'purge', 'expunge', 'select-all', 'select-none', 'sort', false); |
| | | } |
| | | break; |
| | | |
| | |
| | | this.msglist_select(this.message_list); |
| | | this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0)); |
| | | this.enable_command('purge', this.purge_mailbox_test()); |
| | | |
| | | if (response.action == 'list') |
| | | this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount }); |
| | | } |
| | | else if (this.task == 'addressbook') |
| | | else if (this.task == 'addressbook') { |
| | | this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0)); |
| | | |
| | | if (response.action == 'list') |
| | | this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount }); |
| | | } |
| | | break; |
| | | } |
| | | }; |
| | |
| | | this.set_busy(false); |
| | | request.abort(); |
| | | |
| | | this.display_message('Unknown Server Error!' + (errmsg ? ' ('+errmsg+')' : ''), 'error'); |
| | | if (errmsg) |
| | | this.display_message(this.get_label('servererror') + ' (' + errmsg + ')', 'error'); |
| | | }; |
| | | |
| | | // use an image to send a keep-alive siganl to the server |
| | |
| | | return obj.value.length; |
| | | }; |
| | | |
| | | this.set_caret2start = function(obj) |
| | | this.set_caret_pos = function(obj, pos) |
| | | { |
| | | if (obj.createTextRange) |
| | | if (obj.setSelectionRange) |
| | | obj.setSelectionRange(pos, pos); |
| | | else if (obj.createTextRange) |
| | | { |
| | | var range = obj.createTextRange(); |
| | | range.collapse(true); |
| | | range.moveEnd('character', pos); |
| | | range.moveStart('character', pos); |
| | | range.select(); |
| | | } |
| | | else if (obj.setSelectionRange) |
| | | obj.setSelectionRange(0,0); |
| | | |
| | | obj.focus(); |
| | | }; |
| | | } |
| | | |
| | | // set all fields of a form disabled |
| | | this.lock_form = function(form, lock) |