Replaced skipStorage with saveTheme variable
This commit is contained in:
parent
c076d30ce4
commit
1bd94241b7
2 changed files with 4 additions and 4 deletions
|
@ -914,7 +914,7 @@ themePicker.onblur = handleThemeButtonsBlur;
|
||||||
var but = document.createElement('button');
|
var but = document.createElement('button');
|
||||||
but.innerHTML = item;
|
but.innerHTML = item;
|
||||||
but.onclick = function(el) {{
|
but.onclick = function(el) {{
|
||||||
switchTheme(currentTheme, mainTheme, item);
|
switchTheme(currentTheme, mainTheme, item, true);
|
||||||
}};
|
}};
|
||||||
but.onblur = handleThemeButtonsBlur;
|
but.onblur = handleThemeButtonsBlur;
|
||||||
themes.appendChild(but);
|
themes.appendChild(but);
|
||||||
|
|
|
@ -86,7 +86,7 @@ function getCurrentValue(name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchTheme(styleElem, mainStyleElem, newTheme, skipStorage) {
|
function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
|
||||||
var fullBasicCss = "rustdoc" + resourcesSuffix + ".css";
|
var fullBasicCss = "rustdoc" + resourcesSuffix + ".css";
|
||||||
var fullNewTheme = newTheme + resourcesSuffix + ".css";
|
var fullNewTheme = newTheme + resourcesSuffix + ".css";
|
||||||
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
|
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
|
||||||
|
@ -111,7 +111,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, skipStorage) {
|
||||||
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 saved theme, no
|
||||||
// need to save it.
|
// need to save it.
|
||||||
if (skipStorage !== true) {
|
if (saveTheme === true) {
|
||||||
updateLocalStorage("rustdoc-theme", newTheme);
|
updateLocalStorage("rustdoc-theme", newTheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,4 +123,4 @@ function getSystemValue() {
|
||||||
|
|
||||||
switchTheme(currentTheme, mainTheme,
|
switchTheme(currentTheme, mainTheme,
|
||||||
getCurrentValue("rustdoc-theme") || getSystemValue() || "light",
|
getCurrentValue("rustdoc-theme") || getSystemValue() || "light",
|
||||||
true);
|
false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue