-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
102 lines (82 loc) · 3.36 KB
/
index.html
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>FlexNav - Playground</title>
<meta name="description" content="Flexbox Navigation - Playground for flexbox">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css">
<link href="stylesheets/main.css" media="screen, projection" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="wrapper">
<div class="navbar">
<a href="#" class="logo">DEV-KIT</a>
<a href='#' class="menu">Menu</a>
<nav class="prim-nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Pricing</a></li>
<li><a href="#">Partners</a></li>
<li><a href="#">Articles</a>
<li><a href="#">Contact</a></li>
<li class="social"><a href="#"><i class="fa fa-facebook"></i></a></li>
<li class="social"><a href="#"><i class="fa fa-twitter"></i></a></li>
<li class="social"><a href="#"><i class="fa fa-instagram"></i></a></li>
<li class="social"><a href="#"><i class="fa fa-pinterest"></i></a></li>
</ul>
</nav>
</div>
</div>
<script>
(function (window) {
var menu = document.getElementsByClassName('prim-nav')[0];
var elem = document.getElementsByClassName('menu')[0];
function hasClass(el, className) {
if (el.classList)
return el.classList.contains(className)
else
return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'))
}
function addClass(el, className) {
if (el.classList)
el.classList.add(className)
else if (!hasClass(el, className)) el.className += " " + className
}
function removeClass(el, className) {
if (el.classList)
el.classList.remove(className)
else if (hasClass(el, className)) {
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)')
el.className=el.className.replace(reg, ' ')
}
}
//On Menu click check for class open do relevant ternary
elem.addEventListener("click", function(){
hasClass(menu, 'open') ? removeClass(menu, 'open') : addClass(menu, 'open');
});
// Close the dropdown menu if the user clicks outside of the main area
window.onclick = function(event) {
if (!event.target.matches('.menu')) {
var dropdown = document.getElementsByClassName("prim-nav");
var i;
for (i = 0; i < dropdown.length; i++) {
var openDropdown = dropdown[i];
if (openDropdown.classList.contains('open')) {
openDropdown.classList.remove('open');
}
}
}
}
})(window);
</script>
</body>
</html>