From 7857507c7fc43350701700d4215a37baea7655f0 Mon Sep 17 00:00:00 2001 From: Marijke Luttekes Date: Mon, 20 May 2024 15:32:41 -0300 Subject: [PATCH] Refs #35189 -- Removed no longer necessary JavaScript file collapse.js. --- .../contrib/admin/static/admin/js/collapse.js | 43 ------------------- docs/releases/5.1.txt | 3 ++ js_tests/tests.html | 1 - 3 files changed, 3 insertions(+), 44 deletions(-) delete mode 100644 django/contrib/admin/static/admin/js/collapse.js diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js deleted file mode 100644 index c6c7b0f68a2..00000000000 --- a/django/contrib/admin/static/admin/js/collapse.js +++ /dev/null @@ -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); - }); - }); -} diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index e4f0b374025..faaa5c98338 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -425,6 +425,9 @@ Miscellaneous when the fieldset has a name and use the ``collapse`` class, now includes ``
`` and ```` 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. diff --git a/js_tests/tests.html b/js_tests/tests.html index adeac661253..011998e5a75 100644 --- a/js_tests/tests.html +++ b/js_tests/tests.html @@ -143,7 +143,6 @@ -