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 if (!window.location.hash) {
66 var coords = data.coordinates.split(',');
67 OSM.route.moveListenerOff();
68 map.once('moveend', OSM.route.moveListenerOn);
69 map.getZoom() > 15 ? map.panTo(coords) : map.setView(coords, 16);
72 if (!map.hasLayer(halo)) {
73 halo = L.circleMarker(data.coordinates.split(','), {
82 if (map.hasLayer(currentNote)) map.removeLayer(currentNote);
83 currentNote = L.marker(data.coordinates.split(','), {
84 icon: noteIcons[data.status],
88 map.addLayer(currentNote);
91 page.unload = function () {
92 if (map.hasLayer(halo)) map.removeLayer(halo);
93 if (map.hasLayer(currentNote)) map.removeLayer(currentNote);