Optimize update_floating_recipient_bar's showing-and-hiding code.

(imported from commit 6cd67d9c7bf418ae78288363636ee75fdc3fcada)
This commit is contained in:
Waseem Daher
2012-10-15 19:29:03 -04:00
parent 1781a4a616
commit 1c56ad00c9

View File

@@ -126,7 +126,10 @@ function update_autocomplete() {
autocomplete_needs_update = false;
}
var old_label;
var is_narrowbar_showing = false;
function replace_narrowbar(desired_label) {
if (desired_label !== old_label) {
if (desired_label.children(".message_newstyle_stream").length !== 0) {
$("#current_label_stream td:first").replaceWith(desired_label.children(".message_newstyle_stream").clone());
$("#current_label_stream td:last").replaceWith(desired_label.children(".message_newstyle_subject").clone());
@@ -137,11 +140,19 @@ function replace_narrowbar(desired_label) {
$("#current_label_stream").css('display', 'none');
$("#current_label_huddle").css('display', 'table-row');
}
old_label = desired_label;
}
if (!is_narrowbar_showing) {
$(".floating_recipient_bar").css('visibility', 'visible');
is_narrowbar_showing = true;
}
}
function hide_narrowbar() {
if (is_narrowbar_showing) {
$(".floating_recipient_bar").css('visibility', 'hidden');
is_narrowbar_showing = false;
}
}
function update_floating_recipient_bar() {