Add offsets to fixed elements based on the width of the browser scrollbar.

(imported from commit 2026725165dead381d0b99181ef84a67a5bd6626)
This commit is contained in:
Allen Rabinovich 2014-02-12 17:21:04 -07:00
parent 8af170a3c3
commit 01a04c3169
2 changed files with 35 additions and 16 deletions

View File

@ -352,6 +352,16 @@ function set_user_list_heights(res, usable_height, user_presences, group_pms) {
res.group_pms_max_height = blocks[1].max_height;
}
function scrollbarWidth() {
$('body').prepend('<div id="outertest" style="width:200px; height:150px; position: absolute; top: 0; left: 0; overflow-x:hidden; overflow-y:scroll; background: #ff0000; visibility: hidden;"><div id="innertest" style="width:100%; height: 200px; overflow-y: visible;">&nbsp;</div></div>');
var scrollwidth = $("#outertest").outerWidth() - $("#innertest").outerWidth();
$("#outertest").remove();
return scrollwidth;
}
function get_new_heights() {
var res = {};
var viewport_height = viewport.height();
@ -1875,6 +1885,31 @@ $(function () {
}
});
// Workaround for browsers with fixed scrollbars
$(function () {
var sbWidth = scrollbarWidth();
if (sbWidth > 0) {
$(".header").css("left", "-" + sbWidth + "px");
$(".header-main").css("left", sbWidth + "px");
$(".header-main").css("max-width", (1400 + sbWidth) + "px");
$(".header-main .column-middle").css("margin-right", (250 + sbWidth) + "px");
$(".fixed-app").css("left", "-" + sbWidth + "px");
$(".fixed-app .app-main").css("max-width", (1400 + sbWidth) + "px");
$(".fixed-app .column-middle").css("margin-left", (250 + sbWidth) + "px");
$("#compose").css("left", "-" + sbWidth + "px");
$(".compose-content").css({"left": sbWidth + "px",
"margin-right": (250 + sbWidth) + "px"});
$("#compose-container").css("max-width", (1400 + sbWidth) + "px");
}
});
return exports;
}());

View File

@ -98,22 +98,6 @@ var page_params = {{ page_params }};
<i class="icon-vector-remove close-alert-icon"></i>
</div>
</div>
</div>
<div class="fixed-app" id="floating_recipient_bar">
<div class="app-main recipient_bar_content">
<div class="column-middle column-overlay recipient-bar-main">
<div class="floating_recipient">
<div style="display: none;" id="current_label_stream" class="recipient_row">
<div class="message_header_colorblock"></div>
<div class="message_label_clickable message_header message_header_stream right_part"></div>
</div>
<div style="display: none;" id="current_label_private_message" class="recipient_row">
<div class="message_header_colorblock message_header_private_message"></div>
<div class="message_label_clickable message_header message_header_private_message right_part"></div>
</div>
</div>
</div>
</div>
</div>
{% include "zerver/home.html" %}
</div>