From a81680355d96dee10a351e3fbb9b16cd97686409 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 10 Apr 2025 12:36:27 +0300 Subject: [PATCH] Show/hide directions spinner instead of copying --- app/assets/javascripts/index/directions.js | 8 ++++---- app/views/directions/search.html.erb | 8 ++++++++ app/views/layouts/_search.html.erb | 8 -------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index c5d5cce15..354387268 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -100,10 +100,8 @@ OSM.Directions = function (map) { route: points.map(p => `${p.lat},${p.lng}`).join(";") })); - // 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. - $("#directions_content").html($(".directions_form .loader_copy").html()); + $("#directions_loader").prop("hidden", false); + $("#directions_content").prop("hidden", true); map.setSidebarOverlaid(false); controller = new AbortController(); chosenEngine.getRoute(points, controller.signal).then(function (route) { @@ -117,6 +115,8 @@ OSM.Directions = function (map) { $("#directions_content").html("
" + OSM.i18n.t("javascripts.directions.errors.no_route") + "
"); } }).finally(function () { + $("#directions_loader").prop("hidden", true); + $("#directions_content").prop("hidden", false); controller = null; }); } diff --git a/app/views/directions/search.html.erb b/app/views/directions/search.html.erb index a7f83be3f..b7c75fee6 100644 --- a/app/views/directions/search.html.erb +++ b/app/views/directions/search.html.erb @@ -78,4 +78,12 @@ <%= render "sidebar_header", :title => t(".title") %> + +
diff --git a/app/views/layouts/_search.html.erb b/app/views/layouts/_search.html.erb index 68c28c332..4d0456236 100644 --- a/app/views/layouts/_search.html.erb +++ b/app/views/layouts/_search.html.erb @@ -89,13 +89,5 @@ <%= submit_tag t("site.search.submit_text"), :class => "routing_go btn btn-primary py-1 px-2", :data => { :disable_with => false } %> - -
-
-
- <%= t("browse.start_rjs.loading") %> -
-
-
-- 2.39.5