Skip to content

Commit 573aba4

Browse files
author
jordanmccullough
committed
Combine Help and TOC toggle into single function
1 parent 5dd52a4 commit 573aba4

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

_javascript/curriculum.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ $(function(){
88
$(".slide").toggleClass("hidden");
99
});
1010

11-
12-
// "?" Help menu
13-
var help = {};
14-
help.toggle = function(event){
15-
if(event.shiftKey && event.keyCode === 191){
16-
$('#help').modal('toggle');
17-
}
18-
};
19-
20-
document.addEventListener("keydown", help.toggle, false);
21-
22-
2311
// Parse username from querystring
2412
var urlSearch = window.location.search,
2513
teacherQuery = urlSearch.match(/teacher=[a-z,A-Z,0-9]*/),
@@ -111,14 +99,21 @@ $(function(){
11199
}
112100

113101
// Bind checkbox toggle for TOC
114-
var toc = {};
115-
toc.toggle = function(event){
116-
if(event.shiftKey && event.keyCode === 84){
102+
var shortcuts = {};
103+
shortcuts.toggle = function(event){
104+
console.log(event.keyCode);
105+
106+
// Help "?" toggle
107+
if(event.shiftKey && event.keyCode === 191){
108+
$('#help').modal('toggle');
109+
}
110+
// TOC "T" toggle
111+
else if(event.shiftKey && event.keyCode === 84){
117112
$(".col-content").toggleClass("shift-left");
118113
$(".col-toc").toggleClass("shift-left");
119114
}
120115
}
121-
document.addEventListener("keydown", toc.toggle, false);
116+
document.addEventListener("keydown", shortcuts.toggle, false);
122117

123118
// Render the TOC
124119
buildToc();

0 commit comments

Comments
 (0)