summaryrefslogtreecommitdiff
path: root/lib/rdoc/generator/template/darkfish/js/darkfish.js
diff options
context:
space:
mode:
authorStan Lo <[email protected]>2024-08-03 11:29:40 +0100
committerHiroshi SHIBATA <[email protected]>2024-08-05 08:27:45 +0800
commitcbc40bb130fb52f1990ce1fd41e834a5f3fdbcdd (patch)
tree56845ee9fb311d5f7fb952c0392eecac93759e5f /lib/rdoc/generator/template/darkfish/js/darkfish.js
parent7d5cb4573d39e5c62058314dcfc73895b4e6dffd (diff)
Sync rdoc
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11308
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();
});