1 OSM.Note = function (map) {
2 var content = $("#sidebar_content"),
7 iconUrl: OSM.NEW_NOTE_MARKER,
12 iconUrl: OSM.OPEN_NOTE_MARKER,
17 iconUrl: OSM.CLOSED_NOTE_MARKER,
23 page.pushstate = page.popstate = function (path, id) {
24 OSM.loadSidebarContent(path, function () {
25 initialize(path, id, function () {
26 var data = $(".details").data(),
27 latLng = L.latLng(data.coordinates.split(","));
28 if (!map.getBounds().contains(latLng)) moveToNote();
33 page.load = function (path, id) {
34 initialize(path, id, moveToNote);
37 function initialize(path, id, callback) {
38 content.find("input[type=submit]").on("click", function (e) {
40 var data = $(e.target).data();
41 var form = e.target.form;
43 $(form).find("input[type=submit]").prop("disabled", true);
49 data: { text: $(form.text).val() },
50 success: function () {
51 OSM.loadSidebarContent(path, function () {
52 initialize(path, id, moveToNote);
58 content.find("textarea").on("input", function (e) {
59 var form = e.target.form;
61 if ($(e.target).val() === "") {
62 $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
63 $(form.comment).prop("disabled", true);
65 $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
66 $(form.comment).prop("disabled", false);
70 content.find("textarea").val("").trigger("input");
72 var data = $(".details").data();
77 latLng: L.latLng(data.coordinates.split(",")),
78 icon: noteIcons[data.status]
81 if (callback) callback();
84 function moveToNote() {
85 var data = $(".details").data(),
86 latLng = L.latLng(data.coordinates.split(","));
88 if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
89 OSM.router.withoutMoveListener(function () {
90 map.setView(latLng, 15, { reset: true });
95 page.unload = function () {