-
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})}function o(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}var s=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]=s(t[n],"object"==typeof r[n]?r[n]:{})):r[n]=t[n];return r},a=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)}},l=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},p=function(t,e){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++){if(t[r].props.index!==e[r].props.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 p=function(t){return t?" For further help read here: "+t:""};if(Array.isArray(n)){var h=!1;if(n.forEach(function(t){t===e&&(h=!0)}),!h)throw new Error('Filterizr: allowed values for option "'+t+'" are: '+n.map(function(t){return'"'+t+'"'}).join(", ")+'. Value received: "'+e+'".'+p(i))}else if("string"==typeof e&&n instanceof RegExp){if(!e.match(n))throw new Error('Filterizr: invalid value "'+e+'" for option "'+t+'" received.'+p(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"],g=function(){},v=function(){function t(){}return t.prototype.debounceEventHandler=function(t){return a(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}(),y={animationDuration:.5,callbacks:{onInit:g,onFilteringStart:g,onFilteringEnd:g,onShufflingStart:g,onShufflingEnd:g,onSortingStart:g,onSortingEnd:g},controlsSelector:"",delay:0,delayMode:"progressive",easing:"ease-out",filter:"all",filterOutCss:{opacity:0,transform:"scale(0.5)"},filterInCss:{opacity:1,transform:"scale(1)"},gridSelector:".filtr-container",gridItemsSelector:".filtr-item",layout:"sameSize",multifilterLogicalOperator:"or",searchTerm:"",setupControls:!0},m=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._toggle(this._filter,t)},t.prototype._toggle=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}(),E=function(){return(E=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)},C=function(){function t(t){var e=s(y,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=s(this.convertToOptions(this._options),this.validate(t));this._options=this.convertToFilterizrOptions(e)},t.prototype.convertToFilterizrOptions=function(t){return E({},t,{filter:new m(t.filter)})},t.prototype.convertToOptions=function(t){return E({},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}(),w=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.initialize=function(){this.setupFilterControls(),this.setupShuffleControls(),this.setupSearchControls(),this.setupSortControls()},t.prototype.destroy=function(){this.destroyFilterControls(),this.destroyShuffleControls(),this.destroySearchControls(),this.destroySortControls()},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=a(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}(),b=r(1),S=function(){function t(t,e,r){var n=this;this.options=r,this.node=t;var s=this.options.get(),a=(s.animationDuration,s.delay,s.delayMode,s.filterOutCss);s.easing;this.props={data:o(this.node),filteredOut:!1,index:e,lastPosition:{left:0,top:0},onTransitionEndHandler:function(){n.props.filteredOut?(n.node.classList.add("filteredOut"),i(n.node,{zIndex:-1e3})):(n.node.classList.remove("filteredOut"),i(n.node,{zIndex:""}))},sortData:this.node.getAttribute("data-sort"),w:this.getWidth(),h:this.getHeight()},i(this.node,Object.assign({},a,{"-webkit-backface-visibility":"hidden",perspective:"1000px","-webkit-perspective":"1000px","-webkit-transform-style":"preserve-3d",position:"absolute"})),this.setTransitionStyle(),this.bindEvents()}return t.prototype.filterIn=function(t,e){i(this.node,Object.assign({},e,{transform:(e.transform||"")+" translate3d("+t.left+"px, "+t.top+"px, 0)"})),this.props.lastPosition=t,this.props.filteredOut=!1},t.prototype.filterOut=function(t){var e=this.props.lastPosition;i(this.node,Object.assign({},t,{transform:(t.transform||"")+" translate3d("+e.left+"px, "+e.top+"px, 0)"})),this.props.filteredOut=!0},t.prototype.getTransitionDelay=function(t,e){var r=0;return"progressive"===e?r=t*this.props.index:this.props.index%2==0&&(r=t),r},t.prototype.contentsMatchSearch=function(t){return Boolean(this.getContentsLowercase().includes(t))},t.prototype.getContentsLowercase=function(){return this.node.textContent.toLowerCase()},t.prototype.getCategories=function(){return this.node.getAttribute("data-category").split(/\s*,\s*/g)},t.prototype.getHeight=function(){return this.node.clientHeight},t.prototype.getWidth=function(){return this.node.clientWidth},t.prototype.trigger=function(t){var e=new Event(t);this.node.dispatchEvent(e)},t.prototype.updateDimensions=function(){this.props.w=this.getWidth(),this.props.h=this.getHeight()},t.prototype.bindEvents=function(){var t=this;d.forEach(function(e){t.node.addEventListener(e,t.props.onTransitionEndHandler)})},t.prototype.unbindEvents=function(){var t=this;d.forEach(function(e){t.node.removeEventListener(e,t.props.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?b(this.node,function(){setTimeout(function(){i(t.node,{transition:t.getTransitionStyle()})},10)}):setTimeout(function(){i(t.node,{transition:t.getTransitionStyle()})},10)},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.");this.node=t,this.options=e,i(this.node,{padding:0,position:"relative",width:"100%",display:"flex",flexWrap:"wrap"});var r=this.getFilterItems(this.options);if(!r.length)throw new Error("Filterizr: cannot initialize empty container. Make sure the gridItemsSelector option corresponds to the selector of your grid's items");this.props={filterItems:r,w:this.getWidth(),h:0,onTransitionEndHandler:null},this.updateFilterItemsDimensions()}return t.prototype.destroy=function(){this.node.removeAttribute("style"),Array.from(this.node.querySelectorAll(this.options.get().gridItemsSelector)).forEach(function(t){return t.removeAttribute("style")}),this.unbindEvents(this.options.get().callbacks)},t.prototype.getFilterItems=function(t){return Array.from(this.node.querySelectorAll(t.get().gridItemsSelector)).map(function(e,r){return new S(e,r,t)})},t.prototype.push=function(t,e){var r=this.props.filterItems,n=t.cloneNode(!0);n.removeAttribute("style"),this.node.appendChild(n),this.props.filterItems.push(new S(n,r.length,e))},t.prototype.calculateColumns=function(){return Math.round(this.props.w/this.props.filterItems[0].props.w)},t.prototype.updateFilterItemsTransitionStyle=function(t){var e=t.animationDuration,r=t.easing,n=t.delay,o=t.delayMode;this.props.filterItems.forEach(function(t){return i(t.node,{transition:"all "+e+"s "+r+" "+t.getTransitionDelay(n,o)+"ms"})})},t.prototype.updateHeight=function(t){this.props.h=t,i(this.node,{height:t+"px"})},t.prototype.updateWidth=function(){this.props.w=this.getWidth()},t.prototype.updateFilterItemsDimensions=function(){this.props.filterItems.forEach(function(t){return t.updateDimensions()})},t.prototype.updateDimensions=function(){this.updateWidth(),this.updateFilterItemsDimensions()},t.prototype.getWidth=function(){return this.node.clientWidth},t.prototype.bindEvents=function(t){var e=this;this.props.onTransitionEndHandler=t.onTransitionEnd,d.forEach(function(t){e.node.addEventListener(t,e.props.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.props.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}(),F=function(){function t(t,e){this._filterItems=t,this._options=e}return t.prototype.get=function(){return this._filterItems},t.prototype.set=function(t){this._filterItems=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"index"===t||"sortData"===t?e.props[t]:e.props.data[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=l(e)}while(p(e,r));return(r=l(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}(),_=function(t){var e=t.props.filterContainer,r=t.props.filterItems.getFiltered(t.options.get().filter.get()),n=0,i=0,o=r.map(function(t){var e=t.props,r=e.w,o=e.h,s={left:n,top:0};return n+=r,o>i&&(i=o),s});return e.updateHeight(i),o},L=function(t){var e=t.props.filterContainer,r=t.props.filterItems.getFiltered(t.options.get().filter.get()),n=0,i=r.map(function(t){var e=t.props.h,r={left:0,top:n};return n+=e,r});return e.updateHeight(n),i},O=function(t){var e=t.props.filterContainer,r=t.props.filterItems.getFiltered(t.options.get().filter.get()),n=e.props.w,i=r[0].props.h,o=0,s=0,a=r.map(function(t){var e=t.props.w;s+e>n&&(o++,s=0);var r={left:s,top:i*o};return s+=e,r});return e.updateHeight((o+1)*r[0].props.h),a},T=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].props.h,r-=e;return n},A=function(t){var e=t.props.filterContainer,r=t.props.filterItems.getFiltered(t.options.get().filter.get()),n=e.calculateColumns(),i=0,o=Array.apply(null,Array(n)).map(Number.prototype.valueOf,0),s=r.map(function(t,e){var s=t.props,a=s.w,l=s.h;e%n==0&&e>=n&&i++;var p=e-n*i;return o[p]+=l,{left:p*a,top:T(r,n,e)}});return e.updateHeight(Math.max.apply(Math,o)),s},H=function(t){var e=t.props,r=e.filterContainer,n=e.filterItems.getFiltered(t.options.get().filter.get()),i=r.calculateColumns(),o=0,s=n.map(function(t,e){var r=t.props,n=r.w,s=r.h;return e%i==0&&e>=i&&o++,{left:(e-i*o)*n,top:o*s}}),a=n[0]&&n[0].props.h||0;return r.updateHeight((o+1)*a),s},k=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.props.filterContainer,r=t.props.filterItems.getFiltered(t.options.get().filter.get()),n=new k(e.props.w),i=r.map(function(t){var e=t.props;return{w:e.w,h:e.h}});n.fit(i);var o=i.map(function(t){var e=t.fit;return{left:e.x,top:e.y}});return e.updateHeight(n.root.h),o},z=function(t,e){switch(t){case"horizontal":return _(e);case"vertical":return L(e);case"sameHeight":return O(e);case"sameWidth":return A(e);case"packed":return x(e);case"sameSize":default:return H(e)}};function D(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]:y;this._fltr=new W(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 j=function(){return(j=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),q=function(){function t(t,e){void 0===t&&(t=y.gridSelector),void 0===e&&(e={}),this.options=new C(e);var r=new I(u(t),this.options),n=this.options.get(),i=n.setupControls,o=n.controlsSelector;this.props=j({browserWindow:new v,filterContainer:r},i&&{filterControls:new w(this,o)},{filterItems:new F(r.props.filterItems,this.options),filterizrState:c.IDLE}),this._bindEvents(),this._renderWithImagesLoaded(this.options.get().callbacks.onInit)}return t.prototype.filter=function(t){this.props.filterContainer.trigger("filteringStart"),this.props.filterizrState=c.FILTERING,t=Array.isArray(t)?t.map(function(t){return t.toString()}):t.toString(),this.options.filter=t,this._render(this.props.filterItems.getSearched(this.options.searchTerm))},t.prototype.destroy=function(){var t=this.props,e=t.browserWindow,r=t.filterControls;t.filterContainer.destroy(),e.destroy(),this.options.get().setupControls&&r&&r.destroy()},t.prototype.insertItem=function(t){this.props.filterContainer.push(t,this.options),this._renderWithImagesLoaded()},t.prototype.sort=function(t,e){void 0===t&&(t="index"),void 0===e&&(e="asc");var r=this.props,n=r.filterContainer,i=r.filterItems;n.trigger("sortingStart"),this.props.filterizrState=c.SORTING,this._render(i.getSorted(t,e))},t.prototype.search=function(t){void 0===t&&(t=this.options.get().searchTerm),this.options.searchTerm=t.toLowerCase(),this._render(this.props.filterItems.getSearched(this.options.searchTerm))},t.prototype.shuffle=function(){var t=this.props,e=t.filterContainer,r=t.filterItems;e.trigger("shufflingStart"),this.props.filterizrState=c.SHUFFLING,this._render(r.getShuffled())},t.prototype.setOptions=function(t){t.callbacks&&this.props.filterContainer.unbindEvents(this.options.get().callbacks),this.options.set(t),(t.animationDuration||t.delay||t.delayMode||t.easing)&&this.props.filterContainer.updateFilterItemsTransitionStyle(this.options.getRaw()),(t.callbacks||t.animationDuration)&&this._rebindFilterContainerEvents(),"searchTerm"in t&&this.search(t.searchTerm),(t.filter||t.multifilterLogicalOperator)&&this.filter(this.options.filter)},t.prototype.toggleFilter=function(t){this.options.toggleFilter(t),this.filter(this.options.filter)},t.prototype._render=function(t){var e=this.options.get(),r=e.filterInCss,n=e.filterOutCss,i=e.layout;this.props.filterItems.getFilteredOut(this.options.filter).forEach(function(t){t.filterOut(n)});var o=z(i,this);t.forEach(function(t,e){t.filterIn(o[e],r)})},t.prototype._onTransitionEndCallback=function(){var t=this.props,e=t.filterizrState,r=t.filterContainer;switch(e){case c.FILTERING:r.trigger("filteringEnd");break;case c.SORTING:r.trigger("sortingEnd");break;case c.SHUFFLING:r.trigger("shufflingEnd")}this.props.filterizrState=c.IDLE},t.prototype._rebindFilterContainerEvents=function(){var t=this.props.filterContainer,e=this.options.get(),r=e.animationDuration,n=e.callbacks;t.unbindEvents(n),t.bindEvents(j({},n,{onTransitionEnd:a(this._onTransitionEndCallback.bind(this),r,!1)}))},t.prototype._bindEvents=function(){var t=this.props.browserWindow;this._rebindFilterContainerEvents(),t.setResizeEventHandler(this._updateDimensionsAndRerender.bind(this))},t.prototype._renderWithImagesLoaded=function(t){var e=this;void 0===t&&(t=g);var r=this.props.filterContainer;if(!!r.node.querySelectorAll("img").length)N(r.node,function(){e._updateDimensionsAndRerender(),t()});else{var n=this.props.filterItems,i=this.options.filter;this._render(n.getFiltered(i)),t()}},t.prototype._updateDimensionsAndRerender=function(){var t=this.props,e=t.filterContainer,r=t.filterItems,n=this.options.filter;e.updateDimensions(),this._render(r.getFiltered(n))},t.FilterContainer=I,t.FilterItem=S,t.defaultOptions=y,t.installAsJQueryPlugin=D,t}(),W=e.a=q},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 p(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 p(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)},p.prototype=Object.create(l.prototype),p.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())},p.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},p.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;