Skip to content

Commit 0e00679

Browse files
authored
Refactored doc-switcher.js
- Simplified code - Stopped using jQuery - Moved refactored code to `app.js` This is the first in a series of patches that will move JavaScript code out of `require.js` modules and into a single file while also refactoring. This patch should bring no user-facing changes. Refs #1827
1 parent 6dc8f41 commit 0e00679

File tree

4 files changed

+7
-28
lines changed

4 files changed

+7
-28
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Toggle persistent display of documentation version and language options
2+
document.querySelectorAll('.doc-switcher li.current').forEach(function (el) {
3+
el.addEventListener('click', function () {
4+
this.parentElement.classList.toggle('open');
5+
});
6+
});

djangoproject/static/js/main.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ define(function () {
2323
mods.push('mod/version-switcher');
2424
}
2525

26-
if (hasClass('doc-switcher')) {
27-
mods.push('mod/doc-switcher');
28-
}
29-
3026
if (hasClass('doc-floating-warning')) {
3127
mods.push('mod/floating-warning');
3228
}

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

djangoproject/templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
};
166166
</script>
167167
<script data-main="{% static "js/main.js" %}" src="{% static "js/lib/require.js" %}"></script>
168+
<script src="{% static "js/djangoproject.js" %}"></script>
168169
{% block body_extra %}{% endblock body_extra %}
169170
</body>
170171
</html>

0 commit comments

Comments
 (0)