mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Base: Support opening a specific settings tab via anchors
For example, about:settings#privacy will now open the settings page to the Privacy tab.
This commit is contained in:
Notes:
github-actions[bot]
2026-03-05 15:02:48 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/746448f8e06 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8272
@@ -696,16 +696,32 @@
|
||||
<script src="resource://ladybird/about-pages/settings/search.js" type="module"></script>
|
||||
|
||||
<script type="module">
|
||||
function switchTab(name) {
|
||||
const button = document.querySelector(`.tab-button[data-tab="${name}"]`);
|
||||
const panel = document.getElementById(`tab-${name}`);
|
||||
if (!button || !panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.querySelectorAll(".tab-button").forEach(b => b.classList.remove("active"));
|
||||
document.querySelectorAll(".tab-panel").forEach(p => p.classList.remove("active"));
|
||||
|
||||
button.classList.add("active");
|
||||
panel.classList.add("active");
|
||||
}
|
||||
|
||||
document.querySelectorAll(".tab-button").forEach(button => {
|
||||
button.addEventListener("click", () => {
|
||||
document.querySelectorAll(".tab-button").forEach(b => b.classList.remove("active"));
|
||||
document.querySelectorAll(".tab-panel").forEach(p => p.classList.remove("active"));
|
||||
|
||||
button.classList.add("active");
|
||||
document.getElementById(`tab-${button.dataset.tab}`).classList.add("active");
|
||||
switchTab(button.dataset.tab);
|
||||
history.replaceState(null, "", `#${button.dataset.tab}`);
|
||||
});
|
||||
});
|
||||
|
||||
const hash = location.hash.slice(1);
|
||||
if (hash) {
|
||||
switchTab(hash);
|
||||
}
|
||||
|
||||
document.querySelectorAll("dialog").forEach(dialog => {
|
||||
dialog.addEventListener("click", event => {
|
||||
const rect = dialog.getBoundingClientRect();
|
||||
|
||||
Reference in New Issue
Block a user