Update fade on every change to recipient fields. Trac #1261.

(imported from commit 2b966765bef3e7e4d8cd2ee6ad55a05ba1f23ab2)
This commit is contained in:
Kevin Mehall
2013-06-17 13:31:38 -04:00
parent 2795b362a8
commit b1b4c1a625
2 changed files with 19 additions and 19 deletions

View File

@@ -143,23 +143,33 @@ exports.update_recipient_on_narrow = function() {
} }
}; };
function do_fade(reply_message, fade_type) { function update_fade () {
compose.unfade_messages(); if (!is_composing_message) return;
compose.unfade_messages(false);
// Construct faded_to as a mocked up element which has all the // Construct faded_to as a mocked up element which has all the
// fields of a message used by util.same_recipient() // fields of a message used by util.same_recipient()
faded_to = { faded_to = {
type: fade_type type: is_composing_message
}; };
if (fade_type === "stream") {
faded_to.stream = reply_message.stream; if (faded_to.type === "stream") {
faded_to.subject = reply_message.subject; faded_to.stream = $('#stream').val();
faded_to.subject = $('#subject').val();
} else { } else {
faded_to.reply_to = reply_message.reply_to; faded_to.reply_to = $('#private_message_recipient').val();
} }
exports.update_faded_messages();
compose.update_faded_messages();
} }
$(function () {
$('#stream,#subject,#private_message_recipient').bind({
keyup: update_fade,
change: update_fade
});
});
exports.start = function (msg_type, opts) { exports.start = function (msg_type, opts) {
if (reload.is_in_progress()) { if (reload.is_in_progress()) {
return; return;
@@ -218,9 +228,7 @@ exports.start = function (msg_type, opts) {
show('private', $("#" + (focus_area || 'private_message_recipient'))); show('private', $("#" + (focus_area || 'private_message_recipient')));
} }
if (opts.replying_to_message !== undefined) { update_fade();
do_fade(opts.replying_to_message, msg_type);
}
exports.decorate_stream_bar(opts.stream); exports.decorate_stream_bar(opts.stream);
$(document).trigger($.Event('compose_started.zephyr', opts)); $(document).trigger($.Event('compose_started.zephyr', opts));

View File

@@ -143,14 +143,6 @@ function process_hotkey(e) {
return true; return true;
} }
} }
// If we just typed a character to change the recipient in the
// compose box, this means that we're no longer replying to
// whatever the original message was, and we should unfade.
if (compose.composing() &&
$("#stream:focus,#subject:focus,#private_message_recipient:focus").length > 0) {
compose.unfade_messages(true);
return false;
}
if ((event_name === 'up_arrow' || event_name === 'down_arrow') if ((event_name === 'up_arrow' || event_name === 'down_arrow')
&& compose.composing() && compose.composing()