1"use strict"; 2 3if (!Element.prototype.matches) { 4 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 5} 6if (!Element.prototype.closest) { 7 Element.prototype.closest = function (s) { 8 var el = this; 9 do { 10 if (el.matches(s)) return el; 11 el = el.parentElement || el.parentNode; 12 } while (el !== null && el.nodeType === 1); 13 return null; 14 }; 15} 16function ub_getSiblings(element, criteria) { 17 var children = Array.prototype.slice.call(element.parentNode.children).filter(function (child) { 18 return child !== element; 19 }); 20 return criteria ? children.filter(criteria) : children; 21} 22Array.prototype.slice.call(document.getElementsByClassName("ub-content-filter-tag")).forEach(function (instance) { 23 var blockProper = instance.closest(".wp-block-ub-content-filter-block"); 24 var initialSelection = blockProper.getAttribute("data-currentselection"); 25 instance.addEventListener("click", function () { 26 var _this = this; 27 var isOldVersion = this.getAttribute("data-activecolor"); 28 this.setAttribute("data-tagisselected", JSON.stringify(!JSON.parse(this.getAttribute("data-tagisselected")))); 29 if (isOldVersion) { 30 this.style.backgroundColor = this.getAttribute("data-activecolor"); 31 this.style.color = this.getAttribute("data-activetextcolor"); 32 } else { 33 this.classList.toggle("ub-selected"); 34 } 35 var categoryIndex = JSON.parse(this.getAttribute("data-categorynumber")); 36 var filterIndex = JSON.parse(this.getAttribute("data-filternumber")); 37 if (JSON.parse(this.getAttribute("data-tagisselected"))) { 38 if (!JSON.parse(this.parentElement.getAttribute("data-canusemultiple"))) { 39 ub_getSiblings(this, function (elem) { 40 return elem.classList.contains("ub-content-filter-tag"); 41 }
41).forEach(function (sibling) { 42 sibling.setAttribute("data-tagisselected", "false"); 43 if (isOldVersion) { 44 sibling.style.backgroundColor = _this.getAttribute("data-normalcolor"); 45 sibling.style.color = _this.getAttribute("data-normaltextcolor"); 46 } else { 47 sibling.classList.remove("ub-selected"); 48 } 49 }); 50 } 51 } else { 52 if (isOldVersion) { 53 this.style.backgroundColor = this.getAttribute("data-normalcolor"); 54 this.style.color = this.getAttribute("data-normaltextcolor"); 55 } else { 56 this.classList.remove("ub-selected"); 57 } 58 } 59 var newSelection = JSON.parse(blockProper.getAttribute("data-currentselection")); 60 if (Array.isArray(newSelection[categoryIndex])) { 61 newSelection[categoryIndex][filterIndex] = JSON.parse(this.getAttribute("data-tagisselected")); 62 } else { 63 newSelection[categoryIndex] = JSON.parse(this.getAttribute("data-tagisselected")) ? filterIndex : -1; 64 } 65 blockProper.setAttribute("data-currentselection", JSON.stringify(newSelection)); 66 var matchingOption = blockProper.getAttribute("data-matchingoption"); 67 Array.prototype.slice.call(blockProper.querySelectorAll(":scope >
67 .ub-content-filter-panel")).forEach(function (instance) { 68 var panelData = JSON.parse(instance.getAttribute("data-selectedfilters")); 69 var mainData = JSON.parse(blockProper.getAttribute("data-currentselection")); 70 var hasMatchedAll = true; 71 if (initialSelection == blockProper.getAttribute("data-currentselection") && JSON.parse(blockProper.getAttribute("data-initiallyshowall")) === false) { 72 hasMatchedAll = false; 73 } else { 74 panelData.forEach(function (category, i) { 75 if (Array.isArray(category)) { 76 if (category.every(function (f) { 77 return !f; 78 }) && mainData[i].some(function (f) { 79 return f; 80 }) || 81 //panel has no tag from category and maindata has at least one tag selected -> consider as mismatch 82 mainData[i].filter(function (f) { 83 return f; 84 }).length > 0 && !category.some(function (f, j) { 85 return f && f === mainData[i][j]; 86 })) { 87 hasMatchedAll = false; 88 } 89 } else if (mainData[i] !== category && mainData[i] !== -1) { 90 hasMatchedAll = false; 91 } 92 }); 93 } 94 95 //alternate setting 96 var hasMatchedOne = false;
97 if (initialSelection === blockProper.getAttribute("data-currentselection") && JSON.parse(blockProper.getAttribute("data-initiallyshowall")) === true) { 98 hasMatchedOne = true; 99 } else { 100 panelData.forEach(function (category, i) { 101 if (Array.isArray(category)) { 102 if (mainData[i].filter(function (f) { 103 return f; 104 }).length > 0 && category.filter(function (f, j) { 105 return f && f === mainData[i][j]; 106 }).length > 0) { 107 hasMatchedOne = true; 108 } 109 } else if (mainData[i] === category && mainData[i] !== -1) { 110 hasMatchedOne = true; 111 } 112 }); 113 } 114 var isVisible = matchingOption === "matchAll" ? hasMatchedAll : hasMatchedOne; 115 if (isOldVersion) { 116 instance.style.display = isVisible ? "block" : "none"; 117 } else if (isVisible) { 118 instance.classList.remove("ub-hide"); 119 Array.prototype.slice.call(document.getElementsByClassName("ub_image_slider")).forEach(function (slider) { 120 var swiper = new Swiper("#".concat(slider.id), JSON.parse(slider.dataset.swiperData)); 121 }); 122 setTimeout(function () { 123 window.dispatchEvent(new Event("resize")); 124 }, 100); 125 } else { 126 instance.classList.add("ub-hide"); 127 } 128 Array.prototype.slice.call(instance.querySelectorAll(".wp-block-embed iframe")).forEac
128h(function (embeddedContent) { 129 embeddedContent.style.removeProperty("width"); 130 embeddedContent.style.removeProperty("height"); 131 }); 132 }); 133 }); 134}); 135 136/*Array.from(document.getElementsByClassName('ub-content-filter-reset')).forEach( 137 instance => { 138 instance.addEventListener('click', function() { 139 const blockProper = this.closest('.wp-block-ub-content-filter'); 140 141 let blockSelection = JSON.parse( 142 blockProper.getAttribute('data-currentselection') 143 ); 144 145 blockSelection = blockSelection.map(c => 146 Array.isArray(c) ? Array(c.length).fill(false) : -1 147 ); 148 149 blockProper.setAttribute( 150 'data-currentselection', 151 JSON.stringify(blockSelection) 152 ); 153 154 Array.from( 155 blockProper.getElementsByClassName('ub-content-filter-panel') 156 ).forEach(instance => { 157 instance.style.display = 'block'; 158 }); 159 160 Array.from( 161 blockProper.getElementsByClassName('ub-content-filter-tag') 162 ).forEach(instance => { 163 instance.setAttribute('data-tagisselected', 'false'); 164 instance.style.backgroundColor = instance.getAttribute( 165 'data-normalcolor' 166 ); 167 instance.style.color = instance.getAttribute( 168 'data-normaltextcolor' 169 ); 170 }); 171 }); 172 } 173);*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.