0
0
mirror of https://github.com/django/django.git synced 2024-11-21 19:09:18 +01:00

Refs #35189 -- Removed no longer necessary JavaScript file collapse.js.

This commit is contained in:
Marijke Luttekes 2024-05-20 15:32:41 -03:00 committed by nessita
parent 676060d683
commit 7857507c7f
3 changed files with 3 additions and 44 deletions

View File

@ -1,43 +0,0 @@
/*global gettext*/
'use strict';
{
window.addEventListener('load', function() {
// Add anchor tag for Show/Hide link
const fieldsets = document.querySelectorAll('fieldset.collapse');
for (const [i, elem] of fieldsets.entries()) {
// Don't hide if fields in this fieldset have errors
if (elem.querySelectorAll('div.errors, ul.errorlist').length === 0) {
elem.classList.add('collapsed');
const h2 = elem.querySelector('h2');
const link = document.createElement('a');
link.id = 'fieldsetcollapser' + i;
link.className = 'collapse-toggle';
link.href = '#';
link.textContent = gettext('Show');
h2.appendChild(document.createTextNode(' ('));
h2.appendChild(link);
h2.appendChild(document.createTextNode(')'));
}
}
// Add toggle to hide/show anchor tag
const toggleFunc = function(ev) {
if (ev.target.matches('.collapse-toggle')) {
ev.preventDefault();
ev.stopPropagation();
const fieldset = ev.target.closest('fieldset');
if (fieldset.classList.contains('collapsed')) {
// Show
ev.target.textContent = gettext('Hide');
fieldset.classList.remove('collapsed');
} else {
// Hide
ev.target.textContent = gettext('Show');
fieldset.classList.add('collapsed');
}
}
};
document.querySelectorAll('fieldset.module').forEach(function(el) {
el.addEventListener('click', toggleFunc);
});
});
}

View File

@ -425,6 +425,9 @@ Miscellaneous
when the fieldset has a name and use the ``collapse`` class, now includes
``<details>`` and ``<summary>`` elements.
* The JavaScript file ``collapse.js`` is removed since it is no longer needed
in the Django admin site.
* :meth:`.SimpleTestCase.assertURLEqual` and
:meth:`~django.test.SimpleTestCase.assertInHTML` now add ``": "`` to the
``msg_prefix``. This is consistent with the behavior of other assertions.

View File

@ -143,7 +143,6 @@
<script src='./admin/inlines.test.js'></script>
<script src='../django/contrib/admin/static/admin/js/actions.js' data-cover></script>
<script src='../django/contrib/admin/static/admin/js/collapse.js' data-cover></script>
<script src='../django/contrib/admin/static/admin/js/prepopulate.js' data-cover></script>
<script src='../django/contrib/admin/static/admin/js/urlify.js' data-cover></script>
<script src='./admin/URLify.test.js'></script>