Skip to content

Commit

Permalink
Added ability to change logo image in themes
Browse files Browse the repository at this point in the history
  • Loading branch information
aopell committed Jan 31, 2018
1 parent dd46fc0 commit b99ae33
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
--primary-dark: hsl(var(--color-hue), 55%, 40%);
--primary-very-dark: hsl(var(--color-hue), 90%, 50%);
--cursor: auto;
--background-url: none;
cursor: var(--cursor);
}

Expand Down Expand Up @@ -56,6 +57,10 @@ body #primary-settings .unfold {
background-image: none !important;
}

#home a.custom-background-image {
background: var(--background-url) no-repeat 0px 0px !important;
}

#home a.hide-background-image {
background: none !important;
}
Expand Down
23 changes: 22 additions & 1 deletion js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ class Theme {
if (obj.colors) {
Theme.setBackgroundColor(obj.colors[0], obj.colors[1], obj.colors[2], obj.colors[3]);
}
Theme.setLogoVisibility(obj.logo && obj.logo != "schoology");
Theme.setLogoVisibility(obj.logo && obj.logo.toLowerCase() != "schoology");
Theme.setCursorUrl(obj.cursor);
if (obj.logo && obj.logo.toLowerCase() != "schoology" && obj.logo.toLowerCase() != "lausd") {
Theme.setLogoUrl(obj.logo);
}
}
);
}
Expand All @@ -24,6 +27,7 @@ class Theme {
Theme.setBackgroundHue(210);
Theme.setCursorUrl();
Theme.setLogoVisibility(false);
Theme.setLogoUrl();
theme.onapply(storage);
}

Expand Down Expand Up @@ -69,6 +73,23 @@ class Theme {
}, 50);
}

static setLogoUrl(url) {
let interval = setInterval(() => {
let logo = document.querySelector("#home a");
let notLogo = document.querySelector("#home a[role=menuitem]")
if (!notLogo && logo) {
clearInterval(interval);
if (url) {
logo.classList.add("custom-background-image");
document.documentElement.style.setProperty("--background-url", `url(${url})`);
}
else {
logo.classList.remove("custom-background-image");
}
}
}, 50);
}

static setCursorUrl(url) {
if (url) {
document.documentElement.style.setProperty("--cursor", url ? `url(${url}), auto` : "auto");
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Schoology Plus",
"short_name": "Schoology+",
"description": "Provides some enhancements to your LAUSD Schoology experience",
"version": "3.6.1",
"version": "3.7",
"icons": {
"128": "imgs/[email protected]",
"64": "imgs/[email protected]",
Expand Down

0 comments on commit b99ae33

Please sign in to comment.