From 3a40b6b6d7781a7243c8fa7ae37c3b9d62896f67 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 7 Feb 2023 15:24:46 +0100 Subject: [PATCH 1/3] Fixed broken ZIM viewer under SeaMonkey SeaMonkey doesn't yet support ['import.meta'][1]. This change requires that a function `setPermanentGlobalCookie(name, value)` is defined before `setUserLanguage()` (exported by i18n.js) can be called. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta --- static/skin/i18n.js | 3 +-- static/skin/viewer.js | 4 ++++ test/server.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/static/skin/i18n.js b/static/skin/i18n.js index 72d7d3b20..d451f11b4 100644 --- a/static/skin/i18n.js +++ b/static/skin/i18n.js @@ -92,8 +92,7 @@ function getUserLanguage() { } function setUserLanguage(lang, callback) { - const rootPath = new URL('..', import.meta.url).pathname.replace(/\/$/, ''); - document.cookie = `userlang=${lang};path=${rootPath};max-age=31536000`; + setPermanentGlobalCookie('userlang', lang); Translations.load(lang); Translations.whenReady(callback); } diff --git a/static/skin/viewer.js b/static/skin/viewer.js index b4fe88a9f..0426aea0e 100644 --- a/static/skin/viewer.js +++ b/static/skin/viewer.js @@ -512,3 +512,7 @@ function finishViewerSetupOnceTranslationsAreLoaded() viewerSetupComplete = true; } + +function setPermanentGlobalCookie(name, value) { + document.cookie = `${name}=${value};path=${root};max-age=31536000`; +} diff --git a/test/server.cpp b/test/server.cpp index d208e5f9a..0ec08c821 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -59,7 +59,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/skin/favicon/favicon.ico" }, { STATIC_CONTENT, "/ROOT/skin/favicon/favicon.ico?cacheid=fba03a27" }, { DYNAMIC_CONTENT, "/ROOT/skin/i18n.js" }, - { STATIC_CONTENT, "/ROOT/skin/i18n.js?cacheid=dcf3d584" }, + { STATIC_CONTENT, "/ROOT/skin/i18n.js?cacheid=6da2bca0" }, { DYNAMIC_CONTENT, "/ROOT/skin/index.css" }, { STATIC_CONTENT, "/ROOT/skin/index.css?cacheid=0f9ba34e" }, { DYNAMIC_CONTENT, "/ROOT/skin/index.js" }, @@ -73,7 +73,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/skin/taskbar.css" }, { STATIC_CONTENT, "/ROOT/skin/taskbar.css?cacheid=2cbac34b" }, { DYNAMIC_CONTENT, "/ROOT/skin/viewer.js" }, - { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=b3c754ec" }, + { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=430d45b0" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf" }, { STATIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf?cacheid=af705837" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Roboto.ttf" }, @@ -300,9 +300,9 @@ R"EXPECTEDRESULT( - + - + const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032"; From 57484fd63ddf3732ce868a22c21d82d9e0248c76 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 7 Feb 2023 12:32:35 +0100 Subject: [PATCH 2/3] Fixed ZIM viewer iframe height under SeaMonkey SeaMonkey doesn't yet support [Window.visualViewport][1]. As a result the height of the content iframe element was initialized to the default 150 pixels and never changed. Fortunately there is [Window.innerHeight][2] which is supported from the very first days of the Gecko layout engine. The difference between `Window.visualViewport.height` and `Window.innerHeight` is that the latter also includes - the height of the horizontal scroll bar, if present (but in a correctly implemented ZIM viewer there shouldn't be a horizontal scroll bar for the full web-page, so it's OK) - the height of the on-screen keyboard (which is mostly used on mobile devices where SeaMonkey doesn't run). And it is also arguable if the appearing on-screen keyboard should squeeze the iframe or slide over it (in which latter case it may make more sense to always use `innerHeight` instead of `visualViewport.height`). [1]: https://developer.mozilla.org/en-US/docs/Web/API/Window/visualViewport [2]: https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight --- static/skin/viewer.js | 5 ++++- test/server.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/static/skin/viewer.js b/static/skin/viewer.js index 0426aea0e..db7bc2ba8 100644 --- a/static/skin/viewer.js +++ b/static/skin/viewer.js @@ -198,7 +198,10 @@ function updateToolbarVisibilityState() { } function handle_visual_viewport_change() { - contentIframe.height = window.visualViewport.height - contentIframe.offsetTop - 4; + const wh = window.visualViewport + ? window.visualViewport.height + : window.innerHeight; + contentIframe.height = wh - contentIframe.offsetTop - 4; } function handle_location_hash_change() { diff --git a/test/server.cpp b/test/server.cpp index 0ec08c821..db34315fc 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -73,7 +73,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/skin/taskbar.css" }, { STATIC_CONTENT, "/ROOT/skin/taskbar.css?cacheid=2cbac34b" }, { DYNAMIC_CONTENT, "/ROOT/skin/viewer.js" }, - { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=430d45b0" }, + { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=03fd97ee" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf" }, { STATIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf?cacheid=af705837" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Roboto.ttf" }, @@ -302,7 +302,7 @@ R"EXPECTEDRESULT( - + const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032"; From 4bf4b66b27ab8e0c7b7aa0f999fecb4af45cfa17 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 7 Feb 2023 16:07:58 +0100 Subject: [PATCH 3/3] Explicitly styled UI language selector The recently introduced ZIM viewer UI language selector looked adequately nice under Firefox without any explicit styling applied. Under SeaMonkey, however, its default look and feel was intolerable, so I used this opportunity to make the UI language selector comply with the current fashion of the ZIM viewer toolbar. --- static/skin/taskbar.css | 5 +++-- static/viewer.html | 2 +- test/server.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/static/skin/taskbar.css b/static/skin/taskbar.css index 332bd2444..87fbdc319 100644 --- a/static/skin/taskbar.css +++ b/static/skin/taskbar.css @@ -44,8 +44,8 @@ margin: 0 auto; } -#ui_language { - float: left +.kiwix #ui_language { + float: left; } #kiwix_button_show_toggle { @@ -84,6 +84,7 @@ label[for="kiwix_button_show_toggle"], float: right; } +.kiwix #ui_language, .kiwix #kiwixtoolbar button, .kiwix #kiwixtoolbar input[type="submit"] { box-sizing: border-box !important; diff --git a/static/viewer.html b/static/viewer.html index 1eba63657..4c66abbcd 100644 --- a/static/viewer.html +++ b/static/viewer.html @@ -29,7 +29,7 @@