Fix "Edit" button when browsing features

This commit is contained in:
John Firebaugh 2013-10-02 14:31:04 -07:00
parent 3ba036045b
commit 2f076d8f34
2 changed files with 29 additions and 24 deletions

View file

@ -134,7 +134,21 @@ $(document).ready(function () {
$('.leaflet-control .control-button').tooltip({placement: 'left', container: 'body'});
map.on('moveend layeradd layerremove', updateLocation);
map.on('moveend layeradd layerremove', function() {
updatelinks(
map.getCenter().wrap(),
map.getZoom(),
map.getLayersCode(),
map.getBounds().wrap(),
map._object);
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
$.cookie("_osm_location", cookieContent(map), { expires: expiry });
// Trigger hash update on layer changes.
map.hash.onMapMove();
});
if (OSM.PIWIK) {
map.on('layeradd', function (e) {
@ -206,17 +220,3 @@ $(document).ready(function () {
if ('undefined' !== typeof initializeChangesets) initializeChangesets(map);
});
function updateLocation() {
updatelinks(this.getCenter().wrap(),
this.getZoom(),
this.getLayersCode(),
this.getBounds().wrap());
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
$.cookie("_osm_location", cookieContent(this), { expires: expiry });
// Trigger hash update on layer changes.
this.hash.onMapMove();
}

View file

@ -4,6 +4,7 @@ class SiteController < ApplicationController
before_filter :authorize_web
before_filter :set_locale
before_filter :redirect_browse_params, :only => :index
before_filter :redirect_map_params, :only => [:index, :edit, :export]
before_filter :require_user, :only => [:edit, :welcome]
before_filter :require_oauth, :only => [:index]
@ -87,6 +88,18 @@ class SiteController < ApplicationController
private
def redirect_browse_params
if params[:node]
redirect_to node_path(params[:node])
elsif params[:way]
redirect_to way_path(params[:way])
elsif params[:relation]
redirect_to relation_path(params[:relation])
elsif params[:note]
redirect_to browse_note_path(params[:note])
end
end
def redirect_map_params
anchor = []
@ -100,15 +113,7 @@ class SiteController < ApplicationController
anchor << "layers=N"
end
if params[:node]
redirect_to node_path(params[:node])
elsif params[:way]
redirect_to way_path(params[:way])
elsif params[:relation]
redirect_to relation_path(params[:relation])
elsif params[:note]
redirect_to browse_note_path(params[:note])
elsif anchor.present?
if anchor.present?
redirect_to params.merge(:anchor => anchor.join('&'))
end
end