CoreFiles by mySites.guru
searchtools.es6.min.js1 lines, 9,802 bytes, from Joomla_4.0.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta
md5
7cdd03109df039f02e93d51773c811d5
sha1
b787eec66c66903beab8589c014dde6bf624baa3
sha256
3393ea20ccacdaabfc8903fee1c6d74398def88b3ca97c54145e08fd6a4b9f77
Joomla=window.Joomla||{},(a=>{'use strict';a.resetFilters=a=>{const{form:b}=a;if(!b)throw new Error("Element must be inside a form!");const c=[].slice.call(b.elements);if(c.length){const d=[];c.forEach(b=>{"task"===b.getAttribute("name")||"boxchecked"===b.getAttribute("name")||"1"===b.value&&/^[0-9A-F]{32}$/i.test(b.name)||b===a||d.push(b)}),d.forEach(a=>{a.value=""}),b.submit()}};class b{constructor(b,c){this.element=b,this.options=a.extend({formSelector:".js-stools-form",searchFieldSelector:".js-stools-field-search",clearBtnSelector:".js-stools-btn-clear",mainContainerSelector:".js-stools",searchBtnSelector:".js-stools-btn-search",filterBtnSelector:".js-stools-btn-filter",filterContainerSelector:".js-stools-container-filters",filtersHidden:!0,listBtnSelector:".js-stools-btn-list",listContainerSelector:".js-stools-container-list",listHidden:!0,orderColumnSelector:".js-stools-column-order",orderBtnSelector:".js-stools-btn-order",orderFieldSelector:".js-stools-field-order",orderFieldName:"list[fullordering]",limitFieldSelector:".js-stools-field-limit",defaultLimit:20,activeOrder:null,activeDirection:"ASC",clearListOptions:!1},c),this.theForm=document.querySelector(this.options.formSelector),this.filterButton=document.querySelector(`${this.options.formSelector} ${this.options.filterBtnSelector}`),this.filterContainer=document.querySelector(`${this.options.formSelector} ${this.options.filterContainerSelector}`)?document.querySelector(`${this.options.formSelector} ${this.options.filterContainerSelector}`):"",this.filtersHidden=this.options.filtersHidden,this.listButton=document.querySelector(this.options.listBtnSelector),this.listContainer=document.querySelector(`${this.options.formSelector} ${this.options.listContainerSelector}`),this.listHidden=this.options.listHidden,this.mainContainer=document.querySelector(this.options.mainContainerSelector),this.searchButton=document.querySelector(`${this.options.formSelector} ${this.options.searchBtnSelector}`),this.searchField=document.querySelector(`${this.options.formSelector} ${this.options.searchFieldSelector}`),this.searchString=null,this.clearButton=document.querySelector(this.options.clearBtnSelector),this.orderCols=Array.prototype.slice.call(document.querySelectorAll(`${this.options.formSelector} ${this.options.orderColumnSelector}`)),this.orderField=document.querySelector(`${this.options.formSelector} ${this.options.orderFieldSelector}`),this.limitField=document.querySelector(`${this.options.formSelector} ${this.options.limitFieldSelector}`),this.activeColumn=null,this.activeDirection=this.options.activeDirection,this.activeOrder=this.options.activeOrder,this.activeLimit=null,this.clearListOptions=this.options.clearListOptions;const d=this;this.searchString=this.searchField.value,this.showFilters=this.showFilters.bind(this),this.hideFilters=this.hideFilters.bind(this),this.showList=this.showList.bind(this),this.hideList=this.hideList.bind(this),this.toggleFilters=this.toggleFilters.bind(this),this.toggleList=this.toggleList.bind(this),this.checkFilter=this.checkFilter.bind(this),this.clear=this.clear.bind(this),this.createOrderField=this.createOrderField.bind(this),this.checkActiveStatus=this.checkActiveStatus.bind(this),this.activeFilter=this.activeFilter.bind(this),this.deactiveFilter=this.deactiveFilter.bind(this),this.getFilterFields=this.getFilterFields.bind(this),this.getListFields=this.getListFields.bind(this),this.hideContainer=this.hideContainer.bind(this),this.showContainer=this.showContainer.bind(this),this.toggleContainer=this.toggleContainer.bind(this),this.toggleDirection=this.toggleDirection.bind(this),this.updateFieldValue=this.updateFieldValue.bind(this),this.findOption=this.findOption.bind(this),this.filterContainer&&this.filterContainer.classList.contains("js-stools-container-filters-visible")?(this.showFilters(),this.showList()):(this.hideFilters(),this.hideList()),this.filterButton&&this.filterButton.addEventListener("click",a=>{d.toggleFilters(),a.stopPropagation(),a.preventDefault()}),this.listButton&&this.listButton.addEventListener("click",a=>{d.toggleList(),a.stopPropagation(),a.preventDefault()}),this.getFilterFields()&&this.getFilterFields().forEach(a=>{d.checkFilter(a),a.addEventListener("change",()=>{d.checkFilter(a)})}),this.clearButton&&this.clearButton.addEventListener("click",d.clear),this.createOrderField(),this.orderCols.forEach(a=>{a.addEventListener("click",({target:a})=>{const b="span"===a.tagName.toLowerCase()?a.parentNode:a,c=b.getAttribute("data-order"),e=b.getAttribute("data-direction"),f=`${c} ${e}`;c.length&&(d.activeColumn=c,f===d.activeOrder?d.toggleDirection():(d.activeDirection=e,d.activeOrder=f,d.updateFieldValue(d.orderField,f)),d.theForm.submit())})}),this.checkActiveStatus(this)}checkFilter(a){const b=a.querySelector("option:checked");b&&(""===b.value?this.deactiveFilter(a,this):this.activeFilter(a,this))}clear(){const a=this;a.searchField&&(a.searchField.value=""),a.getFilterFields()&&a.getFilterFields().forEach(b=>{b.value="",a.checkFilter(b),window.jQuery&&window.jQuery.chosen&&window.jQuery(b).trigger("chosen:updated")}),a.clearListOptions&&(a.getListFields().forEach(b=>{b.value="",a.checkFilter(b),window.jQuery&&window.jQuery.chosen&&window.jQuery(b).trigger("chosen:updated")}),document.querySelector("#list_limit").value=a.options.defaultLimit,window.jQuery&&window.jQuery.chosen&&window.jQuery("#list_limit").trigger("chosen:updated")),a.theForm.submit()}updateFilterCount(a){this.clearButton&&(this.clearButton.disabled=0===a&&!this.searchString.length)}checkActiveStatus(a){const b=a.mainContainer,c=[].slice.call(b.querySelectorAll(".js-stools-field-filter select"));let d=0;if(c.forEach(b=>{b.classList.contains("active")&&(d+=1,a.filterButton.classList.remove("btn-secondary"),a.filterButton.classList.add("btn-primary"))}),0==d){const a=document.getElementById("filteredBy");a&&a.parentNode.removeChild(a)}this.clearButton&&(this.clearButton.disabled=0===d&&!this.searchString.length)}activeFilter(a){a.classList.add("active");const b=`#${a.getAttribute("id")}`,c=a.querySelector(b);c&&c.classList.add("active");const d=document.getElementById("filteredBy");if(d){let b="";if(!0===a.multiple){const c=a.querySelectorAll("option:checked"),d=[].slice.call(c).map(a=>a.text);b=`${a.labels[0].textContent} - ${d.join()}`}else b=`${a.labels[0].textContent} - ${a.options[a.selectedIndex].text}`;d.textContent+=b}}deactiveFilter(a){a.classList.remove("active");const b=`#${a.getAttribute("id")}`,c=a.querySelector(b);c&&c.classList.remove("active")}getFilterFields(){if(this.filterContainer)return Array.prototype.slice.call(this.filterContainer.querySelectorAll("select,input"))}getListFields(){return Array.prototype.slice.call(this.listContainer.querySelectorAll("select"))}hideContainer(a){a&&(a.classList.remove("js-stools-container-filters-visible"),document.body.classList.remove("filters-shown"))}showContainer(a){a.classList.add("js-stools-container-filters-visible"),document.body.classList.add("filters-shown")}toggleContainer(a){a.classList.contains("js-stools-container-filters-visible")?this.hideContainer(a):this.showContainer(a)}hideList(){this.hideContainer(this.filterContainer)}showList(){this.showContainer(this.filterContainer)}toggleList(){this.toggleContainer(this.filterContainer)}hideFilters(){this.hideContainer(this.filterContainer)}showFilters(){this.showContainer(this.filterContainer)}toggleFilters(){this.toggleContainer(this.filterContainer)}toggleDirection(){const a=this;let b="ASC";"ASC"===a.activeDirection.toUpperCase()&&(b="DESC"),a.activeDirection=b,a.activeOrder=`${a.activeColumn} ${b}`,a.updateFieldValue(a.orderField,a.activeOrder)}createOrderField(){const a=this;if(this.orderField||(this.orderField=document.createElement("input"),this.orderField.setAttribute("type","hidden"),this.orderField.setAttribute("id","js-stools-field-order"),this.orderField.setAttribute("class","js-stools-field-order"),this.orderField.setAttribute("name",a.options.orderFieldName),this.orderField.setAttribute("value",`${a.activeOrder} ${this.activeDirection}`),this.theForm.innerHTML+=this.orderField.outerHTML),"select"===this.orderField.tagName.toLowerCase()){const b=[].slice.call(this.orderField.options);b.forEach(b=>{let c=b.getAttribute("data-order");const d=b.getAttribute("data-name"),e=b.getAttribute("data-direction");if(c&&c.length){c=`${c} ${e}`;let f=a.findOption(a.orderField,c);f.length||(f=document.createElement("option"),f.text=d,f.value=c,b.classList.contains("active")&&f.setAttribute("selected","selected"),this.orderFieldName.innerHTML+=f)}}),window.jQuery&&window.jQuery.chosen&&window.jQuery(this.orderField).trigger("chosen:updated")}this.activeOrder=this.orderField.value}updateFieldValue(a,b){const c=a.getAttribute("type");if("hidden"===c||"text"===c)a.setAttribute("value",b);else if("select"===a.tagName.toLowerCase()){const c=[].slice.call(a.options);let d;if(c.forEach(a=>{a.value===b&&(d=a)}),d&&d.length)d.setAttribute("selected","selected");else{const c=document.createElement("option");c.text=b,c.value=b,c.setAttribute("selected","selected"),a.appendChild(c)}a.value=b,window.jQuery&&window.jQuery.chosen&&a.trigger("chosen:updated")}}findOption(a,b){for(let c=0,d=a.length;d>c;c++)if(a[c].value===b)return a[c]}}const c=()=>{if(a.getOptions("searchtools")){const c=a.getOptions("searchtools"),d=document.querySelector(c.selector);new b(d,c)}const d=document.getElementById("sorted");if(d&&d.hasAttribute("data-caption")){const a=d.getAttribute("data-caption");document.getElementById("orderedBy").textContent+=a}if(d&&d.hasAttribute("data-sort")){const a=d.getAttribute("data-sort");d.parentNode.setAttribute("aria-sort",a)}document.removeEventListener("DOMContentLoaded",c)};document.addEventListener("DOMContentLoaded",c)})(Joomla);

The same content is in 3 releases, Joomla 4.0.0-beta to 4.0.0-beta3. See them all, or every version of this file.