Skip to content

Commit ffef477

Browse files
committed
Refactored messages.js
- Simplified code using a combination of CSS and JavaScript - Stopped using jQuery - Moved refactored code to `djangoproject.js` This patch should bring no user-facing changes. Refs django#1827
1 parent d068670 commit ffef477

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

djangoproject/scss/_style.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,8 @@ ul.corporate-members li {
34163416
color: $green-dark;
34173417
border: 1px solid $green-dark;
34183418
border-radius: 4px;
3419+
opacity: 1;
3420+
transition: opacity 400ms;
34193421

34203422
&::before {
34213423
@include fa-icon();
@@ -3427,6 +3429,10 @@ ul.corporate-members li {
34273429
margin-right: 10px;
34283430
}
34293431

3432+
&.fade-out {
3433+
opacity: 0;
3434+
}
3435+
34303436
&.info {
34313437
&::before {
34323438
content: $fa-var-info-circle;

djangoproject/static/js/djangoproject.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@ document.querySelectorAll('#doc-versions a').forEach(function (el) {
1111
this.href = this.href.split('#')[0] + window.location.hash;
1212
});
1313
});
14+
15+
// Fade out and remove message elements when close icon is clicked
16+
document.querySelectorAll('.messages li .close').forEach(function (el) {
17+
el.addEventListener('click', function (e) {
18+
this.parentElement.classList.add('fade-out');
19+
20+
setTimeout(function () {
21+
el.parentElement.style.display = 'none';
22+
}, 400);
23+
});
24+
});

djangoproject/static/js/main.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ define(function () {
5757
mods.push('mod/corporate-member-join');
5858
}
5959

60-
if (hasClass('messages')) {
61-
mods.push('mod/messages');
62-
}
63-
6460
if (hasClass('code-block-caption') || hasClass('snippet')) {
6561
mods.push('mod/clippify');
6662
}

djangoproject/static/js/mod/messages.js

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

0 commit comments

Comments
 (0)