-
Notifications
You must be signed in to change notification settings - Fork 1
/
scripts.js
53 lines (44 loc) · 1.25 KB
/
scripts.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
/**
* @file _utils - global utilities JavaScript
*/
var _utils = (function() {
var self = {};
self._body = document.body;
return self;
}());
/**
* @file menu.js - menu related JavaScript
*/
var menu = (function() {
var self = {};
const _MenuOpenAction = document.querySelector(".navigation__menu-open-action");
const _MenuCloseAction = document.querySelector(".navigation__menu-close-action");
const _MenuTarget = document.querySelector(".navigation__menu-target");
const menuInClass = "navigation--menu-in";
self.openHandler = function() {
_MenuTarget.classList.add(menuInClass);
};
self.closeHandler = function() {
_MenuTarget.classList.remove(menuInClass);
};
self.bindEvents = function () {
_MenuOpenAction.addEventListener('click', self.openHandler);
_MenuCloseAction.addEventListener('click', self.closeHandler);
};
self.init = function () {
self.bindEvents();
};
return self;
}());
/**
* @file _init - initiate JS modules on page ready JavaScript
*/
function ready() {
if (document.readyState != 'loading'){
// Add init functions here to page ready
menu.init();
} else {
document.addEventListener('DOMContentLoaded', ready);
}
}
ready();