X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/9d5b81094c69a02782faead1528ef32ffcc48aea..6157280d19ca65b3ff00fd8c1f4dfc94fcbdb64c:/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 2d807eb92..4538e9968 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -2,8 +2,7 @@ //= require templates/notes/new function initializeNotes(map) { - var params = OSM.mapParams(), - noteLayer = map.noteLayer, + var noteLayer = map.noteLayer, notes = {}, newNote; @@ -49,20 +48,17 @@ function initializeNotes(map) { } }); - if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { - if (params.notes || params.layers.indexOf('N') >= 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) { @@ -188,7 +184,7 @@ function initializeNotes(map) { notes[feature.properties.id] = updateMarker(marker, feature); newNote = null; - addNoteButton.removeClass("disabled"); + addNoteButton.removeClass("active"); } } @@ -222,8 +218,9 @@ function initializeNotes(map) { e.stopPropagation(); if (addNoteButton.hasClass("disabled")) return; + if (addNoteButton.hasClass("active")) return; - addNoteButton.addClass("disabled"); + addNoteButton.addClass("active"); map.addLayer(noteLayer); @@ -260,7 +257,7 @@ function initializeNotes(map) { newNote.addTo(noteLayer).bindPopup(popupContent[0], popupOptions()).openPopup(); newNote.on("remove", function (e) { - addNoteButton.removeClass("disabled"); + addNoteButton.removeClass("active"); }).on("dragstart", function (e) { $(newNote).stopTime("removenote"); }).on("dragend", function (e) {