]> git.openstreetmap.org Git - rails.git/commitdiff
Fix add note
authorJohn Firebaugh <john.firebaugh@gmail.com>
Thu, 13 Jun 2013 21:56:42 +0000 (14:56 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Thu, 18 Jul 2013 17:45:16 +0000 (10:45 -0700)
app/assets/javascripts/index.js
app/assets/javascripts/index/notes.js.erb
app/assets/javascripts/leaflet.note.js
app/assets/javascripts/templates/notes/new.jst.ejs
app/assets/stylesheets/common.css.scss

index 7744b1ae4c15bc20b3ed9d08f61fb4deccd58671..7988541a680fb4b12d8d13d044a544d2cae49ff4 100644 (file)
@@ -75,11 +75,6 @@ $(document).ready(function () {
     sidebar: sidebar
   }).addTo(map);
 
     sidebar: sidebar
   }).addTo(map);
 
-  L.OSM.note({
-    position: 'topright',
-    sidebar: sidebar
-  }).addTo(map);
-
   L.OSM.share({
     getShortUrl: getShortUrl,
     getUrl: getUrl,
   L.OSM.share({
     getShortUrl: getShortUrl,
     getUrl: getUrl,
@@ -87,6 +82,11 @@ $(document).ready(function () {
     short: true
   }).addTo(map);
 
     short: true
   }).addTo(map);
 
+  L.OSM.note({
+    position: 'topright',
+    sidebar: sidebar
+  }).addTo(map);
+
   L.control.scale()
     .addTo(map);
 
   L.control.scale()
     .addTo(map);
 
index 3a2a153936fb438d64daa0ebf61f948874beb555..2d807eb92e6ccab6554f6249587aada0cf5c11c2 100644 (file)
@@ -160,6 +160,8 @@ function initializeNotes(map) {
     return content[0];
   }
 
     return content[0];
   }
 
+  var addNoteButton = $(".control-note .control-button");
+
   function createNote(marker, form, url) {
     var location = marker.getLatLng();
 
   function createNote(marker, form, url) {
     var location = marker.getLatLng();
 
@@ -186,7 +188,7 @@ function initializeNotes(map) {
       notes[feature.properties.id] = updateMarker(marker, feature);
       newNote = null;
 
       notes[feature.properties.id] = updateMarker(marker, feature);
       newNote = null;
 
-      $("#createnoteanchor").removeClass("disabled").addClass("geolink");
+      addNoteButton.removeClass("disabled");
     }
   }
 
     }
   }
 
@@ -215,12 +217,13 @@ function initializeNotes(map) {
     });
   }
 
     });
   }
 
