X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/7d92ec704786c2d887e1946f25746d6d70ee7ea8..bf7b2cf38194380c56fbb419ced588a29c27f7b8:/app/assets/javascripts/changeset.js diff --git a/app/assets/javascripts/changeset.js b/app/assets/javascripts/changeset.js index 6ad1fd7fa..d9c09bab4 100644 --- a/app/assets/javascripts/changeset.js +++ b/app/assets/javascripts/changeset.js @@ -1,28 +1,46 @@ $(document).ready(function () { - var rects = {}; - var map = createMap("changeset_list_map"); + var changesets = [], rects = {}; + + var map = L.map("changeset_list_map", { + attributionControl: false, + zoomControl: false + }).addLayer(new L.OSM.Mapnik()); + + L.OSM.zoom() + .addTo(map); + var group = L.featureGroup().addTo(map); $("[data-changeset]").each(function () { var changeset = $(this).data('changeset'); if (changeset.bbox) { - var rect = L.rectangle([[changeset.bbox.minlat, changeset.bbox.minlon], - [changeset.bbox.maxlat, changeset.bbox.maxlon]], - {weight: 2, color: "#ee9900", fillColor: "#ffff55", fillOpacity: 0}); - rect.id = changeset.id; - rects[changeset.id] = rect; - rect.addTo(group); + changeset.bounds = L.latLngBounds([changeset.bbox.minlat, changeset.bbox.minlon], + [changeset.bbox.maxlat, changeset.bbox.maxlon]); + changesets.push(changeset); } }); + changesets.sort(function (a, b) { + return b.bounds.getSize() - a.bounds.getSize(); + }); + + for (var i = 0; i < changesets.length; ++i) { + var changeset = changesets[i], + rect = L.rectangle(changeset.bounds, + {weight: 2, color: "#ee9900", fillColor: "#ffff55", fillOpacity: 0}); + rect.id = changeset.id; + rects[changeset.id] = rect; + rect.addTo(group); + } + function highlightChangeset(id) { rects[id].setStyle({fillOpacity: 0.5}); - $("#tr-changeset-" + id).addClass("selected"); + $("#changeset_" + id).addClass("selected"); } function unHighlightChangeset(id) { rects[id].setStyle({fillOpacity: 0}); - $("#tr-changeset-" + id).removeClass("selected"); + $("#changeset_" + id).removeClass("selected"); } group.on({ @@ -43,11 +61,13 @@ $(document).ready(function () { } }); - var params = OSM.mapParams(); - if (params.bbox) { - map.fitBounds([[params.minlat, params.minlon], - [params.maxlat, params.maxlon]]); - } else { - map.fitBounds(group.getBounds()); - } + $(window).scroll(function() { + if ($(window).scrollTop() > $('.content-heading').outerHeight() + $('#top-bar').outerHeight() ) { + $('#changeset_list_map_wrapper').addClass('scrolled'); + } else { + $('#changeset_list_map_wrapper').removeClass('scrolled'); + } + }); + + map.fitBounds(OSM.mapParams().bounds || group.getBounds()); });