Skip to content
Snippets Groups Projects
Commit 42182387 authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Fix the email list not showing the scroll bar with >= 8 emails.

* All screens are now scrollable depending on their height.
* Variable renaming for clarity.
parent 21555313
No related branches found
No related tags found
No related merge requests found
...@@ -143,8 +143,28 @@ section > .contents { ...@@ -143,8 +143,28 @@ section > .contents {
* Set the width of the container for when the arrow animation happens * Set the width of the container for when the arrow animation happens
* otherwise the buttons slide right with the arrow * otherwise the buttons slide right with the arrow
*/ */
width: 250px;
font-size: 13px; font-size: 13px;
position: absolute;
top: 15px;
bottom: 15px;
left: 15px;
width: 250px;
overflow-y: auto;
}
.form_section.vcenter {
position: static;
overflow-y: visible;
/* The below 1px padding is part of a fix for a bug in webkit where there
* is a ghost padding-right to accommodate the scroll bar that is shown
* if there are many email addresses. The ghost padding caused the submit
* button to shift when the user clicked on it, sometimes making the
* submit button require two clicks. The other half of the fix is in
* screen_size_hacks.js, where an adjustment to the width is made.
* These two in combination force Chrome to re-flow, which fixes its
* own bug.
*/
padding-right: 1px;
} }
.form_section p { .form_section p {
...@@ -152,6 +172,7 @@ section > .contents { ...@@ -152,6 +172,7 @@ section > .contents {
} }
.contents > strong { .contents > strong {
display: none; display: none;
} }
...@@ -328,30 +349,6 @@ div#required_email { ...@@ -328,30 +349,6 @@ div#required_email {
font-weight: bold; font-weight: bold;
} }
#selectEmail {
position: absolute;
top: 20px;
bottom: 20px;
left: 20px;
width: 250px;
overflow-y: auto;
}
#selectEmail.vcenter {
position: static;
overflow-y: visible;
/* The below 1px padding is part of a fix for a bug in webkit where there
* is a ghost padding-right to accommodate the scroll bar that is shown
* if there are many email addresses. The ghost padding caused the submit
* button to shift when the user clicked on it, sometimes making the
* submit button require two clicks. The other half of the fix is in
* screen_size_hacks.js, where an adjustment to the width is made.
* These two in combination force Chrome to re-flow, which fixes its
* own bug.
*/
padding-right: 1px;
}
.inputs > li { .inputs > li {
margin-top: 8px; margin-top: 8px;
} }
......
...@@ -9,19 +9,17 @@ ...@@ -9,19 +9,17 @@
* the #content element causes the contents to be vertically centered. * the #content element causes the contents to be vertically centered.
*/ */
function onResize() { function onResize() {
var selectEmailEl = $("#selectEmail"), var scrollableEl = $(".form_section"),
contentEl = $("#content"), contentEl = $("#content"),
signInEl = $("#signIn"); boundingRectEl = $("#signIn");
selectEmailEl.css("position", "static"); scrollableEl.css("position", "static");
// The mobile breakpoint is 640px in the CSS. If the max-width is changed function desktopHacks() {
// there, it must be changed here as well.
if($(window).width() > 640) {
// First, remove the mobile hacks // First, remove the mobile hacks
selectEmailEl.css("width", ""); scrollableEl.css("width", "");
contentEl.css("min-height", ""); contentEl.css("min-height", "");
signInEl.css("top", ""); boundingRectEl.css("top", "");
// This is a hack for desktop mode which centers the form vertically in // This is a hack for desktop mode which centers the form vertically in
// the middle of its container. We have to do this hack because we use // the middle of its container. We have to do this hack because we use
...@@ -30,13 +28,8 @@ ...@@ -30,13 +28,8 @@
// number of emails, we have to print a scrollbar - but only around the // number of emails, we have to print a scrollbar - but only around the
// emails. // emails.
// set the height to static so that we can get the height without if(scrollableEl.innerHeight() < boundingRectEl.innerHeight()) {
// constraints. scrollableEl.addClass("vcenter");
var height = selectEmailEl.innerHeight();
// re-introduce constraints
if(height < $("#signIn .vertical").innerHeight()) {
selectEmailEl.addClass("vcenter");
/* The below width adjustment is part of a fix for a bug in webkit where /* The below width adjustment is part of a fix for a bug in webkit where
* there is a ghost padding-right to accommodate the scroll bar that is * there is a ghost padding-right to accommodate the scroll bar that is
...@@ -47,33 +40,37 @@ ...@@ -47,33 +40,37 @@
* These two in combination force Chrome to re-flow, which fixes its * These two in combination force Chrome to re-flow, which fixes its
* own bug. * own bug.
*/ */
var width = selectEmailEl.width(); var width = scrollableEl.width();
selectEmailEl.width(width); scrollableEl.width(width);
} }
else { else {
selectEmailEl.removeClass("vcenter"); scrollableEl.removeClass("vcenter");
} }
} }
else {
function mobileHacks() {
// First, remove the desktop hacks // First, remove the desktop hacks
selectEmailEl.removeClass("vcenter"); scrollableEl.removeClass("vcenter");
// Hack to make sure the email addresses stay within their container. // Hack to make sure the email addresses stay within their container.
// We have to do this ghettoness because table-cells (which are used to // We have to do this ghettoness because table-cells (which are used to
// vertically center everything) expand to fully contain their children // vertically center everything) expand to fully contain their children
// and the ellipsis never show up as expected. // and the ellipsis never show up as expected.
// First, find the maximum width that emails can be. // First, find the maximum width that emails can be. First set the
selectEmailEl.css("width", "10px").removeClass("vcenter"); // width of the scrollable element to be very narrow so that we can
var constrainedWidth = $("#signIn .contents").innerWidth(); // find the natural innerWidth of the parent.
scrollableEl.css("width", "10px");
var parentNaturalWidth = scrollableEl.parent().innerWidth();
// Find the real maximum width. // Unconstrain the scrollableEl's width to find the real maximum
selectEmailEl.css("width", ""); // width of the emails.
var maxEmailWidth = selectEmailEl.innerWidth(); scrollableEl.css("width", "");
var maxEmailWidth = scrollableEl.innerWidth();
// If we have a too large an email, constrain the width. // If we have a too large an email, constrain the width.
if(maxEmailWidth > constrainedWidth) { if(maxEmailWidth > parentNaturalWidth) {
selectEmailEl.css("width", constrainedWidth + "px"); scrollableEl.css("width", parentNaturalWidth + "px");
} }
// Hack to find the min-height of the content area the footer is pushed // Hack to find the min-height of the content area the footer is pushed
...@@ -118,10 +115,19 @@ ...@@ -118,10 +115,19 @@
var favIconHeight = $("#favicon").outerHeight(); var favIconHeight = $("#favicon").outerHeight();
// Force the top of the main content area to be below the favicon area. // Force the top of the main content area to be below the favicon area.
signInEl.css("top", favIconHeight + "px"); boundingRectEl.css("top", favIconHeight + "px");
}
// The mobile breakpoint is 640px in the CSS. If the max-width is changed
// there, it must be changed here as well.
if($(window).width() > 640) {
desktopHacks();
}
else {
mobileHacks();
} }
selectEmailEl.css("position", ""); scrollableEl.css("position", "");
} }
$(window).resize(onResize); $(window).resize(onResize);
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
<p>
<%= gettext('Sign in as...') %>
</p>
<div id="selectEmail" class="form_section"> <div id="selectEmail" class="form_section">
<p>
<%= gettext('Sign in as...') %>
</p>
<ul class="inputs" id="emailList"> <ul class="inputs" id="emailList">
<% _.each(identities, function(item, index) { var emailAddress = item.address, id = "email_" + index; %> <% _.each(identities, function(item, index) { var emailAddress = item.address, id = "email_" + index; %>
<li> <li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment