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(marker, form, method, url) {
26 $(form).find("input[type=submit]").prop("disabled", true);
32 data: {text: $(form.text).val()},
33 success: function (feature) {
34 marker = noteLayer.getLayer(marker);
35 if (feature.properties.status == "hidden") {
36 noteLayer.removeLayer(marker);
38 marker.setIcon(noteIcons[feature.properties.status]);
46 content.find("input[type=submit]").on("click", function (e) {
48 var data = $(e.target).data();
49 updateNote(data.noteId, e.target.form, data.method, data.url);
52 content.find("textarea").on("input", function (e) {
53 var form = e.target.form;
55 if ($(e.target).val() == "") {
56 $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
57 $(form.comment).prop("disabled", true);
59 $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
60 $(form.comment).prop("disabled", false);
64 content.find("textarea").val('').trigger("input");
67 page.pushstate = page.popstate = function () {
71 page.load = function () {
72 var loadTimer = setTimeout(setLoading, 250);
73 $('#sidebar_content').load(window.location.pathname + "?xhr=1", function (a, b, xhr) {
74 if (xhr.getResponseHeader('X-Page-Title')) {
75 document.title = xhr.getResponseHeader('X-Page-Title');
78 clearTimeout(loadTimer);
81 if (!map.hasLayer(noteLayer)) map.addLayer(noteLayer);
82 if (window.location.hash == "") map.panTo($('.details').data().coordinates.split(','));
86 page.unload = function () {
87 if (marker) map.removeLayer(marker);
90 function setLoading() {
91 if ($('#browse_status').is(':empty')) {
92 $('#browse_status').append($('<p></p>').text(I18n.t('browse.start_rjs.loading')));
96 function clearLoading() {
97 $('#browse_status').empty();