Skip to content

Commit

Permalink
Make version picker keyboard-controllable
Browse files Browse the repository at this point in the history
Pre-merging readthedocs#1160
  • Loading branch information
jonels-msft committed Jun 24, 2021
1 parent fb4c979 commit 8b5bb05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
{%- block footer %}
{%- if not READTHEDOCS %}
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="{{ _('Versions') }}">
<span class="rst-current-version" data-toggle="rst-current-version">
<button class="rst-current-version" aria-expanded="false" aria-controls="docs_versions" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: latest
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
</button>
<div class="rst-other-versions" id="docs_versions">
<dl>
<dt>{{ _('Versions') }}</dt>
{%- if test_versions %}
Expand Down
6 changes: 3 additions & 3 deletions sphinx_rtd_theme_citus/versions.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% if READTHEDOCS %}
{# Add rst-badge after rst-versions for small badge style. #}
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="{{ _('Versions') }}">
<span class="rst-current-version" data-toggle="rst-current-version">
<button class="rst-current-version" aria-expanded="false" aria-controls="docs_versions" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: {{ current_version }}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
</button>
<div class="rst-other-versions" id="docs_versions">
<dl>
<dt>{{ _('Versions') }}</dt>
{% for slug, url in versions %}
Expand Down
1 change: 1 addition & 0 deletions src/sass/_theme_badge.sass
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
font-size: 90%
cursor: pointer
color: $green
width: 100%
+clearfix
.fa
color: $section-background-color
Expand Down
6 changes: 6 additions & 0 deletions src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ function ThemeNav () {
self.hashChange();
})
.on('click', "[data-toggle='rst-current-version']", function() {
var target = $(this);
$("[data-toggle='rst-versions']").toggleClass("shift-up");
target.attr(
'aria-expanded',
$("[data-toggle='rst-versions']").hasClass("shift-up") ?
"true" : "false"
);
})

// Make tables responsive
Expand Down

0 comments on commit 8b5bb05

Please sign in to comment.