-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.js
40 lines (35 loc) · 794 Bytes
/
header.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
31
32
33
34
35
36
37
38
39
40
$(window).on("load", function () {
toggleMenuDependingOnWindowSize();
setHeaderIds();
setActiveClass();
});
// Watch for window resizing event
$(window).resize(function() {
toggleMenuDependingOnWindowSize();
});
function toggleMenuDependingOnWindowSize() {
if ($(window).width() < 800) {
$(".headerUl").hide();
} else {
$(".headerUl").show();
}
}
function setHeaderIds() {
$(".headerUl").
find("[href]").
each(function() {
$(this).attr("id", $(this).attr("href").split(".")[0]);
});
}
function setActiveClass() {
var pageId = "#";
try {
pageId += document.location.href.match(/[^\/]+$/)[0].split(".")[0];
} catch (err) {
pageId = $(".headerUl").firstChild().attr("id");
}
$(pageId).attr("class", "aktiv");
}
function toggleMenu() {
$(".headerUl").toggle();
}