]> git.openstreetmap.org Git - rails.git/commitdiff
Move directions listeners init code to its own function
authorAnton Khorev <tony29@yandex.ru>
Mon, 3 Feb 2025 13:30:10 +0000 (16:30 +0300)
committerAnton Khorev <tony29@yandex.ru>
Thu, 6 Mar 2025 09:06:22 +0000 (12:06 +0300)
app/assets/javascripts/index/directions.js

index 4630237760cc1507a2921e3e74cc957c8a4fa532..5aa773823fd193555914afc01582b6cc52ed1e12 100644 (file)
@@ -294,14 +294,7 @@ OSM.Directions = function (map) {
     endpoints[1].setValue(params.get("to") || route[1] || "");
   }
 
-  const page = {};
-
-  page.pushstate = page.popstate = function () {
-    initializeFromParams();
-
-    $(".search_form").hide();
-    $(".directions_form").show();
-
+  function enableListeners() {
     $("#map").on("dragend dragover", function (e) {
       e.preventDefault();
     });
@@ -322,6 +315,17 @@ OSM.Directions = function (map) {
 
     endpoints[0].enableListeners();
     endpoints[1].enableListeners();
+  }
+
+  const page = {};
+
+  page.pushstate = page.popstate = function () {
+    initializeFromParams();
+
+    $(".search_form").hide();
+    $(".directions_form").show();
+
+    enableListeners();
 
     map.setSidebarOverlaid(!endpoints[0].latlng || !endpoints[1].latlng);
   };