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