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();
28 var latLng = L.latLng(data.coordinates.split(","));
29 if (!map.getBounds().contains(latLng)) moveToNote();
34 page.load = function (path, id) {
35 initialize(path, id, moveToNote);
38 function initialize(path, id, callback) {
39 content.find("input[type=submit]").on("click", function (e) {
41 var data = $(e.target).data();
42 var form = e.target.form;
44 $(form).find("input[type=submit]").prop("disabled", true);
50 data: { text: $(form.text).val() },
51 success: function () {
52 OSM.loadSidebarContent(path, function () {
53 initialize(path, id, moveToNote);
59 content.find("textarea").on("input", function (e) {
60 var form = e.target.form;
62 if ($(e.target).val() === "") {
63 $(form.close).val(I18n.t("javascripts.notes.show.resolve"));
64 $(form.comment).prop("disabled", true);
66 $(form.close).val(I18n.t("javascripts.notes.show.comment_and_resolve"));
67 $(form.comment).prop("disabled", false);
71 content.find("textarea").val("").trigger("input");
73 var data = $(".details").data();
79 latLng: L.latLng(data.coordinates.split(",")),
80 icon: noteIcons[data.status]
84 if (callback) callback();
87 function moveToNote() {
88 var data = $(".details").data();
90 var latLng = L.latLng(data.coordinates.split(","));
92 if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
93 OSM.router.withoutMoveListener(function () {
94 map.setView(latLng, 15, { reset: true });
99 page.unload = function () {