mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
theme: IE11 compat for theme switch #178
This commit is contained in:
parent
4f28e6af83
commit
99a7061a67
1 changed files with 6 additions and 6 deletions
|
@ -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…
Reference in a new issue