forge
Explore
Log in

Don't you dare go Hollow

The PDF reader gets the workbook's full-size panel, a presentation mode, and an aligned header: the plugin only unfolds its full toolbar with room, so the panel takes the viewer out to min(96vw, 1400px) and full height; a Present control fullscreens the panel with the plugin's own toolbar intact, Escape in fullscreen exits the presentation without closing the viewer; and the header's actions center on one row instead of the download box riding the headline's top edge — plus a few stray blank lines in i18n.rs left over from the avatar batch

Browse files at this commit

c7f38efd1a8e684c7408aa9c7245797e4269ecb3Ahmet Kaan GümüşParent: 8eb2137
crates/iz-web/src/detail.rsmodified+36 -2
@@ -31,7 +31,7 @@ use topcoat::router::{HeaderName, StatusCode, header, route};
3131 use topcoat::view::{class, view};
3232
3333 use crate::i18n::{Key, Lang, t};
34-use crate::server::{Refusal, store, back_to, mail, refusal_of, require_user, require_writer};
34+use crate::server::{Refusal, back_to, mail, refusal_of, require_user, require_writer, store};
3535
3636 /// A task this board could be linked to: enough to name it in the picker and
3737 /// nothing more.
@@ -417,7 +417,9 @@ async fn load_snapshot(
417417 state_kind: state_kind.to_string(),
418418 attempts: send.attempts,
419419 last_error: may_administer.then(|| send.last_error.clone()).flatten(),
420- sent_at: send.sent_at.map(|at| moment_label_with_seconds_in(at, zone)),
420+ sent_at: send
421+ .sent_at
422+ .map(|at| moment_label_with_seconds_in(at, zone)),
421423 }
422424 })
423425 .collect();
@@ -1168,6 +1170,7 @@ pub(crate) async fn escape_closes(cx: &Cx) -> Result {
11681170 window.__izEsc.register(90, function () { \
11691171 if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return false; } \
11701172 if (document.querySelector('.viewer-scrim')) { \
1173+ if (document.fullscreenElement) { return true; } \
11711174 window.__izCloseViewer(); \
11721175 return true; \
11731176 } \
@@ -2478,6 +2481,9 @@ pub async fn file_viewer_modal(
24782481 <div class="modal viewer" tabindex="-1">
24792482 <header class="detail-head">
24802483 <span class="detail-headline"><span class="detail-key">(name.clone())</span></span>
2484+ if kind == crate::files::ViewerKind::Pdf {
2485+ <button type="button" class="quiet viewer-present">(t(lang, Key::Present))</button>
2486+ }
24812487 <a class="quiet" href=(download_href)>(t(lang, Key::Download))</a>
24822488 <span class="detail-esc">(t(lang, Key::Esc))</span>
24832489 <a class="detail-close" href=(close_href) aria-label=(t(lang, Key::CloseTheFile))>(glyph::cross(cx).await?)</a>
@@ -2506,10 +2512,38 @@ pub async fn file_viewer_modal(
25062512 }
25072513 </div>
25082514 </div>
2515+ if kind == crate::files::ViewerKind::Pdf {
2516+ (pdf_present_script(cx).await?)
2517+ }
25092518 </div>
25102519 }
25112520 }
25122521
2522+/// The PDF reader's presentation mode: the browser's own plugin fills the
2523+/// screen — its toolbar, page box and thumbnails all keep working there,
2524+/// which a drawn-over canvas of our own would not give. Wiring is one
2525+/// delegated document listener, so a soft swap that replaces the button
2526+/// needs no re-wire: whichever `.viewer-present` is on screen when the
2527+/// click lands is the one that presents. `Escape` in fullscreen is the
2528+/// browser's own exit gesture and never reaches the page; the guard in
2529+/// [`escape_closes`] covers the ones that do.
2530+async fn pdf_present_script(cx: &Cx) -> Result {
2531+ use topcoat::view::Unescaped;
2532+ const JS: &str = "\
2533+ (function () { \
2534+ if (window.__izPresentWired) { return; } \
2535+ window.__izPresentWired = true; \
2536+ document.addEventListener('click', function (e) { \
2537+ var button = e.target.closest('.viewer-present'); \
2538+ if (!button) { return; } \
2539+ var panel = button.closest('.viewer'); \
2540+ if (!panel || !panel.requestFullscreen) { return; } \
2541+ if (document.fullscreenElement) { document.exitFullscreen(); } else { panel.requestFullscreen(); } \
2542+ }); \
2543+ })();";
2544+ view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }
2545+}
2546+
25132547 /// One window of one sheet as a table: the tab strip when the book has more
25142548 /// than one sheet, the grid with its column letters and row numbers, and the
25152549 /// two pagers that move the window. A workbook no reader here understands
crates/iz-web/src/i18n.rsmodified+3 -6
@@ -66,6 +66,7 @@ pub enum Key {
6666 Play,
6767 Pause,
6868 CloseTheFile,
69+ Present,
6970 ThisFileWillNotOpen,
7071 Previous,
7172 Next,
@@ -359,7 +360,6 @@ pub fn take_off_this_task(lang: Lang, name: &str) -> String {
359360 }
360361 }
361362
362-
363363 /// The phrase a key names, in a user's language.
364364 pub fn t(lang: Lang, key: Key) -> &'static str {
365365 use Key::*;
@@ -431,6 +431,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
431431 (Play, Tr) => "Oynat",
432432 (Pause, En) => "Pause",
433433 (Pause, Tr) => "Duraklat",
434+ (Present, En) => "Present",
435+ (Present, Tr) => "Sun",
434436 (CloseTheFile, En) => "Close the file",
435437 (CloseTheFile, Tr) => "Dosyayı kapat",
436438 (ThisFileWillNotOpen, En) => "This file will not open.",
@@ -663,7 +665,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
663665 (SenderNotConfiguredYet, En) => "No sender to test.",
664666 (SenderNotConfiguredYet, Tr) => "Test edilecek gönderen yok.",
665667
666-
667668 (MailRules, En) => "Mail rules",
668669 (MailRules, Tr) => "Posta kuralları",
669670 (EditLabel, En) => "Edit",
@@ -1032,7 +1033,6 @@ pub fn last_seen_label(lang: Lang, day: &str) -> String {
10321033 }
10331034 }
10341035
1035-
10361036 /// The sender panel's failed-test note, in a user's language.
10371037 pub fn not_delivered_label(lang: Lang, moment: &str, problem: &str) -> String {
10381038 match lang {
@@ -1141,9 +1141,6 @@ pub fn unblocked_label(lang: Lang, detail: &str) -> String {
11411141 }
11421142 }
11431143
1144-
1145-
1146-
11471144 pub fn role_changed_label(lang: Lang, detail: &str) -> String {
11481145 match lang {
11491146 Lang::En => format!("made {detail}"),
style/main.scssmodified+40 -0
@@ -1263,6 +1263,45 @@ img.avatar {
12631263
12641264 .viewer-pdf { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: var(--radius-md); }
12651265
1266+// A PDF is the browser's own reader living in an <object>, and it reads like
1267+// a workbook does: the panel takes the viewer the whole way out, because the
1268+// plugin only unfolds its full toolbar — page box, thumbnails, zoom — when
1269+// it has the room, and a document is read, not peeked at through 960px.
1270+.viewer:has(.viewer-pdf) {
1271+ width: min(96vw, 1400px);
1272+ height: calc(100vh - 96px);
1273+ display: flex;
1274+ flex-direction: column;
1275+ overflow: hidden;
1276+
1277+ .viewer-body {
1278+ flex: 1;
1279+ min-height: 0;
1280+ align-items: stretch;
1281+ padding: 16px 20px 20px;
1282+ }
1283+
1284+ .viewer-pdf { height: 100%; max-height: none; }
1285+}
1286+
1287+// Presented, the panel is the screen. The plugin keeps its own toolbar and
1288+// the header keeps its actions; only the frame's chrome comes off.
1289+.viewer:fullscreen {
1290+ width: 100%;
1291+ max-width: none;
1292+ height: 100%;
1293+ max-height: none;
1294+ border: none;
1295+ border-radius: 0;
1296+}
1297+
1298+// The viewer's header actions line up on one centered row: the filename is a
1299+// single line, and the download/present boxes center against it instead of
1300+// riding the headline's top edge the way the task modal's taller controls do.
1301+.viewer .detail-head { align-items: center; }
1302+
1303+.viewer .detail-esc { margin-top: 0; }
1304+
12661305 // A workbook has no element of its own, so the viewer draws it: a tab strip
12671306 // when the book has more than one sheet, and a grid that pans inside its own
12681307 // box — the document never scrolls.
@@ -4107,6 +4146,7 @@ input[type="radio"] {
41074146 .modal-scrim { padding: 16px; }
41084147
41094148 .modal { max-height: calc(100dvh - 32px); }
4149+ .viewer:has(.viewer-pdf) { height: calc(100dvh - 32px); }
41104150
41114151 .new-task-row { flex-wrap: wrap; }
41124152