mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-01-22 14:35:43 -06:00
⚡️ [#676] Optimise appearance.js for no secondary logo
This commit is contained in:
parent
0e07a9f265
commit
c6869834ea
1 changed files with 9 additions and 9 deletions
|
@ -28,7 +28,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
|||
|
||||
var targetAppearance = document.documentElement.classList.contains("dark") ? "dark" : "light"
|
||||
updateMeta()
|
||||
updateLogo(targetAppearance)
|
||||
this.updateLogo?.(targetAppearance)
|
||||
|
||||
if (switcher) {
|
||||
switcher.addEventListener("click", () => {
|
||||
|
@ -39,7 +39,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
|||
targetAppearance
|
||||
);
|
||||
updateMeta()
|
||||
updateLogo(targetAppearance)
|
||||
this.updateLogo?.(targetAppearance)
|
||||
});
|
||||
switcher.addEventListener("contextmenu", (event) => {
|
||||
event.preventDefault();
|
||||
|
@ -55,7 +55,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
|||
targetAppearance
|
||||
);
|
||||
updateMeta()
|
||||
updateLogo(targetAppearance)
|
||||
this.updateLogo?.(targetAppearance)
|
||||
});
|
||||
switcherMobile.addEventListener("contextmenu", (event) => {
|
||||
event.preventDefault();
|
||||
|
@ -72,11 +72,11 @@ var updateMeta = () => {
|
|||
document.querySelector('meta[name="theme-color"]').setAttribute('content', style.backgroundColor);
|
||||
}
|
||||
|
||||
{{ if and (.Site.Params.Logo) (.Site.Params.SecondaryLogo) }}
|
||||
{{ $primaryLogo := resources.Get .Site.Params.Logo }}
|
||||
{{ $secondaryLogo := resources.Get .Site.Params.SecondaryLogo }}
|
||||
{{ if and ($primaryLogo) ($secondaryLogo) }}
|
||||
var updateLogo = (targetAppearance) => {
|
||||
{{ if and (.Site.Params.Logo) (.Site.Params.SecondaryLogo) }}
|
||||
{{ $primaryLogo := resources.Get .Site.Params.Logo }}
|
||||
{{ $secondaryLogo := resources.Get .Site.Params.SecondaryLogo }}
|
||||
{{ if and ($primaryLogo) ($secondaryLogo) }}
|
||||
var elems;
|
||||
elems = document.querySelectorAll("img.logo")
|
||||
targetLogoPath =
|
||||
|
@ -85,6 +85,6 @@ var updateLogo = (targetAppearance) => {
|
|||
for (const elem of elems) {
|
||||
elem.setAttribute("src", targetLogoPath)
|
||||
}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
|
|
Loading…
Reference in a new issue