Mergess TraditionRules with TextRules. Added tabs for other Text. Some bugs persist see readme

This commit is contained in:
Simon Martens
2022-11-26 23:15:42 +01:00
parent 49c32dcc6a
commit 6370b70e35
21 changed files with 420 additions and 789 deletions

View File

@@ -1,92 +1,23 @@
// Code specifically for the letter view
const showhidebutton = function (
buttonid,
divid,
buttonlist,
divlist,
starthidden
) {
let button = document.getElementById(buttonid);
let div = document.getElementById(divid);
// // Code specifically for the letter view
let activetab = null;
let activetabbtn = null;
let tabbtnlist = document.querySelectorAll(".ha-tabbtn");
let tablist = document.querySelectorAll(".ha-tab");
if (starthidden && div !== null) {
div.classList.add("hide");
}
for (let i = 0; i < tabbtnlist.length; i++) {
tablist[i].classList.add("hidden");
tabbtnlist[i].addEventListener("click", () => {
if (activetab != null)
activetab.classList.add("hidden");
if (activetabbtn != null)
activetabbtn.classList.remove("active");
if (!starthidden && button !== null) {
button.classList.add("active");
}
tablist[i].classList.remove("hidden");
tabbtnlist[i].classList.add("active");
activetab = tablist[i];
activetabbtn = tabbtnlist[i];
});
}
if (button !== null) {
button.addEventListener("click", function () {
for (let btn of buttonlist) {
let inactivebutton = document.getElementById(btn);
if (inactivebutton !== null) inactivebutton.classList.remove("active");
}
for (let element of divlist) {
let hiddenelement = document.getElementById(element);
if (hiddenelement !== null) {
hiddenelement.classList.add("hide")
hiddenelement.classList.remove("flow-root");
};
}
if (button !== null) button.classList.add("active");
if (div !== null) {
div.classList.add("flow-root");
div.classList.remove("hide");
}
});
}
};
// Letter View: Show / Hide Tabs
let buttonlist = ["ha-lettertextbtn", "ha-additionsbtn", "ha-marginalsbtn"];
let divlist = ["ha-lettertext", "ha-additions", "ha-marginals"];
if (this.document.getElementById("ha-lettertextbtn") !== null) {
showhidebutton(
"ha-lettertextbtn",
"ha-lettertext",
buttonlist,
divlist,
false
);
showhidebutton(
"ha-additionsbtn",
"ha-additions",
buttonlist,
divlist,
true
);
showhidebutton(
"ha-marginalsbtn",
"ha-marginals",
buttonlist,
divlist,
true
);
} else {
showhidebutton(
"ha-lettertextbtn",
"ha-lettertext",
buttonlist,
divlist,
true
);
showhidebutton(
"ha-additionsbtn",
"ha-additions",
buttonlist,
divlist,
false
);
showhidebutton(
"ha-marginalsbtn",
"ha-marginals",
buttonlist,
divlist,
true
);
}
if (tabbtnlist.length > 0)
tabbtnlist[0].click();

View File

@@ -133,11 +133,11 @@ const overlappingcollapsebox = function (selector, hoverfunction) {
const marginalboxwidthset = function () {
let lt = document.getElementById("ha-letterbody");
if (lt !== null) {
let mg = lt.querySelectorAll(".ha-lettertext .ha-marginalbox");
let mg = lt.querySelectorAll(".ha-text .ha-marginalbox");
if (mg.length > 0) {
let ltbcr = lt.getBoundingClientRect();
let mgbcr = mg[0].getBoundingClientRect();
let nw = ltbcr.right - mgbcr.left - 18;
let nw = ltbcr.right - mgbcr.left - 20;
for (let element of mg) {
element.style.width = nw + "px";
@@ -152,14 +152,14 @@ const collapseboxes = function () {
overlappingcollapsebox(".ha-neuzeit .ha-letlinks", true);
overlappingcollapsebox(".ha-forschung .ha-letlinks", true);
overlappingcollapsebox(".ha-commentlist .ha-letlinks", true);
overlappingcollapsebox(".ha-lettertext .ha-marginalbox", true);
overlappingcollapsebox(".ha-text .ha-marginalbox", true);
};
marginalboxwidthset();
collapseboxes();
var doit;
this.window.addEventListener("resize", function () {
this.clearTimeout(doit);
marginalboxwidthset();
doit = this.setTimeout(collapseboxes, 250);
});
// var doit;
// this.window.addEventListener("resize", function () {
// this.clearTimeout(doit);
// marginalboxwidthset();
// doit = this.setTimeout(collapseboxes, 250);
// });