From 514d6e65146d5155922b7fdd3af926e2bc866c6a Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 9 Feb 2023 16:23:27 +0100 Subject: [PATCH] Added UI language selector on the welcome page Also: - Moved the language selector to the right hand side on the ZIM viewer page (to be consistent with the welcome page) --- static/skin/index.css | 9 +++++++-- static/skin/index.js | 9 +++++++++ static/skin/taskbar.css | 2 +- static/templates/index.html | 3 +++ test/server.cpp | 13 +++++++------ 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/static/skin/index.css b/static/skin/index.css index ae9294fa..e0d43fbb 100644 --- a/static/skin/index.css +++ b/static/skin/index.css @@ -157,6 +157,11 @@ body { font-weight: bolder; } +#ui_language { + float: right; + top: 0; +} + .book__list { position: relative; margin: 0 auto; @@ -472,11 +477,11 @@ body { .kiwixHomeBody { min-height: calc(100vh - 287px); } - + .kiwixSearch { margin-top: 11px; } - + .kiwixButton { margin: 15px 0; width: 229px; diff --git a/static/skin/index.js b/static/skin/index.js index a2e7479c..81ddc971 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -31,6 +31,14 @@ document.querySelector('#feedLink').href = feedLink; } + function changeUILanguage() { + const s = document.getElementById("ui_language"); + const lang = s.options[s.selectedIndex].value; + const q = new URLSearchParams(window.location.search); + q.set("userlang", lang); + location.search = q.toString(); + } + function queryUrlBuilder() { let url = `${root}/catalog/search?`; url += Object.keys(incrementalLoadingParams).map(key => `${key}=${incrementalLoadingParams[key]}`).join("&"); @@ -466,6 +474,7 @@ } async function onload() { + initUILanguageSelector(getUserLanguage(), changeUILanguage); iso = new Isotope( '.book__list', { itemSelector: '.book', getSortData:{ diff --git a/static/skin/taskbar.css b/static/skin/taskbar.css index 87fbdc31..084b7150 100644 --- a/static/skin/taskbar.css +++ b/static/skin/taskbar.css @@ -45,7 +45,7 @@ } .kiwix #ui_language { - float: left; + float: right; } #kiwix_button_show_toggle { diff --git a/static/templates/index.html b/static/templates/index.html index 2b2039a1..6096c701 100644 --- a/static/templates/index.html +++ b/static/templates/index.html @@ -38,6 +38,7 @@ } + @@ -47,6 +48,8 @@
+