theme: IE11 compat for theme switch #178

This commit is contained in:
Sören Weber 2022-02-15 01:37:48 +01:00
parent 4f28e6af83
commit 99a7061a67
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589

View file

@ -27,8 +27,8 @@
{{- end }}
</style>
<script>
// we need to define this script in the head to avoid flickering an
// page load if the user has selected a non default variant
{{ "// we need to define this script in the head to avoid flickering" | safeJS }}
{{ "// on page load if the user has selected a non default variant" | safeJS }}
var theme = window.localStorage.getItem( 'theme' );
changeTheme( theme );
function getTheme(){
@ -53,7 +53,7 @@
{{- $quotedthemevariants = $quotedthemevariants | append (printf "\"%s\"" .) }}
{{- end }}
var themes = [ {{ delimit $quotedthemevariants ", " | safeJS }} ];
if( !themes.find( function(e){ return e==theme; } ) ){
if( themes.indexOf( theme ) < 0 ){
theme = themes.length ? themes[ 0 ] : null;
}
if( !theme ){
@ -69,9 +69,9 @@
window.localStorage.setItem( 'theme', theme );
link.setAttribute( 'href', new_path );
markTheme( theme );
// remove selection, because if some uses an arrow navigation
// by pressing the left or right cursor key, we will automatically
// select a different style
{{ "// remove selection, because if some uses an arrow navigation" | safeJS }}
{{ "// by pressing the left or right cursor key, we will automatically" | safeJS }}
{{ "// select a different style" | safeJS }}
if( document.activeElement ){
document.activeElement.blur();
}