1 OSM.Changeset = function (map) {
3 content = $("#sidebar_content");
5 page.pushstate = page.popstate = function (path) {
6 OSM.loadSidebarContent(path, function () {
11 page.load = function () {
12 const changesetData = content.find("[data-changeset]").data("changeset");
13 changesetData.type = "changeset";
16 map.addObject(changesetData, function (bounds) {
17 if (!window.location.hash && bounds.isValid()) {
18 OSM.router.withoutMoveListener(function () {
19 map.fitBounds(bounds);
25 function updateChangeset(method, url, include_data) {
28 content.find("#comment-error").prop("hidden", true);
29 content.find("button[data-method][data-url]").prop("disabled", true);
32 data = { text: content.find("textarea").val() };
42 success: function () {
43 OSM.loadSidebarContent(window.location.pathname, page.load);
45 error: function (xhr) {
46 content.find("button[data-method][data-url]").prop("disabled", false);
47 content.find("#comment-error")
48 .text(xhr.responseText)
49 .prop("hidden", false)
50 .get(0).scrollIntoView({ block: "nearest" });
55 function initialize() {
56 content.find("button[data-method][data-url]").on("click", function (e) {
58 var data = $(e.target).data();
59 var include_data = e.target.name === "comment";
60 updateChangeset(data.method, data.url, include_data);
63 content.find("textarea").on("input", function (e) {
64 var form = e.target.form;
66 if ($(e.target).val() === "") {
67 $(form.comment).prop("disabled", true);
69 $(form.comment).prop("disabled", false);
73 content.find("textarea").val("").trigger("input");
76 page.unload = function () {