1 OSM.Note = function(map) {
2 var noteLayer = map.noteLayer,
3 content = $('#sidebar_content'),
8 iconUrl: "<%= image_path('new_note_marker.png') %>",
13 iconUrl: "<%= image_path('open_note_marker.png') %>",
18 iconUrl: "<%= image_path('closed_note_marker.png') %>",
24 function updateNote(marker, form, method, url) {
25 $(form).find("input[type=submit]").prop("disabled", true);
31 data: {text: $(form.text).val()},
32 success: function (feature) {
33 marker = noteLayer.getLayer(marker);
34 if (feature.properties.status == "hidden") {
35 noteLayer.removeLayer(marker);
37 marker.setIcon(noteIcons[feature.properties.status]);
45 content.find("input[type=submit]").on("click", function (e) {
47 var data = $(e.target).data();
48 updateNote(data.noteId, e.target.form, data.method, data.url);
51 content.find("textarea").on("input", function (e) {
52 var form = e.target.form;
54 if ($(e.target).val() == "") {
55 $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
56 $(form.comment).prop("disabled", true);
58 $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
59 $(form.comment).prop("disabled", false);
63 content.find("textarea").val('').trigger("input");
66 page.pushstate = page.popstate = function() {
70 page.load = function() {
71 $('#sidebar_content').load(window.location.pathname + "?xhr=1", function(a, b, xhr) {
72 if (xhr.getResponseHeader('X-Page-Title')) {
73 document.title = xhr.getResponseHeader('X-Page-Title');