]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/note.js
Rename map listeners on history page
[rails.git] / app / assets / javascripts / index / note.js
index 3e8cbce1ba7870da38c2d4e070222a84c154a806..a77735c95966890a66eab7c0b3e52ff8995d04bf 100644 (file)
@@ -2,24 +2,6 @@ OSM.Note = function (map) {
   const content = $("#sidebar_content"),
         page = {};
 
-  const noteIcons = {
-    "new": L.icon({
-      iconUrl: OSM.NEW_NOTE_MARKER,
-      iconSize: [25, 40],
-      iconAnchor: [12, 40]
-    }),
-    "open": L.icon({
-      iconUrl: OSM.OPEN_NOTE_MARKER,
-      iconSize: [25, 40],
-      iconAnchor: [12, 40]
-    }),
-    "closed": L.icon({
-      iconUrl: OSM.CLOSED_NOTE_MARKER,
-      iconSize: [25, 40],
-      iconAnchor: [12, 40]
-    })
-  };
-
   page.pushstate = page.popstate = function (path, id) {
     OSM.loadSidebarContent(path, function () {
       const data = $(".details").data();
@@ -41,8 +23,11 @@ OSM.Note = function (map) {
             data = new URLSearchParams();
       content.find("button[name]").prop("disabled", true);
 
-      if (name !== "subscribe" && name !== "unsubscribe" && name !== "reopen") {
-        data.set("text", content.find("textarea").val());
+      if (name !== "subscribe" && name !== "unsubscribe") {
+        const textarea = content.find("textarea");
+        if (textarea.length) {
+          data.set("text", textarea.val());
+        }
       }
 
       fetch(url, {
@@ -79,12 +64,12 @@ OSM.Note = function (map) {
     const data = $(".details").data();
 
     if (data) {
-      const hashParams = OSM.parseHash(location.hash);
+      const hashParams = OSM.parseHash();
       map.addObject({
         type: "note",
         id: parseInt(id, 10),
         latLng: L.latLng(data.coordinates.split(",")),
-        icon: noteIcons[data.status]
+        icon: OSM.getMarker({ icon: `${data.status}_NOTE_MARKER`, shadow: false, height: 40 })
       }, function () {
         if (!hashParams.center && !skipMoveToNote) {
           const latLng = L.latLng(data.coordinates.split(","));