Skip to content

Commit

Permalink
Refactored doc-switcher.js
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
adamzap committed Dec 18, 2024
1 parent 86dbff9 commit 3942cc9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
5 changes: 5 additions & 0 deletions djangoproject/static/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
document.querySelectorAll('.doc-switcher li.current').forEach(function (el) {
el.addEventListener('click', function () {
this.parentElement.classList.toggle('open');
});
});
4 changes: 0 additions & 4 deletions djangoproject/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ define(function() {
mods.push('mod/version-switcher');
}

if (hasClass('doc-switcher')) {
mods.push('mod/doc-switcher');
}

if (hasClass('doc-floating-warning')) {
mods.push('mod/floating-warning');
}
Expand Down
25 changes: 0 additions & 25 deletions djangoproject/static/js/mod/doc-switcher.js

This file was deleted.

1 change: 1 addition & 0 deletions djangoproject/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
};
</script>
<script data-main="{% static "js/main.js" %}" src="{% static "js/lib/require.js" %}"></script>
<script src="{% static "js/app.js" %}"></script>
{% block body_extra %}{% endblock body_extra %}
</body>
</html>

0 comments on commit 3942cc9

Please sign in to comment.