Merge pull request #1170 from ehuss/fix-theme-focus
Fix theme selector focus.
This commit is contained in:
commit
99ecd4f87c
|
@ -285,7 +285,7 @@ function playpen_text(playpen) {
|
||||||
function showThemes() {
|
function showThemes() {
|
||||||
themePopup.style.display = 'block';
|
themePopup.style.display = 'block';
|
||||||
themeToggleButton.setAttribute('aria-expanded', true);
|
themeToggleButton.setAttribute('aria-expanded', true);
|
||||||
themePopup.querySelector("button#" + document.body.className).focus();
|
themePopup.querySelector("button#" + get_theme()).focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideThemes() {
|
function hideThemes() {
|
||||||
|
@ -294,6 +294,16 @@ function playpen_text(playpen) {
|
||||||
themeToggleButton.focus();
|
themeToggleButton.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_theme() {
|
||||||
|
var theme;
|
||||||
|
try { theme = localStorage.getItem('mdbook-theme'); } catch (e) { }
|
||||||
|
if (theme === null || theme === undefined) {
|
||||||
|
return default_theme;
|
||||||
|
} else {
|
||||||
|
return theme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function set_theme(theme, store = true) {
|
function set_theme(theme, store = true) {
|
||||||
let ace_theme;
|
let ace_theme;
|
||||||
|
|
||||||
|
@ -325,9 +335,7 @@ function playpen_text(playpen) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousTheme;
|
var previousTheme = get_theme();
|
||||||
try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { }
|
|
||||||
if (previousTheme === null || previousTheme === undefined) { previousTheme = default_theme; }
|
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
try { localStorage.setItem('mdbook-theme', theme); } catch (e) { }
|
try { localStorage.setItem('mdbook-theme', theme); } catch (e) { }
|
||||||
|
@ -338,9 +346,7 @@ function playpen_text(playpen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set theme
|
// Set theme
|
||||||
var theme;
|
var theme = get_theme();
|
||||||
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
||||||
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
||||||
|
|
||||||
set_theme(theme, false);
|
set_theme(theme, false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue