1 OSM.History = function(map) {
5 .on("click", ".changeset_more a", loadMore)
6 .on("mouseover", "[data-changeset]", function () {
7 highlightChangeset($(this).data("changeset").id);
9 .on("mouseout", "[data-changeset]", function () {
10 unHighlightChangeset($(this).data("changeset").id);
12 .on("click", "[data-changeset]", function () {
13 clickChangeset($(this).data("changeset").id);
16 var group = L.featureGroup()
17 .on("mouseover", function (e) {
18 highlightChangeset(e.layer.id);
20 .on("mouseout", function (e) {
21 unHighlightChangeset(e.layer.id);
23 .on("click", function (e) {
24 clickChangeset(e.layer.id);
27 group.getLayerId = function(layer) {
31 function highlightChangeset(id) {
32 group.getLayer(id).setStyle({fillOpacity: 0.3});
33 $("#changeset_" + id).addClass("selected");
36 function unHighlightChangeset(id) {
37 group.getLayer(id).setStyle({fillOpacity: 0});
38 $("#changeset_" + id).removeClass("selected");
41 function clickChangeset(id) {
42 OSM.route($("#changeset_" + id).find(".changeset_id").attr("href"));
47 url: window.location.pathname,
49 data: {bbox: map.getBounds().toBBoxString()},
50 success: function(html) {
51 $('#sidebar_content .changesets').html(html);
57 function loadMore(e) {
61 var div = $(this).parents(".changeset_more");
64 div.find(".loader").show();
66 $.get($(this).attr("href"), function(data) {
67 div.replaceWith(data);
72 function updateMap() {
77 $("[data-changeset]").each(function () {
78 var changeset = $(this).data('changeset');
80 changeset.bounds = L.latLngBounds(
81 [changeset.bbox.minlat, changeset.bbox.minlon],
82 [changeset.bbox.maxlat, changeset.bbox.maxlon]);
83 changesets.push(changeset);
87 changesets.sort(function (a, b) {
88 return b.bounds.getSize() - a.bounds.getSize();
91 for (var i = 0; i < changesets.length; ++i) {
92 var changeset = changesets[i],
93 rect = L.rectangle(changeset.bounds,
94 {weight: 1, color: "#FF9500", opacity: 1, fillColor: "#FFFFBF", fillOpacity: 0});
95 rect.id = changeset.id;
100 page.pushstate = page.popstate = function(path) {
101 $("#history_tab").addClass("current");
102 $("#sidebar_content").load(path, page.load);
105 page.load = function() {
107 .on("moveend", loadData)
113 page.unload = function() {
115 .off("moveend", loadData)
119 $("#history_tab").removeClass("current");