X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/e11d734f9f965464510dd109970501861001ee5c..1596713871672cc319b0d68b51a3698cc6bf0972:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 191f390bf..79c866b2e 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -5,6 +5,7 @@ //= require leaflet.key //= require leaflet.note //= require leaflet.share +//= require leaflet.polyline //= require leaflet.query //= require index/search //= require index/browse @@ -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() { @@ -30,9 +34,9 @@ // IE<10 doesn't respect Vary: X-Requested-With header, so // prevent caching the XHR response as a full-page URL. if (path.indexOf('?') >= 0) { - path += '&xhr=1' + path += '&xhr=1'; } else { - path += '?xhr=1' + path += '?xhr=1'; } $('#sidebar_content') @@ -68,9 +72,7 @@ } }); }; -})(); -$(document).ready(function () { var params = OSM.mapParams(); var map = new L.OSM.Map("map", { @@ -134,7 +136,7 @@ $(document).ready(function () { L.control.scale() .addTo(map); - if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { + if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') { initializeNotes(map); if (params.layers.indexOf(map.noteLayer.options.code) >= 0) { map.addLayer(map.noteLayer); @@ -162,16 +164,7 @@ $(document).ready(function () { $.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') { + if ($.cookie('_osm_welcome') === 'hide') { $('.welcome').hide(); } @@ -237,32 +230,22 @@ $(document).ready(function () { 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'); }; page.load = function() { + var params = querystring.parse(location.search.substring(1)); + if (params.query) { + $("#sidebar .search_form input[name=query]").value(params.query); + } if (!("autofocus" in document.createElement("input"))) { $("#sidebar .search_form input[name=query]").focus(); } 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; }; @@ -280,7 +263,7 @@ $(document).ready(function () { }; function addObject(type, id, center) { - var bounds = map.addObject({type: type, id: parseInt(id)}, function(bounds) { + map.addObject({type: type, id: parseInt(id)}, function(bounds) { if (!window.location.hash && bounds.isValid() && (center || !map.getBounds().contains(bounds))) { OSM.router.withoutMoveListener(function () { @@ -302,6 +285,7 @@ $(document).ready(function () { 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, @@ -316,7 +300,7 @@ $(document).ready(function () { "/query": OSM.Query(map) }); - if (OSM.preferred_editor == "remote" && document.location.pathname == "/edit") { + if (OSM.preferred_editor === "remote" && document.location.pathname === "/edit") { remoteEditHandler(map.getBounds(), params.object); OSM.router.setCurrentPath("/"); }