From: Anton Khorev Date: Tue, 18 Mar 2025 00:48:52 +0000 (+0300) Subject: Merge branch 'pull/5811' X-Git-Tag: live~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e0434270600e46e888f8ea6d7afbc6e706a278dd?hp=-c Merge branch 'pull/5811' --- e0434270600e46e888f8ea6d7afbc6e706a278dd diff --combined app/assets/javascripts/heatmap.js index 09013ae5a,fccc9a7b0..723fb0017 --- a/app/assets/javascripts/heatmap.js +++ b/app/assets/javascripts/heatmap.js @@@ -16,7 -16,7 +16,7 @@@ document.addEventListener("DOMContentLo const colorScheme = document.documentElement.getAttribute("data-bs-theme") ?? "auto"; const rangeColors = ["#14432a", "#166b34", "#37a446", "#4dd05a"]; const startDate = new Date(Date.now() - (365 * 24 * 60 * 60 * 1000)); - const monthNames = I18n.t("date.abbr_month_names"); + const monthNames = OSM.i18n.t("date.abbr_month_names"); const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)"); @@@ -70,31 -70,29 +70,31 @@@ }] ]); - cal.on("mouseover", (event, _timestamp, value) => { - if (value) event.target.style.cursor = "pointer"; - }); + cal.on("mouseover", (event, timestamp, value) => { + if (!displayName || !value) return; + if (event.target.parentElement.nodeName === "a") return; - cal.on("click", (_event, timestamp) => { - if (!displayName) return; for (const { date, max_id } of heatmapData) { if (!max_id) continue; if (timestamp !== Date.parse(date)) continue; + const params = new URLSearchParams([["before", max_id + 1]]); - location = `/user/${encodeURIComponent(displayName)}/history?${params}`; + const a = document.createElementNS("http://www.w3.org/2000/svg", "a"); + a.setAttribute("href", `/user/${encodeURIComponent(displayName)}/history?${params}`); + $(event.target).wrap(a); + break; } }); } function getTooltipText(date, value) { - const localizedDate = I18n.l("date.formats.long", date); + const localizedDate = OSM.i18n.l("date.formats.long", date); if (value > 0) { - return I18n.t("javascripts.heatmap.tooltip.contributions", { count: value, date: localizedDate }); + return OSM.i18n.t("javascripts.heatmap.tooltip.contributions", { count: value, date: localizedDate }); } - return I18n.t("javascripts.heatmap.tooltip.no_contributions", { date: localizedDate }); + return OSM.i18n.t("javascripts.heatmap.tooltip.no_contributions", { date: localizedDate }); } function getTheme() {