]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/notes.js.erb
Don't try and use OAuth if we don't have a token
[rails.git] / app / assets / javascripts / index / notes.js.erb
index 47a2dc200e153d440b3e9a7babaae7f290b41742..e67749f07d20cbc44e1d188bae244fe0d8912322 100644 (file)
@@ -37,13 +37,15 @@ $(document).ready(function () {
     if (e.layer == noteLayer) {
       map.off("moveend", loadNotes);
       noteLayer.clearLayers();
+      notes = {};
     }
   });
 
   map.on("popupclose", function (e) {
-    if (e.popup == newNote._popup) {
+    if (newNote && e.popup == newNote._popup) {
       $(newNote).oneTime(10, "removenote", function () {
         map.removeLayer(newNote);
+        newNote = null;
       });
     }
   });
@@ -145,10 +147,10 @@ $(document).ready(function () {
       var form = e.target.form;
 
       if ($(e.target).val() == "") {
-        $(form.close).val(I18n.t("javascripts.notes.show.close"));
+        $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
         $(form.comment).prop("disabled", true);
       } else {
-        $(form.close).val(I18n.t("javascripts.notes.show.comment_and_close"));
+        $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
         $(form.comment).prop("disabled", false);
       }
     });
@@ -169,6 +171,7 @@ $(document).ready(function () {
     $.ajax({
       url: url,
       type: "POST",
+      oauth: true,
       data: {
         lat: location.lat,
         lon: location.lng,
@@ -176,8 +179,8 @@ $(document).ready(function () {
       },
       success: function (feature) {
         notes[feature.properties.id] = updateMarker(marker, feature);
+        newNote = null;
 
-        $(".leaflet-popup-close-button").off("click.close");
         $("#createnoteanchor").removeClass("disabled").addClass("geolink");
       }
     });
@@ -189,6 +192,7 @@ $(document).ready(function () {
     $.ajax({
       url: url,
       type: "POST",
+      oauth: true,
       data: {
         text: $(form.text).val()
       },