Skip to content

Commit 903b36c

Browse files
adamzapbmispelon
authored andcommitted
Refactored mobile-menu.js
- Stopped using jQuery - Moved refactored code to `djangoproject.js`
1 parent 5632574 commit 903b36c

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

djangoproject/static/js/djangoproject.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ document.querySelectorAll('.console-block label').forEach(function (el) {
5656
observer.observe(el);
5757
});
5858
})();
59+
60+
// Toggle mobile menu on button click
61+
document.querySelector('.menu-button').addEventListener('click', function () {
62+
const menu_el = document.querySelector('#top [role="navigation"]');
63+
64+
this.classList.toggle('active');
65+
menu_el.classList.toggle('active');
66+
});

djangoproject/static/js/main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Require.js Module Loader - http://requirejs.org
22
define(function () {
3-
var mods = [
4-
'mod/mobile-menu', // require mobile menu automatically
5-
];
3+
var mods = [];
64

75
//detect Class function
86
function hasClass(className) {

djangoproject/static/js/mod/mobile-menu.js

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

djangoproject/templates/base.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
"jquery.flot": extless("{% static 'js/lib/jquery.flot.min.js' %}"),
138138
"mod/floating-warning": extless("{% static 'js/mod/floating-warning.js' %}"),
139139
"mod/list-collapsing": extless("{% static 'js/mod/list-collapsing.js' %}"),
140-
"mod/mobile-menu": extless("{% static 'js/mod/mobile-menu.js' %}"),
141140
"mod/search-key": extless("{% static 'js/mod/search-key.js' %}"),
142141
"mod/stripe-change-card": extless("{% static 'js/mod/stripe-change-card.js' %}"),
143142
"mod/switch-dark-mode": extless("{% static 'js/mod/switch-dark-mode.js' %}"),

0 commit comments

Comments
 (0)