]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/new_note.js.erb
Fixed border consistency
[rails.git] / app / assets / javascripts / index / new_note.js.erb
index c47cb563c9ffa91abc93e71ddb23d659ee93fafb..780bccbca1958abe25bcc91badebc0095719a505 100644 (file)
@@ -3,7 +3,8 @@ OSM.NewNote = function(map) {
     content = $('#sidebar_content'),
     page = {},
     addNoteButton = $(".control-note .control-button"),
-    newNote;
+    newNote,
+    halo;
 
   var noteIcons = {
     "new": L.icon({
@@ -27,6 +28,8 @@ OSM.NewNote = function(map) {
     e.preventDefault();
     e.stopPropagation();
 
+    if ($(this).hasClass('disabled')) return;
+
     OSM.route('/new_note');
   });
 
@@ -77,6 +80,23 @@ OSM.NewNote = function(map) {
     OSM.loadSidebarContent(path, page.load);
   };
 
+  function newHalo(loc, a) {
+    if (a == 'dragstart' && map.hasLayer(halo)) {
+      map.removeLayer(halo);
+    } else {
+      if (map.hasLayer(halo)) map.removeLayer(halo);
+
+      halo = L.circleMarker(loc, {
+        weight: 2.5,
+        radius: 20,
+        fillOpacity: 0.5,
+        color: "#FF6200"
+      });
+
+      map.addLayer(halo);
+    }
+  }
+
   page.load = function () {
     if (addNoteButton.hasClass("disabled")) return;
     if (addNoteButton.hasClass("active")) return;
@@ -102,7 +122,12 @@ OSM.NewNote = function(map) {
       draggable: true
     });
 
+    newNote.on("dragstart dragend", function(a) {
+      newHalo(newNote.getLatLng(), a.type);
+    });
+
     newNote.addTo(noteLayer);
+    newHalo(newNote.getLatLng());
 
     newNote.on("remove", function () {
       addNoteButton.removeClass("active");
@@ -128,6 +153,7 @@ OSM.NewNote = function(map) {
 
   page.unload = function () {
     noteLayer.removeLayer(newNote);
+    map.removeLayer(halo);
     addNoteButton.removeClass("active");
   };