]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/master' into routing-merge
authorMatt Amos <zerebubuth@gmail.com>
Mon, 10 Nov 2014 16:14:06 +0000 (16:14 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 10 Nov 2014 16:14:06 +0000 (16:14 +0000)
Conflicts:
app/assets/javascripts/index.js
config/locales/en.yml

1  2 
app/assets/javascripts/index.js
app/assets/javascripts/router.js
app/assets/stylesheets/common.css.scss
config/locales/en.yml
config/routes.rb

index b89d6c71d55cf9e56b5d53a40fc788c5803e7d67,df975db48fe75b7690d5223cf6ecf894fcaff231..66dfa5b6fac3975a2c00daa6b651d76034303ef0
@@@ -5,7 -5,7 +5,8 @@@
  //= require leaflet.key
  //= require leaflet.note
  //= require leaflet.share
 +//= require leaflet.polyline
+ //= require leaflet.query
  //= require index/search
  //= require index/browse
  //= require index/export
  //= require index/history
  //= require index/note
  //= require index/new_note
 +//= require index/directions
  //= require index/changeset
+ //= require index/query
  //= require router
  
 -(function() {
 +$(document).ready(function () {
    var loaderTimeout;
  
    OSM.loadSidebarContent = function(path, callback) {
 +    map.setSidebarOverlaid(false);
 +
      clearTimeout(loaderTimeout);
  
      loaderTimeout = setTimeout(function() {
@@@ -70,7 -68,9 +72,7 @@@
        }
      });
    };
 -})();
  
 -$(document).ready(function () {
    var params = OSM.mapParams();
  
    var map = new L.OSM.Map("map", {
      sidebar: sidebar
    }).addTo(map);
  
+   L.OSM.query({
+     position: position,
+     sidebar: sidebar
+   }).addTo(map);
    L.control.scale()
      .addTo(map);
  
      $.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
    });
  
-   if ($.cookie('_osm_sotm') == 'hide') {
-     $('#sotm').hide();
-   }
-   $('#sotm .close').on('click', function() {
-     $('#sotm').hide();
-     $.cookie("_osm_sotm", 'hide', { expires: expiry });
-   });
    if ($.cookie('_osm_welcome') == 'hide') {
      $('.welcome').hide();
    }
    OSM.Index = function(map) {
      var page = {};
  
 -    page.pushstate = function() {
 -      $("#content").addClass("overlay-sidebar");
 -      map.invalidateSize({pan: false})
 -        .panBy([-350, 0], {animate: false});
 +    page.pushstate = page.popstate = function() {
 +      map.setSidebarOverlaid(true);
        document.title = I18n.t('layouts.project_name.title');
      };
  
        return map.getState();
      };
  
 -    page.popstate = function() {
 -      $("#content").addClass("overlay-sidebar");
 -      map.invalidateSize({pan: false});
 -      document.title = I18n.t('layouts.project_name.title');
 -    };
 -
 -    page.unload = function() {
 -      map.panBy([350, 0], {animate: false});
 -      $("#content").removeClass("overlay-sidebar");
 -      map.invalidateSize({pan: false});
 -    };
 -
      return page;
    };
  
    OSM.router = OSM.Router(map, {
      "/":                           OSM.Index(map),
      "/search":                     OSM.Search(map),
 +    "/directions":                 OSM.Directions(map),
      "/export":                     OSM.Export(map),
      "/note/new":                   OSM.NewNote(map),
      "/history/friends":            history,
      "/node/:id(/history)":         OSM.Browse(map, 'node'),
      "/way/:id(/history)":          OSM.Browse(map, 'way'),
      "/relation/:id(/history)":     OSM.Browse(map, 'relation'),
-     "/changeset/:id":              OSM.Changeset(map)
+     "/changeset/:id":              OSM.Changeset(map),
+     "/query":                      OSM.Query(map)
    });
  
    if (OSM.preferred_editor == "remote" && document.location.pathname == "/edit") {
index c3f13f9dffc1afc78aff160071b5657184b742e0,dcf8ea6a8cbad7aa45c8a2717e71f67fdf19b6e0..904134fc078630cedbd86c5f0771abafa950e366
@@@ -76,6 -76,8 +76,8 @@@ OSM.Router = function(map, rts) 
          });
        }
  
