From 26f5b0935ef4d8bc01e2b8581f7d7ed3c4508fc2 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Fri, 22 Aug 2008 06:37:48 -0400 Subject: [PATCH] Fix keyboard control of the list widgets and prevent Safari from scrolling (#1485279) --- program/js/app.js | 141 ++++++++++++++++++++++++++++++----------------- 1 files changed, 90 insertions(+), 51 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 657a45d..b5073da 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -195,6 +195,8 @@ { this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); }; this.set_spellcheck_state('ready'); + if (rcube_find_object('_is_html').value == '1') + this.display_spellcheck_controls(false); } if (this.env.drafts_mailbox) this.enable_command('savedraft', true); @@ -204,9 +206,9 @@ this.enable_command('select-all', 'select-none', 'expunge', true); if (this.env.messagecount - && (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox - || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter)) - || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter)))) + && (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox + || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter)) + || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter)))) this.enable_command('purge', true); this.set_page_buttons(); @@ -855,11 +857,13 @@ break; case 'spellcheck': - if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready) - { + if (window.tinyMCE && tinyMCE.get('compose-body')) { + 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.set_spellcheck_state('checking'); - } + } break; case 'savedraft': @@ -1185,7 +1189,7 @@ // start timer for message preview (wait for double click) if (selected && this.env.contentframe && !list.multi_selecting) - this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, this.dblclick_time + 10); + this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, 200); else if (this.env.contentframe) this.show_contentframe(false); }; @@ -1282,8 +1286,8 @@ if (!show && window.frames[this.env.contentframe]) { if (window.frames[this.env.contentframe].location.href.indexOf(this.env.blankpage)<0) - window.frames[this.env.contentframe].location.href = this.env.blankpage; - } + window.frames[this.env.contentframe].location.href = this.env.blankpage; + } else if (!bw.safari) frm.style.display = show ? 'block' : 'none'; } @@ -1506,13 +1510,13 @@ // Send a specifc request with UIDs of all selected messages // @private this._with_selected_messages = function(action, lock, add_url, remove) - { + { var a_uids = new Array(); if (this.env.uid) a_uids[0] = this.env.uid; else - { + { var selection = this.message_list.get_selection(); var rows = this.message_list.rows; var id; @@ -1521,23 +1525,28 @@ id = selection[n]; a_uids[a_uids.length] = id; - if (remove) + if (remove) this.message_list.remove_row(id, (n == selection.length-1)); else - { - rows[id].deleted = true; + { + rows[id].deleted = true; if (rows[id].classname.indexOf('deleted')<0) - { + { rows[id].classname += ' deleted'; this.set_classname(rows[id].obj, 'deleted', true); - } + } + if (this.env.read_when_deleted) + { + rows[id].classname = rows[id].classname.replace(/\s*unread/, ''); + this.set_classname(rows[id].obj, 'unread', false); + } - if (rows[id].icon && this.env.deletedicon) + if (rows[id].icon && this.env.deletedicon) rows[id].icon.src = this.env.deletedicon; - } } } + } // also send search request to get the right messages if (this.env.search_request) @@ -1545,7 +1554,7 @@ // send request to server this.http_post(action, '_uid='+a_uids.join(',')+'&_mbox='+urlencode(this.env.mailbox)+add_url, lock); - }; + }; // set a specific flag to one or more messages @@ -1574,14 +1583,14 @@ { id = a_uids[n]; if ((flag=='read' && this.message_list.rows[id].unread) - || (flag=='unread' && !this.message_list.rows[id].unread) - || (flag=='delete' && !this.message_list.rows[id].deleted) - || (flag=='undelete' && this.message_list.rows[id].deleted) - || (flag=='flagged' && !this.message_list.rows[id].flagged) - || (flag=='unflagged' && this.message_list.rows[id].flagged)) - { - r_uids[r_uids.length] = id; - } + || (flag=='unread' && !this.message_list.rows[id].unread) + || (flag=='delete' && !this.message_list.rows[id].deleted) + || (flag=='undelete' && this.message_list.rows[id].deleted) + || (flag=='flagged' && !this.message_list.rows[id].flagged) + || (flag=='unflagged' && this.message_list.rows[id].flagged)) + { + r_uids[r_uids.length] = id; + } } // nothing to do @@ -1636,7 +1645,7 @@ } if (rows[uid].icon && icn_src - && !(rows[uid].replied && this.env.repliedicon) + && !(rows[uid].replied && this.env.repliedicon) && !(rows[uid].deleted && this.env.deletedicon)) rows[uid].icon.src = icn_src; } @@ -1657,13 +1666,13 @@ parent.rcmail.set_classname(rows[uid].obj, 'unread', false); if (rows[uid].replied && parent.rcmail.env.repliedicon) - icn_src = parent.rcmail.env.repliedicon; + icn_src = parent.rcmail.env.repliedicon; else if (rows[uid].deleted && parent.rcmail.env.deletedicon) - icn_src = parent.rcmail.env.deletedicon; + icn_src = parent.rcmail.env.deletedicon; else if (parent.rcmail.env.messageicon) icn_src = parent.rcmail.env.messageicon; - if (rows[uid].icon && icn_src) + if (rows[uid].icon && icn_src) rows[uid].icon.src = icn_src; } } @@ -1779,16 +1788,21 @@ rows[uid].deleted = true; if (rows[uid].classname.indexOf('deleted')<0) - { + { rows[uid].classname += ' deleted'; this.set_classname(rows[uid].obj, 'deleted', true); } - - if (rows[uid].icon && this.env.deletedicon) + if (this.env.read_when_deleted) + { + rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); + this.set_classname(rows[uid].obj, 'unread', false); + } + + if (rows[uid].icon && this.env.deletedicon) rows[uid].icon.src = this.env.deletedicon; - if (rows[uid].unread) - r_uids[r_uids.length] = uid; + if (rows[uid].unread) + r_uids[r_uids.length] = uid; } } @@ -1817,7 +1831,7 @@ if (rows[uid]) { rows[uid].unread = false; - rows[uid].read = true; + rows[uid].read = true; rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); this.set_classname(rows[uid].obj, 'unread', false); @@ -1889,17 +1903,27 @@ } // check for empty body - if ((input_message.value == '' && - (!window.tinyMCE || tinyMCE.get('compose-body').getContent() == '')) && - !confirm(this.get_label('nobodywarning'))) + if ((!window.tinyMCE || !tinyMCE.get('compose-body')) && input_message.value == '' && !confirm(this.get_label('nobodywarning'))) { input_message.focus(); + return false; + } + else if (window.tinyMCE && tinyMCE.get('compose-body') && !tinyMCE.get('compose-body').getContent() && !confirm(this.get_label('nobodywarning'))) + { + tinyMCE.get('compose-body').focus(); return false; } return true; }; + this.display_spellcheck_controls = function(vis) + { + if (this.env.spellcheck) { + this.env.spellcheck.check_link.style.visibility = vis ? 'visible' : 'hidden'; + this.env.spellcheck.switch_lan_pic.style.visibility = vis ? 'visible' : 'hidden'; + } + }; this.set_spellcheck_state = function(s) { @@ -2189,10 +2213,10 @@ }; - this.sent_successfully = function(msg) + this.sent_successfully = function(type, msg) { this.list_mailbox(); - this.display_message(msg, 'confirmation', true); + this.display_message(msg, type, true); } @@ -2436,12 +2460,12 @@ var id, frame, ref = this; if (id = list.get_single_selection()) - this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, this.dblclick_time + 10); + this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, 200); else if (this.env.contentframe) this.show_contentframe(false); - this.enable_command('edit', id?true:false); this.enable_command('compose', list.selection.length > 0); + this.enable_command('edit', (id && this.env.address_sources && !this.env.address_sources[this.env.source].readonly) ? true : false); this.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly); return false; @@ -3392,6 +3416,13 @@ }; + // replace content of mailboxname display + this.set_mailboxname = function(content) + { + if (this.gui_objects.mailboxname && content) + this.gui_objects.mailboxname.innerHTML = content; + }; + // replace content of quota display this.set_quota = function(content) { @@ -3619,15 +3650,22 @@ { case 'delete': + if (this.task == 'addressbook') + { + var uid = this.contact_list.get_selection(); + this.enable_command('compose', (uid && this.contact_list.rows[uid])); + this.enable_command('delete', 'edit', (uid && this.contact_list.rows[uid] && this.env.address_sources && !this.env.address_sources[this.env.source].readonly)); + break; + } case 'moveto': if (this.env.action=='show') this.command('list'); else if (this.message_list) this.message_list.init(); - + case 'purge': case 'expunge': - if (!this.env.messagecount) + if (!this.env.messagecount && this.task == 'mail') { // clear preview pane content if (this.env.contentframe) @@ -3636,7 +3674,6 @@ this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'delete', 'mark', 'viewsource', 'print', 'load-attachment', 'purge', 'expunge', 'select-all', 'select-none', 'sort', false); } - break; case 'list': @@ -3644,13 +3681,15 @@ case 'check-recent': case 'getunread': - this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0)); - var mailboxtest = (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox + if (this.task == 'mail') + { + this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0)); + var mailboxtest = (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter)) || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter))) ? true : false; - this.enable_command('purge', (this.env.messagecount && mailboxtest)); - + this.enable_command('purge', (this.env.messagecount && mailboxtest)); + } break; } -- Gitblit v1.9.1