]> git.openstreetmap.org Git - rails.git/commitdiff
Position directions close button with flex
authorAnton Khorev <tony29@yandex.ru>
Sat, 27 Aug 2022 21:32:50 +0000 (00:32 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 27 Aug 2022 21:32:50 +0000 (00:32 +0300)
app/assets/javascripts/index/directions.js
app/views/layouts/_search.html.erb

index ad780d4f40dffa74d6f7ecd5346120a66764b4fb..0c867a97d69b945661328a9e283522bc16d0762d 100644 (file)
@@ -254,20 +254,31 @@ OSM.Directions = function (map) {
         map.fitBounds(polyline.getBounds().pad(0.05));
       }
 
         map.fitBounds(polyline.getBounds().pad(0.05));
       }
 
-      var html = "<a class=\"geolink\" href=\"#\"><button type='button' class='btn-close float-end mt-1'></button></a>" +
-        "<h2>" + I18n.t("javascripts.directions.directions") + "</h2>" +
-        "<p>" +
+      var distanceText = $("<p>").append(
         I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " +
         I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " +
-        I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".";
+        I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".");
       if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
       if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
-        html += "<br />" +
+        distanceText.append(
+          $("<br>"),
           I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
           I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
-          I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) + "m.";
+          I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) + "m.");
       }
       }
-      html += "</p><table id=\"turnbyturn\" class=\"mb-3\"/>";
+
+      var turnByTurnTable = $("<table class='mb-3'>");
 
       $("#sidebar_content")
 
       $("#sidebar_content")
-        .html(html);
+        .empty()
+        .append(
+          $("<div class='d-flex'>").append(
+            $("<div class='flex-grow-1 text-break'>").append(
+              $("<h2>")
+                .text(I18n.t("javascripts.directions.directions"))),
+            $("<div>").append(
+              $("<a class='geolink' href='#'>").append(
+                $("<button type='button' class='btn-close mt-1'>")))),
+          distanceText,
+          turnByTurnTable
+        );
 
       // Add each row
       route.steps.forEach(function (step) {
 
       // Add each row
       route.steps.forEach(function (step) {
@@ -309,7 +320,7 @@ OSM.Directions = function (map) {
           map.removeLayer(highlight);
         });
 
           map.removeLayer(highlight);
         });
 
-        $("#turnbyturn").append(row);
+        turnByTurnTable.append(row);
       });
 
       $("#sidebar_content").append("<p class=\"text-center\">" +
       });
 
       $("#sidebar_content").append("<p class=\"text-center\">" +
index 922cd4b240d65a402ec053883df2f513d0ad9580..24b0885047dd709e1a2f0e1aeae439941ba15eeb 100644 (file)
@@ -19,7 +19,7 @@
   </form>
 
   <form method="GET" action="<%= directions_path %>" class="directions_form pb-3">
   </form>
 
   <form method="GET" action="<%= directions_path %>" class="directions_form pb-3">
-    <div class="clearfix px-3 py-3"><button type="button" class="btn-close float-end"></button></div>
+    <div class="d-flex flex-row-reverse px-3 py-3"><button type="button" class="btn-close"></button></div>
 
     <div class="row gx-2 m-1">
       <div class="col-1">
 
     <div class="row gx-2 m-1">
       <div class="col-1">