mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Improve settings menu display
This commit is contained in:
parent
17180f4a56
commit
5e01ba36c9
@ -1404,6 +1404,15 @@ pre.rust {
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
#settings-menu {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
#settings-menu > a {
|
||||||
|
padding: 5px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes rotating {
|
@keyframes rotating {
|
||||||
from {
|
from {
|
||||||
@ -1416,6 +1425,30 @@ pre.rust {
|
|||||||
#settings-menu.rotate img {
|
#settings-menu.rotate img {
|
||||||
animation: rotating 2s linear infinite;
|
animation: rotating 2s linear infinite;
|
||||||
}
|
}
|
||||||
|
#settings-menu #settings {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
z-index: 1;
|
||||||
|
display: block;
|
||||||
|
margin-top: 7px;
|
||||||
|
border-radius: 3px;
|
||||||
|
border: 1px solid;
|
||||||
|
}
|
||||||
|
#settings-menu #settings .setting-line {
|
||||||
|
margin: 0.6em;
|
||||||
|
}
|
||||||
|
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
|
||||||
|
#settings-menu #settings::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
right: 11px;
|
||||||
|
border: solid;
|
||||||
|
border-width: 1px 1px 0 0;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
top: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
#help-button {
|
#help-button {
|
||||||
font-family: "Fira Sans", Arial, sans-serif;
|
font-family: "Fira Sans", Arial, sans-serif;
|
||||||
|
@ -5,7 +5,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
|
|||||||
|
|
||||||
/* General structure and fonts */
|
/* General structure and fonts */
|
||||||
|
|
||||||
body {
|
body, #settings-menu #settings, #settings-menu #settings::before {
|
||||||
background-color: #0f1419;
|
background-color: #0f1419;
|
||||||
color: #c5c5c5;
|
color: #c5c5c5;
|
||||||
}
|
}
|
||||||
@ -541,6 +541,10 @@ kbd {
|
|||||||
filter: invert(100);
|
filter: invert(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings-menu #settings, #settings-menu #settings::before {
|
||||||
|
border-color: #5c6773;
|
||||||
|
}
|
||||||
|
|
||||||
#copy-path {
|
#copy-path {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
body {
|
body, #settings-menu #settings, #settings-menu #settings::before {
|
||||||
background-color: #353535;
|
background-color: #353535;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
}
|
}
|
||||||
@ -420,6 +420,10 @@ kbd {
|
|||||||
border-color: #ffb900;
|
border-color: #ffb900;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings-menu #settings, #settings-menu #settings::before {
|
||||||
|
border-color: #d2d2d2;
|
||||||
|
}
|
||||||
|
|
||||||
#copy-path {
|
#copy-path {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* General structure and fonts */
|
/* General structure and fonts */
|
||||||
|
|
||||||
body {
|
body, #settings-menu #settings, #settings-menu #settings::before {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
@ -405,6 +405,10 @@ kbd {
|
|||||||
border-color: #717171;
|
border-color: #717171;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings-menu #settings, #settings-menu #settings::before {
|
||||||
|
border-color: #DDDDDD;
|
||||||
|
}
|
||||||
|
|
||||||
#copy-path {
|
#copy-path {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Local js definitions:
|
// Local js definitions:
|
||||||
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme */
|
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme */
|
||||||
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
|
/* global addClass, removeClass, onEach, onEachLazy */
|
||||||
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
|
/* global MAIN_ID, getVar, getSettingsButton */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -206,38 +206,60 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Then we build the DOM.
|
// Then we build the DOM.
|
||||||
const el = document.createElement("section");
|
let innerHTML = "";
|
||||||
el.id = "settings";
|
let elementKind = "div";
|
||||||
let innerHTML = `
|
|
||||||
<div class="main-heading">
|
if (isSettingsPage) {
|
||||||
|
elementKind = "section";
|
||||||
|
innerHTML = `<div class="main-heading">
|
||||||
<h1 class="fqn">
|
<h1 class="fqn">
|
||||||
<span class="in-band">Rustdoc settings</span>
|
<span class="in-band">Rustdoc settings</span>
|
||||||
</h1>
|
</h1>
|
||||||
<span class="out-of-band">`;
|
<span class="out-of-band">
|
||||||
|
<a id="back" href="javascript:void(0)" onclick="history.back();">Back</a>
|
||||||
if (isSettingsPage) {
|
</span>
|
||||||
innerHTML +=
|
</div>`;
|
||||||
"<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">Back</a>";
|
|
||||||
} else {
|
|
||||||
innerHTML += "<a id=\"back\" href=\"javascript:void(0)\" " +
|
|
||||||
"onclick=\"switchDisplayedElement(null);\">Back</a>";
|
|
||||||
}
|
}
|
||||||
innerHTML += `</span>
|
innerHTML += `<div class="settings">${buildSettingsPageSections(settings)}</div>`;
|
||||||
</div>
|
|
||||||
<div class="settings">${buildSettingsPageSections(settings)}</div>`;
|
|
||||||
|
|
||||||
|
const el = document.createElement(elementKind);
|
||||||
|
el.id = "settings";
|
||||||
el.innerHTML = innerHTML;
|
el.innerHTML = innerHTML;
|
||||||
|
|
||||||
if (isSettingsPage) {
|
if (isSettingsPage) {
|
||||||
document.getElementById(MAIN_ID).appendChild(el);
|
document.getElementById(MAIN_ID).appendChild(el);
|
||||||
} else {
|
} else {
|
||||||
getNotDisplayedElem().appendChild(el);
|
el.setAttribute("tabindex", "-1");
|
||||||
|
getSettingsButton().appendChild(el);
|
||||||
}
|
}
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingsMenu = buildSettingsPage();
|
const settingsMenu = buildSettingsPage();
|
||||||
|
|
||||||
|
function displaySettings() {
|
||||||
|
settingsMenu.style.display = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function elemIsInParent(elem, parent) {
|
||||||
|
while (elem && elem !== document.body) {
|
||||||
|
if (elem === parent) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
elem = elem.parentElement;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function blurHandler(event) {
|
||||||
|
const settingsButton = getSettingsButton();
|
||||||
|
if (!elemIsInParent(document.activeElement, settingsButton) &&
|
||||||
|
!elemIsInParent(event.relatedTarget, settingsButton))
|
||||||
|
{
|
||||||
|
window.hideSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isSettingsPage) {
|
if (isSettingsPage) {
|
||||||
// We replace the existing "onclick" callback to do nothing if clicked.
|
// We replace the existing "onclick" callback to do nothing if clicked.
|
||||||
getSettingsButton().onclick = function(event) {
|
getSettingsButton().onclick = function(event) {
|
||||||
@ -246,17 +268,27 @@
|
|||||||
} else {
|
} else {
|
||||||
// We replace the existing "onclick" callback.
|
// We replace the existing "onclick" callback.
|
||||||
const settingsButton = getSettingsButton();
|
const settingsButton = getSettingsButton();
|
||||||
|
const settingsMenu = document.getElementById("settings");
|
||||||
|
window.hideSettings = function() {
|
||||||
|
settingsMenu.style.display = "none";
|
||||||
|
};
|
||||||
settingsButton.onclick = function(event) {
|
settingsButton.onclick = function(event) {
|
||||||
|
if (elemIsInParent(event.target, settingsMenu)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (settingsMenu.parentElement.id === NOT_DISPLAYED_ID) {
|
if (settingsMenu.style.display !== "none") {
|
||||||
switchDisplayedElement(settingsMenu);
|
|
||||||
} else {
|
|
||||||
window.hideSettings();
|
window.hideSettings();
|
||||||
|
} else {
|
||||||
|
displaySettings();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.hideSettings = function() {
|
settingsButton.onblur = blurHandler;
|
||||||
switchDisplayedElement(null);
|
settingsButton.querySelector("a").onblur = blurHandler;
|
||||||
};
|
onEachLazy(settingsMenu.querySelectorAll("input"), el => {
|
||||||
|
el.onblur = blurHandler;
|
||||||
|
});
|
||||||
|
settingsMenu.onblur = blurHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We now wait a bit for the web browser to end re-computing the DOM...
|
// We now wait a bit for the web browser to end re-computing the DOM...
|
||||||
@ -264,7 +296,7 @@
|
|||||||
setEvents(settingsMenu);
|
setEvents(settingsMenu);
|
||||||
// The setting menu is already displayed if we're on the settings page.
|
// The setting menu is already displayed if we're on the settings page.
|
||||||
if (!isSettingsPage) {
|
if (!isSettingsPage) {
|
||||||
switchDisplayedElement(settingsMenu);
|
displaySettings();
|
||||||
}
|
}
|
||||||
removeClass(getSettingsButton(), "rotate");
|
removeClass(getSettingsButton(), "rotate");
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -126,10 +126,12 @@
|
|||||||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
|
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
|
||||||
type="search"> {#- -#}
|
type="search"> {#- -#}
|
||||||
<button type="button" id="help-button" title="help">?</button> {#- -#}
|
<button type="button" id="help-button" title="help">?</button> {#- -#}
|
||||||
<a id="settings-menu" href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
|
<div id="settings-menu" tabindex="-1">
|
||||||
<img width="22" height="22" alt="Change settings" {# -#}
|
<a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
|
||||||
|
<img width="22" height="22" alt="Change settings" {# -#}
|
||||||
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
|
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
|
||||||
</a> {#- -#}
|
</a> {#- -#}
|
||||||
|
</div>
|
||||||
</div> {#- -#}
|
</div> {#- -#}
|
||||||
</form> {#- -#}
|
</form> {#- -#}
|
||||||
</nav> {#- -#}
|
</nav> {#- -#}
|
||||||
|
Loading…
Reference in New Issue
Block a user