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("#comment-error").prop("hidden", true);
 
  33     $(form).find("input[type=submit]").prop("disabled", true);
 
  36       data = { text: $(form.text).val() };
 
  46       success: function () {
 
  47         OSM.loadSidebarContent(window.location.pathname, page.load);
 
  49       error: function (xhr) {
 
  50         $(form).find("#comment-error").text(xhr.responseText);
 
  51         $(form).find("#comment-error").prop("hidden", false);
 
  52         $(form).find("input[type=submit]").prop("disabled", false);
 
  57   function initialize() {
 
  58     content.find("input[name=comment]").on("click", function (e) {
 
  60       var data = $(e.target).data();
 
  61       updateChangeset(e.target.form, data.method, data.url, true);
 
  64     content.find(".action-button").on("click", function (e) {
 
  66       var data = $(e.target).data();
 
  67       updateChangeset(e.target.form, data.method, data.url);
 
  70     content.find("textarea").on("input", function (e) {
 
  71       var form = e.target.form;
 
  73       if ($(e.target).val() === "") {
 
  74         $(form.comment).prop("disabled", true);
 
  76         $(form.comment).prop("disabled", false);
 
  80     content.find("textarea").val("").trigger("input");
 
  83   page.unload = function () {