Reposition comment dropdowns horizontally if needed

Closes SCI-258
This commit is contained in:
Luka Murn 2016-08-30 11:39:50 +02:00
parent 4ee4c6caba
commit 77ec5bcff9

View file

@ -1,6 +1,20 @@
function initCommentOptions(scrollableContainer, useParentOffset = true) {
scrollCommentOptions($(".dropdown-comment"), useParentOffset);
// Reposition dropdown to the left
// (only do this when using parent offset)
if (useParentOffset) {
$(document).on("shown.bs.dropdown", ".dropdown-comment", function() {
var $el = $(this);
var menu = $el.find(".dropdown-menu");
var leftPos = $el.offset().left;
if (leftPos + menu.width() > $(window).width()) {
menu.offset({ left: leftPos - menu.width() });
}
});
}
// Reposition dropdowns vertically on scroll events
document.addEventListener('scroll', function (event) {
var $target = $(event.target);
var parent = $(scrollableContainer);