1 OSM.Changeset = function (map) {
3 content = $("#sidebar_content"),
6 page.pushstate = page.popstate = function (path, id) {
7 OSM.loadSidebarContent(path, function () {
12 page.load = function (path, id) {
13 if (id) currentChangesetId = id;
15 addChangeset(currentChangesetId, true);
18 function addChangeset(id, center) {
19 map.addObject({ type: "changeset", id: parseInt(id, 10) }, function (bounds) {
20 if (!window.location.hash && bounds.isValid() &&
21 (center || !map.getBounds().contains(bounds))) {
22 OSM.router.withoutMoveListener(function () {
23 map.fitBounds(bounds);
29 function updateChangeset(form, method, url, include_data) {
32 $(form).find("input[type=submit]").prop("disabled", true);
35 data = { text: $(form.text).val() };
45 success: function () {
46 OSM.loadSidebarContent(window.location.pathname, page.load);
51 function initialize() {
52 content.find("input[name=comment]").on("click", function (e) {
54 var data = $(e.target).data();
55 updateChangeset(e.target.form, data.method, data.url, true);
58 content.find(".action-button").on("click", function (e) {
60 var data = $(e.target).data();
61 updateChangeset(e.target.form, data.method, data.url);
64 content.find("textarea").on("input", function (e) {
65 var form = e.target.form;
67 if ($(e.target).val() === "") {
68 $(form.comment).prop("disabled", true);
70 $(form.comment).prop("disabled", false);
74 content.find("textarea").val("").trigger("input");
77 page.unload = function () {