2 | -----------------------------------------------------------------------------
3 | Functionality for off-canvas menu / sidebar visibility
4 | -----------------------------------------------------------------------------
7 /*jslint browser:true*/
12 document
.addEventListener('DOMContentLoaded', function () {
13 var menu
= document
.getElementById('mobile-menu'),
14 wrapper
= document
.getElementById('site-wrapper'),
15 content
= document
.getElementById('site-content'),
16 menuVisibilityData
= 'data-menu-visible';
18 if (!menu
|| !wrapper
|| !content
) {
23 | ---------------------------------------------------------------------
24 | Click on content element results in menu getting closed
25 | ---------------------------------------------------------------------
27 content
.addEventListener('click', function (event
) {
28 if (wrapper
.getAttribute(menuVisibilityData
)) {
29 wrapper
.removeAttribute(menuVisibilityData
);
31 event
.preventDefault();
32 event
.stopPropagation();
37 | ---------------------------------------------------------------------
38 | Click on menu element results in menu getting opened
39 | ---------------------------------------------------------------------
41 menu
.addEventListener('click', function (event
) {
42 if (!wrapper
.getAttribute(menuVisibilityData
)) {
43 wrapper
.setAttribute(menuVisibilityData
, '1');
45 wrapper
.removeAttribute(menuVisibilityData
);
48 event
.preventDefault();
49 event
.stopPropagation();