mirror of
https://github.com/McShelby/hugo-theme-relearn
synced 2025-05-03 23:42:02 +08:00
theme: IE11 compat for theme switch #178
This commit is contained in:
parent
4f28e6af83
commit
99a7061a67
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user