mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
theme: avoid JS errors if an output format loaded not all files #308
This commit is contained in:
parent
775e5c0e9e
commit
8d19b3b484
4 changed files with 6 additions and 6 deletions
|
@ -33,5 +33,5 @@ This only works in modern browsers.
|
||||||
{{% button style="warning" icon="trash" %}}Reset variant{{% /button %}}
|
{{% button style="warning" icon="trash" %}}Reset variant{{% /button %}}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
variants.generator( '#vargenerator', '.secondary a', '.warning a' );
|
window.variants && variants.generator( '#vargenerator', '.secondary a', '.warning a' );
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
function useMermaid( config ){
|
function useMermaid( config ){
|
||||||
if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') {
|
if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') {
|
||||||
mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, config ) );
|
mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, config ) );
|
||||||
if( config.theme ){
|
if( config.theme && variants ){
|
||||||
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
||||||
write_style.setProperty( '--CONFIG-MERMAID-theme', config.theme );
|
write_style.setProperty( '--CONFIG-MERMAID-theme', config.theme );
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<script>
|
<script>
|
||||||
function useSwagger( config ){
|
function useSwagger( config ){
|
||||||
if( config.theme ){
|
if( config.theme && variants ){
|
||||||
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
||||||
write_style.setProperty( '--CONFIG-SWAGGER-theme', config.theme );
|
write_style.setProperty( '--CONFIG-SWAGGER-theme', config.theme );
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<i class="fas fa-paint-brush fa-fw"></i>
|
<i class="fas fa-paint-brush fa-fw"></i>
|
||||||
<span> </span>
|
<span> </span>
|
||||||
<div class="select-style">
|
<div class="select-style">
|
||||||
<select id="select-variant" onchange="variants.changeVariant( this.value );">
|
<select id="select-variant" onchange="window.variants && variants.changeVariant( this.value );">
|
||||||
{{- $firstvariant := true }}
|
{{- $firstvariant := true }}
|
||||||
{{- range $themevariants }}
|
{{- range $themevariants }}
|
||||||
{{- $themevariant := . }}
|
{{- $themevariant := . }}
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="select-clear"></div>
|
<div class="select-clear"></div>
|
||||||
</a>
|
</a>
|
||||||
<script>variants.markSelectedVariant();</script>
|
<script>window.variants && variants.markSelectedVariant();</script>
|
||||||
</li>
|
</li>
|
||||||
<li class="footerVisitedLinks{{if $showvisitedlinks}} showVisitedLinks{{end}}"><a class="padding" onclick="clearHistory();"><i class="fas fa-history fa-fw"></i> {{ T "Clear-History" }}</a></li>
|
<li class="footerVisitedLinks{{if $showvisitedlinks}} showVisitedLinks{{end}}"><a class="padding" onclick="clearHistory();"><i class="fas fa-history fa-fw"></i> {{ T "Clear-History" }}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -40,6 +40,6 @@
|
||||||
{{- range $themevariants }}
|
{{- range $themevariants }}
|
||||||
{{- $quotedthemevariants = $quotedthemevariants | append (printf "'%s'" .) }}
|
{{- $quotedthemevariants = $quotedthemevariants | append (printf "'%s'" .) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] );
|
window.variants && variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] );
|
||||||
</script>
|
</script>
|
||||||
<script src="{{"js/jquery.min.js"| relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
|
<script src="{{"js/jquery.min.js"| relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
|
Loading…
Reference in a new issue