X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/04fbc71a40ba73f9d9ba7253fc076b54c3d7ec84..cdfe2ac21ec01344b4b10d566582e7cc2b2eb7cb:/app/assets/javascripts/index/notes.js.erb diff --git a/app/assets/javascripts/index/notes.js.erb b/app/assets/javascripts/index/notes.js.erb index 8972d6bf9..4538e9968 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -1,7 +1,7 @@ //= require templates/notes/show //= require templates/notes/new -function initializeNotes(map, params) { +function initializeNotes(map) { var noteLayer = map.noteLayer, notes = {}, newNote; @@ -48,23 +48,17 @@ function initializeNotes(map, params) { } }); - if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { - if (params.layers.indexOf(noteLayer.options.code) >= 0) { - map.addLayer(noteLayer); - } - - if (params.note) { - $.ajax({ - url: "/api/" + OSM.API_VERSION + "/notes/" + params.note + ".json", - success: function (feature) { - var marker = updateMarker(notes[feature.properties.id], feature); - notes[feature.properties.id] = marker; - map.addLayer(noteLayer); - marker.openPopup(); - } - }); - } - } + noteLayer.showNote = function(id) { + $.ajax({ + url: "/api/" + OSM.API_VERSION + "/notes/" + id + ".json", + success: function (feature) { + var marker = updateMarker(notes[feature.properties.id], feature); + notes[feature.properties.id] = marker; + map.addLayer(noteLayer); + marker.openPopup(); + } + }); + }; function updateMarker(marker, feature) { if (marker) { @@ -190,7 +184,7 @@ function initializeNotes(map, params) { notes[feature.properties.id] = updateMarker(marker, feature); newNote = null; - addNoteButton.removeClass("active").addClass("geolink"); + addNoteButton.removeClass("active"); } } @@ -226,7 +220,7 @@ function initializeNotes(map, params) { if (addNoteButton.hasClass("disabled")) return; if (addNoteButton.hasClass("active")) return; - addNoteButton.removeClass("geolink").addClass("active"); + addNoteButton.addClass("active"); map.addLayer(noteLayer); @@ -263,7 +257,7 @@ function initializeNotes(map, params) { newNote.addTo(noteLayer).bindPopup(popupContent[0], popupOptions()).openPopup(); newNote.on("remove", function (e) { - addNoteButton.removeClass("active").addClass("geolink"); + addNoteButton.removeClass("active"); }).on("dragstart", function (e) { $(newNote).stopTime("removenote"); }).on("dragend", function (e) {