1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35137 -- Simplified JS toggle function

This commit is contained in:
denisiko 2024-12-01 15:12:24 +01:00
parent 6a0006ac0f
commit 1830a420c0

View File

@ -101,14 +101,9 @@
}, false); }, false);
}); });
} }
function toggle() { function toggleDisplay(elementId) {
for (var i = 0; i < arguments.length; i++) { var e = document.getElementById(elementId);
var e = document.getElementById(arguments[i]); e.style.display = e.style.display == 'none' ? 'block': 'none';
if (e) {
e.style.display = e.style.display == 'none' ? 'block': 'none';
}
}
return false;
} }
function collapseDetails(summaryId) { function collapseDetails(summaryId) {
var summary = document.getElementById(summaryId); var summary = document.getElementById(summaryId);
@ -125,7 +120,8 @@
s1 = "Switch to copy-and-paste view"; s1 = "Switch to copy-and-paste view";
s2 = "Switch back to interactive view"; s2 = "Switch back to interactive view";
link.textContent = link.textContent.trim() == s1 ? s2: s1; link.textContent = link.textContent.trim() == s1 ? s2: s1;
toggle('browserTraceback', 'pastebinTraceback'); toggleDisplay('browserTraceback');
toggleDisplay('pastebinTraceback');
return false; return false;
} }
</script> </script>