]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Implement closing sidebar
[rails.git] / app / assets / javascripts / index.js
index 3dd9e78d800581596c1943a8a795e1567ea47f36..db858c7c16bcea52ef7063a108b8e5c75dc9a233 100644 (file)
@@ -222,9 +222,11 @@ $(document).ready(function () {
   initializeNotes(map);
 
   OSM.Index = function(map) {
-    var page = {};
+    var page = {}, minimized = false;
 
     page.pushstate = page.popstate = function(path) {
+      if (minimized) $("#sidebar").addClass("minimized");
+      map.invalidateSize();
       $("#view_tab").addClass("current");
       $('#sidebar_content').load(path);
     };
@@ -233,6 +235,14 @@ $(document).ready(function () {
       $("#view_tab").removeClass("current");
     };
 
+    page.minimizeSidebar = function() {
+      $("#sidebar").addClass("minimized");
+      map.invalidateSize();
+      minimized = true;
+    };
+
+    $(document).on("click", "#sidebar_content .close", page.minimizeSidebar);
+
     return page;
   };
 
@@ -240,6 +250,8 @@ $(document).ready(function () {
     var page = {};
 
     page.pushstate = page.popstate = function(path, type, id) {
+      $("#sidebar").removeClass("minimized");
+      map.invalidateSize();
       $('#sidebar_content').load(path, function() {
         page.load(path, type, id);
       });