Skip to content

Commit 1ad8339

Browse files
adamzapbmispelon
authored andcommitted
Refactored console-tabs.js
- Stopped using jQuery - Moved refactored code to `djangoproject.js` I was also to remove the content show/hide functionality that was in the original file because it's handled in CSS.
1 parent a092b11 commit 1ad8339

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

djangoproject/static/js/djangoproject.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ document.querySelectorAll('.messages li .close').forEach(function (el) {
2222
this.parentElement.classList.add('fade-out');
2323
});
2424
});
25+
26+
// Check all console tab inputs of the same type when one's label is clicked
27+
document.querySelectorAll('.console-block label').forEach(function (el) {
28+
el.addEventListener('click', function (e) {
29+
const input_id = e.currentTarget.getAttribute('for');
30+
const selector = input_id.endsWith('unix') ? '.c-tab-unix' : '.c-tab-win';
31+
32+
document.querySelectorAll(selector).forEach(function (input_el) {
33+
input_el.checked = true;
34+
});
35+
});
36+
});

djangoproject/static/js/main.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,5 @@ define(function () {
6161
mods.push('mod/clippify');
6262
}
6363

64-
if (hasClass('console-block')) {
65-
mods.push('mod/console-tabs');
66-
}
67-
6864
require(mods);
6965
});

djangoproject/static/js/mod/console-tabs.js

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

djangoproject/templates/base.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
"mod/search-key": extless("{% static 'js/mod/search-key.js' %}"),
143143
"mod/stripe-change-card": extless("{% static 'js/mod/stripe-change-card.js' %}"),
144144
"mod/switch-dark-mode": extless("{% static 'js/mod/switch-dark-mode.js' %}"),
145-
"mod/console-tabs": extless("{% static 'js/mod/console-tabs.js' %}"),
146145
"stripe-checkout": "https://checkout.stripe.com/checkout",
147146
"stripe": "https://js.stripe.com/v3/?" // ? needed due to require.js
148147
}

0 commit comments

Comments
 (0)