mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
- Commentboxes work (marginals) + mouseover
- Basic Briefe Controller - Generic XML reader
This commit is contained in:
101
HaWeb/Views/Shared/_Javascript.cshtml
Normal file
101
HaWeb/Views/Shared/_Javascript.cshtml
Normal file
@@ -0,0 +1,101 @@
|
||||
@* Javascript gets inlined because it ain't much (but it's honest work) *@
|
||||
@* Only put PRODUCTION JavaScript here *@
|
||||
<script>
|
||||
const openmenu = function () {
|
||||
var x = document.getElementById("ha-topnav");
|
||||
if (x !== null) x.className += " ha-topnav-collapsed";
|
||||
let oldbutton = document.getElementById("openmenubutton");
|
||||
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
|
||||
let newbutton = document.getElementById("closemenubutton");
|
||||
if (newbutton !== null) newbutton.setAttribute('class', '');
|
||||
}
|
||||
|
||||
const closemenu = function () {
|
||||
var x = document.getElementById("ha-topnav");
|
||||
if (x !== null) x.className = "ha-topnav";
|
||||
let oldbutton = document.getElementById("closemenubutton");
|
||||
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
|
||||
let newbutton = document.getElementById("openmenubutton");
|
||||
if (newbutton !== null) newbutton.setAttribute('class', '');
|
||||
|
||||
}
|
||||
|
||||
const markactive_startswith = function (element) {
|
||||
// Marks links as active which target URL starts with the current URL
|
||||
var all_links = element.getElementsByTagName("a"),
|
||||
i = 0, len = all_links.length,
|
||||
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (full_path.startsWith(all_links[i].href.toLowerCase())) {
|
||||
all_links[i].className += " active";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const markactive_exact = function (element) {
|
||||
var all_links = element.getElementsByTagName("a"),
|
||||
i = 0, len = all_links.length,
|
||||
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (full_path == all_links[i].href.toLowerCase()) {
|
||||
all_links[i].className += " active";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getLineHeight = function (element) {
|
||||
var temp = document.createElement(element.nodeName), ret;
|
||||
temp.setAttribute("class", element.className);
|
||||
temp.innerHTML = "A";
|
||||
|
||||
element.parentNode.appendChild(temp);
|
||||
ret = temp.clientHeight;
|
||||
temp.parentNode.removeChild(temp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* TODO: need a resize watcher to undo and reapply the effect on breakpoint */
|
||||
const overlappingboxcollapse = function (selector) {
|
||||
let boxes = document.querySelectorAll(selector);
|
||||
let clientrects = [];
|
||||
let lineheight = 1;
|
||||
|
||||
if (boxes.length >= 1) {
|
||||
lineheight = getLineHeight(boxes[0]);
|
||||
}
|
||||
|
||||
for (element of boxes) {
|
||||
clientrects.push([element, element.getBoundingClientRect()]);
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < clientrects.length; i++) {
|
||||
if (i < clientrects.length-1) {
|
||||
if (clientrects[i][1].bottom >= clientrects[i+1][1].top) {
|
||||
let overlap = clientrects[i][1].bottom - clientrects[i+1][1].top;
|
||||
let newlength = clientrects[i][1].height - overlap;
|
||||
let remainder = newlength % lineheight;
|
||||
newlength = newlength - remainder;
|
||||
clientrects[i][0].style.height = newlength + 'px';
|
||||
clientrects[i][0].style.overflowX = "hidden";
|
||||
clientrects[i][0].style.overflowY = "scroll";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
document.getElementById("openmenubutton").addEventListener('click', openmenu);
|
||||
document.getElementById("closemenubutton").addEventListener('click', closemenu);
|
||||
markactive_startswith(document.getElementById("ha-topnav"));
|
||||
markactive_exact(document.getElementById("ha-register-nav"));
|
||||
overlappingboxcollapse(".ha-neuzeit .ha-letlinks");
|
||||
overlappingboxcollapse(".ha-forschung .ha-letlinks");
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -9,12 +9,22 @@
|
||||
<title>HKB: @ViewData["Title"]</title>
|
||||
|
||||
<!-- crossorigin is a workaround to prevent double downloading bugs in chrome -->
|
||||
<link rel="preload" href="/css/output.css" as="style" />
|
||||
<!-- also, the graphite versions of the font are available for use:
|
||||
<link rel="preload" href="/fonts/LinLibertine_R_G.ttf" as="font" crossorigin/>
|
||||
<link rel="preload" href="/fonts/LinBiolinum_R_G.ttf" as="font" crossorigin/>
|
||||
-->
|
||||
<link rel="preload" href="/css/output.css" as="style" asp-append-version="true"/>
|
||||
<link rel="preload" href="/img/subtlenet2.png" as="image" />
|
||||
<link rel="preload" href="/fonts/LinBiolinum_R_G.ttf" as="font" crossorigin/>
|
||||
<link rel="preload" href="/fonts/LinLibertine_R_G.ttf" as="font" crossorigin/>
|
||||
<link rel="preload" href="/fonts/LinBiolinum_R.woff" as="font" crossorigin/>
|
||||
<link rel="preload" href="/fonts/LinLibertine_R.woff" as="font" crossorigin/>
|
||||
<link rel="preload" href="/fonts/LinLibertine_RI.woff" as="font" crossorigin/>
|
||||
<link rel="preload" href="/fonts/LinLibertine_RB.woff" as="font" crossorigin/>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/css/output.css" />
|
||||
<link rel="stylesheet" href="/css/output.css" asp-append-version="true" />
|
||||
<environment include="Development">
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
</environment>
|
||||
|
||||
</head>
|
||||
|
||||
@@ -24,11 +34,12 @@
|
||||
<main role="main" class="pb-3 w-full desktop:max-w-screen-desktop mx-auto">
|
||||
@RenderBody()
|
||||
</main>
|
||||
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
|
||||
|
||||
@await Html.PartialAsync("/Views/Shared/_Footer.cshtml")
|
||||
|
||||
<environment exclude="Development">
|
||||
@await Html.PartialAsync("/Views/Shared/_Javascript.cshtml")
|
||||
</environment>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user