forked from jonathandfitzgerald/wwp-w2vonline
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (42 loc) · 1.62 KB
/
script.js
File metadata and controls
46 lines (42 loc) · 1.62 KB
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
/*
Javascript for the Word Vector Interface
*/
/* Toggle the Bootstrap v4 "show" class on the sidebar menu. Currently unused.
Instead, the v3 "in" class styling is replicated in wvi.css. */
let toggleSideNav = function(e) {
console.log('Toggling navbar visibility');
let sideMenu = document.getElementById("navbarResponsive");
if ( sideMenu !== undefined ) {
copyNavMenu();
}
sideMenu.classList.toggle('show');
};
/* Duplicate the collapsed menu in the header. */
let copyNavMenu = function() {
if ( ! document.getElementById("navbarResponsive") ) {
let menuEl = document.createElement('section'),
menuList = document.getElementById("navbarResponsiveBase").children[0],
sidebar = document.getElementById("sidebarCollapsed");
menuEl.setAttribute('id', 'navbarResponsive');
menuEl.classList.add('collapse');
menuEl.append(menuList.cloneNode(true));
sidebar.prepend(menuEl);
}
};
/* Create a callback function to be run when the entire document has loaded. */
let onLoad = function() {
console.log("Page loaded");
copyNavMenu();
// When the hamburger menu is clicked, toggle the visibility of the nav menu.
//document.getElementById("sidebar-hider").onclick = toggleSideNav;
};
/* Ensure that the callback function above is run, whether or not the DOM has
already been loaded. Solution by Julian Kühnel:
https://www.sitepoint.com/jquery-document-ready-plain-javascript/ */
if ( document.readyState === 'complete'
|| ( document.readyState !== 'loading' && !document.documentElement.doScroll )
) {
onLoad();
} else {
document.addEventListener('DOMContentLoaded', onLoad);
}