From be79156f43975a90399bb2629684bea6c580f238 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 12 May 2014 12:34:34 -0700 Subject: [PATCH] OSM.Routing -> OSM.Directions Too close of a name collision to OSM.Router. --- app/assets/javascripts/index.js | 15 +++++++-------- .../{routing.js.erb => index/directions.js.erb} | 11 +++++------ .../directions_engines}/graphhopper.js | 4 ++-- .../directions_engines}/mapquest.js | 6 +++--- .../directions_engines}/osrm.js | 2 +- app/views/layouts/_search.html.erb | 6 +++--- 6 files changed, 21 insertions(+), 23 deletions(-) rename app/assets/javascripts/{routing.js.erb => index/directions.js.erb} (98%) rename app/assets/javascripts/{routing_engines => index/directions_engines}/graphhopper.js (92%) rename app/assets/javascripts/{routing_engines => index/directions_engines}/mapquest.js (92%) rename app/assets/javascripts/{routing_engines => index/directions_engines}/osrm.js (95%) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 52b8b4c23..66e0e0642 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -13,9 +13,8 @@ //= require index/history //= require index/note //= require index/new_note +//= require index/directions //= require router -//= require routing -//= require_tree ./routing_engines (function() { var loaderTimeout; @@ -326,8 +325,8 @@ $(document).ready(function () { $(".search_form").on("submit", function(e) { e.preventDefault(); if ($(".query_wrapper.routing").is(":visible")) { - // Routing - OSM.routing.requestRoute(true, true); + // Directions + OSM.directions.requestRoute(true, true); } else { // Search $("header").addClass("closed"); @@ -348,8 +347,8 @@ $(document).ready(function () { map.getCenter().lng.toFixed(precision))); }); - OSM.routing = OSM.Routing(map,'OSM.routing',$('.query_wrapper.routing')); - OSM.routing.chooseEngine('javascripts.directions.engines.osrm_car'); + OSM.directions = OSM.Directions(map, 'OSM.directions', $('.query_wrapper.routing')); + OSM.directions.chooseEngine('javascripts.directions.engines.osrm_car'); $(".get_directions").on("click",function(e) { e.preventDefault(); @@ -358,7 +357,7 @@ $(document).ready(function () { $(".search_form input[type='submit']").addClass("routing_submit"); $(".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(); }); + $("#map").on('drop',function(e) { OSM.directions.handleDrop(e); e.preventDefault(); }); $(".routing_marker").on('dragstart',function(e) { e.originalEvent.dataTransfer.effectAllowed = 'move'; e.originalEvent.dataTransfer.setData('id', this.id); @@ -374,7 +373,7 @@ $(document).ready(function () { $(".search").show(); $(".routing").hide(); $(".search_form input[type='submit']").removeClass("routing_submit"); - OSM.routing.close(); + OSM.directions.close(); $("#map").off('dragend drop dragover'); $(".routing_marker").off('dragstart'); $(".query_wrapper.search [name=query]").focus(); diff --git a/app/assets/javascripts/routing.js.erb b/app/assets/javascripts/index/directions.js.erb similarity index 98% rename from app/assets/javascripts/routing.js.erb rename to app/assets/javascripts/index/directions.js.erb index fc2bb8d30..fb16c7915 100644 --- a/app/assets/javascripts/routing.js.erb +++ b/app/assets/javascripts/index/directions.js.erb @@ -1,6 +1,5 @@ -/* - osm.org routing interface -*/ +//= require_self +//= require_tree ./directions_engines var TURN_INSTRUCTIONS = []; @@ -16,14 +15,14 @@ var ROUTING_POLYLINE_HIGHLIGHT = { weight: 12 }; -OSM.RoutingEngines = { +OSM.DirectionsEngines = { list: [], add: function (supportsHTTPS, engine) { if (document.location.protocol == "http:" || supportsHTTPS) this.list.push(engine); } }; -OSM.Routing = function (map, name, jqSearch) { +OSM.Directions = function (map, name, jqSearch) { var r = {}; TURN_INSTRUCTIONS = [ @@ -298,7 +297,7 @@ OSM.Routing = function (map, name, jqSearch) { // Routing engine handling // Add all engines - var list = OSM.RoutingEngines.list; + var list = OSM.DirectionsEngines.list; list.sort(function (a, b) { return I18n.t(a.name) > I18n.t(b.name); }); diff --git a/app/assets/javascripts/routing_engines/graphhopper.js b/app/assets/javascripts/index/directions_engines/graphhopper.js similarity index 92% rename from app/assets/javascripts/routing_engines/graphhopper.js rename to app/assets/javascripts/index/directions_engines/graphhopper.js index a0e877e4b..9f9c549b5 100644 --- a/app/assets/javascripts/routing_engines/graphhopper.js +++ b/app/assets/javascripts/index/directions_engines/graphhopper.js @@ -77,5 +77,5 @@ GraphHopperEngine.prototype.createConfig = function () { }; }; -OSM.RoutingEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); -OSM.RoutingEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig()); +OSM.DirectionsEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); +OSM.DirectionsEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig()); diff --git a/app/assets/javascripts/routing_engines/mapquest.js b/app/assets/javascripts/index/directions_engines/mapquest.js similarity index 92% rename from app/assets/javascripts/routing_engines/mapquest.js rename to app/assets/javascripts/index/directions_engines/mapquest.js index 67fc534b7..f24d8fab6 100644 --- a/app/assets/javascripts/routing_engines/mapquest.js +++ b/app/assets/javascripts/index/directions_engines/mapquest.js @@ -92,7 +92,7 @@ MapQuestEngine.prototype.createConfig = function () { }; }; -OSM.RoutingEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig()); -OSM.RoutingEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig()); -OSM.RoutingEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig()); +OSM.DirectionsEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig()); +OSM.DirectionsEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig()); +OSM.DirectionsEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig()); // can be: routeType=fastest|shortest|pedestrian|multimodal|bicycle diff --git a/app/assets/javascripts/routing_engines/osrm.js b/app/assets/javascripts/index/directions_engines/osrm.js similarity index 95% rename from app/assets/javascripts/routing_engines/osrm.js rename to app/assets/javascripts/index/directions_engines/osrm.js index 6a197bb98..ac78699f9 100644 --- a/app/assets/javascripts/routing_engines/osrm.js +++ b/app/assets/javascripts/index/directions_engines/osrm.js @@ -66,4 +66,4 @@ OSRMEngine.prototype.createConfig = function () { }; }; -OSM.RoutingEngines.add(false, new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig()); +OSM.DirectionsEngines.add(false, new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig()); diff --git a/app/views/layouts/_search.html.erb b/app/views/layouts/_search.html.erb index 9ac3eae33..8d216ee80 100644 --- a/app/views/layouts/_search.html.erb +++ b/app/views/layouts/_search.html.erb @@ -18,10 +18,10 @@
<%= image_tag "marker-green.png", :class => 'routing_marker', :id => 'marker_from', :draggable => 'true' %> - <%= text_field_tag "route_from", params[:from], :placeholder => t('site.search.from'), :onchange=>"OSM.routing.geocode('route_from',event)" %> + <%= text_field_tag "route_from", params[:from], :placeholder => t('site.search.from'), :onchange=>"OSM.directions.geocode('route_from',event)" %> <%= image_tag "marker-red.png" , :class => 'routing_marker', :id => 'marker_to' , :draggable => 'true' %> - <%= text_field_tag "route_to" , params[:to] , :placeholder => t('site.search.to') , :onchange=>"OSM.routing.geocode('route_to' ,event)" %> - + <%= text_field_tag "route_to" , params[:to] , :placeholder => t('site.search.to') , :onchange=>"OSM.directions.geocode('route_to' ,event)" %> + <%= image_tag "searching-small.gif", :class => 'spinner', :style => "vertical-align: middle; display: none;" %>
-- 2.43.2