]> git.openstreetmap.org Git - rails.git/commitdiff
Fix "Edit" button when browsing features
authorJohn Firebaugh <john.firebaugh@gmail.com>
Wed, 2 Oct 2013 21:31:04 +0000 (14:31 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Sun, 13 Oct 2013 21:46:07 +0000 (14:46 -0700)
app/assets/javascripts/index.js
app/controllers/site_controller.rb

index ef553f328253937ae8897ecf61f53405c08f7505..d57b76b280be1c547790882398b674cd52746bf5 100644 (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();
-}
index 0f06b22833d63c300e8a2a572ddd58377e1b9773..f4564100c1edc6ff284411b710776415f68fd7ed 100644 (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