]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/_sidebar.rhtml
Improve the layout of the browse sidebar a bit.
[rails.git] / app / views / site / _sidebar.rhtml
index ae557f90d98bf435ea56ebda3601434d4e000336..ad2845ff47ed8a637f6079e9fbf3ff31017a2124 100644 (file)
 
 <script type="text/javascript">
 <!--
-  function openSidebar() {
+  var onclose;
+
+  function openSidebar(options) {
+    options = options || {};
+
+    if (onclose) {
+       onclose();
+       onclose = null;
+    }
+
+    if (options.width) { $("sidebar").style.width = options.width; }
+    else { $("sidebar").style.width = "30%"; }
+
     $("sidebar").style.display = "block";
+
     <%= onopen %>
+
+    onclose = options.onclose;
   }
 
   function closeSidebar() {
     $("sidebar").style.display = "none";
+
     <%= onclose %>
+
+    if (onclose) {
+       onclose();
+       onclose = null;
+    }
   }
 
   function updateSidebar(title, content) {
     $("sidebar_title").innerHTML = title;
     $("sidebar_content").innerHTML = content;
   }
+
+  function sidebarOpen(title) {
+    return $("sidebar").style.display == "block" &&
+           $("sidebar_title").innerHTML == title;
+  }
 // -->
 </script>