X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/853dc286b9c9093d0c1ad2082671111316703e4f..9c7e0e13d79248830a4041877ccdcdb3981a0b7b:/app/assets/javascripts/index/new_note.js.erb?ds=sidebyside diff --git a/app/assets/javascripts/index/new_note.js.erb b/app/assets/javascripts/index/new_note.js.erb index c47cb563c..9990da783 100644 --- a/app/assets/javascripts/index/new_note.js.erb +++ b/app/assets/javascripts/index/new_note.js.erb @@ -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,11 +28,13 @@ OSM.NewNote = function(map) { e.preventDefault(); e.stopPropagation(); - OSM.route('/new_note'); + if ($(this).hasClass('disabled')) return; + + OSM.router.route('/note/new'); }); function createNote(marker, form, url) { - var location = marker.getLatLng(); + var location = marker.getLatLng().wrap(); marker.options.draggable = false; marker.dragging.disable(); @@ -58,7 +61,7 @@ OSM.NewNote = function(map) { newNote = null; noteLayer.removeLayer(marker); addNoteButton.removeClass("active"); - OSM.route('/browse/note/' + feature.properties.id); + OSM.router.route('/note/' + feature.properties.id); } } @@ -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"); @@ -124,10 +149,13 @@ OSM.NewNote = function(map) { e.preventDefault(); createNote(newNote, e.target.form, '/api/0.6/notes.json'); }); + + return map.getState(); }; page.unload = function () { noteLayer.removeLayer(newNote); + map.removeLayer(halo); addNoteButton.removeClass("active"); };