Bug 18066: Fix map positioning in admin/usage_statistics.pl

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
This commit is contained in:
Julian Maurice 2017-03-21 12:01:45 +01:00 committed by Brendan A Gallagher
parent 7aff869661
commit c3db243ad4

View file

@ -10,28 +10,32 @@
<script type="text/javascript">
//<![CDATA[
var originalOffset;
$(window).scroll(function () {
function positionMap() {
var tbh = $("#mapid");
var offsetTop = tbh.offset().top;
var mapContainer = tbh.parent();
mapContainer.css('position', 'relative');
mapContainer.css('min-height', tbh.outerHeight(true));
tbh.css('position', 'absolute');
tbh.css('right', 0);
var offsetTop = mapContainer.offset().top;
var s = parseInt($(window).scrollTop(), 10);
var fixMe = (s > offsetTop);
if ( !originalOffset ) originalOffset = tbh.position().top;
var repositionMe = (s < originalOffset);
if (fixMe) {
tbh.css({
'position': 'fixed',
'top': '0',
'margin-left': '40%'
});
}
if (repositionMe) {
tbh.css({
'position': 'absolute',
'top': originalOffset,
'margin-left': '40%'
});
tbh.css('top', '').css('bottom', '');
if (s > offsetTop) {
var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
tbh.css('bottom', 0);
} else {
tbh.css('top', s - offsetTop);
}
} else {
tbh.css('top', 0);
}
}
$(document).ready(function() {
$(window).scroll(positionMap);
positionMap();
});
//]]>
</script>
@ -321,6 +325,7 @@
$("#UsageStatsLibrariesInfo").on('change', function(){
if ( $(this).val() == 1 ) $("#libraries_info").show()
else $("#libraries_info").hide();
positionMap();
});
</script>