SinkDark/myblog/static/admin/js/collapse.min.js
2024-09-17 17:30:58 +08:00

3 lines
1004 B
JavaScript

(function(){var e=function(a,b){return a.nodeName===b.toUpperCase()?a:"BODY"===a.parentNode.nodeName?null:a.parentNode&&e(a.parentNode,b)};window.addEventListener("load",function(){for(var a=document.querySelectorAll("fieldset.collapse"),b=0;b<a.length;b++){var c=a[b];if(0===c.querySelectorAll("div.errors").length){c.classList.add("collapsed");c=c.querySelector("h2");var d=document.createElement("a");d.setAttribute("id","fieldsetcollapser"+b);d.setAttribute("class","collapse-toggle");d.setAttribute("href",
"#");d.textContent=gettext("Show");c.appendChild(document.createTextNode(" ("));c.appendChild(d);c.appendChild(document.createTextNode(")"))}}a=document.querySelectorAll("fieldset.collapse a.collapse-toggle");c=function(a){a.preventDefault();a=e(this,"fieldset");a.classList.contains("collapsed")?(this.textContent=gettext("Hide"),a.classList.remove("collapsed")):(this.textContent=gettext("Show"),a.classList.add("collapsed"))};for(b=0;b<a.length;b++)a[b].addEventListener("click",c)})})();