[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/ -> table-columns-es5.min.js (source)

   1  !function(){"use strict";var t=function(){function t(t,e){var n=this;this.$table=t,this.tableName=e,this.storageKey="joomla-tablecolumns-"+this.tableName,this.$headers=[].slice.call(t.querySelector("thead tr").children),this.$rows=[].slice.call(t.querySelectorAll("tbody tr")),this.listOfHidden=[],this.loadState(),this.protectedCols=[0],this.$rows[0]&&[].slice.call(this.$rows[0].children).forEach((function(t,e){if("TH"===t.nodeName){n.protectedCols.push(e);var i=n.listOfHidden.indexOf(e);-1!==i&&n.listOfHidden.splice(i,1)}})),this.createControls(),this.listOfHidden.forEach((function(t){n.toggleColumn(t,!0)}))}var e=t.prototype;return e.createControls=function(){var t=this,e=document.createElement("div");e.setAttribute("class","dropdown float-end pb-2");var n=document.createElement("div");n.setAttribute("class","dropdown-menu dropdown-menu-end"),n.setAttribute("data-bs-popper","static");var i=document.createElement("button");i.type="button",i.textContent=Joomla.Text._("JGLOBAL_COLUMNS"),i.classList.add("btn","btn-primary","btn-sm","dropdown-toggle"),i.setAttribute("data-bs-toggle","dropdown"),i.setAttribute("data-bs-auto-close","false"),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded","false");var a=document.createElement("ul");a.setAttribute("class","list-unstyled p-2"),a.setAttribute("id","columnList"),this.$headers.forEach((function(e,n){if(0!==n||"TH"===e.nodeName){var i=document.createElement("li"),s=document.createElement("label"),l=document.createElement("input");l.classList.add("form-check-input","me-1"),l.type="checkbox",l.name="table[column][]",l.checked=-1===t.listOfHidden.indexOf(n),l.disabled=-1!==t.protectedCols.indexOf(n),l.value=n;var o=e.querySelector("span"),d=o?o.textContent.trim():"";d||(d=(o=e.querySelector("span.visually-hidden")||e).textContent.trim()),d.includes(":")&&(d=d.split(":",2)[1].trim()),s.textContent=d,s.insertAdjacentElement("afterbegin",l),i.appendChild(s),a.appendChild(i)}})),this.$table.insertAdjacentElement("beforebegin",e),e.appendChild(i),e.appendChild(n),n.appendChild(a),a.addEventListener("change",(function(e){t.toggleColumn(parseInt(e.target.value,10)),t.saveState()})),this.$headers.forEach((function(t){t.classList.remove("d-none","d-md-table-cell","d-lg-table-cell","d-xl-table-cell")})),this.$rows.forEach((function(t){[].slice.call(t.children).forEach((function(t){t.classList.remove("d-none","d-md-table-cell","d-lg-table-cell","d-xl-table-cell")}))})),this.$button=i,this.$menu=a,this.updateCounter()},e.updateCounter=function(){var t=this.$headers.length-1,e=t-this.listOfHidden.length;this.$button.textContent=e+"/"+t+" "+Joomla.Text._("JGLOBAL_COLUMNS")},e.toggleColumn=function(t,e){if(this.$headers[t]&&-1===this.protectedCols.indexOf(t)){var n=this.listOfHidden.indexOf(t);-1===n?this.listOfHidden.push(t):!0!==e&&this.listOfHidden.splice(n,1),this.$headers[t].classList.toggle("d-none",e),this.$rows.forEach((function(n){n.children[t].classList.toggle("d-none",e)})),this.updateCounter()}},e.saveState=function(){window.localStorage.setItem(this.storageKey,this.listOfHidden.join(","))},e.loadState=function(){var t=window.localStorage.getItem(this.storageKey);t&&(this.listOfHidden=t.split(",").map((function(t){return parseInt(t,10)})))},t}();window.innerWidth>992&&[].concat(document.querySelectorAll("table")).forEach((function(e){var n=e.dataset.name?e.dataset.name:document.querySelector(".page-title").textContent.trim().replace(/[^a-z0-9]/gi,"-").toLowerCase();n&&new t(e,n)}))}();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer