From: Anton Khorev Date: Sun, 9 Mar 2025 15:09:41 +0000 (+0300) Subject: Merge branch 'pull/5745' X-Git-Tag: live~171 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/a0768a4d04d3eb5afa9e8864b8fc73a64286bf2c?hp=46d7e9fe8d16ec3370bb75aa9690abe2b8a77e7e Merge branch 'pull/5745' --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index b79c33088..9220e1205 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -398,7 +398,7 @@ $(function () { } }); - $(document).on("click", "#sidebar_content .btn-close", function () { + $(document).on("click", "#sidebar .sidebar-close-controls button", function () { OSM.router.route("/" + OSM.formatHash(map)); }); }); diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 89888bbd1..aee262e02 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -70,11 +70,28 @@ OSM.Directions = function (map) { OSM.router.route("/" + OSM.formatHash(map)); }); - function formatDistance(m) { - const unitTemplate = "javascripts.directions.distance_"; - if (m < 1000) return I18n.t(unitTemplate + "m", { distance: Math.round(m) }); - if (m < 10000) return I18n.t(unitTemplate + "km", { distance: (m / 1000.0).toFixed(1) }); - return I18n.t(unitTemplate + "km", { distance: Math.round(m / 1000) }); + function formatTotalDistance(m) { + if (m < 1000) { + return I18n.t("javascripts.directions.distance_m", { distance: Math.round(m) }); + } else if (m < 10000) { + return I18n.t("javascripts.directions.distance_km", { distance: (m / 1000.0).toFixed(1) }); + } else { + return I18n.t("javascripts.directions.distance_km", { distance: Math.round(m / 1000) }); + } + } + + function formatStepDistance(m) { + if (m < 5) { + return ""; + } else if (m < 200) { + return I18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 10) * 10) }); + } else if (m < 1500) { + return I18n.t("javascripts.directions.distance_m", { distance: String(Math.round(m / 100) * 100) }); + } else if (m < 5000) { + return I18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 100) / 10) }); + } else { + return I18n.t("javascripts.directions.distance_km", { distance: String(Math.round(m / 1000)) }); + } } function formatHeight(m) { @@ -147,7 +164,7 @@ OSM.Directions = function (map) { } const distanceText = $("

").append( - I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " + + I18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " + I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + "."); if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") { distanceText.append( @@ -177,7 +194,7 @@ OSM.Directions = function (map) { row.append(""); } row.append("" + instruction); - row.append("" + getDistText(dist)); + row.append("" + formatStepDistance(dist)); row.on("click", function () { popup @@ -218,14 +235,6 @@ OSM.Directions = function (map) { }).finally(function () { controller = null; }); - - function getDistText(dist) { - if (dist < 5) return ""; - if (dist < 200) return String(Math.round(dist / 10) * 10) + "m"; - if (dist < 1500) return String(Math.round(dist / 100) * 100) + "m"; - if (dist < 5000) return String(Math.round(dist / 100) / 10) + "km"; - return String(Math.round(dist / 1000)) + "km"; - } } function hideRoute(e) { @@ -294,7 +303,7 @@ OSM.Directions = function (map) { } function enableListeners() { - $("#sidebar_content").on("click", ".btn-close", hideRoute); + $("#sidebar .sidebar-close-controls button").on("click", hideRoute); $("#map").on("dragend dragover", function (e) { e.preventDefault(); @@ -350,7 +359,7 @@ OSM.Directions = function (map) { $(".search_form").show(); $(".directions_form").hide(); - $("#sidebar_content").off("click", ".btn-close", hideRoute); + $("#sidebar .sidebar-close-controls button").off("click", hideRoute); $("#map").off("dragend dragover drop"); map.off("locationfound", sendstartinglocation); diff --git a/app/assets/javascripts/leaflet.sidebar-pane.js b/app/assets/javascripts/leaflet.sidebar-pane.js index 06fad7b66..7408585f2 100644 --- a/app/assets/javascripts/leaflet.sidebar-pane.js +++ b/app/assets/javascripts/leaflet.sidebar-pane.js @@ -18,16 +18,11 @@ L.OSM.sidebarPane = function (options, uiClass, buttonTitle, paneTitle) { button.appendTo($container); const $ui = $("

") - .attr("class", uiClass + "-ui"); - - $("
") - .appendTo($ui) - .append($("

") - .text(I18n.t(paneTitle))) - .append($("
") - .append($(" -
-

+

<%= title %>

diff --git a/app/views/changesets/_changeset.html.erb b/app/views/changesets/_changeset.html.erb index 2c6809763..85142c251 100644 --- a/app/views/changesets/_changeset.html.erb +++ b/app/views/changesets/_changeset.html.erb @@ -4,20 +4,24 @@ <%= changeset.tags["comment"].to_s.presence || t("browse.no_comment") %>

-
-
+
+
<%= changeset_details(changeset) %> · #<%= changeset.id %>
-
+
<%= tag.div :class => ["d-flex align-items-baseline gap-1", { "opacity-50" => changeset.comments.empty? }], :title => t(".comments", :count => changeset.comments.length) do %> <%= changeset.comments.length %> - + <% if changeset.comments.empty? %> + + <% else %> + + <% end %> <% end %> <%= tag.div :class => ["d-flex align-items-baseline gap-1", { "opacity-50" => changeset.num_changes.zero? }], diff --git a/app/views/layouts/_sidebar_close.html.erb b/app/views/layouts/_sidebar_close.html.erb new file mode 100644 index 000000000..6c9686a50 --- /dev/null +++ b/app/views/layouts/_sidebar_close.html.erb @@ -0,0 +1,14 @@ + + + diff --git a/app/views/layouts/map.html.erb b/app/views/layouts/map.html.erb index eeb6d7472..62e979c05 100644 --- a/app/views/layouts/map.html.erb +++ b/app/views/layouts/map.html.erb @@ -18,19 +18,22 @@
+ <%= render :partial => "layouts/sidebar_close" %> + -