compose_ui: Extract method to set color of stream header bar.

Similar method will be used to set color for stream selection bar
when editing stream of topic/message.
This commit is contained in:
Aman Agrawal
2020-05-12 14:20:50 +05:30
committed by Tim Abbott
parent 0a61754635
commit 9734bcc7cd
3 changed files with 26 additions and 27 deletions

View File

@@ -1,17 +1,5 @@
const autosize = require('autosize');
function update_lock_icon_for_stream(stream_name) {
const icon = $("#compose-lock-icon");
const streamfield = $("#stream_message_recipient_stream");
if (stream_data.get_invite_only(stream_name)) {
icon.show();
streamfield.addClass("lock-padding");
} else {
icon.hide();
streamfield.removeClass("lock-padding");
}
}
exports.blur_textarea = function () {
$('.message_comp').find('input, textarea, button').blur();
};
@@ -124,25 +112,12 @@ exports.complete_starting_tasks = function (msg_type, opts) {
exports.maybe_scroll_up_selected_message();
ui_util.change_tab_to("#home");
compose_fade.start_compose(msg_type);
exports.decorate_stream_bar(opts.stream);
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"));
$(document).trigger($.Event('compose_started.zulip', opts));
resize.resize_bottom_whitespace();
exports.update_placeholder_text(opts);
};
// In an attempt to decrease mixing, make the composebox's
// stream bar look like what you're replying to.
// (In particular, if there's a color associated with it,
// have that color be reflected here too.)
exports.decorate_stream_bar = function (stream_name) {
const color = stream_data.get_color(stream_name);
update_lock_icon_for_stream(stream_name);
$("#stream-message .message_header_stream")
.css('background-color', color)
.removeClass(stream_color.color_classes)
.addClass(stream_color.get_color_class(color));
};
exports.maybe_scroll_up_selected_message = function () {
// If the compose box is obscuring the currently selected message,
// scroll up until the message is no longer occluded.