- md5
- 867e0b7626dae9061b52d16a07364018
- sha1
- c83758f00813bde507ebd22e4d1a5498b6155bcb
- sha256
- 32ea2b93e22088150d194887b1523bcdf4996b16cfb969d63dee7983c4ffd5f0
function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}(function(){"use strict";var a=function(){function a(b,c){var d=this;_classCallCheck(this,a);this.element=b,this.options=Joomla.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("".concat(this.options.formSelector," ").concat(this.options.filterBtnSelector)),this.filterContainer=document.querySelector("".concat(this.options.formSelector," ").concat(this.options.filterContainerSelector))?document.querySelector("".concat(this.options.formSelector," ").concat(this.options.filterContainerSelector)):"",this.filtersHidden=this.options.filtersHidden,this.listButton=document.querySelector(this.options.listBtnSelector),this.listContainer=document.querySelector("".concat(this.options.formSelector," ").concat(this.options.listContainerSelector)),this.listHidden=this.options.listHidden,this.mainContainer=document.querySelector(this.options.mainContainerSelector),this.searchButton=document.querySelector("".concat(this.options.formSelector," ").concat(this.options.searchBtnSelector)),this.searchField=document.querySelector("".concat(this.options.formSelector," ").concat(this.options.searchFieldSelector)),this.searchString=null,this.clearButton=document.querySelector(this.options.clearBtnSelector),this.orderCols=Array.prototype.slice.call(document.querySelectorAll("".concat(this.options.formSelector," ").concat(this.options.orderColumnSelector))),this.orderField=document.querySelector("".concat(this.options.formSelector," ").concat(this.options.orderFieldSelector)),this.limitField=document.querySelector("".concat(this.options.formSelector," ").concat(this.options.limitFieldSelector)),this.activeColumn=null,this.activeDirection=this.options.activeDirection,this.activeOrder=this.options.activeOrder,this.activeLimit=null,this.clearListOptions=this.options.clearListOptions;var f=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",function(a){f.toggleFilters(),a.stopPropagation(),a.preventDefault()}),this.listButton&&this.listButton.addEventListener("click",function(a){f.toggleList(),a.stopPropagation(),a.preventDefault()}),this.getFilterFields()&&this.getFilterFields().forEach(function(a){f.checkFilter(a),a.addEventListener("change",function(){f.checkFilter(a)})}),this.clearButton&&this.clearButton.addEventListener("click",f.clear),this.createOrderField(),this.orderCols.forEach(function(a){a.addEventListener("click",function(a){var b="span"===a.target.tagName.toLowerCase()?a.target.parentNode:a.target,c=b.getAttribute("data-order"),d=b.getAttribute("data-direction"),e="".concat(c," ").concat(d);c.length&&(f.activeColumn=c,e===f.activeOrder?f.toggleDirection():(f.activeDirection=d,f.activeOrder=e,f.updateFieldValue(f.orderField,e)),f.theForm.submit())})}),this.checkActiveStatus(this),document.body.addEventListener("click",function(a){if(document.body.classList.contains("filters-shown")){if(!(a.composedPath&&"function"==typeof a.composedPath))for(var b=a.target;b!==document.body;){if(b===d.filterContainer)return;b=b.parentNode}else if(-1!==a.composedPath().indexOf(d.filterContainer))return;d.hideFilters()}})}return _createClass(a,[{key:"checkFilter",value:function c(a){var b=a.querySelector("option:checked");b&&(""===b.value?this.deactiveFilter(a,this):this.activeFilter(a,this))}},{key:"clear",value:function b(){var a=this;a.searchField&&(a.searchField.value=""),a.getFilterFields()&&a.getFilterFields().forEach(function(b){b.value="",a.checkFilter(b),window.jQuery&&window.jQuery.chosen&&window.jQuery(b).trigger("chosen:updated")}),a.clearListOptions&&(a.getListFields().forEach(function(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()}},{key:"checkActiveStatus",value:function d(a){var b=a.mainContainer,c=[].slice.call(b.querySelectorAll(".js-stools-field-filter select"));c.forEach(function(b){b.classList.contains("active")&&(a.filterButton.classList.remove("btn-secondary"),a.filterButton.classList.add("btn-primary"))})}},{key:"activeFilter",value:function d(a){a.classList.add("active");var b="#".concat(a.getAttribute("id")),c=a.querySelector(b);c&&c.classList.add("active")}},{key:"deactiveFilter",value:function d(a){a.classList.remove("active");var b="#".concat(a.getAttribute("id")),c=a.querySelector(b);c&&c.classList.remove("active")}},{key:"getFilterFields",value:function a(){if(this.filterContainer)return Array.prototype.slice.call(this.filterContainer.querySelectorAll("select,input"))}},{key:"getListFields",value:function a(){return Array.prototype.slice.call(this.listContainer.querySelectorAll("select"))}},{key:"hideContainer",value:function b(a){a&&(a.classList.remove("js-filters-show"),document.body.classList.remove("filters-shown"))}},{key:"showContainer",value:function b(a){a.classList.add("js-filters-show"),document.body.classList.add("filters-shown")}},{key:"toggleContainer",value:function b(a){a.classList.contains("js-filters-show")?this.hideContainer(a):this.showContainer(a)}},{key:"hideList",value:function a(){this.hideContainer(this.filterContainer)}},{key:"showList",value:function a(){this.showContainer(this.filterContainer)}},{key:"toggleList",value:function a(){this.toggleContainer(this.filterContainer)}},{key:"hideFilters",value:function a(){this.hideContainer(this.filterContainer)}},{key:"showFilters",value:function a(){this.showContainer(this.filterContainer)}},{key:"toggleFilters",value:function a(){this.toggleContainer(this.filterContainer)}},{key:"toggleDirection",value:function c(){var a=this,b="ASC";"ASC"===a.activeDirection.toUpperCase()&&(b="DESC"),a.activeDirection=b,a.activeOrder="".concat(a.activeColumn," ").concat(b),a.updateFieldValue(a.orderField,a.activeOrder)}},{key:"createOrderField",value:function c(){var a=this,b=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",b.options.orderFieldName),this.orderField.setAttribute("value","".concat(b.activeOrder," ").concat(this.activeDirection)),this.theForm.innerHTML+=this.orderField.outerHTML),"select"===this.orderField.tagName.toLowerCase()){var d=[].slice.call(this.orderField.options);d.forEach(function(c){var d=c.getAttribute("data-order"),e=c.getAttribute("data-name"),f=c.getAttribute("data-direction");if(d&&d.length){d="".concat(d," ").concat(f);var g=b.findOption(b.orderField,d);g.length||(g=document.createElement("option"),g.text=e,g.value=d,c.classList.contains("active")&&g.setAttribute("selected","selected"),a.orderFieldName.innerHTML+=g)}}),window.jQuery&&window.jQuery.chosen&&window.jQuery(this.orderField).trigger("chosen:updated")}this.activeOrder=this.orderField.value}},{key:"updateFieldValue",value:function f(a,b){var c=a.getAttribute("type");if("hidden"===c||"text"===c)a.setAttribute("value",b);else if("select"===a.tagName.toLowerCase()){var d,e=[].slice.call(a.options);if(e.forEach(function(a){a.value===b&&(d=a)}),d&&d.length)d.setAttribute("selected","selected");else{var g=document.createElement("option");g.text=b,g.value=b,g.setAttribute("selected","selected"),a.appendChild(g)}a.value=b,window.jQuery&&window.jQuery.chosen&&a.trigger("chosen:updated")}}},{key:"findOption",value:function c(a,b){for(var d=0,e=a.length;e>d;d++)if(a[d].value===b)return a[d]}}]),a}(),b=function(){if(Joomla.getOptions("searchtools")){var c=Joomla.getOptions("searchtools"),d=document.querySelector(c.selector);new a(d,c)}var e=document.getElementById("sorted");if(e&&e.hasAttribute("data-caption")){var f=e.getAttribute("data-caption");document.getElementById("captionTable").textContent+=f}if(e&&e.hasAttribute("data-sort")){var g=e.getAttribute("data-sort");e.parentNode.setAttribute("aria-sorted",g)}document.removeEventListener("DOMContentLoaded",b)};document.addEventListener("DOMContentLoaded",b)})();
No other release has this exact content. See every version of this file.