From 10ce739ca801b4a53f8a86defd64fc9a81c43be3 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Wed, 6 Jun 2012 13:09:41 +0100 Subject: [PATCH] Fix the scroll bar appearing on the main site's index page if it is not needed. issue #1693 --- resources/static/pages/start.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/resources/static/pages/start.js b/resources/static/pages/start.js index 7f735a5e6..f6bb1b258 100644 --- a/resources/static/pages/start.js +++ b/resources/static/pages/start.js @@ -59,20 +59,35 @@ $(function() { return divHeight === 110; } + function elementHeightWithMargins(element) { + element = $(element); + var height = element.outerHeight() + + parseInt(element.css("margin-top"), 10) + + parseInt(element.css("margin-bottom"), 10); + return height; + } + + xhr.init({ time_until_delay: 10 * 1000 }); network.init(); $(".display_always,.display_auth,.display_nonauth").hide(); + $(window).bind('resize', function() { - var height = $(window).height() - $("header").outerHeight() - $("footer").outerHeight(); - $("#vAlign").css({ "height": height }); + var height = $(window).height() + // To find the height of the content, subtract the height of the + // header and footer INCLUDING any top and bottom margins they + // have. If the margins are not included, the center content + // will be too tall and a scroll bar appears. + - elementHeightWithMargins("header") + - elementHeightWithMargins("footer"); + $("#vAlign").css({ "height": height }); // On the manage page, the content element sometimes does not take up the // full height of the screen, leaving the footer to float somewhere in the // middle. To compensate, force the min-height of the content so that the // footer remains at the bottom of the screen. - var paddingTop = 0, paddingBottom = 0; if(paddingAddedToMinHeight()) { -- GitLab