forked from mazipan/bulma-admin-dashboard-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module-event.js
37 lines (30 loc) · 1.13 KB
/
module-event.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
document.addEventListener('DOMContentLoaded', function () {
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
if ($navbarBurgers.length > 0) {
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
var target = $el.dataset.target;
var $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
// Get all "is-tab" elements
var $isTabs = Array.prototype.slice.call(document.querySelectorAll('.is-tab'), 0);
if ($isTabs.length > 0) {
function removeAllIsActive(){
$isTabs.forEach(function ($el) {
$el.classList.remove('is-active');
});
}
$isTabs.forEach(function ($el) {
$el.addEventListener('click', function () {
removeAllIsActive();
$el.classList.add('is-active');
});
});
}
});