From 6670de16a1981144869d7132e0bcc94a3b804513 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 5 Dec 2013 10:40:21 +0000 Subject: [PATCH] Make remote edit work when /edit is loaded Change detection of the edit request to use the URL as the class will not be set on the body now, and force the router to think we actually loaded the normal view. --- app/assets/javascripts/index.js | 9 +++++---- app/assets/javascripts/router.js | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index c5532cfc4..55f1f8f1e 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -201,10 +201,6 @@ $(document).ready(function () { e.preventDefault(); }); - if (OSM.preferred_editor == "remote" && $('body').hasClass("site-edit")) { - remoteEditHandler(map.getBounds()); - } - if (OSM.params().edit_help) { $('#editanchor') .removeAttr('title') @@ -284,6 +280,11 @@ $(document).ready(function () { "/changeset/:id": OSM.Browse(map, 'changeset') }); + if (OSM.preferred_editor == "remote" && document.location.pathname == "/edit") { + remoteEditHandler(map.getBounds()); + OSM.router.setCurrentPath("/"); + } + OSM.router.load(); $(document).on("click", "a", function(e) { diff --git a/app/assets/javascripts/router.js b/app/assets/javascripts/router.js index 200edd266..2f76f2f18 100644 --- a/app/assets/javascripts/router.js +++ b/app/assets/javascripts/router.js @@ -167,6 +167,11 @@ OSM.Router = function(map, rts) { router.stateChange(loadState || {}); }; + router.setCurrentPath = function (path) { + currentPath = path; + currentRoute = routes.recognize(currentPath); + }; + map.on('moveend baselayerchange overlaylayerchange', router.updateHash); $(window).on('hashchange', router.hashUpdated); -- 2.43.2