]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/notes.js.erb
Add a scrollbar when a note gets too big
[rails.git] / app / assets / javascripts / index / notes.js.erb
index 876aeb193d46924a670ee0175cf8881964ddcc02..154c6026df47f279cf3d92eab7bba7f8f1daaa7d 100644 (file)
@@ -61,7 +61,7 @@ $(document).ready(function () {
         opacity: 0.7
       });
 
-      marker.addTo(noteLayer).bindPopup(popupContent);
+      marker.addTo(noteLayer).bindPopup(popupContent, popupOptions());
     }
 
     return marker;
@@ -93,6 +93,12 @@ $(document).ready(function () {
     });
   };
 
+  function popupOptions() {
+    var mapSize = map.getSize();
+
+    return { maxHeight: mapSize.y * 2 / 3 };
+  }
+
   function createPopupContent(marker, properties) {
     var content = $(JST["templates/notes/show"]({ note: properties }));
 
@@ -173,7 +179,7 @@ $(document).ready(function () {
       createNote(marker, e.target.form, $(e.target).data("url"));
     });
 
-    marker.addTo(noteLayer).bindPopup(popupContent[0]).openPopup();
+    marker.addTo(noteLayer).bindPopup(popupContent[0], popupOptions()).openPopup();
 
     $(".leaflet-popup-close-button").on("click.close", function (e) {
       map.removeLayer(marker);