mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-02-02 11:32:30 -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"
|
var targetAppearance = document.documentElement.classList.contains("dark") ? "dark" : "light"
|
||||||
updateMeta()
|
updateMeta()
|
||||||
updateLogo(targetAppearance)
|
this.updateLogo?.(targetAppearance)
|
||||||
|
|
||||||
if (switcher) {
|
if (switcher) {
|
||||||
switcher.addEventListener("click", () => {
|
switcher.addEventListener("click", () => {
|
||||||
|
@ -39,7 +39,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||||
targetAppearance
|
targetAppearance
|
||||||
);
|
);
|
||||||
updateMeta()
|
updateMeta()
|
||||||
updateLogo(targetAppearance)
|
this.updateLogo?.(targetAppearance)
|
||||||
});
|
});
|
||||||
switcher.addEventListener("contextmenu", (event) => {
|
switcher.addEventListener("contextmenu", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -55,7 +55,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||||
targetAppearance
|
targetAppearance
|
||||||
);
|
);
|
||||||
updateMeta()
|
updateMeta()
|
||||||
updateLogo(targetAppearance)
|
this.updateLogo?.(targetAppearance)
|
||||||
});
|
});
|
||||||
switcherMobile.addEventListener("contextmenu", (event) => {
|
switcherMobile.addEventListener("contextmenu", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -72,11 +72,11 @@ var updateMeta = () => {
|
||||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', style.backgroundColor);
|
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) => {
|
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;
|
var elems;
|
||||||
elems = document.querySelectorAll("img.logo")
|
elems = document.querySelectorAll("img.logo")
|
||||||
targetLogoPath =
|
targetLogoPath =
|
||||||
|
@ -85,6 +85,6 @@ var updateLogo = (targetAppearance) => {
|
||||||
for (const elem of elems) {
|
for (const elem of elems) {
|
||||||
elem.setAttribute("src", targetLogoPath)
|
elem.setAttribute("src", targetLogoPath)
|
||||||
}
|
}
|
||||||
{{ end }}
|
|
||||||
{{- end }}
|
|
||||||
}
|
}
|
||||||
|
{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
|
Loading…
Reference in a new issue