Refine changeset browse behavior
The general history view shows changesets in the current view and updates when you move the map. The view for an individual user, nearby users, or friends zooms the map to the extent of the results, and doesn't change when you move the map.
This commit is contained in:
parent
a5e8b4cb88
commit
d0de36b607
5 changed files with 41 additions and 28 deletions
|
@ -242,19 +242,18 @@ $(document).ready(function () {
|
||||||
return page;
|
return page;
|
||||||
};
|
};
|
||||||
|
|
||||||
var history = OSM.History(map),
|
var history = OSM.History(map);
|
||||||
note = OSM.Note(map);
|
|
||||||
|
|
||||||
OSM.route = OSM.Router(map, {
|
OSM.route = OSM.Router(map, {
|
||||||
"/": OSM.Index(map),
|
"/": OSM.Index(map),
|
||||||
"/search": OSM.Search(map),
|
"/search": OSM.Search(map),
|
||||||
"/export": OSM.Export(map),
|
"/export": OSM.Export(map),
|
||||||
"/history": history,
|
|
||||||
"/new_note": OSM.NewNote(map),
|
"/new_note": OSM.NewNote(map),
|
||||||
|
"/history": history,
|
||||||
"/user/:display_name/edits": history,
|
"/user/:display_name/edits": history,
|
||||||
"/browse/friends": history,
|
"/browse/friends": history,
|
||||||
"/browse/nearby": history,
|
"/browse/nearby": history,
|
||||||
"/browse/note/:id": note,
|
"/browse/note/:id": OSM.Note(map),
|
||||||
"/browse/:type/:id(/history)": OSM.Browse(map)
|
"/browse/:type/:id(/history)": OSM.Browse(map)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,16 @@ OSM.History = function(map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadData() {
|
function loadData() {
|
||||||
|
var data = {};
|
||||||
|
|
||||||
|
if (window.location.pathname === '/history') {
|
||||||
|
data = {bbox: map.getBounds().wrap().toBBoxString()};
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: window.location.pathname,
|
url: window.location.pathname,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
data: {bbox: map.getBounds().wrap().toBBoxString()},
|
data: data,
|
||||||
success: function(html, status, xhr) {
|
success: function(html, status, xhr) {
|
||||||
$('#sidebar_content .changesets').html(html);
|
$('#sidebar_content .changesets').html(html);
|
||||||
updateMap();
|
updateMap();
|
||||||
|
@ -95,6 +101,11 @@ OSM.History = function(map) {
|
||||||
rect.id = changeset.id;
|
rect.id = changeset.id;
|
||||||
rect.addTo(group);
|
rect.addTo(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window.location.pathname !== '/history') {
|
||||||
|
var bounds = group.getBounds();
|
||||||
|
if (bounds.isValid()) map.fitBounds(bounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
page.pushstate = page.popstate = function(path) {
|
page.pushstate = page.popstate = function(path) {
|
||||||
|
@ -103,19 +114,22 @@ OSM.History = function(map) {
|
||||||
};
|
};
|
||||||
|
|
||||||
page.load = function() {
|
page.load = function() {
|
||||||
map
|
map.addLayer(group);
|
||||||
.on("moveend", loadData)
|
|
||||||
.addLayer(group);
|
if (window.location.pathname === '/history') {
|
||||||
|
map.on("moveend", loadData)
|
||||||
|
}
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
};
|
};
|
||||||
|
|
||||||
page.unload = function() {
|
page.unload = function() {
|
||||||
map
|
map.removeLayer(group);
|
||||||
.off("moveend", loadData)
|
|
||||||
.removeLayer(group);
|
if (window.location.pathname === '/history') {
|
||||||
|
map.off("moveend", loadData)
|
||||||
|
}
|
||||||
|
|
||||||
group.clearLayers();
|
|
||||||
$("#history_tab").removeClass("current");
|
$("#history_tab").removeClass("current");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -279,18 +279,12 @@ class ChangesetController < ApplicationController
|
||||||
else
|
else
|
||||||
changesets = changesets.where("false")
|
changesets = changesets.where("false")
|
||||||
end
|
end
|
||||||
end
|
elsif params[:bbox]
|
||||||
|
|
||||||
if params[:friends] && @user
|
|
||||||
changesets = changesets.where(:user_id => @user.friend_users.public)
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:nearby] && @user
|
|
||||||
changesets = changesets.where(:user_id => @user.nearby)
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:bbox]
|
|
||||||
changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params))
|
changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params))
|
||||||
|
elsif params[:friends] && @user
|
||||||
|
changesets = changesets.where(:user_id => @user.friend_users.public)
|
||||||
|
elsif params[:nearby] && @user
|
||||||
|
changesets = changesets.where(:user_id => @user.nearby)
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:max_id]
|
if params[:max_id]
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
<%= link_to t('changeset.list.load_more'), url_for(params.merge(:max_id => @edits.last.id - 1)), :class => "button load_more" %>
|
<%= link_to t('changeset.list.load_more'), url_for(params.merge(:max_id => @edits.last.id - 1)), :class => "button load_more" %>
|
||||||
<%= image_tag "searching.gif", :class => "loader", :style => "display: none;" %>
|
<%= image_tag "searching.gif", :class => "loader", :style => "display: none;" %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif params[:max_id] %>
|
<% elsif params[:bbox] %>
|
||||||
<div class="inner22"><%= t('changeset.list.no_more') %></div>
|
<div class="inner22"><%= t(params[:max_id] ? 'changeset.list.no_more_area' : 'changeset.list.empty_area') %></div>
|
||||||
|
<% elsif params[:display_name] %>
|
||||||
|
<div class="inner22"><%= t(params[:max_id] ? 'changeset.list.no_more_user' : 'changeset.list.empty_user') %></div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="inner22"><%= t('changeset.list.empty') %></div>
|
<div class="inner22"><%= t(params[:max_id] ? 'changeset.list.no_more' : 'changeset.list.empty') %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -214,8 +214,12 @@ en:
|
||||||
title_user: "Changesets by %{user}"
|
title_user: "Changesets by %{user}"
|
||||||
title_friend: "Changesets by your friends"
|
title_friend: "Changesets by your friends"
|
||||||
title_nearby: "Changesets by nearby users"
|
title_nearby: "Changesets by nearby users"
|
||||||
empty: "No changesets in this area."
|
empty: "No changesets found."
|
||||||
no_more: "No more changesets in this area."
|
empty_area: "No changesets in this area."
|
||||||
|
empty_user: "No changesets by this user."
|
||||||
|
no_more: "No more changesets found."
|
||||||
|
no_more_area: "No more changesets in this area."
|
||||||
|
no_more_user: "No more changesets by this user."
|
||||||
load_more: "Load more"
|
load_more: "Load more"
|
||||||
timeout:
|
timeout:
|
||||||
sorry: "Sorry, the list of changesets you requested took too long to retrieve."
|
sorry: "Sorry, the list of changesets you requested took too long to retrieve."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue