summaryrefslogtreecommitdiff
path: root/lib/rdoc/generator/template/darkfish/js/darkfish.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/generator/template/darkfish/js/darkfish.js')
-rw-r--r--lib/rdoc/generator/template/darkfish/js/darkfish.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js
index 19a85c54e1..bea0a5f1cb 100644
--- a/lib/rdoc/generator/template/darkfish/js/darkfish.js
+++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js
@@ -90,8 +90,25 @@ function hookFocus() {
});
}
+function hookSidebar() {
+ var navigation = document.querySelector('#navigation');
+ var navigationToggle = document.querySelector('#navigation-toggle');
+
+ navigationToggle.addEventListener('click', function() {
+ navigation.hidden = !navigation.hidden;
+ navigationToggle.ariaExpanded = navigationToggle.ariaExpanded !== 'true';
+ });
+
+ var isSmallViewport = window.matchMedia("(max-width: 1024px)").matches;
+ if (isSmallViewport) {
+ navigation.hidden = true;
+ navigationToggle.ariaExpanded = false;
+ }
+}
+
document.addEventListener('DOMContentLoaded', function() {
hookSourceViews();
hookSearch();
hookFocus();
+ hookSidebar();
});