mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
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:
@@ -1,17 +1,5 @@
|
|||||||
const autosize = require('autosize');
|
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 () {
|
exports.blur_textarea = function () {
|
||||||
$('.message_comp').find('input, textarea, button').blur();
|
$('.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();
|
exports.maybe_scroll_up_selected_message();
|
||||||
ui_util.change_tab_to("#home");
|
ui_util.change_tab_to("#home");
|
||||||
compose_fade.start_compose(msg_type);
|
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));
|
$(document).trigger($.Event('compose_started.zulip', opts));
|
||||||
resize.resize_bottom_whitespace();
|
resize.resize_bottom_whitespace();
|
||||||
exports.update_placeholder_text(opts);
|
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 () {
|
exports.maybe_scroll_up_selected_message = function () {
|
||||||
// If the compose box is obscuring the currently selected message,
|
// If the compose box is obscuring the currently selected message,
|
||||||
// scroll up until the message is no longer occluded.
|
// scroll up until the message is no longer occluded.
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ exports.initialize_kitchen_sink_stuff = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#stream_message_recipient_stream").on('blur', function () {
|
$("#stream_message_recipient_stream").on('blur', function () {
|
||||||
compose_actions.decorate_stream_bar(this.value);
|
ui_util.decorate_stream_bar(this.value, $("#stream-message .message_header_stream"));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('blur', function () {
|
$(window).on('blur', function () {
|
||||||
|
|||||||
@@ -30,4 +30,28 @@ exports.blur_active_element = function () {
|
|||||||
document.activeElement.blur();
|
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;
|
window.ui_util = exports;
|
||||||
|
|||||||
Reference in New Issue
Block a user