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 () {
27 var data = $(".details").data();
29 var latLng = L.latLng(data.coordinates.split(","));
30 if (!map.getBounds().contains(latLng)) moveToNote();
34 page.load = function (path, id) {
39 function initialize(path, id) {
40 content.find("button[name]").on("click", function (e) {
42 var data = $(e.target).data();
43 var name = $(e.target).attr("name");
49 OSM.loadSidebarContent(path, () => {
55 content.find("#comment-error")
56 .text(xhr.responseText)
57 .prop("hidden", false)
58 .get(0).scrollIntoView({ block: "nearest" });
63 if (name !== "subscribe" && name !== "unsubscribe" && name !== "reopen") {
64 ajaxSettings.data = { text: $("textarea").val() };
67 content.find("button[name]").prop("disabled", true);
71 content.find("textarea").on("input", function (e) {
72 updateButtons(e.target.form);
75 content.find("textarea").val("").trigger("input");
77 var data = $(".details").data();
83 latLng: L.latLng(data.coordinates.split(",")),
84 icon: noteIcons[data.status]
89 function updateButtons() {
90 var resolveButton = content.find("button[name='close']");
91 var commentButton = content.find("button[name='comment']");
93 content.find("button[name]").prop("disabled", false);
94 if (content.find("textarea").val() === "") {
95 resolveButton.text(resolveButton.data("defaultActionText"));
96 commentButton.prop("disabled", true);
98 resolveButton.text(resolveButton.data("commentActionText"));
102 function moveToNote() {
103 var data = $(".details").data();
105 var latLng = L.latLng(data.coordinates.split(","));
107 if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
108 OSM.router.withoutMoveListener(function () {
109 map.setView(latLng, 15, { reset: true });
114 page.unload = function () {