Skip to content

Commit 97b62f4

Browse files
FestplattenSchnitzellukasjuhrich
authored andcommitted
Replace bootstrap-toc with Tocbot
The bootstrap-toc project is rather unmainted, Tocbot is the alternative recommended by the authors. Also see afeld/bootstrap-toc#74
1 parent 954fe47 commit 97b62f4

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

sipa/static/css/tocbot.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sipa/static/css/usersuite_index.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
#usersuite-sidebar-nav .nav>li>a {
2-
font-size: 20px;
1+
.toc .node-name--H2 {
2+
font-size: 1.5rem;
33
}
4-
#usersuite-sidebar-nav .nav .nav>li>a {
5-
font-size: 19px;
4+
.toc .node-name--H3 {
5+
font-size: 1.25rem;
66
}
7+
78
h2,h3 {
89
padding-top: 70px;
910
margin-top: -50px;

sipa/static/js/tocbot.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sipa/static/js/usersuite_index.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
document.addEventListener("DOMContentLoaded", () => {
2-
const selector = '#usersuite-sidebar-nav';
3-
const $toc = $(selector);
4-
const $parent = $toc.parent();
5-
const offset = 60;
6-
const $body = $('body');
7-
Toc.init($toc);
8-
$body.scrollspy({target: selector, offset: offset});
9-
$toc.affix({
10-
offset: {top: () => $parent.offset().top - offset}
11-
});
12-
// Handle window resize
13-
$(window).resize(() => $toc.affix('checkPosition'));
1+
tocbot.init({
2+
// Where to render the table of contents.
3+
tocSelector: '.js-toc',
4+
// Where to grab the headings to build the table of contents.
5+
contentSelector: '.js-toc-content',
6+
// Which headings to grab inside of the contentSelector element.
7+
headingSelector: 'h2, h3',
8+
// For headings inside relative or absolute positioned containers within content.
9+
hasInnerContainers: true,
10+
11+
positionFixedSelector: '#usersuite-sidebar-nav',
12+
extraLinkClasses: 'text-decoration-none'
1413
});

sipa/templates/base.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</script>
6969
</head>
7070

71-
<body>
71+
<body class="js-toc-content">
7272
<nav id="main-navbar" class="navbar navbar-default navbar-fixed-top navbar-expand-lg">
7373
<div class="container">
7474
<a class="navbar-brand" href="{{ url_for('generic.index') }}">
@@ -234,6 +234,7 @@ <h1>AG DSN</h1>
234234
<div id="sidebar" class="col-sm-3">
235235
{% block sidebar %}
236236
<div>
237+
<!-- TODO Fix visibility -->
237238
<div class="module hidden-xs">
238239
<h2>
239240
{{ _("Status") }}

sipa/templates/usersuite/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
{% endblock %}
1414

1515
{% block sidebar %}
16-
<nav id="usersuite-sidebar-nav" class="hidden-xs hidden-print"></nav>
16+
<nav id="usersuite-sidebar-nav" class="js-toc toc d-none d-md-block"></nav>
1717
{% endblock %}
1818

1919
{% block custom_css %}
20-
<link rel="stylesheet" href="{{ url_for("static", filename="css/bootstrap-toc.min.css") }}"/>
20+
<link rel="stylesheet" href="{{ url_for("static", filename="css/tocbot.css") }}"/>
2121
<link rel="stylesheet" href="{{ url_for("static", filename="css/usersuite_index.css") }}"/>
2222
{% endblock %}
2323

2424
{% block custom_script %}
25-
<script src="{{ url_for("static", filename="js/bootstrap-toc.min.js") }}"></script>
25+
<script src="{{ url_for("static", filename="js/tocbot.min.js") }}"></script>
2626
<script src="{{ url_for("static", filename="js/usersuite_index.js") }}"></script>
2727
<script src="{{ url_for("static", filename="js/svg.jquery.js") }}"></script>
2828
<script src="{{ url_for("static", filename="js/pygal-tooltips.js") }}"></script>

0 commit comments

Comments
 (0)