mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-10 13:52:17 -06:00
Compare commits
2 Commits
v4.4.10
...
20044-elev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c39f2c7de5 | ||
|
|
68e995d551 |
10
netbox/project-static/dist/netbox.js
vendored
10
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
6
netbox/project-static/dist/netbox.js.map
vendored
6
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -28,13 +28,27 @@ function updateElements(targetMode: ColorMode): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const elevation of getElements<HTMLObjectElement>('.rack_elevation')) {
|
for (const elevation of getElements<HTMLObjectElement>('.rack_elevation')) {
|
||||||
const svg = elevation.contentDocument?.querySelector('svg') ?? null;
|
const svg = elevation.firstElementChild ?? null;
|
||||||
if (svg !== null) {
|
if (svg !== null && svg.nodeName == 'svg') {
|
||||||
svg.setAttribute(`data-bs-theme`, targetMode);
|
svg.setAttribute(`data-bs-theme`, targetMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the color mode to light of elevations after an htmx call.
|
||||||
|
* Pulls current color mode from document
|
||||||
|
*
|
||||||
|
* @param event htmx listener event details. See: https://htmx.org/events/#htmx:afterSwap
|
||||||
|
*/
|
||||||
|
function updateElevations(evt: CustomEvent, ): void {
|
||||||
|
const swappedElement = evt.detail.elt
|
||||||
|
if (swappedElement.nodeName == 'svg') {
|
||||||
|
const currentMode = localStorage.getItem(COLOR_MODE_KEY);
|
||||||
|
swappedElement.setAttribute('data-bs-theme', currentMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call all functions necessary to update the color mode across the UI.
|
* Call all functions necessary to update the color mode across the UI.
|
||||||
*
|
*
|
||||||
@@ -115,6 +129,7 @@ function initColorModeToggle(): void {
|
|||||||
*/
|
*/
|
||||||
export function initColorMode(): void {
|
export function initColorMode(): void {
|
||||||
window.addEventListener('load', defaultColorMode);
|
window.addEventListener('load', defaultColorMode);
|
||||||
|
window.addEventListener('htmx:afterSwap', updateElevations as EventListener); // Uses a custom event from HTMX
|
||||||
for (const func of [initColorModeToggle]) {
|
for (const func of [initColorModeToggle]) {
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user