X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/6e508a7b70fbe65d9229b421cc6d5111bb00f9c1..7ff77d9d3d7960ae993bf5ef97a66dbb10f2496e:/app/views/site/_resize.html.erb?ds=sidebyside diff --git a/app/views/site/_resize.html.erb b/app/views/site/_resize.html.erb index c88f50052..4b312bf8c 100644 --- a/app/views/site/_resize.html.erb +++ b/app/views/site/_resize.html.erb @@ -16,19 +16,26 @@ } function resizeMap() { - var sidebar_width = 0 + $("#sidebar:visible").outerWidth(true); + var content_width = $("#content").width(); + var content_height = $("#content").height(); + var sidebar_width = 0; var left_border = parseFloat($("#map").css("border-left-width")); var right_border = parseFloat($("#map").css("border-right-width")); var top_border = parseFloat($("#map").css("border-top-width")); var bottom_border = parseFloat($("#map").css("border-bottom-width")); + $("#sidebar:visible").each(function () { + sidebar_width = sidebar_width + $(this).outerWidth(true); + }); + <% if t('html.dir') == "ltr" -%> $("#map").css("left", (sidebar_width) + "px"); <% else -%> $("#map").css("right", (sidebar_width) + "px"); <% end -%> - $("#map").width($("#content").width() - sidebar_width - left_border - right_border); - $("#map").height($("#content").height() - top_border - bottom_border); + $("#map").width(content_width - sidebar_width - left_border - right_border); + $("#map").height(content_height - top_border - bottom_border); + $("#map").trigger("resized"); } function handleResize() { @@ -38,4 +45,9 @@ resizeMap(); } + + $(document).ready(function () { + $("#sidebar").on("opened", resizeMap); + $("#sidebar").on("closed", resizeMap); + });