-
Notifications
You must be signed in to change notification settings - Fork 141
/
site.js
30 lines (27 loc) · 970 Bytes
/
site.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// position body according to header size
function positionBody() {
let headerHeight = $(".navbar").outerHeight();
let viewportHeight = $(".attack-website-wrapper").outerHeight();
$(".sidebar.nav").css({
"top": headerHeight + "px",
"max-height": viewportHeight - headerHeight + "px"
});
}
//scroll the active element into view in the sidenav
function initSidenavScroll() {
let sidenav = $(".sidenav-list");
let sidenav_active_elements = $(".sidenav .active");
if (sidenav_active_elements.length > 0) setTimeout(() => { //setTimeout gives bootstrap time to execute first
sidenav[0].scrollTop = sidenav_active_elements[0].offsetTop - 60;
});
}
// when the document loads, position the body
$(document).ready(function() {
positionBody();
initSidenavScroll();
$('[data-toggle="tooltip"]').tooltip();
});
// when the document resizes, position body
$(window).resize(function() {
positionBody();;
});