From 080f560e0fc2f910e410c0ca8cc68a88e0363a08 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 29 Oct 2014 05:34:58 -0400 Subject: [PATCH] Fix reply scrolling issue with text mode and start message below the quote (#1490114) --- program/js/app.js | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 37 insertions(+), 16 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 98c4385..6e0d690 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -187,6 +187,11 @@ if (this.env.permaurl) this.enable_command('permaurl', 'extwin', true); + // initialize html editor + if (this.env.html_editor_init && window.rcmail_editor_init) { + rcmail_editor_init(this.env.html_editor_init); + } + switch (this.task) { case 'mail': @@ -980,7 +985,7 @@ if (this.task == 'mail') { url._mbox = this.env.mailbox; if (props) - url._to = props; + url._to = props; // also send search request so we can go back to search result after message is sent if (this.env.search_request) url._search = this.env.search_request; @@ -1008,8 +1013,12 @@ break; } } - else if (props) + else if (props && typeof props == 'string') { url._to = props; + } + else if (props && typeof props == 'object') { + $.extend(url, props); + } this.open_compose_step(url); break; @@ -2287,7 +2296,7 @@ // expand all threads with unread children this.expand_unread = function() { - var r, tbody = this.gui_objects.messagelist.tBodies[0], + var r, tbody = this.message_list.tbody, new_row = tbody.firstChild; while (new_row) { @@ -3119,7 +3128,7 @@ if (!this.gui_objects.messageform) return false; - var input_from = $("[name='_from']"), + var i, pos, input_from = $("[name='_from']"), input_to = $("[name='_to']"), input_subject = $("input[name='_subject']"), input_message = $("[name='_message']").get(0), @@ -3148,16 +3157,23 @@ // init live search events this.init_address_input_events(input_to, ac_props); - for (var i in ac_fields) { + for (i in ac_fields) { this.init_address_input_events($("[name='_"+ac_fields[i]+"']"), ac_props); } if (!html_mode) { - this.set_caret_pos(input_message, this.env.top_posting ? 0 : $(input_message).val().length); + pos = this.env.top_posting ? 0 : input_message.value.length; + this.set_caret_pos(input_message, pos); + // add signature according to selected identity // if we have HTML editor, signature is added in callback if (input_from.prop('type') == 'select-one') { this.change_identity(input_from[0]); + } + + // scroll to the bottom of the textarea (#1490114) + if (pos) { + $(input_message).scrollTop(input_message.scrollHeight); } } @@ -3857,6 +3873,16 @@ if (!show_sig) show_sig = this.env.show_sig; + var id = obj.options[obj.selectedIndex].value; + + // enable manual signature insert + if (this.env.signatures && this.env.signatures[id]) { + this.enable_command('insert-sig', true); + this.env.compose_commands.push('insert-sig'); + } + else + this.enable_command('insert-sig', false); + // first function execution if (!this.env.identities_initialized) { this.env.identities_initialized = true; @@ -3867,7 +3893,6 @@ } var cursor_pos, p = -1, - id = obj.options[obj.selectedIndex].value, input_message = $("[name='_message']"), message = input_message.val(), is_html = ($("input[name='_is_html']").val() == '1'), @@ -3907,14 +3932,6 @@ if (old_val || new_val) input.val(input_val).change(); }); - - // enable manual signature insert - if (this.env.signatures && this.env.signatures[id]) { - this.enable_command('insert-sig', true); - this.env.compose_commands.push('insert-sig'); - } - else - this.enable_command('insert-sig', false); if (!is_html) { // remove the 'old' signature @@ -4684,6 +4701,7 @@ this.list_contacts = function(src, group, page) { var win, folder, url = {}, + refresh = src === undefined && group === undefined && page === undefined, target = window; if (!src) @@ -4696,7 +4714,7 @@ page = this.env.current_page = 1; this.reset_qsearch(); } - else if (group != this.env.group) + else if (!refresh && group != this.env.group) page = this.env.current_page = 1; if (this.env.search_id) @@ -4833,6 +4851,9 @@ if (this.env.group) url._gid = this.env.group; + if (this.env.search_request) + url._search = this.env.search_request; + url._action = action; url._source = this.env.source; url._cid = cid; -- Gitblit v1.9.1