]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
More work on draggable markers
[rails.git] / app / assets / javascripts / index.js
index f3df5ae676955a1925eeedaeabf4a4c541e47cd5..fc772a1a8692cb93fbed2ce45cd988e98d45db09 100644 (file)
@@ -352,21 +352,26 @@ $(document).ready(function () {
   OSM.routing.chooseEngine('Car (OSRM)');
 
   $(".get_directions").on("click",function(e) {
-       e.preventDefault();
-       $(".search").hide();
-       $(".routing").show();
-       $(".query_wrapper.routing [name=route_from]").focus();
-       $("#map").on('dragend dragover',function(e) { e.preventDefault(); });
-       $("#map").on('drop',function(e) { OSM.routing.handleDrop(e); });
+    e.preventDefault();
+    $(".search").hide();
+    $(".routing").show();
+    $(".query_wrapper.routing [name=route_from]").focus();
+    $("#map").on('dragend dragover',function(e) { e.preventDefault(); });
+    $("#map").on('drop',function(e) { OSM.routing.handleDrop(e); });
+    $(".routing_marker").on('dragstart',function(e) {
+    e.originalEvent.dataTransfer.effectAllowed = 'move';
+      e.originalEvent.dataTransfer.setData('id', this.id);
+    });
   });
 
   $(".close_directions").on("click",function(e) {
-       e.preventDefault();
-       $(".search").show();
-       $(".routing").hide();
-       OSM.routing.close();
-       $("#map").off('dragend drop dragover');
-       $(".query_wrapper.search [name=query]").focus();
+    e.preventDefault();
+    $(".search").show();
+    $(".routing").hide();
+    OSM.routing.close();
+    $("#map").off('dragend drop dragover');
+    $(".routing_marker").off('dragstart');
+    $(".query_wrapper.search [name=query]").focus();
   });
 
 });