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) {
14 currentChangesetId = id;
16 addChangeset(currentChangesetId, true);
19 function addChangeset(id, center) {
20 map.addObject({type: 'changeset', id: parseInt(id)}, function(bounds) {
21 if (!window.location.hash && bounds.isValid() &&
22 (center || !map.getBounds().contains(bounds))) {
23 OSM.router.withoutMoveListener(function () {
24 map.fitBounds(bounds);
30 function updateChangeset(form, method, url, include_data) {
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);
52 function initialize() {
53 content.find("input[name=comment]").on("click", function (e) {
55 var data = $(e.target).data();
56 updateChangeset(e.target.form, data.method, data.url, true);
59 content.find(".action-button").on("click", function (e) {
61 var data = $(e.target).data();
62 updateChangeset(e.target.form, data.method, data.url);
65 content.find("textarea").on("input", function (e) {
66 var form = e.target.form;
68 if ($(e.target).val() === "") {
69 $(form.comment).prop("disabled", true);
71 $(form.comment).prop("disabled", false);
75 content.find("textarea").val('').trigger("input");
78 page.unload = function() {