From 224fcebfc98f90a21d6d54c3dfddef71cd8fd07a Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 6 Jun 2013 17:52:02 -0400 Subject: [PATCH] Extract viewport.is_below_visible_bottom(). This encapsulates logic about things covering the viewport inside of viewport.js. (imported from commit 429e979fb0ab288d94064b75280a8b053f9a2aa4) --- zephyr/static/js/notifications_bar.js | 6 ++++-- zephyr/static/js/viewport.js | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zephyr/static/js/notifications_bar.js b/zephyr/static/js/notifications_bar.js index 931f77fe1d..fc26522e0d 100644 --- a/zephyr/static/js/notifications_bar.js +++ b/zephyr/static/js/notifications_bar.js @@ -29,8 +29,10 @@ function hide() { // If there's a custom message, or if the last message is off the bottom of the // screen, then show the notifications bar. exports.update = function (num_unread) { - if (rows.last_visible().offset() !== null // otherwise the next line will error - && rows.last_visible().offset().top + rows.last_visible().height() > viewport.scrollTop() + viewport.height() - $("#compose").height() + var last_row = rows.last_visible(); + if (last_row + && last_row.offset() !== null // otherwise the next line will error + && viewport.is_below_visible_bottom(last_row.offset().top + last_row.height()) && num_unread > 0) show(); else diff --git a/zephyr/static/js/viewport.js b/zephyr/static/js/viewport.js index f7a4353a06..6a73b83e5d 100644 --- a/zephyr/static/js/viewport.js +++ b/zephyr/static/js/viewport.js @@ -49,6 +49,10 @@ exports.at_bottom = function () { return bottom + 2 >= window_size; }; +exports.is_below_visible_bottom = function (offset) { + return offset > viewport.scrollTop() + viewport.height() - $("#compose").height(); +}; + exports.set_message_position = function (message_top, message_height, viewport_info, ratio) { // message_top = offset of the top of a message that you are positioning // message_height = height of the message that you are positioning