]> git.openstreetmap.org Git - rails.git/commitdiff
Merge pull request #5151 from AntonKhorev/no-history-and-export-buttons
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 13 Nov 2024 19:15:59 +0000 (19:15 +0000)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2024 19:15:59 +0000 (19:15 +0000)
Move History and Export buttons to secondary nav

app/assets/javascripts/index.js
app/assets/javascripts/index/search.js
app/assets/javascripts/router.js
app/assets/stylesheets/common.scss
app/views/layouts/_header.html.erb

index 4dfc849feb5d9d24361566c50de3793d1c65ebd6..c419f93216b44507f4aed454b01792feba3744e9 100644 (file)
@@ -405,6 +405,9 @@ $(document).ready(function () {
 
     if (OSM.router.route(this.pathname + this.search + this.hash)) {
       e.preventDefault();
+      if (this.pathname !== "/directions") {
+        $("header").addClass("closed");
+      }
     }
   });
 
index 476ad30a1ac11de80ad555ecf430ca6ef61923b1..2bfbb2e1c6d4fa9bc18c7264cdbb65651785899a 100644 (file)
@@ -32,6 +32,7 @@ OSM.Search = function (map) {
 
   $(".describe_location").on("click", function (e) {
     e.preventDefault();
+    $("header").addClass("closed");
     var center = map.getCenter().wrap(),
         precision = OSM.zoomPrecision(map.getZoom()),
         lat = center.lat.toFixed(precision),
index d890f38a480a384d6edd5570e384f71916cc30bc..c4e52417004c5c50871f23fe28edf967596c68b7 100644 (file)
@@ -101,6 +101,16 @@ OSM.Router = function (map, rts) {
 
   var router = {};
 
+  function updateSecondaryNav() {
+    $("header nav.secondary > ul > li > a").each(function () {
+      var active = $(this).attr("href") === window.location.pathname;
+
+      $(this)
+        .toggleClass("text-secondary", !active)
+        .toggleClass("text-secondary-emphasis", active);
+    });
+  }
+
   $(window).on("popstate", function (e) {
     if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
     var path = window.location.pathname + window.location.search,
@@ -110,6 +120,7 @@ OSM.Router = function (map, rts) {
     currentPath = path;
     currentRoute = route;
     currentRoute.run("popstate", currentPath);
+    updateSecondaryNav();
     map.setState(e.originalEvent.state, { animate: false });
   });
 
@@ -124,6 +135,7 @@ OSM.Router = function (map, rts) {
     currentPath = path;
     currentRoute = route;
     currentRoute.run("pushstate", currentPath);
+    updateSecondaryNav();
     return true;
   };
 
index 73f8521d7fbc3f2a816deaa75661c81783df846d..c4391be2d1f8084b1ec63573fd8934db2becefd8 100644 (file)
@@ -131,7 +131,7 @@ header {
 }
 
 nav.primary {
-  & > .btn-group .btn-outline-primary {
+  #edit_tab .btn-outline-primary {
     @include button-outline-variant($green, $color-hover: $white, $active-color: $white);
   }
 
@@ -209,9 +209,7 @@ body.small-nav {
     }
   }
 
-  #sidebar .search_forms,
-  #edit_tab,
-  #export_tab {
+  #sidebar .search_forms {
     display: none;
   }
 
@@ -219,7 +217,7 @@ body.small-nav {
     margin-right: 0;
     padding: 0;
 
-    .btn-group {
+    #edit_tab {
       width: 100%;
       padding: 10px;
     }
index e96564b82b84839d0ab4d15bbfe998b9d80b1d58..fcf134fd29c8b0d9c673fcea647e3679b54e448b 100644 (file)
@@ -8,27 +8,23 @@
   <a href="#" id="menu-icon"></a>
   <nav class='primary'>
     <%= content_for :header %>
-    <div class="btn-group">
-      <div id="edit_tab" class="btn-group">
-        <%= link_to t("layouts.edit"),
-                    edit_path,
-                    :class => "btn btn-outline-primary geolink editlink",
-                    :id => "editanchor",
-                    :data => { :editor => preferred_editor } %>
-        <button class='btn btn-outline-primary dropdown-toggle dropdown-toggle-split' type='button' data-bs-toggle='dropdown'></button>
-        <ul class='dropdown-menu'>
-          <% Editors::RECOMMENDED_EDITORS.each do |editor| %>
-            <li>
-              <%= link_to t("layouts.edit_with", :editor => t("editor.#{editor}.description")),
-                          edit_path(:editor => editor),
-                          :data => { :editor => editor },
-                          :class => "geolink editlink dropdown-item" %>
-            </li>
-          <% end %>
-        </ul>
-      </div>
-      <%= link_to t("layouts.history"), history_path, :class => "btn btn-outline-primary geolink flex-grow-1", :id => "history_tab" %>
-      <%= link_to t("layouts.export"), export_path, :class => "btn btn-outline-primary geolink", :id => "export_tab" %>
+    <div id="edit_tab" class="btn-group">
+      <%= link_to t("layouts.edit"),
+                  edit_path,
+                  :class => "btn btn-outline-primary geolink editlink",
+                  :id => "editanchor",
+                  :data => { :editor => preferred_editor } %>
+      <button class='btn btn-outline-primary dropdown-toggle dropdown-toggle-split flex-grow-0' type='button' data-bs-toggle='dropdown'></button>
+      <ul class='dropdown-menu'>
+        <% Editors::RECOMMENDED_EDITORS.each do |editor| %>
+          <li>
+            <%= link_to t("layouts.edit_with", :editor => t("editor.#{editor}.description")),
+                        edit_path(:editor => editor),
+                        :data => { :editor => editor },
+                        :class => "geolink editlink dropdown-item" %>
+          </li>
+        <% end %>
+      </ul>
     </div>
   </nav>
   <nav class='secondary d-flex gap-2 align-items-center'>
           <% end -%>
         </li>
       <% end %>
+      <li class="compact-hide nav-item">
+        <%= link_to t("layouts.history"), history_path, :class => header_nav_link_class(history_path) %>
+      </li>
+      <li class="compact-hide nav-item">
+        <%= link_to t("layouts.export"), export_path, :class => header_nav_link_class(export_path) %>
+      </li>
       <li class="compact-hide nav-item">
         <%= link_to t("layouts.gps_traces"), traces_path, :class => header_nav_link_class(traces_path) %>
       </li>
@@ -70,6 +72,8 @@
               <% end -%>
             </li>
           <% end %>
+          <li><%= link_to t("layouts.history"), history_path, :class => "dropdown-item" %></li>
+          <li><%= link_to t("layouts.export"), export_path, :class => "dropdown-item" %></li>
           <li><%= link_to t("layouts.gps_traces"), traces_path, :class => "dropdown-item" %></li>
           <li><%= link_to t("layouts.user_diaries"), diary_entries_path, :class => "dropdown-item" %></li>
           <li><%= link_to t("layouts.communities"), communities_path, :class => "dropdown-item" %></li>