OSM.Routing -> OSM.Directions
authorJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 12 May 2014 19:34:34 +0000 (12:34 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 12 May 2014 19:46:09 +0000 (12:46 -0700)
Too close of a name collision to OSM.Router.

app/assets/javascripts/index.js
app/assets/javascripts/index/directions.js.erb [moved from app/assets/javascripts/routing.js.erb with 98% similarity]
app/assets/javascripts/index/directions_engines/graphhopper.js [moved from app/assets/javascripts/routing_engines/graphhopper.js with 92% similarity]
app/assets/javascripts/index/directions_engines/mapquest.js [moved from app/assets/javascripts/routing_engines/mapquest.js with 92% similarity]
app/assets/javascripts/index/directions_engines/osrm.js [moved from app/assets/javascripts/routing_engines/osrm.js with 95% similarity]
app/views/layouts/_search.html.erb

index 52b8b4c2300c1386a93b518976ddbee10b8920a0..66e0e064237ff4d00c5a45b92a4552612646ee8a 100644 (file)
@@ -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();
similarity index 98%
rename from app/assets/javascripts/routing.js.erb
rename to app/assets/javascripts/index/directions.js.erb
index fc2bb8d30e4f02adc6441f254647e3c10fc9984b..fb16c791566396a6c937dff701ea9a50b0630853 100644 (file)
@@ -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);
   });
similarity index 92%
rename from app/assets/javascripts/routing_engines/graphhopper.js
rename to app/assets/javascripts/index/directions_engines/graphhopper.js
index a0e877e4b288af7a79da56b68e5a9e57c92e40dc..9f9c549b5ff17934c4d3c4367faa4355fe3bd574 100644 (file)
@@ -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());
similarity index 92%
rename from app/assets/javascripts/routing_engines/mapquest.js
rename to app/assets/javascripts/index/directions_engines/mapquest.js
index 67fc534b78f15d8dac0a74a3a4cb1dd17fa2abe2..f24d8fab6604337e6973997ca3091808407338fe 100644 (file)
@@ -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
similarity index 95%
rename from app/assets/javascripts/routing_engines/osrm.js
rename to app/assets/javascripts/index/directions_engines/osrm.js
index 6a197bb98f17198ccebb05fa0687e4c1766b1a5f..ac78699f9c61caf9d950a5852962d2feb68a8d30 100644 (file)
@@ -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());
index 9ac3eae33ab244c2854755714e7104f8922d8a8d..8d216ee80ac3c026812328c5a03970f6c717eec2 100644 (file)
 
   <div class='query_wrapper routing'>
     <%= 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)" %>
-    <select class='routing_engines' name='routing_engines' onchange="OSM.routing.selectEngine(event)"></select>
+    <%= text_field_tag "route_to"  , params[:to]  , :placeholder => t('site.search.to')  , :onchange=>"OSM.directions.geocode('route_to'  ,event)" %>
+    <select class='routing_engines' name='routing_engines' onchange="OSM.directions.selectEngine(event)"></select>
     <%= image_tag "searching-small.gif", :class => 'spinner', :style => "vertical-align: middle; display: none;" %>
   </div>