From 394ff3f7b2ee1e940c848be2cec246f441d85077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 1 Oct 2023 12:21:29 +0200 Subject: [PATCH] mermaid: improve zoom UX #659 --- i18n/ar.toml | 3 +++ i18n/cs.toml | 3 +++ i18n/de.toml | 3 +++ i18n/en.toml | 3 +++ i18n/es.toml | 3 +++ i18n/fi.toml | 3 +++ i18n/fr.toml | 3 +++ i18n/hi.toml | 3 +++ i18n/hu.toml | 3 +++ i18n/id.toml | 3 +++ i18n/it.toml | 5 ++++- i18n/ja.toml | 3 +++ i18n/ko.toml | 3 +++ i18n/nl.toml | 3 +++ i18n/pir.toml | 3 +++ i18n/pl.toml | 3 +++ i18n/pt.toml | 5 ++++- i18n/ru.toml | 3 +++ i18n/tr.toml | 3 +++ i18n/vi.toml | 3 +++ i18n/zh-cn.toml | 3 +++ i18n/zh-tw.toml | 3 +++ i18n/zh.toml | 3 +++ layouts/partials/stylesheet.html | 1 + static/js/theme.js | 14 ++++++++++++-- 25 files changed, 84 insertions(+), 4 deletions(-) diff --git a/i18n/ar.toml b/i18n/ar.toml index 3f3e22eeca..66bac7e388 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -22,6 +22,9 @@ other = "مسح السجل" [Reset-view] other = "إعادة تعيين طريقة العرض" +[View-reset] +other = "عرض إعادة تعيين!" + [Attachments-label] other = "مرفقات" diff --git a/i18n/cs.toml b/i18n/cs.toml index aab587292e..9d76088e41 100644 --- a/i18n/cs.toml +++ b/i18n/cs.toml @@ -22,6 +22,9 @@ other = "Vymazat historii" [Reset-view] other = "Obnovit zobrazení" +[View-reset] +other = "Resetovat zobrazení!" + [Attachments-label] other = "Přílohy" diff --git a/i18n/de.toml b/i18n/de.toml index e9f650db55..ba55797494 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -22,6 +22,9 @@ other = "Verlauf löschen" [Reset-view] other = "Ansicht zurücksetzen" +[View-reset] +other = "Ansicht zurückgesetzt!" + [Attachments-label] other = "Anhänge" diff --git a/i18n/en.toml b/i18n/en.toml index ab0781da76..02bb6f1e82 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -22,6 +22,9 @@ other = "Clear History" [Reset-view] other = "Reset view" +[View-reset] +other = "View reset!" + [Attachments-label] other = "Attachments" diff --git a/i18n/es.toml b/i18n/es.toml index 943c924ffa..bfa9921432 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -22,6 +22,9 @@ other = "Borrar Historial" [Reset-view] other = "Restablecer vista" +[View-reset] +other = "¡Ver reajuste!" + [Attachments-label] other = "Adjuntos" diff --git a/i18n/fi.toml b/i18n/fi.toml index b7c05097e5..37e7bbfb50 100644 --- a/i18n/fi.toml +++ b/i18n/fi.toml @@ -22,6 +22,9 @@ other = "Tyhjennä historia" [Reset-view] other = "Palauta näkymä" +[View-reset] +other = "Näkymä nollattu!" + [Attachments-label] other = "Liitteet" diff --git a/i18n/fr.toml b/i18n/fr.toml index 0051c6444e..a212fcd88c 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -22,6 +22,9 @@ other = "Supprimer l'historique" [Reset-view] other = "Réinitialiser la vue" +[View-reset] +other = "Vue réinitialisée!" + [Attachments-label] other = "Pièces jointes" diff --git a/i18n/hi.toml b/i18n/hi.toml index 77063ef3fd..594875c907 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -22,6 +22,9 @@ other = "इतिहास मिटाएँ" [Reset-view] other = "दृश्य रीसेट करें" +[View-reset] +other = "देखें रीसेट!" + [Attachments-label] other = "संलग्नंक (अटैचमेंट)" diff --git a/i18n/hu.toml b/i18n/hu.toml index 2f9d17b24b..6c08811ecd 100644 --- a/i18n/hu.toml +++ b/i18n/hu.toml @@ -19,6 +19,9 @@ other = "Előzmények törlése" [Reset-view] other = "Nézet visszaállítása" +[View-reset] +other = "Visszaállítás megtekintése!" + [Clear-search] other = "Keresések törlése" diff --git a/i18n/id.toml b/i18n/id.toml index d80eef1164..51a01df400 100644 --- a/i18n/id.toml +++ b/i18n/id.toml @@ -22,6 +22,9 @@ other = "Bersihkan Riwayat" [Reset-view] other = "Setel ulang tampilan" +[View-reset] +other = "Lihat ulang!" + [Attachments-label] other = "Lampiran" diff --git a/i18n/it.toml b/i18n/it.toml index 828c58110d..d3c69e1b5d 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -20,7 +20,10 @@ other = "{1} risultati trovati per \"{0}\"" other = "Reimposta storico" [Reset-view] -other = "Ripristina visualizzazione" +other = "Azzeramento vista" + +[View-reset] +other = "Vista azzerata!" [Attachments-label] other = "Allegati" diff --git a/i18n/ja.toml b/i18n/ja.toml index 1e7b3c525c..b3351f47e6 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -22,6 +22,9 @@ other = "履歴削除" [Reset-view] other = "ビューのリセット" +[View-reset] +other = "リセットを見る" + [Attachments-label] other = "添付" diff --git a/i18n/ko.toml b/i18n/ko.toml index fa0a3c8363..ed53fe8dfd 100644 --- a/i18n/ko.toml +++ b/i18n/ko.toml @@ -22,6 +22,9 @@ other = "방문 기록 삭제" [Reset-view] other = "보기 재설정" +[View-reset] +other = "보기 초기화!" + [Attachments-label] other = "첨부파일" diff --git a/i18n/nl.toml b/i18n/nl.toml index 222afd1e53..870c5adefe 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -22,6 +22,9 @@ other = "Wis geschiedenis" [Reset-view] other = "Weergave opnieuw instellen" +[View-reset] +other = "Opnieuw instellen weergeven!" + [Attachments-label] other = "Bijlagen" diff --git a/i18n/pir.toml b/i18n/pir.toml index 3bdc2d3f13..d8cc10927d 100644 --- a/i18n/pir.toml +++ b/i18n/pir.toml @@ -22,6 +22,9 @@ other = "Clearrr Historrry" [Reset-view] other = "Rrreset view" +[View-reset] +other = "View rrreset!" + [Attachments-label] other = "Attachments" diff --git a/i18n/pl.toml b/i18n/pl.toml index a59ecdb5cd..a91a852fa1 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -22,6 +22,9 @@ other = "Wyczyść historię" [Reset-view] other = "Resetowanie widoku" +[View-reset] +other = "Widok zresetowany!" + [Attachments-label] other = "Załączniki" diff --git a/i18n/pt.toml b/i18n/pt.toml index 8690a882a8..9bb8293c66 100644 --- a/i18n/pt.toml +++ b/i18n/pt.toml @@ -20,7 +20,10 @@ other = "{1} resultados encontrados para \"{0}\"" other = "Limpar Histórico" [Reset-view] -other = "Redefinir modo de exibição" +other = "Repor vista" + +[View-reset] +other = "Ver reposição!" [Attachments-label] other = "Anexos" diff --git a/i18n/ru.toml b/i18n/ru.toml index a10bb79035..fa790ff20f 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -22,6 +22,9 @@ other = "Очистить историю" [Reset-view] other = "Вид на сброс" +[View-reset] +other = "Посмотреть сброс!" + [Attachments-label] other = "Присоединенные файлы" diff --git a/i18n/tr.toml b/i18n/tr.toml index 59e0edcffc..054c0861a4 100644 --- a/i18n/tr.toml +++ b/i18n/tr.toml @@ -22,6 +22,9 @@ other = "Geçmişi Temizle" [Reset-view] other = "Görünümü sıfırla" +[View-reset] +other = "Görünüm sıfırlandı!" + [Attachments-label] other = "Ekler" diff --git a/i18n/vi.toml b/i18n/vi.toml index f28ee93d85..d1f9af62c4 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -22,6 +22,9 @@ other = "Xóa lịch sử.." [Reset-view] other = "Đặt lại dạng xem" +[View-reset] +other = "Xem đặt lại!" + [Attachments-label] other = "Tập tin đính kèm" diff --git a/i18n/zh-cn.toml b/i18n/zh-cn.toml index 2b033c7b1e..b1d7b40789 100644 --- a/i18n/zh-cn.toml +++ b/i18n/zh-cn.toml @@ -22,6 +22,9 @@ other = "清理历史记录" [Reset-view] other = "重置视图" +[View-reset] +other = "查看重置!" + [Attachments-label] other = "附件" diff --git a/i18n/zh-tw.toml b/i18n/zh-tw.toml index d286d42bd9..49509135ad 100644 --- a/i18n/zh-tw.toml +++ b/i18n/zh-tw.toml @@ -22,6 +22,9 @@ other = "清除歷史紀錄" [Reset-view] other = "重置檢視" +[View-reset] +other = "查看重置!" + [Attachments-label] other = "附件" diff --git a/i18n/zh.toml b/i18n/zh.toml index 2b033c7b1e..b1d7b40789 100644 --- a/i18n/zh.toml +++ b/i18n/zh.toml @@ -22,6 +22,9 @@ other = "清理历史记录" [Reset-view] other = "重置视图" +[View-reset] +other = "查看重置!" + [Attachments-label] other = "附件" diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html index e905bbc96f..d908a7beac 100644 --- a/layouts/partials/stylesheet.html +++ b/layouts/partials/stylesheet.html @@ -48,6 +48,7 @@ window.T_Copy_link_to_clipboard = '{{ T "Copy-link-to-clipboard" | safeJS }}'; window.T_Link_copied_to_clipboard = '{{ T "Link-copied-to-clipboard" | safeJS }}'; window.T_Reset_view = '{{ T "Reset-view" | safeJS }}'; + window.T_View_reset = '{{ T "View-reset" | safeJS }}'; window.T_No_results_found = '{{ T "No-results-found" | safeJS }}'; window.T_N_results_found = '{{ T "N-results-found" | safeJS }}'; {{ "// some further base stuff" | safeJS }} diff --git a/static/js/theme.js b/static/js/theme.js index 1d202b2876..d10dbcc212 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -155,6 +155,9 @@ function restoreTabSelections() { } function initMermaid( update, attrs ) { + var doBeside = false; + var isImageRtl = false; + // we are either in update or initialization mode; // during initialization, we want to edit the DOM; // during update we only want to execute if something changed @@ -324,12 +327,19 @@ function initMermaid( update, attrs ) { // we need to copy the maxWidth, otherwise our reset button will not align in the upper right parent.style.maxWidth = this.style.maxWidth || this.getAttribute( 'width' ); // if no unit is given for the width - parent.style.maxWidth = parent.style.maxWidth || this.getAttribute( 'width' ) + 'px'; + parent.style.maxWidth = parent.style.maxWidth || 'calc( ' + this.getAttribute( 'width' ) + 'px + 1rem )'; parent.insertAdjacentHTML( 'beforeend', '' ); - parent.querySelector( '.svg-reset-button' ).addEventListener( 'click', function( event ){ + var button = parent.querySelector( '.svg-reset-button' ); + button.addEventListener( 'click', function( event ){ inner.transition() .duration( 350 ) .call( zoom.transform, d3.zoomIdentity ); + this.setAttribute( 'aria-label', window.T_View_reset ); + this.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isImageRtl?'e':'w')) ); + }); + button.addEventListener( 'mouseleave', function() { + this.removeAttribute( 'aria-label' ); + this.classList.remove( 'tooltipped', 'tooltipped-w', 'tooltipped-se', 'tooltipped-sw' ); }); }); },