diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index cbb6afafe..b79c33088 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -37,7 +37,7 @@ $(function () { map.setSidebarOverlaid(false); - $("#sidebar_loader").show().addClass("delayed-fade-in"); + $("#sidebar_loader").prop("hidden", false).addClass("delayed-fade-in"); // Prevent caching the XHR response as a full-page URL // https://github.com/openstreetmap/openstreetmap-website/issues/5663 @@ -53,7 +53,7 @@ $(function () { fetch(content_path, { headers: { "accept": "text/html", "x-requested-with": "XMLHttpRequest" } }) .then(response => { $("#flash").empty(); - $("#sidebar_loader").removeClass("delayed-fade-in").hide(); + $("#sidebar_loader").removeClass("delayed-fade-in").prop("hidden", true); const title = response.headers.get("X-Page-Title"); if (title) document.title = decodeURIComponent(title); diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 0b52d3d4c..e3f6afa46 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -14,23 +14,16 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch autoPan: true }); - endpoint.enable = function () { + endpoint.enableListeners = function () { endpoint.marker.on("drag dragend", markerDragListener); input.on("keydown", inputKeydownListener); input.on("change", inputChangeListener); }; - endpoint.disable = function () { + endpoint.disableListeners = function () { endpoint.marker.off("drag dragend", markerDragListener); input.off("keydown", inputKeydownListener); input.off("change", inputChangeListener); - - if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort(); - delete endpoint.geocodeRequest; - removeLatLng(); - delete endpoint.value; - input.val(""); - map.removeLayer(endpoint.marker); }; function markerDragListener(e) { @@ -91,6 +84,15 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch } }; + endpoint.clearValue = function () { + if (endpoint.geocodeRequest) endpoint.geocodeRequest.abort(); + delete endpoint.geocodeRequest; + removeLatLng(); + delete endpoint.value; + input.val(""); + map.removeLayer(endpoint.marker); + }; + endpoint.swapCachedReverseGeocodes = function (otherEndpoint) { const g0 = endpoint.cachedReverseGeocode; const g1 = otherEndpoint.cachedReverseGeocode; diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 40ca85d96..cddb3a451 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -134,7 +134,7 @@ OSM.Directions = function (map) { // copy loading item to sidebar and display it. we copy it, rather than // just using it in-place and replacing it in case it has to be used // again. - $("#sidebar_content").html($(".directions_form .loader_copy").html()); + $("#directions_content").html($(".directions_form .loader_copy").html()); map.setSidebarOverlaid(false); controller = new AbortController(); chosenEngine.getRoute(points, controller.signal).then(function (route) { @@ -158,16 +158,10 @@ OSM.Directions = function (map) { const turnByTurnTable = $("