forked from DPSN/dpsnmunc-checkin-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.js
82 lines (81 loc) · 2.78 KB
/
base.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Mobile view init */
var navBarLi = document.querySelectorAll('.navbar li');
var navbarTotalWidth = 0;
for(var i = 1; i < navBarLi.length; i++) {
navbarTotalWidth = navbarTotalWidth + $(navBarLi[i]).width();
}
var mobileView = $(document).width() < navbarTotalWidth;
/* Navigation bar stick init */
var navStick = false;
/* Stick navigation bar to top on scrolling */
var navStickScroll = function () {
if(document.body.scrollTop > parseInt($('.header').height())) {
document.querySelector('.navbar').style.position = 'fixed';
document.querySelector('.navbar').style.top = '0';
document.querySelector('#flogo').style.display = 'block';
navStick = true;
}
else {
document.querySelector('.navbar').style.position = null;
document.querySelector('.navbar').style.top = null;
document.querySelector('#flogo').style.display = 'none';
navStick = false;
}
};
if(!mobileView) { document.onscroll = navStickScroll; }
/* Make navigation bar links float vertically to fit contents if mobileView*/
var navFloatMobile = function () {
if(mobileView) {
var li = document.querySelectorAll('.navbar li');
for(var i = 0; i < li.length; i++) {
li[i].style.float = 'none';
}
document.querySelector('#togglemenu').style.display = 'block';
}
};
navFloatMobile();
/* Navigation bar menu toggle button */
var menuView = false;
var hideMenu = function () {
var navBar = document.querySelector('.navbar ul');
navBar.style.minWidth = null;
navBar.style.minHeight = null;
navBar.style.position = null;
navBar.style.top = null;
document.querySelector('#flogo').style.display = 'none';
document.querySelector('.navbar').style.display = 'block';
// $('.navbar').fadeIn();
var li = document.querySelectorAll('.navbar li');
for(var i = 2; i < li.length; i++) {
li[i].style.display = 'none';
}
menuView = false;
};
var showMenu = function () {
var navBar = document.querySelector('.navbar ul');
// navBar.style.minWidth = '100vw';
navBar.style.minHeight = '100vh';
navBar.style.position = 'fixed';
navBar.style.top = 0;
document.querySelector('#flogo').style.display = 'block';
document.querySelector('.navbar').style.display = 'none';
$('.navbar').fadeIn();
var li = document.querySelectorAll('.navbar li');
for(var i = 2; i < li.length; i++) {
li[i].style.display = 'block';
}
menuView = true;
};
if(mobileView) {
hideMenu();
}
document.querySelector('a#menubutton').onclick = function () {
if(menuView) {
document.querySelector('a#menubutton').innerHTML = '≡';
hideMenu();
}
else {
document.querySelector('a#menubutton').innerHTML = '<small>x</small>';
showMenu();
}
};