(Refactoring) Extracted get_new_heights() out of resizehandler()

(imported from commit 13707f0d188676b96d4cad1d091b447435a22229)
This commit is contained in:
Steve Howell
2013-05-10 11:18:06 -04:00
parent 0a36340216
commit 85ded308e9

View File

@@ -218,6 +218,38 @@ function need_skinny_mode() {
} }
} }
function get_new_heights() {
var res = {};
res.bottom_whitespace_height =
viewport.height() * 0.4;
res.main_div_min_height =
viewport.height()
- $("top_navbar").height();
res.bottom_sidebar_height =
viewport.height()
- $("#top_navbar").height()
- $(".upper_sidebar").height()
- 40;
res.right_sidebar_height =
viewport.height()
- $("#top_navbar").height()
- $("#notifications-area").height()
- 14 // margin for right sidebar
- 10; // padding on notifications bar
res.stream_filters_max_height =
res.bottom_sidebar_height * 0.75;
res.user_presences_max_height =
res.right_sidebar_height * 0.90;
return res;
}
function resizehandler(e) { function resizehandler(e) {
var composebox = $("#compose"); var composebox = $("#compose");
var floating_recipient_bar = $("#floating_recipient_bar"); var floating_recipient_bar = $("#floating_recipient_bar");
@@ -230,18 +262,14 @@ function resizehandler(e) {
composebox.width(desired_width); composebox.width(desired_width);
floating_recipient_bar.width(desired_width); floating_recipient_bar.width(desired_width);
$("#bottom_whitespace").height(viewport.height() * 0.4); var h = get_new_heights();
$("#main_div").css('min-height', viewport.height() - $("#top_navbar").height());
/* total viewport - height of navbar - height of upper sidebar - padding*/ $("#bottom_whitespace").height(h.bottom_whitespace_height);
var bottom_sidebar_height = viewport.height() - $("#top_navbar").height() - $(".upper_sidebar").height() - 40; $("#main_div").css('min-height', h.main_div_min_height);
$(".bottom_sidebar").height(bottom_sidebar_height); $(".bottom_sidebar").height(h.bottom_sidebar_height);
/* viewport - navbar - notifications area - margin on the right-sidebar - padding on the notifications-bar */ $("#right-sidebar").height(h.right_sidebar_height);
var right_sidebar_height = viewport.height() - $("#top_navbar").height() - $("#notifications-area").height() - 14 - 10; $("#stream_filters").css('max-height', h.stream_filters_max_height);
$("#right-sidebar").height(right_sidebar_height); $("#user_presences").css('max-height', h.user_presences_max_height);
$("#stream_filters").css('max-height', bottom_sidebar_height * 0.75);
$("#user_presences").css('max-height', right_sidebar_height * 0.90);
// This function might run onReady (if we're in a narrow window), // This function might run onReady (if we're in a narrow window),
// but before we've loaded in the messages; in that case, don't // but before we've loaded in the messages; in that case, don't