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 var bounds = 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) {
31 $(form).find("input[type=submit]").prop("disabled", true);
33 data = {text: $(form.text).val()};
43 success: function () {
44 OSM.loadSidebarContent(window.location.pathname, page.load);
49 function initialize() {
50 content.find("input[name=comment]").on("click", function (e) {
52 var data = $(e.target).data();
53 updateChangeset(e.target.form, data.method, data.url, true);
56 content.find(".action-button").on("click", function (e) {
58 var data = $(e.target).data();
59 updateChangeset(e.target.form, data.method, data.url);
62 content.find("textarea").on("input", function (e) {
63 var form = e.target.form;
65 if ($(e.target).val() == "") {
66 $(form.comment).prop("disabled", true);
68 $(form.comment).prop("disabled", false);
72 content.find("textarea").val('').trigger("input");
75 page.unload = function() {