]> git.openstreetmap.org Git - rails.git/commitdiff
Read the content area size before making any changes
authorTom Hughes <tom@compton.nu>
Sat, 11 Feb 2012 11:32:08 +0000 (11:32 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 12 Feb 2012 15:17:43 +0000 (15:17 +0000)
Adjusting the position of the map can impact the apparent size of
the content area, so make sure we read that before we start making
any changes to the position and size of the map.

app/views/site/_resize.html.erb

index d018cedc913206b87ffa04799a6231ee267eec02..a6583762fea4073778ec986312c373b3b4d74e5e 100644 (file)
@@ -16,6 +16,8 @@
   }
 
   function resizeMap() {
+    var content_width = $("#content").width();
+    var content_height = $("#content").height();
     var sidebar_width = 0 + $("#sidebar:visible").outerWidth(true);
     var left_border = parseFloat($("#map").css("border-left-width"));
     var right_border = parseFloat($("#map").css("border-right-width"));
@@ -27,8 +29,8 @@
     <% 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);
 
     <% if params[:controller] == "site" and params[:action] == "index" -%>
     map.updateSize();