1 //= require templates/notes/show
2 //= require templates/notes/new
4 OSM.Note = function(map) {
5 var noteLayer = map.noteLayer,
6 content = $('#sidebar_content'),
11 iconUrl: "<%= image_path('new_note_marker.png') %>",
16 iconUrl: "<%= image_path('open_note_marker.png') %>",
21 iconUrl: "<%= image_path('closed_note_marker.png') %>",
27 function updateNote(marker, form, method, url) {
28 $(form).find("input[type=submit]").prop("disabled", true);
34 data: {text: $(form.text).val()},
35 success: function (feature) {
36 marker = noteLayer.getLayer(marker);
37 if (feature.properties.status == "hidden") {
38 noteLayer.removeLayer(marker);
40 marker.setIcon(noteIcons[feature.properties.status]);
48 content.find("input[type=submit]").on("click", function (e) {
50 var data = $(e.target).data();
51 updateNote(data.noteId, e.target.form, data.method, data.url);
54 content.find("textarea").on("input", function (e) {
55 var form = e.target.form;
57 if ($(e.target).val() == "") {
58 $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
59 $(form.comment).prop("disabled", true);
61 $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
62 $(form.comment).prop("disabled", false);
66 content.find("textarea").val('').trigger("input");
69 page.pushstate = page.popstate = function(path) {
73 page.load = function() {
74 $('#sidebar_content').load(window.location.pathname + "?xhr=1", function(a, b, xhr) {
75 if (xhr.getResponseHeader('X-Page-Title')) {
76 document.title = xhr.getResponseHeader('X-Page-Title');