From: Matt Amos Date: Mon, 10 Nov 2014 16:14:06 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/master' into routing-merge X-Git-Tag: live~5255^2~13^2~4 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/0cb475cc1ad12c82ff0a36f7b9629c2288737a4f?ds=sidebyside;hp=-c Merge remote-tracking branch 'upstream/master' into routing-merge Conflicts: app/assets/javascripts/index.js config/locales/en.yml --- 0cb475cc1ad12c82ff0a36f7b9629c2288737a4f diff --combined app/assets/javascripts/index.js index b89d6c71d,df975db48..66dfa5b6f --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@@ -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 @@@ -13,16 -13,14 +14,17 @@@ //= 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", { @@@ -126,6 -126,11 +128,11 @@@ sidebar: sidebar }).addTo(map); + L.OSM.query({ + position: position, + sidebar: sidebar + }).addTo(map); + L.control.scale() .addTo(map); @@@ -157,15 -162,6 +164,6 @@@ $.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(); } @@@ -232,8 -228,10 +230,8 @@@ 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'); }; @@@ -244,6 -242,18 +242,6 @@@ 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; }; @@@ -283,7 -293,6 +281,7 @@@ 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, @@@ -294,7 -303,8 +292,8 @@@ "/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") { diff --combined app/assets/javascripts/router.js index c3f13f9df,dcf8ea6a8..904134fc0 --- a/app/assets/javascripts/router.js +++ b/app/assets/javascripts/router.js @@@ -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); }; @@@ -101,11 -103,12 +103,12 @@@ 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}); }); @@@ -114,7 -117,7 +117,7 @@@ 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); @@@ -124,10 -127,6 +127,10 @@@ 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)); @@@ -136,7 -135,7 +139,7 @@@ } }; } else { - router.route = function (url) { + router.route = router.replace = function (url) { window.location.assign(url); }; diff --combined app/assets/stylesheets/common.css.scss index aa729640e,aa95e818a..95e5d8328 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@@ -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; } @@@ -680,6 -680,14 +680,14 @@@ #map { height: 100%; overflow: hidden; + + &.query-active { + cursor: help; + } + + &.query-disabled { + cursor: not-allowed; + } } #map-ui { @@@ -899,18 -907,15 +907,18 @@@ } } -/* 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 { @@@ -939,8 -944,10 +947,8 @@@ border-radius: 0 2px 2px 0; } - .describe_location { - position: absolute; - top: 6px; - right: 6px; + .query_options { + text-align: right; font-size: 10px; color: $blue; } @@@ -982,49 -989,6 +990,49 @@@ 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 { @@@ -1180,6 -1144,34 +1188,34 @@@ 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 */ @@@ -1236,15 -1228,6 +1272,15 @@@ } } +/* 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 7548833d8,87123f282..d2797511b --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -204,6 -204,11 +204,11 @@@ en reopened_by: "Reactivated by %{user} %{when} ago" reopened_by_anonymous: "Reactivated by anonymous %{when} ago" hidden_by: "Hidden by %{user} %{when} ago" + 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}" @@@ -521,7 -526,7 +526,7 @@@ primary_link: "Primary Road" proposed: "Proposed Road" raceway: "Raceway" - residential: "Residential" + residential: "Residential Road" rest_area: "Rest Area" road: "Road" secondary: "Secondary Road" @@@ -732,6 -737,8 +737,8 @@@ tram: "Tramway" tram_stop: "Tram Stop" yard: "Railway Yard" + route: + bus: "Bus Route" shop: alcohol: "Off License" antiques: "Antiques" @@@ -937,10 -944,6 +944,6 @@@ 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 @@@ -1353,12 -1356,6 +1356,12 @@@ 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" @@@ -2132,6 -2129,8 +2135,8 @@@ 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" @@@ -2151,40 -2150,13 +2156,47 @@@ 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 b28b6aff4,7084d1c8d..3d47c6dcf --- a/config/routes.rb +++ b/config/routes.rb @@@ -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 @@@ -246,9 -247,6 +247,9 @@@ 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