fixed comment options dropdown position

This commit is contained in:
zmagod 2016-10-05 15:26:11 +02:00
parent d90f17d1eb
commit bca3d19562

View file

@ -170,7 +170,7 @@ var Comments = (function() {
} else { } else {
useParentOffset = true; useParentOffset = true;
} }
scrollCommentOptions($('.dropdown-comment'), useParentOffset); scrollCommentOptions($('.dropdown-comment'));
// Reposition dropdown to the left // Reposition dropdown to the left
// (only do this when using parent offset) // (only do this when using parent offset)
@ -191,22 +191,17 @@ var Comments = (function() {
var parent = $(scrollableContainer); var parent = $(scrollableContainer);
if ($target.length) { if ($target.length) {
scrollCommentOptions(parent.find('.dropdown-comment'), useParentOffset); scrollCommentOptions(parent.find('.dropdown-comment'));
} }
}, true); }, true);
} }
function scrollCommentOptions(selector, useParentOffset) { function scrollCommentOptions(selector) {
if ( ! _.isUndefined(typeof useParentOffset) ) {
useParentOffset = useParentOffset;
} else {
useParentOffset = true;
}
_.each(selector, function(el) { _.each(selector, function(el) {
var $el = $(el); var $el = $(el);
var offset = useParentOffset ? $el.offset().top : $el.position().top; var offset = $el.offset().top;
$el.find('.dropdown-menu-fixed') $el.find('.dropdown-menu-fixed')
.offset({ top: (offset + 20) }); .offset({ top: (offset + 20) });
}); });
} }
@ -337,7 +332,6 @@ var Comments = (function() {
form: initCommentForm, form: initCommentForm,
bindNewElement: bindCommentInitializerToNewElement, bindNewElement: bindCommentInitializerToNewElement,
initCommentOptions: initCommentOptions, initCommentOptions: initCommentOptions,
scrollCommentOptions: scrollCommentOptions,
initDeleteComments: initDeleteComments, initDeleteComments: initDeleteComments,
initEditComments: initEditComments initEditComments: initEditComments
}; };