Skip to content

Commit da11430

Browse files
committed
Propagate the fragment identifier in *all* versions (not just dev).
In d48b796, I added the ability of the apge to track the fragment identifier in the URL so that switching between version would preserve it. However, I overlooked the fact that the block of code I used was only executed when viewing the dev version of the docs. This commit makes the fragement identifier tracking available for all version.
1 parent 91c7a89 commit da11430

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

docs/templates/docs/doc.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
{% block title %}{{ doc.title|striptags|safe }} | {% trans "Django documentation" %}{% endblock %}
66

77
{% block extrabody %}
8+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
9+
<script>
10+
// Propagate the fragment identifier to the links in the version switcher
11+
if (window.location.hash) {
12+
$('#doc-versions a').each(function () {
13+
var anchor = $(this);
14+
anchor.attr('href', anchor.attr('href') + window.location.hash);
15+
});
16+
}
17+
</script>
818
{% if version == 'dev' %}
919
<div id="dev-warning">
1020
{% trans "This document is for Django's development version, which can be significantly different from previous releases. For older releases, use the version selector floating in the bottom right corner of this page." %}
@@ -14,7 +24,6 @@
1424
margin-top: 2em;
1525
}
1626
</style>
17-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
1827
<script>
1928
{% comment %}
2029
Here we are doing something really annoying, we catch clicks on
@@ -53,13 +62,6 @@
5362
}, 50);
5463
});
5564

56-
// Propagate the fragment identifier to the links in the version switcher
57-
if (window.location.hash) {
58-
$('#doc-versions a').each(function () {
59-
var anchor = $(this);
60-
anchor.attr('href', anchor.attr('href') + window.location.hash);
61-
});
62-
}
6365
</script>
6466
{% endif %}
6567
{% endblock extrabody %}

0 commit comments

Comments
 (0)