+       params = params.concat(Array.prototype.slice.call(arguments, 2));
        return (controller[action] || $.noop).apply(controller, params);
      };
  
    if (window.history && window.history.pushState) {
      $(window).on('popstate', function(e) {
        if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
-       var path = window.location.pathname + window.location.search;
+       var path = window.location.pathname + window.location.search,
+         route = routes.recognize(path);
        if (path === currentPath) return;
-       currentRoute.run('unload');
+       currentRoute.run('unload', null, route === currentRoute);
        currentPath = path;
-       currentRoute = routes.recognize(currentPath);
+       currentRoute = route;
        currentRoute.run('popstate', currentPath);
        map.setState(e.originalEvent.state, {animate: false});
      });
        var path = url.replace(/#.*/, ''),
          route = routes.recognize(path);
        if (!route) return false;
-       currentRoute.run('unload');
+       currentRoute.run('unload', null, route === currentRoute);
        var state = OSM.parseHash(url);
        map.setState(state);
        window.history.pushState(state, document.title, url);
        return true;
      };
  
 +    router.replace = function (url) {
 +      window.history.replaceState(OSM.parseHash(url), document.title, url);
 +    };
 +
      router.stateChange = function(state) {
        if (state.center) {
          window.history.replaceState(state, document.title, OSM.formatHash(state));
        }
      };
    } else {
 -    router.route = function (url) {
 +    router.route = router.replace = function (url) {
        window.location.assign(url);
      };
  
index aa729640eadabf7b2e61ca06a528f38a94d6f48a,aa95e818a844972008acfc69feabedd602495b3c..95e5d8328dd144460847ed268e8135ea1068cd96
@@@ -169,7 -169,7 +169,7 @@@ small, aside 
  .icon.close:hover { background-position: -200px -20px; }
  .icon.check       { background-position: -220px 0; }
  .icon.note        { background-position: -240px 0; }
- .icon.gear        { background-position: -260px 0; }
+ .icon.query       { background-position: -260px 0; }
  
  /* Rules for links */
  
@@@ -566,16 -566,16 +566,16 @@@ nav.secondary 
      background-color: black;
    }
  
-   &.active {
-     background-color: #9ed485;
-   }
    &.disabled {
      background-color: #333;
      background-color: rgba(0,0,0,.5);
      cursor: default;
    }
  
+   &.active {
+     background-color: #9ed485;
+   }
    .icon {
      margin: 10px;
    }
    #map {
      height: 100%;
      overflow: hidden;
+     &.query-active {
+       cursor: help;
+     }
+     &.query-disabled {
+       cursor: not-allowed;
+     }
    }
  
    #map-ui {
    }
  }
  
 -/* Rules for the search box */
 +/* Rules for the search and direction forms */
  
 -header .search_form {
 +header .search_forms,
 +.directions_form {
    display: none;
  }
  
 -.search_form {
 +.search_form,
 +.directions_form {
    position: relative;
    padding: $lineheight/2;
 +  padding-top: 1px;
    background-color: $lightgrey;
  
    .query_wrapper {
      border-radius: 0 2px 2px 0;
    }
  
 -  .describe_location {
 -    position: absolute;
 -    top: 6px;
 -    right: 6px;
 +  .query_options {
 +    text-align: right;
      font-size: 10px;
      color: $blue;
    }
    color: #f00;
  }
  
 +/* Rules for routing */
 +
 +#sidebar_content>table {
 +    padding: 5px 20px 10px 15px;
 +    width: 100%;
 +    border-collapse: separate;
 +}
 +
 +td.direction {
 +    background-image: image-url('routing-sprite.png'); 
 +    width: 20px; height: 20px; 
 +    background-repeat: no-repeat;
 +}
 +@for $i from 1 through 17 {
 +td.direction.i#{$i}  { background-position: #{($i)*-20+20}px 0px; }
 +}
 +
 +.directions_form input[type="submit"] {
 +    margin-top: 30px !important;
 +}
 +
 +p#routing_summary {
 +    padding: 0 $lineheight $lineheight/4;
 +}
 +
 +td.instruction, td.distance {
 +    padding-top: 0;
 +    border-bottom: 1px solid #DDD;
 +}
 +td.distance {
 +    color: #BBB;
 +    text-align: right;
 +    font-size: x-small;
 +}
 +tr.turn {
 +    cursor: pointer;
 +}
 +tr.turn:hover {
 +    background: lighten($green, 30%); 
 +}
 +.routing_engines, #route_from, #route_to { margin-left: 25px; }
 +.routing_marker { width: 15px; position: absolute; }
 +
  /* Rules for entity history */
  
  #sidebar_content {
      overflow: hidden;
      margin: 0 0 10px 10px;
    }
