Move themes and version into rustdoc-vars
We had been injecting the list of themes and the rustdoc version into main.js by rewriting it at doc generation time. By avoiding this rewrite, we can make it easier to edit main.js without regenerating all the docs. Added a more convenient accessor for rustdoc-vars. Changed storage.js to not rely on resourcesSuffix. It could in theory use rustdoc-vars, but because rustdoc-vars is at the end of the HTML, it's not available when storage.js runs (very early in page load).
This commit is contained in:
parent
3649b90b33
commit
f0683f98fa
5 changed files with 37 additions and 49 deletions
|
@ -1,5 +1,3 @@
|
|||
// From rust:
|
||||
/* global resourcesSuffix */
|
||||
var darkThemes = ["dark", "ayu"];
|
||||
window.currentTheme = document.getElementById("themeStyle");
|
||||
window.mainTheme = document.getElementById("mainThemeStyle");
|
||||
|
@ -107,9 +105,8 @@ function getCurrentValue(name) {
|
|||
}
|
||||
|
||||
function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
|
||||
var fullBasicCss = "rustdoc" + resourcesSuffix + ".css";
|
||||
var fullNewTheme = newTheme + resourcesSuffix + ".css";
|
||||
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
|
||||
var newHref = mainStyleElem.href.replace(
|
||||
/\/rustdoc([^/]*)\.css/, "/" + newTheme + "$1" + ".css");
|
||||
|
||||
// If this new value comes from a system setting or from the previously
|
||||
// saved theme, no need to save it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue