created javascript modules

This commit is contained in:
Simon-Martens
2024-01-25 15:26:15 +01:00
parent e033bd23f3
commit 065246acdc
12 changed files with 66 additions and 24 deletions

View File

@@ -19,4 +19,4 @@ const startup_markanchor = function () {
}
}
startup_markanchor();
export { startup_markanchor };

View File

@@ -9,5 +9,4 @@ const startup_clipboard = function () {
});
}
startup_clipboard();
export { startup_clipboard };

View File

@@ -1 +1,10 @@
import "../css/site.css";
import "../css/site.css";
import { startup_marginals } from "./marginals.mjs";
import { startup_theme } from "./theme.mjs";
import { startup_menu } from "./menu.js";
import { startup_markanchor } from "./anchor.mjs";
import { startup_mobilemenu } from "./mobilemenu.js";
import { startup_scrollbutton } from "./scrollbutton.mjs";
import { startup_clipboard } from "./clipboard.mjs";
export { startup_clipboard, startup_mobilemenu, startup_markanchor, startup_menu, startup_scrollbutton, startup_marginals, startup_theme };

View File

@@ -154,10 +154,10 @@ const startup_marginals = function () {
overlappingcollapsebox(".ha-text .ha-marginalbox", true);
};
var collapsedboxes = [];
let collapsedboxes = [];
const clearcollapsedboxes = function () {
var elements = document.querySelectorAll(".ha-text .ha-marginalbox");
let elements = document.querySelectorAll(".ha-text .ha-marginalbox");
elements.forEach(element => {
element.removeAttribute("style");
});
@@ -167,7 +167,7 @@ const startup_marginals = function () {
element.outerHTML = element.outerHTML;
});
collapsedboxes = [];
var elements = document.querySelectorAll(".ha-btn-collapsed-box");
elements = document.querySelectorAll(".ha-btn-collapsed-box");
elements.forEach(element => {
element.remove();
});
@@ -184,10 +184,10 @@ const startup_marginals = function () {
collapseboxes();
var doit;
this.window.addEventListener("resize", function () {
this.clearTimeout(doit);
doit = this.setTimeout(resetall, 17);
window.addEventListener("resize", function () {
clearTimeout(doit);
doit = setTimeout(resetall, 17);
});
};
startup_marginals();
export { startup_marginals };

View File

@@ -1,4 +1,4 @@
const startup_active = function () {
const startup_menu = function () {
// Gives active classes to links with active URLs
// Marks links as active which target URL starts with the current URL
const markactive_startswith = function (element) {
@@ -65,9 +65,9 @@ const startup_active = function () {
markactive_menu(document.getElementById("ha-topnav"));
if (document.getElementById("ha-register-nav") !== null)
markactive_exact(document.getElementById("ha-register-nav"));
if (this.document.getElementById("ha-adminuploadfields") !== null)
if (document.getElementById("ha-adminuploadfields") !== null)
markactive_exact(document.getElementById("ha-adminuploadfields"));
};
startup_active();
export { startup_menu };

View File

@@ -32,4 +32,4 @@ const startup_mobilemenu = function () {
}
};
startup_mobilemenu();
export { startup_mobilemenu };

View File

@@ -2,7 +2,7 @@ const startup_scrollbutton = function () {
// Script for showing and acting upon the "scroll to top button"
const scrollFunction = function () {
button = document.getElementById("ha-scrollbutton");
let button = document.getElementById("ha-scrollbutton");
if (button !== null) {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
// button.style.display = "block";
@@ -28,4 +28,4 @@ const startup_scrollbutton = function () {
}
};
startup_scrollbutton();
export { startup_scrollbutton };

View File

@@ -20,7 +20,7 @@ const startup_theme = function () {
if (
document.getElementById("ha-togglebright") !== null &&
this.document.getElementById("ha-toggledark") !== null
document.getElementById("ha-toggledark") !== null
) {
document
.getElementById("ha-togglebright")
@@ -32,4 +32,4 @@ const startup_theme = function () {
get_theme_settings("ha-togglebright");
};
startup_theme();
export { startup_theme };