1
Fork 0

Coding style fixes

This commit is contained in:
nasso 2020-10-11 17:52:47 +02:00
parent 3a6437cd98
commit db7c8f4c3c
4 changed files with 22 additions and 25 deletions

View file

@ -1386,11 +1386,11 @@ impl Setting {
description, description,
), ),
Setting::Select { js_data_name, description, default_value, ref options } => format!( Setting::Select { js_data_name, description, default_value, ref options } => format!(
"<div class='setting-line'>\ "<div class=\"setting-line\">\
<div>{}</div>\ <div>{}</div>\
<label class='select-wrapper'>\ <label class=\"select-wrapper\">\
<select id='{}' autocomplete='off'>{}</select>\ <select id=\"{}\" autocomplete=\"off\">{}</select>\
<img src='{}down-arrow{}.svg' alt='Select item'>\ <img src=\"{}down-arrow{}.svg\" alt=\"Select item\">\
</label>\ </label>\
</div>", </div>",
description, description,

View file

@ -31,9 +31,7 @@
.select-wrapper { .select-wrapper {
float: right; float: right;
position: relative; position: relative;
height: 27px; height: 27px;
min-width: 25%; min-width: 25%;
} }
@ -42,23 +40,18 @@
appearance: none; appearance: none;
-moz-appearance: none; -moz-appearance: none;
-webkit-appearance: none; -webkit-appearance: none;
background: none; background: none;
border: 2px solid #ccc; border: 2px solid #ccc;
padding-right: 28px; padding-right: 28px;
width: 100%; width: 100%;
} }
.select-wrapper img { .select-wrapper img {
pointer-events: none; pointer-events: none;
position: absolute; position: absolute;
right: 0; right: 0;
bottom: 0; bottom: 0;
background: #ccc; background: #ccc;
height: 100%; height: 100%;
width: 28px; width: 28px;
padding: 0px 4px; padding: 0px 4px;

View file

@ -1,21 +1,21 @@
// Local js definitions: // Local js definitions:
/* global getCurrentValue, updateLocalStorage */ /* global getCurrentValue, updateLocalStorage, updateSystemTheme */
(function () { (function () {
function changeSetting(settingName, value) { function changeSetting(settingName, value) {
updateLocalStorage('rustdoc-' + settingName, value); updateLocalStorage("rustdoc-" + settingName, value);
switch (settingName) { switch (settingName) {
case 'preferred-dark-theme': case "preferred-dark-theme":
case 'preferred-light-theme': case "preferred-light-theme":
case 'use-system-theme': case "use-system-theme":
updateSystemTheme(); updateSystemTheme();
break; break;
} }
} }
function getSettingValue(settingName) { function getSettingValue(settingName) {
return getCurrentValue('rustdoc-' + settingName); return getCurrentValue("rustdoc-" + settingName);
} }
function setEvents() { function setEvents() {
@ -23,9 +23,10 @@
toggles: document.getElementsByClassName("slider"), toggles: document.getElementsByClassName("slider"),
selects: document.getElementsByClassName("select-wrapper") selects: document.getElementsByClassName("select-wrapper")
}; };
var i;
if (elems.toggles && elems.toggles.length > 0) { if (elems.toggles && elems.toggles.length > 0) {
for (var i = 0; i < elems.toggles.length; ++i) { for (i = 0; i < elems.toggles.length; ++i) {
var toggle = elems.toggles[i].previousElementSibling; var toggle = elems.toggles[i].previousElementSibling;
var settingId = toggle.id; var settingId = toggle.id;
var settingValue = getSettingValue(settingId); var settingValue = getSettingValue(settingId);
@ -39,8 +40,8 @@
} }
if (elems.selects && elems.selects.length > 0) { if (elems.selects && elems.selects.length > 0) {
for (var i = 0; i < elems.selects.length; ++i) { for (i = 0; i < elems.selects.length; ++i) {
var select = elems.selects[i].getElementsByTagName('select')[0]; var select = elems.selects[i].getElementsByTagName("select")[0];
var settingId = select.id; var settingId = select.id;
var settingValue = getSettingValue(settingId); var settingValue = getSettingValue(settingId);
if (settingValue !== null) { if (settingValue !== null) {

View file

@ -110,8 +110,8 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
}); });
if (found === true) { if (found === true) {
styleElem.href = newHref; styleElem.href = newHref;
// If this new value comes from a system setting or from the previously saved theme, no // If this new value comes from a system setting or from the previously
// need to save it. // saved theme, no need to save it.
if (saveTheme === true) { if (saveTheme === true) {
updateLocalStorage("rustdoc-theme", newTheme); updateLocalStorage("rustdoc-theme", newTheme);
} }
@ -182,7 +182,10 @@ if (getCurrentValue("rustdoc-use-system-theme") !== "false" && window.matchMedia
// call the function to initialize the theme at least once! // call the function to initialize the theme at least once!
updateSystemTheme(); updateSystemTheme();
} else { } else {
switchTheme(currentTheme, mainTheme, switchTheme(
getCurrentValue("rustdoc-theme") || "light", currentTheme,
false); mainTheme,
getCurrentValue("rustdoc-theme") || "light",
false
);
} }