-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathvanilla.filterizr.min.js
12 lines (12 loc) · 30.4 KB
/
vanilla.filterizr.min.js
1
2
3
4
5
6
7
8
9
10
11
12
var Filterizr=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=4)}([function(t,e,r){"use strict";var n=function(t){if(!t.includes("-"))return t;var e=t.split("-");return""+e[0]+e.slice(1,e.length).map(function(t){return t[0].toUpperCase()+t.slice(1,t.length)}).join("")};function i(t,e){Object.entries(e).forEach(function(e){var r=e[0],i=e[1];t.style[n(r)]=i})}var o=function(t,e){var r=function(t){var e={};for(var r in t)e[r]=t[r];return e}(e);for(var n in t)n in r?"object"!=typeof r[n]||"object"!=typeof t[n]||Array.isArray(t[n])||(r[n]=o(t[n],"object"==typeof r[n]?r[n]:{})):r[n]=t[n];return r},s=function(t,e,r){var n;return function(){var i=this,o=arguments;clearTimeout(n),n=window.setTimeout(function(){n=null,r||t.apply(i,o)},e),r&&!n&&t.apply(i,o)}},a=function(t){for(var e=t.slice(0),r=[];0!==e.length;){var n=Math.floor(e.length*Math.random());r.push(e[n]),e.splice(n,1)}return r},l=function(t,e){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++){if(t[r].getSortAttribute("index")!==e[r].getSortAttribute("index"))return!1}return!0},h=function(t,e,r,n,i){if(void 0!==e){var o=new Error('Filterizr: expected type of option "'+t+'" to be "'+r+'", but its type is: "'+typeof e+'"'),s=!1,a=!1,l=r.includes("array");if((typeof e).match(r)?s=!0:!s&&l&&(a=Array.isArray(e)),!s&&!l)throw o;if(!s&&l&&!a)throw o;var h=function(t){return t?" For further help read here: "+t:""};if(Array.isArray(n)){var u=!1;if(n.forEach(function(t){t===e&&(u=!0)}),!u)throw new Error('Filterizr: allowed values for option "'+t+'" are: '+n.map(function(t){return'"'+t+'"'}).join(", ")+'. Value received: "'+e+'".'+h(i))}else if("string"==typeof e&&n instanceof RegExp){if(!e.match(n))throw new Error('Filterizr: invalid value "'+e+'" for option "'+t+'" received.'+h(i))}}},u=function(t){return"string"==typeof t?document.querySelector(t):t},f=/(^linear$)|(^ease-in-out$)|(^ease-in$)|(^ease-out$)|(^ease$)|(^step-start$)|(^step-end$)|(^steps\(\d\s*,\s*(end|start)\))$|(^cubic-bezier\((\d*\.*\d+)\s*,\s*(\d*\.*\d+)\s*,\s*(\d*\.*\d+)\s*,\s*(\d*\.*\d+)\))$/,c={IDLE:"IDLE",FILTERING:"FILTERING",SORTING:"SORTING",SHUFFLING:"SHUFFLING"},d=["webkitTransitionEnd","otransitionend","oTransitionEnd","msTransitionEnd","transitionend"],p=function(){},g=function(){function t(){}return t.prototype.debounceEventHandler=function(t){return s(t,250,!1)},t.prototype.destroy=function(){this.removeResizeHandler()},t.prototype.setResizeEventHandler=function(t){this.removeResizeHandler(),this.resizeHandler=this.debounceEventHandler(t),window.addEventListener("resize",this.resizeHandler)},t.prototype.removeResizeHandler=function(){window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null},t}(),m={animationDuration:.5,callbacks:{onInit:p,onFilteringStart:p,onFilteringEnd:p,onShufflingStart:p,onShufflingEnd:p,onSortingStart:p,onSortingEnd:p},controlsSelector:"",delay:0,delayMode:"progressive",easing:"ease-out",filter:"all",filterOutCss:{opacity:0,transform:"scale(0.5)"},filterInCss:{opacity:1,transform:"scale(1)"},gridItemsSelector:".filtr-item",layout:"sameSize",multifilterLogicalOperator:"or",searchTerm:"",setupControls:!0},y=function(){function t(t){this.filter=t}return t.prototype.get=function(){return this.filter},t.prototype.set=function(t){this.filter=t},t.prototype.toggle=function(t){this.filter=this.toggleFilter(this.filter,t)},t.prototype.toggleFilter=function(t,e){if("all"===t)return e;if(Array.isArray(t)){if(t.includes(e)){var r=t.filter(function(t){return t!==e});return 1===r.length?r[0]:r}return t.concat([e])}return t===e?"all":[t,e]},t}(),v=function(){return(v=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},E=function(){function t(t){var e=o(m,this.validate(t));this.options=this.convertToFilterizrOptions(e)}return Object.defineProperty(t.prototype,"filter",{get:function(){return this.options.filter.get()},set:function(t){this.options.filter.set(t)},enumerable:!0,configurable:!0}),t.prototype.toggleFilter=function(t){this.options.filter.toggle(t)},Object.defineProperty(t.prototype,"searchTerm",{get:function(){return this.options.searchTerm},set:function(t){this.options.searchTerm=t},enumerable:!0,configurable:!0}),t.prototype.get=function(){return this.options},t.prototype.getRaw=function(){return this.convertToOptions(this.options)},t.prototype.set=function(t){var e=o(this.convertToOptions(this.options),this.validate(t));this.options=this.convertToFilterizrOptions(e)},t.prototype.convertToFilterizrOptions=function(t){return v({},t,{filter:new y(t.filter)})},t.prototype.convertToOptions=function(t){return v({},t,{filter:t.filter.get()})},t.prototype.validate=function(t){return h("animationDuration",t.animationDuration,"number"),h("callbacks",t.callbacks,"object"),h("controlsSelector",t.controlsSelector,"string"),h("delay",t.delay,"number"),h("easing",t.easing,"string",f,"https://www.w3schools.com/cssref/css3_pr_transition-timing-function.asp"),h("delayMode",t.delayMode,"string",["progressive","alternate"]),h("filter",t.filter,"string|number|array"),h("filterOutCss",t.filterOutCss,"object"),h("filterInCss",t.filterOutCss,"object"),h("layout",t.layout,"string",["sameSize","vertical","horizontal","sameHeight","sameWidth","packed"]),h("multifilterLogicalOperator",t.multifilterLogicalOperator,"string",["and","or"]),h("searchTerm",t.searchTerm,"string"),h("setupControls",t.setupControls,"boolean"),t},t}(),b=function(){function t(t,e){void 0===e&&(e=""),this.filterControls=document.querySelectorAll(e+"[data-filter]"),this.multiFilterControls=document.querySelectorAll(e+"[data-multifilter]"),this.shuffleControls=document.querySelectorAll(e+"[data-shuffle]"),this.searchControls=document.querySelectorAll(e+"[data-search]"),this.sortAscControls=document.querySelectorAll(e+"[data-sortAsc]"),this.sortDescControls=document.querySelectorAll(e+"[data-sortDesc]"),this.props={filterizr:t,selector:e,handlers:{filterControlsHandler:null,multiFilterControlsHandler:null,shuffleControlsHandler:null,searchControlsHandler:null,sortAscControlsHandler:null,sortDescControlsHandler:null}},this.initialize()}return t.prototype.destroy=function(){this.destroyFilterControls(),this.destroyShuffleControls(),this.destroySearchControls(),this.destroySortControls()},t.prototype.initialize=function(){this.setupFilterControls(),this.setupShuffleControls(),this.setupSearchControls(),this.setupSortControls()},t.prototype.setupFilterControls=function(){var t=this,e=this.filterControls,r=this.multiFilterControls,n=this.props.filterizr;e&&(this.props.handlers.filterControlsHandler=function(t){var e=t.currentTarget.getAttribute("data-filter");n.filter(e)},e.forEach(function(e){return e.addEventListener("click",t.props.handlers.filterControlsHandler)})),r&&(this.props.handlers.multiFilterControlsHandler=function(t){var e=t.target.getAttribute("data-multifilter");n.toggleFilter(e)},r.forEach(function(e){return e.addEventListener("click",t.props.handlers.multiFilterControlsHandler)}))},t.prototype.destroyFilterControls=function(){var t=this,e=this.filterControls,r=this.multiFilterControls;e&&e.forEach(function(e){return e.removeEventListener("click",t.props.handlers.filterControlsHandler)}),r&&r.forEach(function(e){return e.removeEventListener("click",t.props.handlers.multiFilterControlsHandler)})},t.prototype.setupShuffleControls=function(){var t=this,e=this.shuffleControls,r=this.props.filterizr;e&&(this.props.handlers.shuffleControlsHandler=function(){r.shuffle()},e.forEach(function(e){return e.addEventListener("click",t.props.handlers.shuffleControlsHandler)}))},t.prototype.destroyShuffleControls=function(){var t=this,e=this.shuffleControls;e&&e.forEach(function(e){return e.removeEventListener("click",t.props.handlers.shuffleControlsHandler)})},t.prototype.setupSearchControls=function(){var t=this,e=this.searchControls,r=this.props.filterizr;e&&(this.props.handlers.searchControlsHandler=s(function(t){var e=t.target.value;r.search(e)},250,!1),e.forEach(function(e){return e.addEventListener("keyup",t.props.handlers.searchControlsHandler)}))},t.prototype.destroySearchControls=function(){var t=this,e=this.searchControls;e&&e.forEach(function(e){return e.removeEventListener("keyup",t.props.handlers.searchControlsHandler)})},t.prototype.setupSortControls=function(){var t=this,e=this.sortAscControls,r=this.sortDescControls,n=this.props,i=n.filterizr,o=n.selector;e&&(this.props.handlers.sortAscControlsHandler=function(){var t=document.querySelector(o+"[data-sortOrder]").value;i.sort(t,"asc")},e.forEach(function(e){return e.addEventListener("click",t.props.handlers.sortAscControlsHandler)})),r&&(this.props.handlers.sortDescControlsHandler=function(){var t=document.querySelector(o+"[data-sortOrder]").value;i.sort(t,"desc")},r.forEach(function(e){return e.addEventListener("click",t.props.handlers.sortDescControlsHandler)}))},t.prototype.destroySortControls=function(){var t=this,e=this.sortAscControls,r=this.sortDescControls;e&&e.forEach(function(e){return e.removeEventListener("click",t.props.handlers.sortAscControlsHandler)}),r&&r.forEach(function(e){return e.removeEventListener("click",t.props.handlers.sortDescControlsHandler)})},t}(),w=r(1),C=function(){function t(t,e,r){var n=this;this.data=function(t){for(var e={category:"",sort:""},r=0,n=t.attributes,i=n.length;r<i;r++){var o=n[r],s=o.nodeName,a=o.nodeValue;s.includes("data")&&(e[s.slice(5,s.length)]=a)}return delete e.category,delete e.sort,e}(t),this.filteredOut=!1,this.index=e,this.lastPosition={left:0,top:0},this.node=t,this.options=r,this.sortData=t.getAttribute("data-sort"),this.dimensions={width:this.node.clientWidth,height:this.node.clientHeight},this.onTransitionEndHandler=function(){n.filteredOut?(n.node.classList.add("filteredOut"),i(n.node,{zIndex:-1e3})):(n.node.classList.remove("filteredOut"),i(n.node,{zIndex:""}))};var o=this.options.get().filterOutCss;i(this.node,Object.assign({},o,{"-webkit-backface-visibility":"hidden",perspective:"1000px","-webkit-perspective":"1000px","-webkit-transform-style":"preserve-3d",position:"absolute"})),this.setTransitionStyle(),this.bindEvents()}return t.prototype.destroy=function(){this.node.removeAttribute("style"),this.unbindEvents()},t.prototype.filterIn=function(t,e){i(this.node,Object.assign({},e,{transform:(e.transform||"")+" translate3d("+t.left+"px, "+t.top+"px, 0)"})),this.lastPosition=t,this.filteredOut=!1},t.prototype.filterOut=function(t){var e=this.lastPosition;i(this.node,Object.assign({},t,{transform:(t.transform||"")+" translate3d("+e.left+"px, "+e.top+"px, 0)"})),this.filteredOut=!0},t.prototype.getTransitionDelay=function(t,e){var r=0;return"progressive"===e?r=t*this.index:this.index%2==0&&(r=t),r},t.prototype.contentsMatchSearch=function(t){return Boolean(this.getContentsLowercase().includes(t))},t.prototype.updateDimensions=function(){this.dimensions.width=this.node.clientWidth,this.dimensions.height=this.node.clientHeight},t.prototype.getCategories=function(){return this.node.getAttribute("data-category").split(/\s*,\s*/g)},t.prototype.getSortAttribute=function(t){return"index"===t||"sortData"===t?this[t]:this.data[t]},t.prototype.getContentsLowercase=function(){return this.node.textContent.toLowerCase()},t.prototype.bindEvents=function(){var t=this;d.forEach(function(e){t.node.addEventListener(e,t.onTransitionEndHandler)})},t.prototype.unbindEvents=function(){var t=this;d.forEach(function(e){t.node.removeEventListener(e,t.onTransitionEndHandler)})},t.prototype.getTransitionStyle=function(){var t=this.options.get(),e=t.animationDuration,r=t.easing,n=t.delay,i=t.delayMode;return"all "+e+"s "+r+" "+this.getTransitionDelay(n,i)+"ms"},t.prototype.setTransitionStyle=function(){var t=this;!!this.node.querySelectorAll("img").length?w(this.node,function(){setTimeout(function(){i(t.node,{transition:t.getTransitionStyle()})},10)}):setTimeout(function(){i(t.node,{transition:t.getTransitionStyle()})},10)},t}(),S=function(){function t(t,e){this.filterItems=t,this.options=e}return Object.defineProperty(t.prototype,"length",{get:function(){return this.filterItems.length},enumerable:!0,configurable:!0}),t.prototype.get=function(){return this.filterItems},t.prototype.getItem=function(t){return this.filterItems[t]},t.prototype.set=function(t){this.filterItems=t},t.prototype.destroy=function(){this.filterItems.forEach(function(t){return t.destroy()})},t.prototype.updateTransitionStyle=function(){var t=this.options.getRaw(),e=t.animationDuration,r=t.easing,n=t.delay,o=t.delayMode;this.filterItems.forEach(function(t){return i(t.node,{transition:"all "+e+"s "+r+" "+t.getTransitionDelay(n,o)+"ms"})})},t.prototype.updateDimensions=function(){this.filterItems.forEach(function(t){return t.updateDimensions()})},t.prototype.push=function(t){return this.filterItems.push(t)},t.prototype.getFiltered=function(t){var e=this,r=this.get();return"all"===t?r:r.filter(function(r){var n=r.getCategories();return e.shouldBeFiltered(n,t)})},t.prototype.getFilteredOut=function(t){var e=this;return this.get().filter(function(r){var n=r.getCategories(),i=e.shouldBeFiltered(n,t),o=r.contentsMatchSearch(e.options.searchTerm);return!i||!o})},t.prototype.getSorted=function(t,e){void 0===t&&(t="index"),void 0===e&&(e="asc");var r,n=this.get(),i=(r=function(e){return e.getSortAttribute(t)},n.slice(0).sort(function(t){return function(e,r){var n=t(e),i=t(r);return n<i?-1:n>i?1:0}}(r))),o="asc"===e?i:i.reverse();return this.set(o),this.getFiltered(this.options.filter)},t.prototype.getSearched=function(t){var e=this.getFiltered(this.options.filter);return t?e.filter(function(e){return e.contentsMatchSearch(t)}):e},t.prototype.getShuffled=function(){var t=this,e=this.getFiltered(this.options.filter);if(e.length<=1)return e;var r,n=this.getFiltered(this.options.filter).map(function(e){return t.get().indexOf(e)}).slice();do{r=a(e)}while(l(e,r));return(r=a(e)).forEach(function(e,r){var i,o=n[r];t.set(Object.assign([],t.get(),((i={})[o]=e,i)))}),r},t.prototype.shouldBeFiltered=function(t,e){var r,n,i=this.options.get().multifilterLogicalOperator;return Array.isArray(e)?"or"===i?!!(r=t,n=e,Array.prototype.filter.call(r,function(t){return n.includes(t)})).length:function(t,e){for(var r=0;r<t.length;r++){for(var n=!1,i=t[r],o=0;o<e.length;o++)i===e[o]&&(n=!0);if(!n)return!1}return!0}(e,t):t.includes(e)},t}(),I=function(){function t(t,e){if(!t)throw new Error("Filterizr: could not initialize container, check the selector or node you passed to the constructor exists.");if(this.node=t,this.options=e,this.onTransitionEndHandler=null,i(this.node,{padding:0,position:"relative",width:"100%",display:"flex",flexWrap:"wrap"}),this.filterItems=this.makeFilterItems(this.options),!this.filterItems.length)throw new Error("Filterizr: cannot initialize empty container. Make sure the gridItemsSelector option corresponds to the selector of your grid's items");this.dimensions={width:this.node.clientWidth,height:0},this.filterItems.updateDimensions()}return t.prototype.destroy=function(){this.node.removeAttribute("style"),this.unbindEvents(this.options.get().callbacks),this.filterItems.destroy()},t.prototype.makeFilterItems=function(t){var e=Array.from(this.node.querySelectorAll(t.get().gridItemsSelector)).map(function(e,r){return new C(e,r,t)});return new S(e,t)},t.prototype.insertItem=function(t,e){var r=t.cloneNode(!0);r.removeAttribute("style"),this.node.appendChild(r),this.filterItems.push(new C(r,this.filterItems.length,e))},t.prototype.calculateColumns=function(){return Math.round(this.dimensions.width/this.filterItems.getItem(0).dimensions.width)},t.prototype.updateDimensions=function(){this.updateWidth(),this.filterItems.updateDimensions()},t.prototype.updateHeight=function(t){this.dimensions.height=t,i(this.node,{height:t+"px"})},t.prototype.bindEvents=function(t){var e=this;this.onTransitionEndHandler=t.onTransitionEnd,d.forEach(function(t){e.node.addEventListener(t,e.onTransitionEndHandler)}),this.node.addEventListener("filteringStart",t.onFilteringStart),this.node.addEventListener("filteringEnd",t.onFilteringEnd),this.node.addEventListener("shufflingStart",t.onShufflingStart),this.node.addEventListener("shufflingEnd",t.onShufflingEnd),this.node.addEventListener("sortingStart",t.onSortingStart),this.node.addEventListener("sortingEnd",t.onSortingEnd)},t.prototype.unbindEvents=function(t){var e=this;d.forEach(function(t){e.node.removeEventListener(t,e.onTransitionEndHandler)}),this.node.removeEventListener("filteringStart",t.onFilteringStart),this.node.removeEventListener("filteringEnd",t.onFilteringEnd),this.node.removeEventListener("shufflingStart",t.onShufflingStart),this.node.removeEventListener("shufflingEnd",t.onShufflingEnd),this.node.removeEventListener("sortingStart",t.onSortingStart),this.node.removeEventListener("sortingEnd",t.onSortingEnd)},t.prototype.trigger=function(t){var e=new Event(t);this.node.dispatchEvent(e)},t.prototype.updateWidth=function(){this.dimensions.width=this.node.clientWidth},t}(),F=function(t){var e=t.filterItems.getFiltered(t.options.get().filter.get()),r=0,n=0,i=e.map(function(t){var e=t.dimensions,i=e.width,o=e.height,s={left:r,top:0};return r+=i,o>n&&(n=o),s});return t.updateHeight(n),i},L=function(t){var e=t.filterItems.getFiltered(t.options.get().filter.get()),r=0,n=e.map(function(t){var e=t.dimensions.height,n={left:0,top:r};return r+=e,n});return t.updateHeight(r),n},O=function(t){var e=t.filterItems.getFiltered(t.options.get().filter.get()),r=t.dimensions.width,n=e[0].dimensions.height,i=0,o=0,s=e.map(function(t){var e=t.dimensions.width;o+e>r&&(i++,o=0);var s={left:o,top:n*i};return o+=e,s});return t.updateHeight((i+1)*e[0].dimensions.height),s},A=function(t,e,r){if(e<=0)return 0;var n=0;if(r<e-1)return 0;for(r-=e;r>=0;)n+=t[r].dimensions.height,r-=e;return n},T=function(t){var e=t.filterItems.getFiltered(t.options.get().filter.get()),r=t.calculateColumns(),n=0,i=Array.apply(null,Array(r)).map(Number.prototype.valueOf,0),o=e.map(function(t,o){var s=t.dimensions,a=s.width,l=s.height;o%r==0&&o>=r&&n++;var h=o-r*n;return i[h]+=l,{left:h*a,top:A(e,r,o)}});return t.updateHeight(Math.max.apply(Math,i)),o},k=function(t){var e=t.filterItems.getFiltered(t.options.get().filter.get()),r=t.calculateColumns(),n=0,i=e.map(function(t,e){var i=t.dimensions,o=i.width,s=i.height;return e%r==0&&e>=r&&n++,{left:(e-r*n)*o,top:n*s}}),o=e[0]&&e[0].dimensions.height||0;return t.updateHeight((n+1)*o),i},H=function(){function t(t){this.init(t)}return t.prototype.init=function(t){this.root={x:0,y:0,w:t}},t.prototype.fit=function(t){var e,r,n,i=t.length,o=i>0?t[0].h:0;for(this.root.h=o,e=0;e<i;e++)n=t[e],(r=this.findNode(this.root,n.w,n.h))?n.fit=this.splitNode(r,n.w,n.h):n.fit=this.growDown(n.w,n.h)},t.prototype.findNode=function(t,e,r){return t.used?this.findNode(t.right,e,r)||this.findNode(t.down,e,r):e<=t.w&&r<=t.h?t:null},t.prototype.splitNode=function(t,e,r){return t.used=!0,t.down={x:t.x,y:t.y+r,w:t.w,h:t.h-r},t.right={x:t.x+e,y:t.y,w:t.w-e,h:r},t},t.prototype.growDown=function(t,e){var r;return this.root={used:!0,x:0,y:0,w:this.root.w,h:this.root.h+e,down:{x:0,y:this.root.h,w:this.root.w,h:e},right:this.root},(r=this.findNode(this.root,t,e))?this.splitNode(r,t,e):null},t}(),x=function(t){var e=t.filterItems.getFiltered(t.options.get().filter.get()),r=new H(t.dimensions.width),n=e.map(function(t){var e=t.dimensions;return{w:e.width,h:e.height}});r.fit(n);var i=n.map(function(t){var e=t.fit;return{left:e.x,top:e.y}});return t.updateHeight(r.root.h),i},z=function(t,e){switch(t){case"horizontal":return F(e);case"vertical":return L(e);case"sameHeight":return O(e);case"sameWidth":return T(e);case"packed":return x(e);case"sameSize":default:return k(e)}};function j(t){if(!t)throw new Error("Filterizr as a jQuery plugin, requires jQuery to work. If you would prefer to use the vanilla JS version, please use the correct bundle file.");t.fn.filterizr=function(){var e="."+t.trim(this.get(0).className).replace(/\s+/g,"."),r=arguments;if(!this._fltr&&0===r.length||1===r.length&&"object"==typeof r[0]){var n=r.length>0?r[0]:m;this._fltr=new q(e,n)}else if(r.length>=1&&"string"==typeof r[0]){var i=r[0],o=Array.prototype.slice.call(r,1),s=this._fltr;switch(i){case"filter":return s.filter.apply(s,o),this;case"insertItem":return s.insertItem.apply(s,o),this;case"toggleFilter":return s.toggleFilter.apply(s,o),this;case"sort":return s.sort.apply(s,o),this;case"shuffle":return s.shuffle.apply(s,o),this;case"search":return s.search.apply(s,o),this;case"setOptions":return s.setOptions.apply(s,o),this;case"destroy":return s.destroy.apply(s,o),delete this._fltr,this;default:throw new Error("Filterizr: "+i+" is not part of the Filterizr API. Please refer to the docs for more information.")}}return this}}var D=function(){return(D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},N=r(1),_=function(){function t(t,e){void 0===t&&(t=".filtr-container"),void 0===e&&(e={}),this.options=new E(e);var r=this.options.get(),n=r.setupControls,i=r.controlsSelector;this.browserWindow=new g,this.filterContainer=new I(u(t),this.options),this.filterizrState=c.IDLE,n&&(this.filterControls=new b(this,i)),this.bindEvents(),this.renderWithImagesLoaded(this.options.get().callbacks.onInit)}return Object.defineProperty(t.prototype,"filterItems",{get:function(){return this.filterContainer.filterItems},enumerable:!0,configurable:!0}),t.prototype.filter=function(t){var e=this.filterContainer,r=this.filterItems;e.trigger("filteringStart"),this.filterizrState=c.FILTERING,t=Array.isArray(t)?t.map(function(t){return t.toString()}):t.toString(),this.options.filter=t,this.render(r.getSearched(this.options.searchTerm))},t.prototype.destroy=function(){var t=this.browserWindow,e=this.filterControls;this.filterContainer.destroy(),t.destroy(),this.options.get().setupControls&&e&&e.destroy()},t.prototype.insertItem=function(t){this.filterContainer.insertItem(t,this.options),this.renderWithImagesLoaded()},t.prototype.sort=function(t,e){void 0===t&&(t="index"),void 0===e&&(e="asc");var r=this.filterContainer,n=this.filterItems;r.trigger("sortingStart"),this.filterizrState=c.SORTING,this.render(n.getSorted(t,e))},t.prototype.search=function(t){void 0===t&&(t=this.options.get().searchTerm),this.options.searchTerm=t.toLowerCase(),this.render(this.filterItems.getSearched(this.options.searchTerm))},t.prototype.shuffle=function(){var t=this.filterContainer,e=this.filterItems;t.trigger("shufflingStart"),this.filterizrState=c.SHUFFLING,this.render(e.getShuffled())},t.prototype.setOptions=function(t){var e=this.filterContainer,r=this.filterItems,n=this.options.filter;t.callbacks&&e.unbindEvents(this.options.get().callbacks),this.options.set(t),(t.animationDuration||t.delay||t.delayMode||t.easing)&&r.updateTransitionStyle(),(t.callbacks||t.animationDuration)&&this.rebindFilterContainerEvents(),"searchTerm"in t&&this.search(t.searchTerm),(t.filter||t.multifilterLogicalOperator)&&this.filter(t.filter||n)},t.prototype.toggleFilter=function(t){this.options.toggleFilter(t),this.filter(this.options.filter)},t.prototype.render=function(t){var e=this.filterContainer,r=this.filterItems,n=this.options.filter,i=this.options.get(),o=i.filterInCss,s=i.filterOutCss,a=i.layout;r.getFilteredOut(n).forEach(function(t){t.filterOut(s)});var l=z(a,e);t.forEach(function(t,e){t.filterIn(l[e],o)})},t.prototype.onTransitionEndCallback=function(){var t=this.filterizrState,e=this.filterContainer;switch(t){case c.FILTERING:e.trigger("filteringEnd");break;case c.SORTING:e.trigger("sortingEnd");break;case c.SHUFFLING:e.trigger("shufflingEnd")}this.filterizrState=c.IDLE},t.prototype.rebindFilterContainerEvents=function(){var t=this.filterContainer,e=this.options.get(),r=e.animationDuration,n=e.callbacks;t.unbindEvents(n),t.bindEvents(D({},n,{onTransitionEnd:s(this.onTransitionEndCallback.bind(this),r,!1)}))},t.prototype.bindEvents=function(){var t=this.browserWindow;this.rebindFilterContainerEvents(),t.setResizeEventHandler(this.updateDimensionsAndRerender.bind(this))},t.prototype.renderWithImagesLoaded=function(t){var e=this;void 0===t&&(t=p);var r=this.filterContainer,n=this.filterItems,i=this.options.filter;!!r.node.querySelectorAll("img").length?N(r.node,function(){e.updateDimensionsAndRerender(),t()}):(this.render(n.getFiltered(i)),t())},t.prototype.updateDimensionsAndRerender=function(){var t=this.filterContainer,e=this.filterItems,r=this.options.filter;t.updateDimensions(),this.render(e.getFiltered(r))},t.FilterContainer=I,t.FilterItem=C,t.defaultOptions=m,t.installAsJQueryPlugin=j,t}(),q=e.a=_},function(t,e,r){var n,i;
/*!
* imagesLoaded v4.1.4
* JavaScript is all like "You images are done yet or what?"
* MIT License
*/
/*!
* imagesLoaded v4.1.4
* JavaScript is all like "You images are done yet or what?"
* MIT License
*/
!function(o,s){"use strict";n=[r(2)],void 0===(i=function(t){return function(t,e){var r=t.jQuery,n=t.console;function i(t,e){for(var r in e)t[r]=e[r];return t}var o=Array.prototype.slice;function s(t,e,a){if(!(this instanceof s))return new s(t,e,a);var l=t;"string"==typeof t&&(l=document.querySelectorAll(t)),l?(this.elements=function(t){if(Array.isArray(t))return t;if("object"==typeof t&&"number"==typeof t.length)return o.call(t);return[t]}(l),this.options=i({},this.options),"function"==typeof e?a=e:i(this.options,e),a&&this.on("always",a),this.getImages(),r&&(this.jqDeferred=new r.Deferred),setTimeout(this.check.bind(this))):n.error("Bad element for imagesLoaded "+(l||t))}s.prototype=Object.create(e.prototype),s.prototype.options={},s.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},s.prototype.addElementImages=function(t){"IMG"==t.nodeName&&this.addImage(t),!0===this.options.background&&this.addElementBackgroundImages(t);var e=t.nodeType;if(e&&a[e]){for(var r=t.querySelectorAll("img"),n=0;n<r.length;n++){var i=r[n];this.addImage(i)}if("string"==typeof this.options.background){var o=t.querySelectorAll(this.options.background);for(n=0;n<o.length;n++){var s=o[n];this.addElementBackgroundImages(s)}}}};var a={1:!0,9:!0,11:!0};function l(t){this.img=t}function h(t,e){this.url=t,this.element=e,this.img=new Image}return s.prototype.addElementBackgroundImages=function(t){var e=getComputedStyle(t);if(e)for(var r=/url\((['"])?(.*?)\1\)/gi,n=r.exec(e.backgroundImage);null!==n;){var i=n&&n[2];i&&this.addBackground(i,t),n=r.exec(e.backgroundImage)}},s.prototype.addImage=function(t){var e=new l(t);this.images.push(e)},s.prototype.addBackground=function(t,e){var r=new h(t,e);this.images.push(r)},s.prototype.check=function(){var t=this;function e(e,r,n){setTimeout(function(){t.progress(e,r,n)})}this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?this.images.forEach(function(t){t.once("progress",e),t.check()}):this.complete()},s.prototype.progress=function(t,e,r){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&n&&n.log("progress: "+r,t,e)},s.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){var e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},l.prototype=Object.create(e.prototype),l.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.src)},l.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},l.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.img,e])},l.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},l.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},l.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},l.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},h.prototype=Object.create(l.prototype),h.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},h.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},h.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},s.makeJQueryPlugin=function(e){(e=e||t.jQuery)&&((r=e).fn.imagesLoaded=function(t,e){return new s(this,t,e).jqDeferred.promise(r(this))})},s.makeJQueryPlugin(),s}(o,t)}.apply(e,n))||(t.exports=i)}("undefined"!=typeof window?window:this)},function(t,e,r){var n,i;"undefined"!=typeof window&&window,void 0===(i="function"==typeof(n=function(){"use strict";function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var r=this._events=this._events||{},n=r[t]=r[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var r=this._onceEvents=this._onceEvents||{};return(r[t]=r[t]||{})[e]=!0,this}},e.off=function(t,e){var r=this._events&&this._events[t];if(r&&r.length){var n=r.indexOf(e);return-1!=n&&r.splice(n,1),this}},e.emitEvent=function(t,e){var r=this._events&&this._events[t];if(r&&r.length){r=r.slice(0),e=e||[];for(var n=this._onceEvents&&this._onceEvents[t],i=0;i<r.length;i++){var o=r[i];n&&n[o]&&(this.off(t,o),delete n[o]),o.apply(this,e)}return this}},e.allOff=function(){delete this._events,delete this._onceEvents},t})?n.call(e,r,e,t):n)||(t.exports=i)},,function(t,e,r){"use strict";r.r(e);var n=r(0);r.d(e,"default",function(){return n.a})}]).default;