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