-  $(".leaflet-control-attribution").on("click", "#createnoteanchor", function (e) {
+  addNoteButton.on("click", function (e) {
     e.preventDefault();
     e.preventDefault();
+    e.stopPropagation();
 
 
-    if ($(e.target).hasClass("disabled")) return;
+    if (addNoteButton.hasClass("disabled")) return;
 
 
-    $(e.target).removeClass("geolink").addClass("disabled");
+    addNoteButton.addClass("disabled");
 
     map.addLayer(noteLayer);
 
 
     map.addLayer(noteLayer);
 
@@ -241,25 +244,23 @@ function initializeNotes(map) {
       draggable: true
     });
 
       draggable: true
     });
 
-    var popupContent = $(JST["templates/notes/new"]({
-        create_url: $(e.target).attr("href")
-    }));
+    var popupContent = $(JST["templates/notes/new"]());
 
     popupContent.find("textarea").on("input", disableWhenBlank);
 
     function disableWhenBlank(e) {
 
     popupContent.find("textarea").on("input", disableWhenBlank);
 
     function disableWhenBlank(e) {
-      $(e.target.form).prop("disabled", $(e.target).val() === "");
+      $(e.target.form.add).prop("disabled", $(e.target).val() === "");
     }
 
     popupContent.find("input[type=submit]").on("click", function (e) {
       e.preventDefault();
     }
 
     popupContent.find("input[type=submit]").on("click", function (e) {
       e.preventDefault();
-      createNote(newNote, e.target.form, $(e.target).data("url"));
+      createNote(newNote, e.target.form, '/api/0.6/notes.json');
     });
 
     newNote.addTo(noteLayer).bindPopup(popupContent[0], popupOptions()).openPopup();
 
     newNote.on("remove", function (e) {
     });
 
     newNote.addTo(noteLayer).bindPopup(popupContent[0], popupOptions()).openPopup();
 
     newNote.on("remove", function (e) {
-      $("#createnoteanchor").removeClass("disabled").addClass("geolink");
+      addNoteButton.removeClass("disabled");
     }).on("dragstart", function (e) {
       $(newNote).stopTime("removenote");
     }).on("dragend", function (e) {
     }).on("dragstart", function (e) {
       $(newNote).stopTime("removenote");
     }).on("dragend", function (e) {
index 68e09c88deb90a4403479d5b30660f53f04c522a..77fb9baff90f3afc6936dfdd7d4a599fda8daf30 100644 (file)
@@ -8,22 +8,10 @@ L.OSM.note = function (options) {
     $('<a>')
       .attr('class', 'control-button')
       .attr('href', '#')
     $('<a>')
       .attr('class', 'control-button')
       .attr('href', '#')
-      .attr('title', 'Notes')
+      .attr('title', I18n.t('javascripts.notes.new.add'))
       .html('<span class="icon note"></span>')
       .html('<span class="icon note"></span>')
-      .on('click', toggle)
       .appendTo($container);
 
       .appendTo($container);
 
-    function toggle(e) {
-      e.stopPropagation();
-      e.preventDefault();
-
-      if (map.hasLayer(map.noteLayer)) {
-        map.removeLayer(map.noteLayer);
-      } else {
-        map.addLayer(map.noteLayer);
-      }
-    }
-
     return $container[0];
   };
 
     return $container[0];
   };
 
index a4ea5079ae31dc908ed3faf3b1e11fa20b5cf8a0..003971088cd37a626b20da30e05387f96522756f 100644 (file)
@@ -6,7 +6,7 @@
     <textarea class="comment" name="text" cols="40" rows="10"></textarea>
     <br/>
     <div class="buttons clearfix">
     <textarea class="comment" name="text" cols="40" rows="10"></textarea>
     <br/>
     <div class="buttons clearfix">
-      <input type="submit" name="add" value="<%- I18n.t('javascripts.notes.new.add') %>" data-url="<%- create_url %>" disabled="1">
+      <input type="submit" name="add" value="<%- I18n.t('javascripts.notes.new.add') %>" disabled="1">
     </div>
   </form>
 </div>
     </div>
   </form>
 </div>
index 484d5661e0ef16427b2a9ca5b398d5dd20e3e718..b45d43bcb469d0dc3756dfac402817dd16e8e215 100644 (file)
@@ -556,19 +556,18 @@ a.donate {
 }
 
 .leaflet-control .zoomin,
 }
 
 .leaflet-control .zoomin,
-.control-layers .control-button,
-.control-note .control-button {
+.control-layers .control-button {
   margin-bottom: 0px;
   border-radius: 4px 4px 0px 0px;
 }
 
   margin-bottom: 0px;
   border-radius: 4px 4px 0px 0px;
 }
 
-.leaflet-control .zoomout {
+.leaflet-control .zoomout,
+.control-key .control-button {
   margin-bottom: 0px;
   border-radius: 0px;
 }
 
 .control-locate .control-button,
   margin-bottom: 0px;
   border-radius: 0px;
 }
 
 .control-locate .control-button,
-.control-key .control-button,
 .control-share .control-button {
   border-radius: 0px 0px 4px 4px;
 }
 .control-share .control-button {
   border-radius: 0px 0px 4px 4px;
 }