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

@@ -30,4 +30,28 @@ exports.blur_active_element = function () {
document.activeElement.blur();
};
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");
}
}
// In an attempt to decrease mixing, set stream bar
// color look like the stream being used.
// (In particular, if there's a color associated with it,
// have that color be reflected here too.)
exports.decorate_stream_bar = function (stream_name, element) {
const color = stream_data.get_color(stream_name);
update_lock_icon_for_stream(stream_name);
element.css('background-color', color)
.removeClass(stream_color.color_classes)
.addClass(stream_color.get_color_class(color));
};
window.ui_util = exports;