From e0e0aa313b2d6c61eeb563ceb08acdf6eb256be0 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Mon, 6 Jan 2025 18:06:48 +0900 Subject: [PATCH] Apply RTL appearance to the options page, group tabs, and the startup page #3689 --- webextensions/common/common.js | 2 ++ webextensions/options/init.js | 2 ++ webextensions/resources/group-tab.js | 3 +++ webextensions/resources/module/startup.js | 3 +++ 4 files changed, 10 insertions(+) diff --git a/webextensions/common/common.js b/webextensions/common/common.js index 6d77365cf..892ea41dc 100644 --- a/webextensions/common/common.js +++ b/webextensions/common/common.js @@ -62,6 +62,7 @@ const localKeys = DEVICE_SPECIFIC_CONFIG_KEYS.concat(mapAndFilter(` optionsExpandedGroups optionsExpandedSections outOfScreenTabsRenderingPages + rtl, sidebarPosition sidebarVirtuallyClosedWindows sidebarVirtuallyOpenedWindows @@ -142,6 +143,7 @@ export const configs = new Configs({ sidebarPosition: Constants.kTABBAR_POSITION_AUTO, sidebarPositionRighsideNotificationShown: false, sidebarPositionOptionNotificationTimeout: 20 * 1000, + rtl: isRTL(), style: /^Mac/i.test(navigator.platform) ? 'sidebar' : 'proton', colorScheme: /^Linux/i.test(navigator.platform) ? 'system-color' : 'photon' , diff --git a/webextensions/options/init.js b/webextensions/options/init.js index 7b1ee0256..a78869a2f 100644 --- a/webextensions/options/init.js +++ b/webextensions/options/init.js @@ -58,6 +58,8 @@ if ((location.hash && /independent=true/.test(location.search)) document.body.classList.add('independent'); +document.documentElement.classList.toggle('rtl', isRTL()); + const CODEMIRROR_THEMES = ` 3024-day 3024-night diff --git a/webextensions/resources/group-tab.js b/webextensions/resources/group-tab.js index ea66bc1bb..227afb122 100644 --- a/webextensions/resources/group-tab.js +++ b/webextensions/resources/group-tab.js @@ -286,6 +286,7 @@ 'renderTreeInGroupTabs', 'showAutoGroupOptionHint', 'showAutoGroupOptionHintWithOpener', + 'rtl', ] }), browser.runtime.sendMessage({ @@ -304,6 +305,8 @@ `; gUserStyleRules.textContent = userStyleRules; + document.documentElement.classList.toggle('rtl', configs.rtl); + updateTree.enabled = configs.renderTreeInGroupTabs; updateTree(); diff --git a/webextensions/resources/module/startup.js b/webextensions/resources/module/startup.js index 9f265b887..c4668c0bf 100644 --- a/webextensions/resources/module/startup.js +++ b/webextensions/resources/module/startup.js @@ -9,10 +9,13 @@ import '/extlib/l10n.js'; import { configs, + isRTL, } from '/common/common.js'; import * as Constants from '/common/constants.js'; import * as Permissions from '/common/permissions.js'; +document.documentElement.classList.toggle('rtl', isRTL()); + window.addEventListener('DOMContentLoaded', () => { document.querySelector('#title').textContent = document.title = `${browser.i18n.getMessage('extensionName')} ${browser.runtime.getManifest().version}`; document.querySelector('#syncTabsToDeviceOptionsLink').href = `${Constants.kSHORTHAND_URIS.options}#syncTabsToDeviceOptions`;