]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/_sidebar.html.erb
Improve handling of sidebar close link
[rails.git] / app / views / site / _sidebar.html.erb
index dd15ef7ba64b2e00ac17de7da3066d3a11c38f0f..481f897957f91d4607279487b962fe37c971781a 100644 (file)
@@ -1,8 +1,8 @@
 <div id="sidebar">
   <table class="sidebar_title" width="100%">
     <tr>
-      <td align="left" id="sidebar_title"><% t 'site.sidebar.search_results' %></td>
-      <td align="right"><a href="javascript:closeSidebar()"><%= t 'site.sidebar.close' %></a></td>
+      <td id="sidebar_title"><% t 'site.sidebar.search_results' %></td>
+      <td id="sidebar_close"><a class="sidebar_close" href="#"><%= t 'site.sidebar.close' %></a></td>
     </tr>
   </table>
   <div id="sidebar_content">
        onclose = null;
     }
 
-    if (options.width) { $("sidebar").style.width = options.width; }
-    else { $("sidebar").style.width = "30%"; }
+    if (options.title) { $("#sidebar_title").html(options.title); }
 
-    $("sidebar").style.display = "block";
+    if (options.width) { $("#sidebar").width(options.width); }
+    else { $("#sidebar").width("30%"); }
+
+    $("#sidebar").css("display", "block");
 
     <%= onopen %>
 
     onclose = options.onclose;
   }
 
-  function closeSidebar() {
-    $("sidebar").style.display = "none";
+  $(".sidebar_close").click(function (e) {
+    $("#sidebar").css("display", "none");
 
     <%= onclose %>
 
        onclose();
        onclose = null;
     }
-  }
 
-  function updateSidebar(title, content) {
-    $("sidebar_title").innerHTML = title;
-    $("sidebar_content").innerHTML = content;
-  }
+    e.preventDefault();
+  });
 
-  function sidebarOpen(title) {
-    return $("sidebar").style.display == "block" &&
-           $("sidebar_title").innerHTML == title;
+  function updateSidebar(title, content) {
+    $("#sidebar_title").html(title);
+    $("#sidebar_content").html(content);
   }
 // -->
 </script>