From 36143e7bd116ccb7ffe2ccd15b9f423050b6f436 Mon Sep 17 00:00:00 2001 From: Johannes Kinast Date: Tue, 15 Dec 2020 11:41:32 +0100 Subject: [PATCH 01/19] Support multiple Facets --- assets/js/facets.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/js/facets.js b/assets/js/facets.js index 0b648a644d..400543bb4a 100644 --- a/assets/js/facets.js +++ b/assets/js/facets.js @@ -1,7 +1,5 @@ import { debounce } from './utils/helpers'; -const facetTerms = document.querySelector('.widget_ep-facet .terms'); - /** * Filters the facets to match the input search term when * the number of terms exceeds the threshold determined @@ -9,7 +7,7 @@ const facetTerms = document.querySelector('.widget_ep-facet .terms'); * * @param {event} event - keyup */ -const handleFacetSearch = (event) => { +const handleFacetSearch = (event, facetTerms) => { const { target } = event; const searchTerm = target.value.replace(/\s/g, '').toLowerCase(); const terms = facetTerms.querySelectorAll('.term'); @@ -29,17 +27,19 @@ const handleFacetSearch = (event) => { /** * Filter facet choices to match the search field term */ -const facetSearchInput = document.querySelector('.widget_ep-facet .facet-search'); +const facets = document.querySelectorAll('.widget_ep-facet'); -if (facetSearchInput) { - facetSearchInput.addEventListener( +facets.forEach(facet => { + const facetSearchInput = facet.querySelector('.facet-search'); + const facetTerms = facet.querySelector('.terms'); + + facet.querySelector('.facet-search').addEventListener( 'keyup', debounce((event) => { if (event.keyCode === 13) { return; } - handleFacetSearch(event); - }, 200), - ); -} + handleFacetSearch(event, facetTerms); + }, 200) +}); From 61d3fb081f9bb0fe461a3c182f2c31b0bb3bab2c Mon Sep 17 00:00:00 2001 From: Johannes Kinast Date: Thu, 21 Jan 2021 09:07:59 +0100 Subject: [PATCH 02/19] Update facets.js Check if facetSearchInput exists. --- assets/js/facets.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/js/facets.js b/assets/js/facets.js index 400543bb4a..94e861aa11 100644 --- a/assets/js/facets.js +++ b/assets/js/facets.js @@ -33,6 +33,10 @@ facets.forEach(facet => { const facetSearchInput = facet.querySelector('.facet-search'); const facetTerms = facet.querySelector('.terms'); + if(!facetSearchInput) { + return; + } + facet.querySelector('.facet-search').addEventListener( 'keyup', debounce((event) => { From d7acb690c1979f9c017c3a3fffc9935dc55cb424 Mon Sep 17 00:00:00 2001 From: Johannes Kinast Date: Mon, 1 Feb 2021 19:21:35 +0100 Subject: [PATCH 03/19] Update facets.js Add missing ); --- assets/js/facets.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/assets/js/facets.js b/assets/js/facets.js index 94e861aa11..c2ac8b0efb 100644 --- a/assets/js/facets.js +++ b/assets/js/facets.js @@ -6,6 +6,7 @@ import { debounce } from './utils/helpers'; * by the ep_facet_search_threshold filter * * @param {event} event - keyup + * @param facetTerms */ const handleFacetSearch = (event, facetTerms) => { const { target } = event; @@ -29,14 +30,14 @@ const handleFacetSearch = (event, facetTerms) => { */ const facets = document.querySelectorAll('.widget_ep-facet'); -facets.forEach(facet => { +facets.forEach((facet) => { const facetSearchInput = facet.querySelector('.facet-search'); const facetTerms = facet.querySelector('.terms'); - - if(!facetSearchInput) { + + if (!facetSearchInput) { return; } - + facet.querySelector('.facet-search').addEventListener( 'keyup', debounce((event) => { @@ -45,5 +46,6 @@ facets.forEach(facet => { } handleFacetSearch(event, facetTerms); - }, 200) + }, 200), + ); }); From c12f3d422fc7acfbfd3f6fad5e1d5810e3d0f6ea Mon Sep 17 00:00:00 2001 From: Johannes Kinast Date: Mon, 1 Feb 2021 19:25:45 +0100 Subject: [PATCH 04/19] Add facetTerms type and description --- assets/js/facets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/facets.js b/assets/js/facets.js index c2ac8b0efb..a457eaf26b 100644 --- a/assets/js/facets.js +++ b/assets/js/facets.js @@ -6,7 +6,7 @@ import { debounce } from './utils/helpers'; * by the ep_facet_search_threshold filter * * @param {event} event - keyup - * @param facetTerms + * @param {Node} facetTerms - terms node */ const handleFacetSearch = (event, facetTerms) => { const { target } = event; From f3b56403a3fb3a0d19e6846ee3aecca375506b92 Mon Sep 17 00:00:00 2001 From: Johannes Kinast Date: Mon, 1 Feb 2021 19:25:56 +0100 Subject: [PATCH 05/19] Include dist files --- dist/js/facets-script.min.js | 2 +- dist/js/facets-script.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/js/facets-script.min.js b/dist/js/facets-script.min.js index 9a9093222f..df2682a504 100644 --- a/dist/js/facets-script.min.js +++ b/dist/js/facets-script.min.js @@ -1,2 +1,2 @@ -!function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"===typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=361)}([,,function(t,r,n){(function(r){var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof r&&r)||Function("return this")()}).call(this,n(51))},function(t,r){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,r,n){var e=n(2),o=n(34),i=n(6),c=n(35),u=n(37),a=n(65),f=o("wks"),s=e.Symbol,l=a?s:s&&s.withoutSetter||c;t.exports=function(t){return i(f,t)||(u&&i(s,t)?f[t]=s[t]:f[t]=l("Symbol."+t)),f[t]}},function(t,r,n){var e=n(2),o=n(28).f,i=n(10),c=n(17),u=n(23),a=n(68),f=n(53);t.exports=function(t,r){var n,s,l,p,v,d=t.target,g=t.global,y=t.stat;if(n=g?e:y?e[d]||u(d,{}):(e[d]||{}).prototype)for(s in r){if(p=r[s],l=t.noTargetGet?(v=o(n,s))&&v.value:n[s],!f(g?s:d+(y?".":"#")+s,t.forced)&&void 0!==l){if(typeof p===typeof l)continue;a(p,l)}(t.sham||l&&l.sham)&&i(p,"sham",!0),c(n,s,p,t)}}},function(t,r){var n={}.hasOwnProperty;t.exports=function(t,r){return n.call(t,r)}},function(t,r){t.exports=function(t){return"object"===typeof t?null!==t:"function"===typeof t}},function(t,r,n){var e=n(7);t.exports=function(t){if(!e(t))throw TypeError(String(t)+" is not an object");return t}},function(t,r,n){var e=n(3);t.exports=!e((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(t,r,n){var e=n(9),o=n(11),i=n(21);t.exports=e?function(t,r,n){return o.f(t,r,i(1,n))}:function(t,r,n){return t[r]=n,t}},function(t,r,n){var e=n(9),o=n(38),i=n(8),c=n(25),u=Object.defineProperty;r.f=e?u:function(t,r,n){if(i(t),r=c(r,!0),i(n),o)try{return u(t,r,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[r]=n.value),t}},function(t,r,n){var e=n(19),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,r,n){var e=n(27),o=n(14);t.exports=function(t){return e(o(t))}},function(t,r){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,r,n){var e=n(14);t.exports=function(t){return Object(e(t))}},function(t,r){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,r,n){var e=n(2),o=n(10),i=n(6),c=n(23),u=n(33),a=n(41),f=a.get,s=a.enforce,l=String(String).split("String");(t.exports=function(t,r,n,u){var a=!!u&&!!u.unsafe,f=!!u&&!!u.enumerable,p=!!u&&!!u.noTargetGet;"function"==typeof n&&("string"!=typeof r||i(n,"name")||o(n,"name",r),s(n).source=l.join("string"==typeof r?r:"")),t!==e?(a?!p&&t[r]&&(f=!0):delete t[r],f?t[r]=n:o(t,r,n)):f?t[r]=n:c(r,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&f(this).source||u(this)}))},function(t,r,n){var e=n(63),o=n(2),i=function(t){return"function"==typeof t?t:void 0};t.exports=function(t,r){return arguments.length<2?i(e[t])||i(o[t]):e[t]&&e[t][r]||o[t]&&o[t][r]}},function(t,r){var n=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:n)(t)}},function(t,r,n){var e=n(9),o=n(3),i=n(6),c=Object.defineProperty,u={},a=function(t){throw t};t.exports=function(t,r){if(i(u,t))return u[t];r||(r={});var n=[][t],f=!!i(r,"ACCESSORS")&&r.ACCESSORS,s=i(r,0)?r[0]:a,l=i(r,1)?r[1]:void 0;return u[t]=!!n&&!o((function(){if(f&&!e)return!0;var t={length:-1};f?c(t,1,{enumerable:!0,get:a}):t[1]=1,n.call(t,s,l)}))}},function(t,r){t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},function(t,r,n){var e=n(107),o=n(108),i=n(109);t.exports=function(t){return e(t)||o(t)||i()}},function(t,r,n){var e=n(2),o=n(10);t.exports=function(t,r){try{o(e,t,r)}catch(n){e[t]=r}return r}},function(t,r){t.exports={}},function(t,r,n){var e=n(7);t.exports=function(t,r){if(!e(t))return t;var n,o;if(r&&"function"==typeof(n=t.toString)&&!e(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!e(o=n.call(t)))return o;if(!r&&"function"==typeof(n=t.toString)&&!e(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,r){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(t,r,n){var e=n(3),o=n(16),i="".split;t.exports=e((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==o(t)?i.call(t,""):Object(t)}:Object},function(t,r,n){var e=n(9),o=n(57),i=n(21),c=n(13),u=n(25),a=n(6),f=n(38),s=Object.getOwnPropertyDescriptor;r.f=e?s:function(t,r){if(t=c(t),r=u(r,!0),f)try{return s(t,r)}catch(t){}if(a(t,r))return i(!o.f.call(t,r),t[r])}},function(t,r,n){var e=n(34),o=n(35),i=e("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},function(t,r){t.exports=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}},function(t,r,n){var e=n(49),o=n(27),i=n(15),c=n(12),u=n(45),a=[].push,f=function(t){var r=1==t,n=2==t,f=3==t,s=4==t,l=6==t,p=5==t||l;return function(v,d,g,y){for(var h,x,S=i(v),b=o(S),m=e(d,g,3),E=c(b.length),O=0,w=y||u,A=r?w(v,E):n?w(v,0):void 0;E>O;O++)if((p||O in b)&&(x=m(h=b[O],O,S),t))if(r)A[O]=x;else if(x)switch(t){case 3:return!0;case 5:return h;case 6:return O;case 2:a.call(A,h)}else if(s)return!1;return l?-1:f||s?s:A}};t.exports={forEach:f(0),map:f(1),filter:f(2),some:f(3),every:f(4),find:f(5),findIndex:f(6)}},,function(t,r,n){var e=n(40),o=Function.toString;"function"!=typeof e.inspectSource&&(e.inspectSource=function(t){return o.call(t)}),t.exports=e.inspectSource},function(t,r,n){var e=n(42),o=n(40);(t.exports=function(t,r){return o[t]||(o[t]=void 0!==r?r:{})})("versions",[]).push({version:"3.6.5",mode:e?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})},function(t,r){var n=0,e=Math.random();t.exports=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++n+e).toString(36)}},function(t,r,n){var e=n(16);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,r,n){var e=n(3);t.exports=!!Object.getOwnPropertySymbols&&!e((function(){return!String(Symbol())}))},function(t,r,n){var e=n(9),o=n(3),i=n(39);t.exports=!e&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},function(t,r,n){var e=n(2),o=n(7),i=e.document,c=o(i)&&o(i.createElement);t.exports=function(t){return c?i.createElement(t):{}}},function(t,r,n){var e=n(2),o=n(23),i=e["__core-js_shared__"]||o("__core-js_shared__",{});t.exports=i},function(t,r,n){var e,o,i,c=n(67),u=n(2),a=n(7),f=n(10),s=n(6),l=n(29),p=n(24),v=u.WeakMap;if(c){var d=new v,g=d.get,y=d.has,h=d.set;e=function(t,r){return h.call(d,t,r),r},o=function(t){return g.call(d,t)||{}},i=function(t){return y.call(d,t)}}else{var x=l("state");p[x]=!0,e=function(t,r){return f(t,x,r),r},o=function(t){return s(t,x)?t[x]:{}},i=function(t){return s(t,x)}}t.exports={set:e,get:o,has:i,enforce:function(t){return i(t)?o(t):e(t,{})},getterFor:function(t){return function(r){var n;if(!a(r)||(n=o(r)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}}},function(t,r){t.exports=!1},function(t,r,n){var e=n(6),o=n(13),i=n(52).indexOf,c=n(24);t.exports=function(t,r){var n,u=o(t),a=0,f=[];for(n in u)!e(c,n)&&e(u,n)&&f.push(n);for(;r.length>a;)e(u,n=r[a++])&&(~i(f,n)||f.push(n));return f}},function(t,r,n){var e=n(3),o=n(4),i=n(59),c=o("species");t.exports=function(t){return i>=51||!e((function(){var r=[];return(r.constructor={})[c]=function(){return{foo:1}},1!==r[t](Boolean).foo}))}},function(t,r,n){var e=n(7),o=n(36),i=n(4)("species");t.exports=function(t,r){var n;return o(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!o(n.prototype)?e(n)&&null===(n=n[i])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===r?0:r)}},function(t,r,n){"use strict";var e=n(60),o=n(85),i=RegExp.prototype.exec,c=String.prototype.replace,u=i,a=function(){var t=/a/,r=/b*/g;return i.call(t,"a"),i.call(r,"a"),0!==t.lastIndex||0!==r.lastIndex}(),f=o.UNSUPPORTED_Y||o.BROKEN_CARET,s=void 0!==/()??/.exec("")[1];(a||s||f)&&(u=function(t){var r,n,o,u,l=this,p=f&&l.sticky,v=e.call(l),d=l.source,g=0,y=t;return p&&(-1===(v=v.replace("y","")).indexOf("g")&&(v+="g"),y=String(t).slice(l.lastIndex),l.lastIndex>0&&(!l.multiline||l.multiline&&"\n"!==t[l.lastIndex-1])&&(d="(?: "+d+")",y=" "+y,g++),n=new RegExp("^(?:"+d+")",v)),s&&(n=new RegExp("^"+d+"$(?!\\s)",v)),a&&(r=l.lastIndex),o=i.call(p?n:l,y),p?o?(o.input=o.input.slice(g),o[0]=o[0].slice(g),o.index=l.lastIndex,l.lastIndex+=o[0].length):l.lastIndex=0:a&&o&&(l.lastIndex=l.global?o.index+o[0].length:r),s&&o&&o.length>1&&c.call(o[0],n,(function(){for(u=1;us;)if((u=a[s++])!=u)return!0}else for(;f>s;s++)if((t||s in a)&&a[s]===n)return t||s||0;return!t&&-1}};t.exports={includes:c(!0),indexOf:c(!1)}},function(t,r,n){var e=n(3),o=/#|\.prototype\./,i=function(t,r){var n=u[c(t)];return n==f||n!=a&&("function"==typeof r?e(r):!!r)},c=i.normalize=function(t){return String(t).replace(o,".").toLowerCase()},u=i.data={},a=i.NATIVE="N",f=i.POLYFILL="P";t.exports=i},function(t,r,n){"use strict";var e=n(25),o=n(11),i=n(21);t.exports=function(t,r,n){var c=e(r);c in t?o.f(t,c,i(0,n)):t[c]=n}},,function(t,r,n){"use strict";var e=n(3);t.exports=function(t,r){var n=[][t];return!!n&&e((function(){n.call(null,r||function(){throw 1},1)}))}},function(t,r,n){"use strict";var e={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i=o&&!e.call({1:2},1);r.f=i?function(t){var r=o(this,t);return!!r&&r.enumerable}:e},function(t,r,n){var e,o=n(8),i=n(79),c=n(26),u=n(24),a=n(73),f=n(39),s=n(29),l=s("IE_PROTO"),p=function(){},v=function(t){return"