From: John Firebaugh Date: Wed, 2 Oct 2013 21:31:04 +0000 (-0700) Subject: Fix "Edit" button when browsing features X-Git-Tag: live~4615^2~234 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2f076d8f349837751e701d9c948414abc7ddeeaf?ds=sidebyside Fix "Edit" button when browsing features --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index ef553f328..d57b76b28 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -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(); -} diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 0f06b2283..f4564100c 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -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