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.

Refs #1827
  • Loading branch information
adamzap authored Dec 20, 2024
1 parent 6dc8f41 commit 0e00679
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
6 changes: 6 additions & 0 deletions djangoproject/static/js/djangoproject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Toggle persistent display of documentation version and language options
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
24 changes: 0 additions & 24 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/djangoproject.js" %}"></script>
{% block body_extra %}{% endblock body_extra %}
</body>
</html>

0 comments on commit 0e00679

Please sign in to comment.