//= require_self
//= require leaflet.sidebar
//= require leaflet.sidebar-pane
-//= require leaflet.locatecontrol/dist/L.Control.Locate.umd
//= require leaflet.locate
//= require leaflet.layers
//= require leaflet.key
map.setSidebarOverlaid(false);
- $("#sidebar_loader").show().addClass("delayed-fade-in");
+ $("#sidebar_loader").prop("hidden", false).addClass("delayed-fade-in");
// Prevent caching the XHR response as a full-page URL
// https://github.com/openstreetmap/openstreetmap-website/issues/5663
fetch(content_path, { headers: { "accept": "text/html", "x-requested-with": "XMLHttpRequest" } })
.then(response => {
$("#flash").empty();
- $("#sidebar_loader").removeClass("delayed-fade-in").hide();
+ $("#sidebar_loader").removeClass("delayed-fade-in").prop("hidden", true);
const title = response.headers.get("X-Page-Title");
if (title) document.title = decodeURIComponent(title);
}
addControlGroup([
- L.OSM.zoom({ position: position }),
- L.OSM.locate({ position: position })
+ L.OSM.zoom({ position }),
+ L.OSM.locate({ position })
]);
addControlGroup([
L.OSM.layers({
- position: position,
- layers: map.baseLayers,
- sidebar: sidebar
- }),
- L.OSM.key({
- position: position,
- sidebar: sidebar
+ position,
+ sidebar,
+ layers: map.baseLayers
}),
+ L.OSM.key({ position, sidebar }),
L.OSM.share({
- "position": position,
- "sidebar": sidebar,
+ position,
+ sidebar,
"short": true
})
]);
addControlGroup([
- L.OSM.note({
- position: position,
- sidebar: sidebar
- })
+ L.OSM.note({ position, sidebar })
]);
addControlGroup([
- L.OSM.query({
- position: position,
- sidebar: sidebar
- })
+ L.OSM.query({ position, sidebar })
]);
L.control.scale()
})
.catch(() => {
// eslint-disable-next-line no-alert
- alert(I18n.t("site.index.remote_failed"));
+ alert(OSM.i18n.t("site.index.remote_failed"));
});
function sendRemoteEditCommand(url) {
e.preventDefault();
});
- if (OSM.params().edit_help) {
+ if (new URLSearchParams(location.search).get("edit_help")) {
$("#editanchor")
.removeAttr("title")
.tooltip({
placement: "bottom",
- title: I18n.t("javascripts.edit_help")
+ title: OSM.i18n.t("javascripts.edit_help")
})
.tooltip("show");
page.pushstate = page.popstate = function () {
map.setSidebarOverlaid(true);
- document.title = I18n.t("layouts.project_name.title");
+ document.title = OSM.i18n.t("layouts.project_name.title");
};
page.load = function () {
if (params.has("query")) {
$("#sidebar .search_form input[name=query]").value(params.get("query"));
}
- if (!("autofocus" in document.createElement("input"))) {
- $("#sidebar .search_form input[name=query]").focus();
- }
return map.getState();
};
};
function addObject(type, id, version, center) {
- const hashParams = OSM.parseHash(location.hash);
+ const hashParams = OSM.parseHash();
map.addObject({ type: type, id: parseInt(id, 10), version: version && parseInt(version, 10) }, function (bounds) {
if (!hashParams.center && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
return;
}
+ // Open local anchor links as normal.
+ if ($(this).attr("href")?.startsWith("#")) {
+ return;
+ }
+
// Ignore cross-protocol and cross-origin links.
if (location.protocol !== this.protocol || location.host !== this.host) {
return;
}
});
- $(document).on("click", "#sidebar_content .btn-close", function () {
+ $(document).on("click", "#sidebar .sidebar-close-controls button", function () {
OSM.router.route("/" + OSM.formatHash(map));
});
});