From 0ab7a210f9e0f67d4b49035170df7852204b8be2 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 6 May 2016 17:32:07 +0200 Subject: [PATCH] hovercard: better placement management --- js/hovercard.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/hovercard.js b/js/hovercard.js index 9b326dcd3e..1fce282c08 100644 --- a/js/hovercard.js +++ b/js/hovercard.js @@ -62,7 +62,16 @@ $(document).ready(function(){ if(data) { targetElement.popover({ html: true, - placement: 'auto', + placement: function () { + // Calculate the placement of the the hovercard (if top or bottom) + // The placement depence on the distance between window top and the element + // which triggers the hover-card + var get_position = $(targetElement).offset().top - $(window).scrollTop(); + if (get_position < 270 ){ + return "bottom"; + } + return "top"; + }, trigger: 'manual', template: '