1 OSM.Note = function (map) {
2 var noteLayer = map.noteLayer,
3 content = $('#sidebar_content'),
9 iconUrl: "<%= image_path('new_note_marker.png') %>",
14 iconUrl: "<%= image_path('open_note_marker.png') %>",
19 iconUrl: "<%= image_path('closed_note_marker.png') %>",
25 function updateNote(form, method, url) {
26 $(form).find("input[type=submit]").prop("disabled", true);
32 data: {text: $(form.text).val()},
33 success: function () {
34 OSM.loadSidebarContent(window.location.pathname, page.load);
39 page.pushstate = page.popstate = function (path) {
40 OSM.loadSidebarContent(path, page.load);
43 page.load = function () {
44 content.find("input[type=submit]").on("click", function (e) {
46 var data = $(e.target).data();
47 updateNote(e.target.form, data.method, data.url);
50 content.find("textarea").on("input", function (e) {
51 var form = e.target.form;
53 if ($(e.target).val() == "") {
54 $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
55 $(form.comment).prop("disabled", true);
57 $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
58 $(form.comment).prop("disabled", false);
62 content.find("textarea").val('').trigger("input");
64 var data = $('.details').data(),
65 latLng = data.coordinates.split(',');
67 if (!window.location.hash) {
68 OSM.route.moveListenerOff();
69 map.once('moveend', OSM.route.moveListenerOn);
70 map.getZoom() > 15 ? map.panTo(latLng) : map.setView(latLng, 16);
73 if (!map.hasLayer(halo)) {
74 halo = L.circleMarker(latLng, {
83 if (map.hasLayer(currentNote)) map.removeLayer(currentNote);
84 currentNote = L.marker(latLng, {
85 icon: noteIcons[data.status],
89 map.addLayer(currentNote);
92 page.unload = function () {
93 if (map.hasLayer(halo)) map.removeLayer(halo);
94 if (map.hasLayer(currentNote)) map.removeLayer(currentNote);