From: Tom Hughes Date: Wed, 5 Nov 2014 20:19:21 +0000 (+0000) Subject: Don't enable query mode when loading a query URL X-Git-Tag: live~4846^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6b09732854d0efa94b5211000afe3226e1f61da0?ds=inline Don't enable query mode when loading a query URL --- diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 30a05419c..b0fdd54ef 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -317,11 +317,12 @@ OSM.Query = function(map) { } queryOverpass(params.lat, params.lon); - enableQueryMode(); }; - page.unload = function() { - disableQueryMode(); + page.unload = function(sameController) { + if (!sameController) { + disableQueryMode(); + } }; return page; diff --git a/app/assets/javascripts/router.js b/app/assets/javascripts/router.js index 9af70c21d..dcf8ea6a8 100644 --- a/app/assets/javascripts/router.js +++ b/app/assets/javascripts/router.js @@ -76,6 +76,8 @@ OSM.Router = function(map, rts) { }); } + params = params.concat(Array.prototype.slice.call(arguments, 2)); + return (controller[action] || $.noop).apply(controller, params); }; @@ -101,11 +103,12 @@ OSM.Router = function(map, rts) { if (window.history && window.history.pushState) { $(window).on('popstate', function(e) { if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change? - var path = window.location.pathname + window.location.search; + var path = window.location.pathname + window.location.search, + route = routes.recognize(path); if (path === currentPath) return; - currentRoute.run('unload'); + currentRoute.run('unload', null, route === currentRoute); currentPath = path; - currentRoute = routes.recognize(currentPath); + currentRoute = route; currentRoute.run('popstate', currentPath); map.setState(e.originalEvent.state, {animate: false}); }); @@ -114,7 +117,7 @@ OSM.Router = function(map, rts) { var path = url.replace(/#.*/, ''), route = routes.recognize(path); if (!route) return false; - currentRoute.run('unload'); + currentRoute.run('unload', null, route === currentRoute); var state = OSM.parseHash(url); map.setState(state); window.history.pushState(state, document.title, url);