+   .query-intro p {
+     padding: $lineheight $lineheight $lineheight/2;
+   }
+   .query-results {
+     display: none;
+     h3 {
+       padding: $lineheight $lineheight $lineheight/2;
+       margin: 0;
+     }
+     ul {
+       li {
+         padding: 15px 20px;
+         border-bottom: 1px solid #ddd;
+         &.query-result {
+           cursor: pointer;
+         }
+         &.selected {
+           background: #FFFFE6;
+         }
+       }
+     }
+   }
  }
  
  /* Rules for export sidebar */
    }
  }
  
 +/* Rules for the routing sidebar */
 +
 +#sidebar_content {
 +  #routing_credit {
 +    text-align: center;
 +    padding: 0.5em;
 +  }
 +}
 +
  /* Rules for edit pages */
  
  .site-edit {
@@@ -2618,36 -2601,6 +2654,6 @@@ input.richtext_title[type="text"] 
    }
  }
  
- #sidebar #sotm {
-   padding: 10px;
-   min-height: 120px;
-   img {
-     float: left;
-     width: 100px;
-     height: 100px;
-   }
-   h2 {
-     margin-left: 100px;
-     padding: 7px 10px 6px 15px;
-   }
-   p {
-     margin-left: 100px;
-     padding: 6px 10px 7px 15px;
-   }
-   a {
-     color: $darkgrey;
-   }
-   :hover {
-     text-decoration: none;
-     color: darken($darkgrey, 25%);
-   }
- }
  @import 'browse';
  
  @media only screen and (max-width:960px) {
diff --combined config/locales/en.yml
index 7548833d855c2d62b4e9b2340247105eb7c80a15,87123f282b142baebbb598dade977624c9b06d9d..d2797511bec70a6de1a59c17394111d514aefc62
@@@ -204,6 -204,11 +204,11 @@@ en
        reopened_by: "Reactivated by %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
        reopened_by_anonymous: "Reactivated by anonymous <abbr title='%{exact_time}'>%{when} ago</abbr>"
        hidden_by: "Hidden by %{user} <abbr title='%{exact_time}'>%{when} ago</abbr>"
+     query:
+       title: "Query Features"
+       introduction: "Click on the map to find nearby features."
+       nearby: "Nearby features"
+       enclosing: "Enclosing features"
    changeset:
      changeset_paging_nav:
        showing_page: "Page %{page}"
            primary_link: "Primary Road"
            proposed: "Proposed Road"
            raceway: "Raceway"
-           residential: "Residential"
+           residential: "Residential Road"
            rest_area: "Rest Area"
            road: "Road"
            secondary: "Secondary Road"
            tram: "Tramway"
            tram_stop: "Tram Stop"
            yard: "Railway Yard"
+         route:
+           bus: "Bus Route"
          shop:
            alcohol: "Off License"
            antiques: "Antiques"
        text: Make a Donation
      learn_more: "Learn More"
      more: More
-     sotm_header: State of the Map 2014
-     sotm_line_1: 8th Annual Conference
-     sotm_line_2: November 7th-9th 2014
-     sotm_line_3: Buenos Aires, Argentina
    license_page:
      foreign:
        title: About this translation
        close: Close
      search:
        search: Search
 +      get_directions: "Get directions"
 +      get_directions_title: "Find directions between two points"
 +      close_directions: "Close directions"
 +      close_directions_title: "Close the directions panel"
 +      from: "From"
 +      to: "To"
        where_am_i: "Where am I?"
        where_am_i_title: Describe the current location using the search engine
        submit_text: "Go"
        createnote_disabled_tooltip: Zoom in to add a note to the map
        map_notes_zoom_in_tooltip: Zoom in to see map notes
        map_data_zoom_in_tooltip: Zoom in to see map data
+       queryfeature_tooltip: Query features
+       queryfeature_disabled_tooltip: Zoom in to query features
      changesets:
        show:
          comment: "Comment"
          comment_and_resolve: Comment & Resolve
          comment: Comment
      edit_help: Move the map and zoom in on a location you want to edit, then click here.
 +    directions:
 +      engines:
 +        graphhopper_bicycle: "Bicycle (GraphHopper)"
 +        graphhopper_foot: "Foot (GraphHopper)"
 +        mapquest_bicycle: "Bicycle (MapQuest)"
 +        mapquest_car: "Car (MapQuest)"
 +        mapquest_foot: "Foot (MapQuest)"
 +        osrm_car: "Car (OSRM)"
 +      directions: "Directions"
 +      distance: "Distance"
 +      errors:
 +        no_route: "Couldn't find a route between those two places."
 +        no_place: "Sorry - couldn't find that place."
 +      instructions:
 +        continue_on: "Continue on "
 +        slight_right: "Slight right onto "
 +        turn_right: "Turn right onto "
 +        sharp_right: "Sharp right onto "
 +        uturn: "U-turn along "
 +        sharp_left: "Sharp left onto "
 +        turn_left: "Turn left onto "
 +        slight_left: "Slight left onto "
 +        via_point: "(via point) "
 +        follow:  "Follow "
 +        roundabout: "At roundabout take "
 +        leave_roundabout: "Leave roundabout - "
 +        stay_roundabout: "Stay on roundabout - "
 +        start: "Start at end of "
 +        destination: "Reach destination"
 +        against_oneway: "Go against one-way on "
 +        end_oneway: "End of one-way on "
 +        unnamed: "(unnamed)"
 +        courtesy: "Directions courtesy of %{link}"
 +      time: "Time"
+     query:
+       node: Node
+       way: Way
+       relation: Relation
+       nothing_found: No features found
+       error: "Error contacting %{server}: %{error}"
+       timeout: "Timeout contacting %{server}"
    redaction:
      edit:
        description: "Description"
diff --combined config/routes.rb
index b28b6aff40d056e83e6a8a49270cc8c0990fba7d,7084d1c8dac071a8ab8f4ec4546a5b3ac2280491..3d47c6dcf9897632e4a3a4ad553cc061c1160b83
@@@ -157,6 -157,7 +157,7 @@@ OpenStreetMap::Application.routes.draw 
    match '/offline' => 'site#offline', :via => :get
    match '/key' => 'site#key', :via => :get
    match '/id' => 'site#id', :via => :get
+   match '/query' => 'browse#query', :via => :get
    match '/user/new' => 'user#new', :via => :get
    match '/user/new' => 'user#create', :via => :post
    match '/user/terms' => 'user#terms', :via => :get
    match '/geocoder/search_osm_nominatim_reverse' => 'geocoder#search_osm_nominatim_reverse', :via => :get
    match '/geocoder/search_geonames_reverse' => 'geocoder#search_geonames_reverse', :via => :get
  
 +  # directions
 +  match '/directions' => 'directions#search', :via => :get, :as => :directions
 +
    # export
    match '/export/finish' => 'export#finish', :via => :post
    match '/export/embed' => 'export#embed', :via => :get