Skip to content

Commit f77f88e

Browse files
committed
Refactored version-switcher.js
- Simplified code - Stopped using jQuery - Moved refactored code to `djangoproject.js` This patch should bring no user-facing changes. Refs django#1827
1 parent 124be99 commit f77f88e

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
lines changed

djangoproject/static/js/djangoproject.js

+7
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ document.querySelectorAll('.doc-switcher li.current').forEach(function (el) {
44
this.parentElement.classList.toggle('open');
55
});
66
});
7+
8+
// Propagate the current fragment identifier when switching docs versions
9+
document.querySelectorAll('#doc-versions a').forEach(function (el) {
10+
el.addEventListener('click', function () {
11+
this.href = this.href.split('#')[0] + window.location.hash;
12+
});
13+
});

djangoproject/static/js/main.js

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ define(function () {
1919
mods.push('mod/list-collapsing');
2020
}
2121

22-
if (hasClass('version-switcher')) {
23-
mods.push('mod/version-switcher');
24-
}
25-
2622
if (hasClass('doc-floating-warning')) {
2723
mods.push('mod/floating-warning');
2824
}

djangoproject/static/js/mod/version-switcher.js

-25
This file was deleted.

djangoproject/templates/base.html

-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
"mod/list-collapsing": extless("{% static 'js/mod/list-collapsing.js' %}"),
155155
"mod/list-feature": extless("{% static 'js/mod/list-feature.js' %}"),
156156
"mod/mobile-menu": extless("{% static 'js/mod/mobile-menu.js' %}"),
157-
"mod/version-switcher": extless("{% static 'js/mod/version-switcher.js' %}"),
158157
"mod/search-key": extless("{% static 'js/mod/search-key.js' %}"),
159158
"mod/stripe-change-card": extless("{% static 'js/mod/stripe-change-card.js' %}"),
160159
"mod/switch-dark-mode": extless("{% static 'js/mod/switch-dark-mode.js' %}"),

0 commit comments

Comments
 (0)