From: Tom Hughes Date: Sun, 1 Dec 2013 22:37:04 +0000 (+0000) Subject: Fix URL updating in Potlatch 1 X-Git-Tag: live~4600 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/d5a765588f5818bf46575392fa7ccbd4af0de574 Fix URL updating in Potlatch 1 Potlatch 1 has hard coded calls to updatelinks, so rename the updatelinks function to updateLinks and add an updatelinks function using the old style argument list for Potlatch 1 to call. --- diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index bc8719700..37172f439 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -58,7 +58,7 @@ function remoteEditHandler(bbox, select) { * Called as the user scrolls/zooms around to maniplate hrefs of the * view tab and various other links */ -function updatelinks(loc, zoom, layers, object) { +function updateLinks(loc, zoom, layers, object) { $(".geolink").each(function(index, link) { var href = link.href.split(/[?#]/)[0], args = querystring.parse(link.search.substring(1)), diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 43b7fefe0..273ce581a 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -144,7 +144,7 @@ $(document).ready(function () { expiry.setYear(expiry.getFullYear() + 10); map.on('moveend layeradd layerremove', function() { - updatelinks( + updateLinks( map.getCenter().wrap(), map.getZoom(), map.getLayersCode(), diff --git a/app/views/site/_potlatch.html.erb b/app/views/site/_potlatch.html.erb index d48fd799d..32dc99e8e 100644 --- a/app/views/site/_potlatch.html.erb +++ b/app/views/site/_potlatch.html.erb @@ -18,6 +18,15 @@ function markChanged(a) { changesaved=a; } + function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,object) { + updateLinks({ lon: lon, lat: lat }, zoom); + + var hash = OSM.formatHash({ lon: lon, lat: lat, zoom: zoom }); + if (hash !== location.hash) { + location.replace(hash); + } + } + function doSWF(lat,lon,sc) { if (sc < 11) sc = 11; diff --git a/app/views/site/_potlatch2.html.erb b/app/views/site/_potlatch2.html.erb index faff8de1e..2f8e10a5b 100644 --- a/app/views/site/_potlatch2.html.erb +++ b/app/views/site/_potlatch2.html.erb @@ -66,7 +66,7 @@ // 700,600 for fixed size, 100%,100% for resizable if (lat && lon) { - updatelinks({ lon: lon, lat: lat }, zoom); + updateLinks({ lon: lon, lat: lat }, zoom); } } @@ -88,7 +88,7 @@ }); var mapMoved = $.throttle(250, function(lon, lat, zoom) { - updatelinks({ lon: lon, lat: lat }, zoom); + updateLinks({ lon: lon, lat: lat }, zoom); var hash = OSM.formatHash({ lon: lon, lat: lat, zoom: zoom }); if (hash !== location.hash) { diff --git a/app/views/site/id.html.erb b/app/views/site/id.html.erb index fa47bb00c..38f2e0d3d 100644 --- a/app/views/site/id.html.erb +++ b/app/views/site/id.html.erb @@ -37,7 +37,7 @@ center = id.map().center(), llz = { lon: center[0], lat: center[1], zoom: zoom }; - parent.updatelinks(llz, zoom); + parent.updateLinks(llz, zoom); // Manually resolve URL to avoid iframe JS context weirdness. // http://bl.ocks.org/jfirebaugh/5439412