From: Tom Hughes Date: Sat, 15 Feb 2025 16:42:53 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/4301' X-Git-Tag: live~154 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/70e1a23248922af1f6f31360d542335c67be36cf?hp=6569ed24e4bcc74b8fcbdd70591d4c4a6d907691 Merge remote-tracking branch 'upstream/pull/4301' --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index c3ee1e3bc..b6ead9f2d 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -309,8 +309,9 @@ $(document).ready(function () { }; function addObject(type, id, center) { + var hashParams = OSM.parseHash(window.location.hash); map.addObject({ type: type, id: parseInt(id, 10) }, function (bounds) { - if (!window.location.hash && bounds.isValid() && + if (!hashParams.center && bounds.isValid() && (center || !map.getBounds().contains(bounds))) { OSM.router.withoutMoveListener(function () { map.fitBounds(bounds); diff --git a/app/assets/javascripts/index/changeset.js b/app/assets/javascripts/index/changeset.js index 39b4abde1..d3e61270b 100644 --- a/app/assets/javascripts/index/changeset.js +++ b/app/assets/javascripts/index/changeset.js @@ -12,9 +12,10 @@ OSM.Changeset = function (map) { const changesetData = content.find("[data-changeset]").data("changeset"); changesetData.type = "changeset"; + var hashParams = OSM.parseHash(window.location.hash); initialize(); map.addObject(changesetData, function (bounds) { - if (!window.location.hash && bounds.isValid()) { + if (!hashParams.center && bounds.isValid()) { OSM.router.withoutMoveListener(function () { map.fitBounds(bounds); }); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index e9c51f9bf..6a0487aaa 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -27,13 +27,16 @@ OSM.Note = function (map) { var data = $(".details").data(); if (!data) return; var latLng = L.latLng(data.coordinates.split(",")); - if (!map.getBounds().contains(latLng)) moveToNote(); + if (!map.getBounds().contains(latLng)) { + OSM.router.withoutMoveListener(function () { + map.setView(latLng, 15, { reset: true }); + }); + } }); }; page.load = function (path, id) { initialize(path, id); - moveToNote(); }; function initialize(path, id) { @@ -48,7 +51,6 @@ OSM.Note = function (map) { success: () => { OSM.loadSidebarContent(path, () => { initialize(path, id); - moveToNote(); }); }, error: (xhr) => { @@ -77,11 +79,19 @@ OSM.Note = function (map) { var data = $(".details").data(); if (data) { + var hashParams = OSM.parseHash(window.location.hash); map.addObject({ type: "note", id: parseInt(id, 10), latLng: L.latLng(data.coordinates.split(",")), icon: noteIcons[data.status] + }, function () { + if (!hashParams.center) { + var latLng = L.latLng(data.coordinates.split(",")); + OSM.router.withoutMoveListener(function () { + map.setView(latLng, 15, { reset: true }); + }); + } }); } } @@ -99,18 +109,6 @@ OSM.Note = function (map) { } } - function moveToNote() { - var data = $(".details").data(); - if (!data) return; - var latLng = L.latLng(data.coordinates.split(",")); - - if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) { - OSM.router.withoutMoveListener(function () { - map.setView(latLng, 15, { reset: true }); - }); - } - } - page.unload = function () { map.removeObject(); }; diff --git a/app/assets/stylesheets/errors.scss b/app/assets/stylesheets/errors.scss index fd1400232..77b440a88 100644 --- a/app/assets/stylesheets/errors.scss +++ b/app/assets/stylesheets/errors.scss @@ -1,8 +1,43 @@ -.logo { - float: left; - margin: 10px; +body { + margin: 1rem; + margin-top: 2rem; + font-family: system-ui; } -.details { - float: left; +main { + display: flex; + flex-direction: column; + align-items: center; + gap: 1rem 2rem; + max-width: 960px; + + .logo { + flex-shrink: 0; + + img { + display: block; + max-width: 100%; + height: auto; + } + } + + .details { + h1 { + margin-top: 0; + } + } +} + +@media (min-width: 640px) { + body { + margin: 2rem; + } + + main { + flex-direction: row; + + .logo { + align-self: start; + } + } } diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index e6d709b27..37d830ef6 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -1,6 +1,5 @@ <%= tag.head :data => application_data do %> - - + <%= render :partial => "layouts/meta" %> <%= javascript_include_tag "turbo", :type => "module" %> <%= javascript_include_tag "application" %> <%= javascript_include_tag "i18n/#{I18n.locale}" %> @@ -11,7 +10,6 @@ <% end %> <%= stylesheet_link_tag "print-#{dir}", :media => "print" %> <%= stylesheet_link_tag "leaflet-all", :media => "screen, print" %> - <%= render :partial => "layouts/meta" %> <%= yield :head %> <%= yield :auto_discovery_link_tag %> <%= csrf_meta_tag %> diff --git a/app/views/layouts/_meta.html.erb b/app/views/layouts/_meta.html.erb index 4c88887f9..48be6e0aa 100644 --- a/app/views/layouts/_meta.html.erb +++ b/app/views/layouts/_meta.html.erb @@ -1,3 +1,5 @@ + + <% [57, 60, 72, 76, 114, 120, 144, 152, 180].each do |size| -%> <%= favicon_link_tag "apple-touch-icon-#{size}x#{size}.png", :rel => "apple-touch-icon", :sizes => "#{size}x#{size}", :type => "image/png" %> <% end -%> diff --git a/app/views/layouts/error.html.erb b/app/views/layouts/error.html.erb index dfcb3cb91..eab764aa3 100644 --- a/app/views/layouts/error.html.erb +++ b/app/views/layouts/error.html.erb @@ -1,5 +1,5 @@ - + OpenStreetMap @@ -7,11 +7,13 @@ <%= render :partial => "layouts/meta" %> - - <%= image_tag "osm_logo.svg", :alt => t("layouts.logo.alt_text"), :class => "logo" %> - -
- <%= yield %> -
+
+ +
+ <%= yield %> +
+