From c7f38efd1a8e684c7408aa9c7245797e4269ecb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 00:43:10 +0300 Subject: [PATCH] =?UTF-8?q?The=20PDF=20reader=20gets=20the=20workbook's=20?= =?UTF-8?q?full-size=20panel,=20a=20presentation=20mode,=20and=20an=20alig?= =?UTF-8?q?ned=20header:=20the=20plugin=20only=20unfolds=20its=20full=20to?= =?UTF-8?q?olbar=20with=20room,=20so=20the=20panel=20takes=20the=20viewer?= =?UTF-8?q?=20out=20to=20min(96vw,=201400px)=20and=20full=20height;=20a=20?= =?UTF-8?q?Present=20control=20fullscreens=20the=20panel=20with=20the=20pl?= =?UTF-8?q?ugin's=20own=20toolbar=20intact,=20Escape=20in=20fullscreen=20e?= =?UTF-8?q?xits=20the=20presentation=20without=20closing=20the=20viewer;?= =?UTF-8?q?=20and=20the=20header's=20actions=20center=20on=20one=20row=20i?= =?UTF-8?q?nstead=20of=20the=20download=20box=20riding=20the=20headline's?= =?UTF-8?q?=20top=20edge=20=E2=80=94=20plus=20a=20few=20stray=20blank=20li?= =?UTF-8?q?nes=20in=20i18n.rs=20left=20over=20from=20the=20avatar=20batch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/iz-web/src/detail.rs | 38 +++++++++++++++++++++++++++++++++-- crates/iz-web/src/i18n.rs | 9 +++------ style/main.scss | 40 +++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/crates/iz-web/src/detail.rs b/crates/iz-web/src/detail.rs index 8de3fb6..72efdeb 100644 --- a/crates/iz-web/src/detail.rs +++ b/crates/iz-web/src/detail.rs @@ -31,7 +31,7 @@ use topcoat::router::{HeaderName, StatusCode, header, route}; use topcoat::view::{class, view}; use crate::i18n::{Key, Lang, t}; -use crate::server::{Refusal, store, back_to, mail, refusal_of, require_user, require_writer}; +use crate::server::{Refusal, back_to, mail, refusal_of, require_user, require_writer, store}; /// A task this board could be linked to: enough to name it in the picker and /// nothing more. @@ -417,7 +417,9 @@ async fn load_snapshot( state_kind: state_kind.to_string(), attempts: send.attempts, last_error: may_administer.then(|| send.last_error.clone()).flatten(), - sent_at: send.sent_at.map(|at| moment_label_with_seconds_in(at, zone)), + sent_at: send + .sent_at + .map(|at| moment_label_with_seconds_in(at, zone)), } }) .collect(); @@ -1168,6 +1170,7 @@ pub(crate) async fn escape_closes(cx: &Cx) -> Result { window.__izEsc.register(90, function () { \ if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return false; } \ if (document.querySelector('.viewer-scrim')) { \ + if (document.fullscreenElement) { return true; } \ window.__izCloseViewer(); \ return true; \ } \ @@ -2478,6 +2481,9 @@ pub async fn file_viewer_modal( + if kind == crate::files::ViewerKind::Pdf { + (pdf_present_script(cx).await?) + } } } +/// The PDF reader's presentation mode: the browser's own plugin fills the +/// screen — its toolbar, page box and thumbnails all keep working there, +/// which a drawn-over canvas of our own would not give. Wiring is one +/// delegated document listener, so a soft swap that replaces the button +/// needs no re-wire: whichever `.viewer-present` is on screen when the +/// click lands is the one that presents. `Escape` in fullscreen is the +/// browser's own exit gesture and never reaches the page; the guard in +/// [`escape_closes`] covers the ones that do. +async fn pdf_present_script(cx: &Cx) -> Result { + use topcoat::view::Unescaped; + const JS: &str = "\ + (function () { \ + if (window.__izPresentWired) { return; } \ + window.__izPresentWired = true; \ + document.addEventListener('click', function (e) { \ + var button = e.target.closest('.viewer-present'); \ + if (!button) { return; } \ + var panel = button.closest('.viewer'); \ + if (!panel || !panel.requestFullscreen) { return; } \ + if (document.fullscreenElement) { document.exitFullscreen(); } else { panel.requestFullscreen(); } \ + }); \ + })();"; + view! { cx => } +} + /// One window of one sheet as a table: the tab strip when the book has more /// than one sheet, the grid with its column letters and row numbers, and the /// two pagers that move the window. A workbook no reader here understands diff --git a/crates/iz-web/src/i18n.rs b/crates/iz-web/src/i18n.rs index 0688ca3..9f2a341 100644 --- a/crates/iz-web/src/i18n.rs +++ b/crates/iz-web/src/i18n.rs @@ -66,6 +66,7 @@ pub enum Key { Play, Pause, CloseTheFile, + Present, ThisFileWillNotOpen, Previous, Next, @@ -359,7 +360,6 @@ pub fn take_off_this_task(lang: Lang, name: &str) -> String { } } - /// The phrase a key names, in a user's language. pub fn t(lang: Lang, key: Key) -> &'static str { use Key::*; @@ -431,6 +431,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (Play, Tr) => "Oynat", (Pause, En) => "Pause", (Pause, Tr) => "Duraklat", + (Present, En) => "Present", + (Present, Tr) => "Sun", (CloseTheFile, En) => "Close the file", (CloseTheFile, Tr) => "Dosyayı kapat", (ThisFileWillNotOpen, En) => "This file will not open.", @@ -663,7 +665,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (SenderNotConfiguredYet, En) => "No sender to test.", (SenderNotConfiguredYet, Tr) => "Test edilecek gönderen yok.", - (MailRules, En) => "Mail rules", (MailRules, Tr) => "Posta kuralları", (EditLabel, En) => "Edit", @@ -1032,7 +1033,6 @@ pub fn last_seen_label(lang: Lang, day: &str) -> String { } } - /// The sender panel's failed-test note, in a user's language. pub fn not_delivered_label(lang: Lang, moment: &str, problem: &str) -> String { match lang { @@ -1141,9 +1141,6 @@ pub fn unblocked_label(lang: Lang, detail: &str) -> String { } } - - - pub fn role_changed_label(lang: Lang, detail: &str) -> String { match lang { Lang::En => format!("made {detail}"), diff --git a/style/main.scss b/style/main.scss index aca91d5..af06e14 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1263,6 +1263,45 @@ img.avatar { .viewer-pdf { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: var(--radius-md); } +// A PDF is the browser's own reader living in an , and it reads like +// a workbook does: the panel takes the viewer the whole way out, because the +// plugin only unfolds its full toolbar — page box, thumbnails, zoom — when +// it has the room, and a document is read, not peeked at through 960px. +.viewer:has(.viewer-pdf) { + width: min(96vw, 1400px); + height: calc(100vh - 96px); + display: flex; + flex-direction: column; + overflow: hidden; + + .viewer-body { + flex: 1; + min-height: 0; + align-items: stretch; + padding: 16px 20px 20px; + } + + .viewer-pdf { height: 100%; max-height: none; } +} + +// Presented, the panel is the screen. The plugin keeps its own toolbar and +// the header keeps its actions; only the frame's chrome comes off. +.viewer:fullscreen { + width: 100%; + max-width: none; + height: 100%; + max-height: none; + border: none; + border-radius: 0; +} + +// The viewer's header actions line up on one centered row: the filename is a +// single line, and the download/present boxes center against it instead of +// riding the headline's top edge the way the task modal's taller controls do. +.viewer .detail-head { align-items: center; } + +.viewer .detail-esc { margin-top: 0; } + // A workbook has no element of its own, so the viewer draws it: a tab strip // when the book has more than one sheet, and a grid that pans inside its own // box — the document never scrolls. @@ -4107,6 +4146,7 @@ input[type="radio"] { .modal-scrim { padding: 16px; } .modal { max-height: calc(100dvh - 32px); } + .viewer:has(.viewer-pdf) { height: calc(100dvh - 32px); } .new-task-row { flex-wrap: wrap; }