soundcite player gets loaded only if there's .soundcite element in a page..
This commit is contained in:
parent
2cf0849d9d
commit
8c493c5928
|
@ -1,10 +1,14 @@
|
||||||
window.addEventListener('scroll', function(e) {
|
window.addEventListener('scroll', function(e) {
|
||||||
if (document.querySelector('body').clientWidth > 1024) {
|
if (document.querySelector('body').clientWidth > 1024) {
|
||||||
let rightcolumn = document.querySelector('.rightcolumn');
|
let rightcolumn = document.querySelector('.rightcolumn');
|
||||||
let mantletitle = document.querySelector('.mantletitle') || document.querySelector('.crusttitle');
|
let mantletitle = document.querySelector('.mantletitle') || document.querySelector('.crusttitle') || false;
|
||||||
|
if (!mantletitle) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let mantlebar = document.querySelector('.mantlebar')
|
let mantlebar = document.querySelector('.mantlebar')
|
||||||
let grid = document.querySelector('.grid')
|
let grid = document.querySelector('.grid')
|
||||||
let gridrect = mantletitle.getBoundingClientRect();
|
let gridrect = mantletitle.getBoundingClientRect();
|
||||||
|
|
||||||
if (gridrect.top < 20 && !grid.classList.contains('moved')) {
|
if (gridrect.top < 20 && !grid.classList.contains('moved')) {
|
||||||
grid.classList.add('moved');
|
grid.classList.add('moved');
|
||||||
mantlebar.style.display = "inline";
|
mantlebar.style.display = "inline";
|
||||||
|
@ -28,4 +32,11 @@ window.addEventListener('DOMContentLoaded', (e) => {
|
||||||
s.appendChild(par.cloneNode(true))
|
s.appendChild(par.cloneNode(true))
|
||||||
par.remove()
|
par.remove()
|
||||||
document.querySelector("#TableOfContents > ol:first-child").insertBefore(s, document.querySelector("#TableOfContents > ol:first-child").firstChild)
|
document.querySelector("#TableOfContents > ol:first-child").insertBefore(s, document.querySelector("#TableOfContents > ol:first-child").firstChild)
|
||||||
|
|
||||||
|
if (document.querySelector(".soundcite")) {
|
||||||
|
var soundcite = document.createElement('script');
|
||||||
|
soundcite.src = `/js/soundcite.min.js`;
|
||||||
|
document.body.appendChild(soundcite);
|
||||||
|
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -32,11 +32,9 @@
|
||||||
{{- else if strings.HasPrefix .Destination "audio:" -}}
|
{{- else if strings.HasPrefix .Destination "audio:" -}}
|
||||||
{{- $a_destination := (substr .Destination 6) -}}
|
{{- $a_destination := (substr .Destination 6) -}}
|
||||||
{{- if findRE "^.*static" $a_destination -}}
|
{{- if findRE "^.*static" $a_destination -}}
|
||||||
<div>{{ .Text }}</div>
|
<span class="soundcite" data-url="{{- (replaceRE "^.*static" "" $a_destination ) | safeURL -}}">{{ .Text }}</span>
|
||||||
<audio src="{{- (replaceRE "^.*static" "" $a_destination ) | safeURL -}}" preload="metadata" controls="true"></audio>
|
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<div>{{ .Text }}</div>
|
<span class="soundcite" data-url="{{- $a_destination | safeURL -}}">{{ .Text }}</span>
|
||||||
<audio src="{{- $a_destination | safeURL -}}" preload="metadata" controls="true"></audio>
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else if findRE "^.*static" .Destination -}}
|
{{- else if findRE "^.*static" .Destination -}}
|
||||||
<img src="{{- (replaceRE "^.*static" "" .Destination ) | safeURL -}}" alt="{{- .Text -}}" {{- with .Title}} title="{{- . -}}"{{- end -}} />
|
<img src="{{- (replaceRE "^.*static" "" .Destination ) | safeURL -}}" alt="{{- .Text -}}" {{- with .Title}} title="{{- . -}}"{{- end -}} />
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
{{ if (or (eq hugo.Environment "gitea") (eq hugo.Environment "preview") ) }}
|
{{ if (or (eq hugo.Environment "gitea") (eq hugo.Environment "preview") ) }}
|
||||||
<link rel="stylesheet" href="/css/site.css">
|
<link rel="stylesheet" href="/css/site.min.css">
|
||||||
|
<link rel="stylesheet" href="/css/player.min.css">
|
||||||
{{ else if .Site.IsServer }}
|
{{ else if .Site.IsServer }}
|
||||||
{{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
|
{{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
|
||||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||||
|
{{ $style := resources.Get "css/player.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
|
||||||
|
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $flist := newScratch }}
|
{{ $flist := newScratch }}
|
||||||
{{ $flist.Set "initial" "nop" }}
|
{{ $flist.Set "initial" "nop" }}
|
||||||
|
|
Loading…
Reference in New Issue