From 1c66d7f50fe4d8ef22771f99d8690bc5136f30b7 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 3 Feb 2025 16:30:10 +0300 Subject: [PATCH] Move directions listeners init code to its own function --- app/assets/javascripts/index/directions.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 463023776..5aa773823 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -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); }; -- 2.39.5