mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +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 %}}
|
||||
|
||||
<script>
|
||||
variants.generator( '#vargenerator', '.secondary a', '.warning a' );
|
||||
window.variants && variants.generator( '#vargenerator', '.secondary a', '.warning a' );
|
||||
</script>
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
function useMermaid( config ){
|
||||
if (typeof mermaid != 'undefined' && typeof mermaid.mermaidAPI != 'undefined') {
|
||||
mermaid.initialize( Object.assign( { "securityLevel": "antiscript", "startOnLoad": false }, config ) );
|
||||
if( config.theme ){
|
||||
if( config.theme && variants ){
|
||||
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
||||
write_style.setProperty( '--CONFIG-MERMAID-theme', config.theme );
|
||||
}
|
||||
|
@ -96,7 +96,7 @@
|
|||
{{- end }}
|
||||
<script>
|
||||
function useSwagger( config ){
|
||||
if( config.theme ){
|
||||
if( config.theme && variants ){
|
||||
var write_style = variants.findLoadedStylesheet( 'variant-style' );
|
||||
write_style.setProperty( '--CONFIG-SWAGGER-theme', config.theme );
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<i class="fas fa-paint-brush fa-fw"></i>
|
||||
<span> </span>
|
||||
<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 }}
|
||||
{{- range $themevariants }}
|
||||
{{- $themevariant := . }}
|
||||
|
@ -100,7 +100,7 @@
|
|||
</div>
|
||||
<div class="select-clear"></div>
|
||||
</a>
|
||||
<script>variants.markSelectedVariant();</script>
|
||||
<script>window.variants && variants.markSelectedVariant();</script>
|
||||
</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>
|
||||
|
|
|
@ -40,6 +40,6 @@
|
|||
{{- range $themevariants }}
|
||||
{{- $quotedthemevariants = $quotedthemevariants | append (printf "'%s'" .) }}
|
||||
{{- end }}
|
||||
variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] );
|
||||
window.variants && variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] );
|
||||
</script>
|
||||
<script src="{{"js/jquery.min.js"| relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
|
Loading…
Reference in a new issue