mirror of https://github.com/zulip/zulip.git
popovers: Use fix_positions option for streams popover.
The fix_positions argument here fixes the horizontal position of the stream popover. It also fixes the vertical position, both in the default case, and also doing an appropriate adjustment for the case that the color picker is open. This contains a few changes by tabbott to, rather than hiding the arrow unconditionally, only do so when it would no longer point at the right part of the screen. Fixes #2374. Fixes #6059. Fixes #7290.
This commit is contained in:
parent
19a434a289
commit
8779e550a4
|
@ -77,9 +77,21 @@ function update_spectrum(popover, update_func) {
|
|||
|
||||
var popover_root = popover.closest(".popover");
|
||||
var current_top_px = parseFloat(popover_root.css('top').replace('px', ''));
|
||||
var height_delta = -(after_height - initial_height) * 0.5;
|
||||
var height_delta = after_height - initial_height;
|
||||
var top = current_top_px - height_delta / 2;
|
||||
|
||||
popover_root.css('top', current_top_px + height_delta + "px");
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
popover_root.find("div.arrow").hide();
|
||||
} else if (top + after_height > $(window).height() - 20) {
|
||||
top = $(window).height() - after_height - 20;
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
}
|
||||
popover_root.find("div.arrow").hide();
|
||||
}
|
||||
|
||||
popover_root.css('top', top + "px");
|
||||
}
|
||||
|
||||
function build_stream_popover(e) {
|
||||
|
@ -106,6 +118,7 @@ function build_stream_popover(e) {
|
|||
content: content,
|
||||
trigger: "manual",
|
||||
fixed: true,
|
||||
fix_positions: true,
|
||||
});
|
||||
|
||||
$(elt).popover("show");
|
||||
|
|
|
@ -1289,14 +1289,21 @@
|
|||
*/
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
} else if (top + actualHeight > win_height) {
|
||||
top = win_height - actualHeight;
|
||||
$tip.find("div.arrow").hide();
|
||||
} else if (top + actualHeight > win_height - 20) {
|
||||
top = win_height - actualHeight - 20;
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
}
|
||||
$tip.find("div.arrow").hide();
|
||||
}
|
||||
|
||||
if (left < 0) {
|
||||
left = 0;
|
||||
$tip.find("div.arrow").hide();
|
||||
} else if (left + actualWidth > win_width) {
|
||||
left = win_width - actualWidth;
|
||||
$tip.find("div.arrow").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue