]> git.openstreetmap.org Git - rails.git/blob - app/views/site/_resize.html.erb
Mobile layout improvements
[rails.git] / app / views / site / _resize.html.erb
1 <script type="text/javascript">
2   var brokenContentSize = $("#content").prop("offsetWidth") == 0;
3
4   function resizeContent() {
5     var content = $("#content");
6     var leftMargin = parseInt(content.css("left"));
7     var rightMargin = parseInt(content.css("right"));
8     var bottomMargin = parseInt(content.css("bottom"));
9
10     <% if t('html.dir') == "ltr" -%>
11     content.width($(window).width() - content.prop("offsetLeft") - rightMargin);
12     <% else -%>
13     content.width($(window).width() - content.prop("offsetRight") - leftMargin);
14     <% end -%>
15     content.height($(window).height() - content.prop("offsetTop") - bottomMargin);
16   }
17
18   function resizeMap() {
19     var sidebar_width = 0 + $("#sidebar:visible").width();
20
21     if (sidebar_width > 0 && window.width > 641) {
22       sidebar_width = sidebar_width + 5
23     }
24
25     <% if t('html.dir') == "ltr" -%>
26     $("#map").css("left", (sidebar_width) + "px");
27     <% else -%>
28     $("#map").css("right", (sidebar_width) + "px");
29     <% end -%>
30     $("#map").width($("#content").width() - sidebar_width);
31     if (window.width > 641) {
32       $("#map").height($("#content").height() - 2);
33     }
34   }
35
36   function handleResize() {
37     if (brokenContentSize) {
38       resizeContent();
39     }
40
41     resizeMap();
42   }
43 </script>