Skip to content

Commit ca42b63

Browse files
committed
changes to fix footer overlap
1 parent 175fce1 commit ca42b63

File tree

1 file changed

+38
-29
lines changed

1 file changed

+38
-29
lines changed

_templates/_page_openshift.html.erb

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@
286286
<!-- remove toc active class when page is loaded -->
287287
<script type="text/javascript">
288288
window.addEventListener('DOMContentLoaded', () => {
289-
var tocItems = $("#toc a");
289+
toc_items = document.querySelectorAll('#toc a')
290290

291-
for (let i = 0; i < tocItems.length; i++) {
292-
tocItems[i].classList.remove("toc-active");
291+
for (let i = 0; i < toc_items.length; i++) {
292+
toc_items[i].classList.remove("toc-active");
293293
}
294294
})
295295
</script>
@@ -329,9 +329,9 @@
329329
<!-- clear and add toc-active to clicked toc link -->
330330
<script type="text/javascript">
331331
$("#toc a").click(function() {
332-
var tocItems = $("#toc a");
333-
for (let i = 0; i < tocItems.length; i++) {
334-
tocItems[i].classList.remove("toc-active");
332+
toc_items = document.querySelectorAll('#toc a')
333+
for (let i = 0; i < toc_items.length; i++) {
334+
toc_items[i].classList.remove("toc-active");
335335
}
336336
this.classList.add("toc-active");
337337
});
@@ -365,7 +365,8 @@
365365
e.map(i => {
366366
if (i.isIntersecting && i.intersectionRatio >= 1) {
367367
allTocLinks.forEach(link => link.classList.remove("toc-active"));
368-
document.querySelector(`#toc li a[href="#${i.target.id}"]`).classList.add('toc-active');
368+
toc_item = document.querySelector(`#toc li a[href="#${i.target.id}"]`)
369+
if(toc_item !== null) toc_item.classList.add('toc-active');
369370
}
370371
});
371372
};
@@ -376,9 +377,9 @@
376377
document.querySelectorAll('.main h2[id], .main h3[id]').forEach((h) => {
377378
observer.unobserve(h);
378379
});
379-
var tocItems = $("#toc a");
380-
for (let i = 0; i < tocItems.length; i++) {
381-
tocItems[i].classList.remove("toc-active");
380+
toc_items = document.querySelectorAll('#toc a')
381+
for (let i = 0; i < toc_items.length; i++) {
382+
toc_items[i].classList.remove("toc-active");
382383
}
383384
this.classList.add("toc-active");
384385
})
@@ -387,45 +388,53 @@
387388

388389
<!--handle page scroll top and bottom, add toc-active -->
389390
<script type="text/javascript">
391+
toc_items = document.querySelectorAll('#toc a')
390392
document.addEventListener('scroll', () => {
391393
//scroll to bottom
392394
if(document.documentElement.scrollHeight === window.pageYOffset + window.innerHeight) {
393-
var tocItems = $("#toc a");
394-
for (let i = 0; i < tocItems.length; i++) {
395-
tocItems[i].classList.remove("toc-active")
396-
};
397-
tocItems[tocItems.length - 1].classList.add("toc-active");
395+
if(toc_items !== null) {
396+
for (let i = 0; i < toc_items.length; i++) {
397+
toc_items[i].classList.remove("toc-active")
398+
};
399+
toc_items[toc_items.length - 1].classList.add("toc-active");
400+
}
398401
};
399402
//scroll to top
400403
if(window.pageYOffset === 0) {
401-
var tocItems = $("#toc a");
402-
for (let i = 0; i < tocItems.length; i++) {
403-
tocItems[i].classList.remove("toc-active");
404+
for (let i = 0; i < toc_items.length; i++) {
405+
if(toc_items !== null) {
406+
toc_items[i].classList.remove("toc-active");
404407
};
405-
tocItems[0].classList.add("toc-active");
406-
};
407-
})
408+
toc_items[0].classList.add("toc-active");
409+
}
410+
};
411+
})
408412
</script>
409413

410414
<!-- adjust alerts on mobile -->
411415
<script type="text/javascript">
416+
alert_item = document.querySelector('#support-alert')
412417
window.addEventListener("wheel", () => {
413418
if (window.innerWidth < 1425) {
414419
//adjust alert
415420
if(window.pageYOffset > 0) {
416-
document.querySelector('#support-alert').style.position = "fixed";
417-
document.querySelector('#support-alert').style.bottom = "0px";
418-
document.querySelector('#support-alert').style.margin = "5px";
419-
document.querySelector('#support-alert').style.zIndex = "9999999";
421+
if(alert_item !== null) {
422+
alert_item.style.position = "fixed";
423+
alert_item.style.bottom = "0px";
424+
alert_item.style.margin = "5px";
425+
alert_item.style.zIndex = "9999999";
426+
}
420427
}
421428
}
422429
});
423430
window.addEventListener('resize', () => {
424431
if (window.innerWidth >= 1425) {
425-
document.querySelector('#support-alert').style.removeProperty('position');
426-
document.querySelector('#support-alert').style.removeProperty('bottom');
427-
document.querySelector('#support-alert').style.removeProperty('margin');
428-
document.querySelector('#support-alert').style.removeProperty('zIndex');
432+
if(alert_item !== null) {
433+
alert_item.style.removeProperty('position');
434+
alert_item.style.removeProperty('bottom');
435+
alert_item.style.removeProperty('margin');
436+
alert_item.style.removeProperty('zIndex');
437+
}
429438
}
430439
})
431440
</script>

0 commit comments

Comments
 (0)