MediaWiki:BibleGet.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 26: Line 26:
let left = $span.offset().left + $span.outerWidth() + 15;
let left = $span.offset().left + $span.outerWidth() + 15;
$bGetTIP.css({"top":top,"left":left});
$bGetTIP.css({"top":top,"left":left});
if($bGetTIP.is(':offscreen') ){
//how far off the bottom of the screen are we?
let rect = $bGetTIP[0].getBoundingClientRect();
let excessHeight = (rect.y + rect.height) - window.innerHeight;
//if this amount is less than the distance from the top of the screen,
// then let's just move our div up by that much
if(excessHeight < rect.y){
let newTop = top - excessHeight;
$bGetTIP.css({"top":newTop});
}
}
});
});
Line 201: Line 212:
jQuery(this).addClass('ready hidden');
jQuery(this).addClass('ready hidden');
});
});
};
jQuery.expr.filters.offscreen = function(el) {
  let rect = el.getBoundingClientRect();
  return ( rect.x < 0 || rect.y < 0 ||
          (rect.x + rect.width) > window.innerWidth ||
          (rect.y + rect.height) > window.innerHeight );
};
};