From df829b3210b8c5a668004f2f52dbfe7b5e749e9d Mon Sep 17 00:00:00 2001 From: Yiotis Kaltsikis Date: Wed, 24 Jan 2018 09:32:06 +0100 Subject: [PATCH] Deploy version 1.3.1 --- CHANGELOG.md | 3 +++ dist/jquery.filterizr.min.js | 4 ++-- package.json | 2 +- src/index.js | 4 ++-- tests/Filterizr.test.js | 8 ++++++++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b086cd..0e18c02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## Version 1.3.1 +* Fix bug where Filterizr would not be instantiated if the .filtr-container had more than one class names + ## Version 1.3.0 * Gave a corerewrite to the plugin, with ES6 and Babel, maintaining a backwards compatible API. * Added tests for most important methods. diff --git a/dist/jquery.filterizr.min.js b/dist/jquery.filterizr.min.js index 50e1f0d..5c0030c 100644 --- a/dist/jquery.filterizr.min.js +++ b/dist/jquery.filterizr.min.js @@ -4,7 +4,7 @@ * * @author Yiotis Kaltsikis * @see {@link http://yiotis.net/filterizr} -* @version 1.3.0 +* @version 1.3.1 * @license MIT License */ -!function(t){if(!t)throw new Error("Filterizr requires jQuery to work.");t.fn.filterizr=function(){var t="."+this.get(0).className,e=arguments;if(!this._fltr&&0===e.length||1===e.length&&"object"===l(e[0])){var r=e.length>0?e[0]:a.a;this._fltr=new n.a(t,r)}else if(e.length>=1&&"string"==typeof e[0]){var o=e[0],s=Array.prototype.slice.call(e,1),u=this._fltr;switch(o){case"filter":return u.filter.apply(u,i(s)),this;case"insertItem":return u.insertItem.apply(u,i(s)),this;case"toggleFilter":return u.toggleFilter.apply(u,i(s)),this;case"sort":return u.sort.apply(u,i(s)),this;case"shuffle":return u.shuffle.apply(u,i(s)),this;case"search":return u.search.apply(u,i(s)),this;case"setOptions":return u.setOptions.apply(u,i(s)),this;case"destroy":return u.destroy.apply(u,i(s)),delete this._fltr,this;default:throw new Error("Filterizr: "+o+" is not part of the Filterizr API. Please refer to the docs for more information.")}}return this}}(jQuery)},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=r(7),o=r(1),s=r(8),a=r(3),l=r(0),u=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:".filtr-container",r=arguments[1];i(this,t),this.options=Object(l.i)(a.a,r);var s=new o.a(e,this.options);if(!s.$node.length)throw new Error("Filterizr: could not find a container with the selector "+e+", to initialize Filterizr.");new n.a(this,this.options.controlsSelector),this.props={filterizrState:l.a.IDLE,searchTerm:"",sort:"index",sortOrder:"asc",FilterContainer:s,FilterItems:s.props.FilterItems,FilteredItems:[]},this.bindEvents(),this.filter(this.options.filter)}return u(t,[{key:"filter",value:function(t){var e=this.props,r=e.searchTerm,i=e.FilterContainer,n=e.FilterItems;i.trigger("filteringStart"),this.props.filterizrState=l.a.FILTERING,t=Array.isArray(t)?t.map(function(t){return t.toString()}):t.toString();var o=this.searchFilterItems(this.filterFilterItems(n,t),r);this.props.FilteredItems=o,this.render(o)}},{key:"destroy",value:function(){var t=this.props.FilterContainer,e=this.options.controlsSelector;t.destroy(),$(window).off("resize.Filterizr"),$(e+" *[data-filter]").off("click.Filterizr"),$(e+" *[data-multifilter]").off("click.Filterizr"),$(e+" *[data-shuffle]").off("click.Filterizr"),$(e+" *[data-search]").off("keyup.Filterizr"),$(e+" *[data-sortAsc]").off("click.Filterizr"),$(e+" *[data-sortDesc]").off("click.Filterizr")}},{key:"insertItem",value:function(t){var e=this.props.FilterContainer,r=t.clone().attr("style","");e.push(r,this.options);var i=this.filterFilterItems(this.props.FilterItems,this.options.filter);this.render(i)}},{key:"sort",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"index",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc",r=this.props,i=r.FilterContainer,n=r.FilterItems;i.trigger("sortingStart"),this.props.filterizrState=l.a.SORTING,this.props.FilterItems=this.sortFilterItems(n,t,e);var o=this.filterFilterItems(this.props.FilterItems,this.options.filter);this.props.FilteredItems=o,this.render(o)}},{key:"search",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.searchTerm,e=this.props.FilterItems,r=this.searchFilterItems(this.filterFilterItems(e,this.options.filter),t);this.props.FilteredItems=r,this.render(r)}},{key:"shuffle",value:function(){var t=this.props,e=t.FilterContainer,r=t.FilteredItems;e.trigger("shufflingStart"),this.props.filterizrState=l.a.SHUFFLING;var i=this.shuffleFilterItems(r);this.props.FilteredItems=i,this.render(i)}},{key:"setOptions",value:function(t){Object(l.c)("animationDuration",t.animationDuration,"number"),Object(l.c)("callbacks",t.callbacks,"object"),Object(l.c)("controlsSelector",t.controlsSelector,"string"),Object(l.c)("delay",t.delay,"number"),Object(l.c)("easing",t.easing,"string",l.e,"https://www.w3schools.com/cssref/css3_pr_transition-timing-function.asp"),Object(l.c)("delayMode",t.delayMode,"string",["progressive","alternate"]),Object(l.c)("filter",t.filter,"string|number|array"),Object(l.c)("filterOutCss",t.filterOutCss,"object"),Object(l.c)("filterInCss",t.filterOutCss,"object"),Object(l.c)("layout",t.layout,"string",["sameSize","vertical","horizontal","sameHeight","sameWidth","packed"]),Object(l.c)("multifilterLogicalOperator",t.multifilterLogicalOperator,"string",["and","or"]),Object(l.c)("setupControls",t.setupControls,"boolean"),this.options=Object(l.i)(this.options,t),(t.animationDuration||t.delay||t.delayMode||t.easing)&&this.props.FilterContainer.updateFilterItemsTransitionStyle(t.animationDuration,t.easing,t.delay,t.delayMode),(t.callbacks||t.animationDuration)&&this.rebindFilterContainerEvents(),t.filter&&this.filter(t.filter),t.multifilterLogicalOperator&&this.filter(this.options.filter)}},{key:"toggleFilter",value:function(t){var e=this.options.filter;"all"===e?e=t:Array.isArray(e)?Object(l.l)(e,t)?(e=e.filter(function(e){return e!==t}),1===e.length&&(e=e[0])):e.push(t):e=e===t?"all":[e,t],this.setOptions({filter:e}),this.filter(this.options.filter)}},{key:"filterFilterItems",value:function(t,e){var r=this.options.multifilterLogicalOperator;return"all"===e?t:t.filter(function(t){var i=t.getCategories();return Array.isArray(e)?"or"===r?Object(l.h)(i,e).length:Object(l.b)(e,i):Object(l.l)(i,e)})}},{key:"sortFilterItems",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"index",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"asc",i=Object(l.k)(t,function(t){return"index"!==e&&"sortData"!==e?t.props.data[e]:t.props[e]});return i="asc"===r?i:i.reverse()}},{key:"searchFilterItems",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props.searchTerm;return e?t.filter(function(t){return~t.getContentsLowercase().lastIndexOf(e)}):t}},{key:"shuffleFilterItems",value:function(t){for(var e=Object(l.j)(t);t.length>1&&Object(l.g)(t,e);)e=Object(l.j)(t);return e}},{key:"render",value:function(t){var e=this,r=this.options.multifilterLogicalOperator;this.props.FilterItems.filter(function(t){var i=t.getCategories(),n=e.options.filter;return Array.isArray(n)?"or"===r?!Object(l.h)(i,n).length:!Object(l.b)(n,i):!Object(l.l)(i,n)}).forEach(function(t){t.filterOut(e.options.filterOutCss)});var i=Object(s.a)(this.options.layout,this);t.forEach(function(t,r){t.filterIn(i[r],e.options.filterInCss)})}},{key:"onTransitionEndCallback",value:function(){var t=this.props,e=t.filterizrState,r=t.FilterContainer;switch(e){case l.a.FILTERING:r.trigger("filteringEnd");break;case l.a.SORTING:r.trigger("sortingEnd");break;case l.a.SHUFFLING:r.trigger("shufflingEnd")}this.props.filterizrState=l.a.IDLE}},{key:"rebindFilterContainerEvents",value:function(){var t=this,e=this.props.FilterContainer,r=this.options,i=r.animationDuration,n=r.callbacks;e.unbindEvents(),e.bindEvents(n),e.bindTransitionEnd(function(){t.onTransitionEndCallback()},i)}},{key:"bindEvents",value:function(){var t=this,e=this.props.FilterContainer;this.rebindFilterContainerEvents(),$(window).on("resize.Filterizr",Object(l.f)(function(){e.updateWidth(),e.updateFilterItemsDimensions(),t.filter(t.options.filter)},250))}}]),t}();e.a=c},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=r(0),o=function(){function t(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"";i(this,t),this.props={Filterizr:e,selector:r},this.setupFilterControls(),this.setupShuffleControls(),this.setupSearchControls(),this.setupSortControls()}return o(t,[{key:"setupFilterControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-filter]").on("click.Filterizr",function(t){var r=$(t.target),i=r.attr("data-filter");e.setOptions({filter:i}),e.filter(e.options.filter)}),$(r+"[data-multifilter]").on("click.Filterizr",function(t){var r=$(t.target),i=r.attr("data-multifilter");e.toggleFilter(i)})}},{key:"setupShuffleControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-shuffle]").on("click.Filterizr",function(){e.shuffle()})}},{key:"setupSearchControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-search]").on("keyup.Filterizr",Object(n.f)(function(t){var r=$(t.target),i=r.val();e.props.searchTerm=i.toLowerCase(),e.search(e.props.searchTerm)},250))}},{key:"setupSortControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-sortAsc]").on("click.Filterizr",function(){var t=$(r+"[data-sortOrder]").val();e.props.sortOrder="asc",e.sort(t,"asc")}),$(r+"[data-sortDesc]").on("click.Filterizr",function(){var t=$(r+"[data-sortOrder]").val();e.props.sortOrder="desc",e.sort(t,"desc")})}},{key:"destroy",value:function(){var t=this.props.selector;$(t+"[data-filter]").off("click.Filterizr"),$(t+"[data-multifilter]").off("click.Filterizr"),$(t+"[data-shuffle]").off("click.Filterizr"),$(t+"[data-search]").off("keyup.Filterizr"),$(t+"[data-sortAsc]").off("click.Filterizr"),$(t+"[data-sortDesc]").off("click.Filterizr")}}]),t}();e.a=s},function(t,e,r){"use strict";var i=r(9),n=r(10),o=r(11),s=r(12),a=r(13),l=r(14),u=function(t,e){switch(t){case"horizontal":return Object(i.a)(e);case"vertical":return Object(n.a)(e);case"sameHeight":return Object(o.a)(e);case"sameWidth":return Object(s.a)(e);case"sameSize":return Object(a.a)(e);case"packed":return Object(l.a)(e);default:return Object(a.a)(e)}};e.a=u},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=0,o=0,s=i.map(function(t){var e={left:n,top:0};return n+=t.props.w,t.props.h>o&&(o=t.props.h),e});return r.updateHeight(o),s};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=0,o=i.map(function(t){var e={left:0,top:n};return n+=t.props.h,e});return r.updateHeight(n),o};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=r.props.w,o=i[0].props.h,s=0,a=0,l=i.map(function(t){var e=t.props.w;a+e>n&&(s++,a=0);var r={left:a,top:o*s};return a+=e,r});return r.updateHeight((s+1)*i[0].props.h),l};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,o=r.calcColumns(),s=0,a=0,l=0,u=i.map(function(t,e){var r=t.props.h;return r>a&&(a=r),e%o==0&&e>=o&&(s++,l+=a,a=0),{left:(e-o*s)*t.props.w,top:n(i,o,e)}});return l+=a,r.updateHeight(l),u},n=function(t,e,r){var i=0;if(r=0;)i+=t[r].props.h,r-=e;return i};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=r.calcColumns(),o=0,s=i.map(function(t,e){return e%n==0&&e>=n&&o++,{left:(e-n*o)*t.props.w,top:o*t.props.h}});return r.updateHeight((o+1)*i[0].props.h),s};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,o=new n(r.props.w),s=i.map(function(t){return{w:t.props.w,h:t.props.h}});o.fit(s);var a=s.map(function(t){var e=t.fit;return{left:e.x,top:e.y}});return r.updateHeight(o.root.h),a},n=function(t){this.init(t)};n.prototype={init:function(t){this.root={x:0,y:0,w:t}},fit:function(t){var e,r,i,n=t.length,o=n>0?t[0].h:0;for(this.root.h=o,e=0;e0?r[0]:a.a;this._fltr=new n.a(e,o)}else if(r.length>=1&&"string"==typeof r[0]){var s=r[0],u=Array.prototype.slice.call(r,1),c=this._fltr;switch(s){case"filter":return c.filter.apply(c,i(u)),this;case"insertItem":return c.insertItem.apply(c,i(u)),this;case"toggleFilter":return c.toggleFilter.apply(c,i(u)),this;case"sort":return c.sort.apply(c,i(u)),this;case"shuffle":return c.shuffle.apply(c,i(u)),this;case"search":return c.search.apply(c,i(u)),this;case"setOptions":return c.setOptions.apply(c,i(u)),this;case"destroy":return c.destroy.apply(c,i(u)),delete this._fltr,this;default:throw new Error("Filterizr: "+s+" is not part of the Filterizr API. Please refer to the docs for more information.")}}return this}}(jQuery)},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=r(7),o=r(1),s=r(8),a=r(3),l=r(0),u=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:".filtr-container",r=arguments[1];i(this,t),this.options=Object(l.i)(a.a,r);var s=new o.a(e,this.options);if(!s.$node.length)throw new Error("Filterizr: could not find a container with the selector "+e+", to initialize Filterizr.");new n.a(this,this.options.controlsSelector),this.props={filterizrState:l.a.IDLE,searchTerm:"",sort:"index",sortOrder:"asc",FilterContainer:s,FilterItems:s.props.FilterItems,FilteredItems:[]},this.bindEvents(),this.filter(this.options.filter)}return u(t,[{key:"filter",value:function(t){var e=this.props,r=e.searchTerm,i=e.FilterContainer,n=e.FilterItems;i.trigger("filteringStart"),this.props.filterizrState=l.a.FILTERING,t=Array.isArray(t)?t.map(function(t){return t.toString()}):t.toString();var o=this.searchFilterItems(this.filterFilterItems(n,t),r);this.props.FilteredItems=o,this.render(o)}},{key:"destroy",value:function(){var t=this.props.FilterContainer,e=this.options.controlsSelector;t.destroy(),$(window).off("resize.Filterizr"),$(e+" *[data-filter]").off("click.Filterizr"),$(e+" *[data-multifilter]").off("click.Filterizr"),$(e+" *[data-shuffle]").off("click.Filterizr"),$(e+" *[data-search]").off("keyup.Filterizr"),$(e+" *[data-sortAsc]").off("click.Filterizr"),$(e+" *[data-sortDesc]").off("click.Filterizr")}},{key:"insertItem",value:function(t){var e=this.props.FilterContainer,r=t.clone().attr("style","");e.push(r,this.options);var i=this.filterFilterItems(this.props.FilterItems,this.options.filter);this.render(i)}},{key:"sort",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"index",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asc",r=this.props,i=r.FilterContainer,n=r.FilterItems;i.trigger("sortingStart"),this.props.filterizrState=l.a.SORTING,this.props.FilterItems=this.sortFilterItems(n,t,e);var o=this.filterFilterItems(this.props.FilterItems,this.options.filter);this.props.FilteredItems=o,this.render(o)}},{key:"search",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.searchTerm,e=this.props.FilterItems,r=this.searchFilterItems(this.filterFilterItems(e,this.options.filter),t);this.props.FilteredItems=r,this.render(r)}},{key:"shuffle",value:function(){var t=this.props,e=t.FilterContainer,r=t.FilteredItems;e.trigger("shufflingStart"),this.props.filterizrState=l.a.SHUFFLING;var i=this.shuffleFilterItems(r);this.props.FilteredItems=i,this.render(i)}},{key:"setOptions",value:function(t){Object(l.c)("animationDuration",t.animationDuration,"number"),Object(l.c)("callbacks",t.callbacks,"object"),Object(l.c)("controlsSelector",t.controlsSelector,"string"),Object(l.c)("delay",t.delay,"number"),Object(l.c)("easing",t.easing,"string",l.e,"https://www.w3schools.com/cssref/css3_pr_transition-timing-function.asp"),Object(l.c)("delayMode",t.delayMode,"string",["progressive","alternate"]),Object(l.c)("filter",t.filter,"string|number|array"),Object(l.c)("filterOutCss",t.filterOutCss,"object"),Object(l.c)("filterInCss",t.filterOutCss,"object"),Object(l.c)("layout",t.layout,"string",["sameSize","vertical","horizontal","sameHeight","sameWidth","packed"]),Object(l.c)("multifilterLogicalOperator",t.multifilterLogicalOperator,"string",["and","or"]),Object(l.c)("setupControls",t.setupControls,"boolean"),this.options=Object(l.i)(this.options,t),(t.animationDuration||t.delay||t.delayMode||t.easing)&&this.props.FilterContainer.updateFilterItemsTransitionStyle(t.animationDuration,t.easing,t.delay,t.delayMode),(t.callbacks||t.animationDuration)&&this.rebindFilterContainerEvents(),t.filter&&this.filter(t.filter),t.multifilterLogicalOperator&&this.filter(this.options.filter)}},{key:"toggleFilter",value:function(t){var e=this.options.filter;"all"===e?e=t:Array.isArray(e)?Object(l.l)(e,t)?(e=e.filter(function(e){return e!==t}),1===e.length&&(e=e[0])):e.push(t):e=e===t?"all":[e,t],this.setOptions({filter:e}),this.filter(this.options.filter)}},{key:"filterFilterItems",value:function(t,e){var r=this.options.multifilterLogicalOperator;return"all"===e?t:t.filter(function(t){var i=t.getCategories();return Array.isArray(e)?"or"===r?Object(l.h)(i,e).length:Object(l.b)(e,i):Object(l.l)(i,e)})}},{key:"sortFilterItems",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"index",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"asc",i=Object(l.k)(t,function(t){return"index"!==e&&"sortData"!==e?t.props.data[e]:t.props[e]});return i="asc"===r?i:i.reverse()}},{key:"searchFilterItems",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props.searchTerm;return e?t.filter(function(t){return~t.getContentsLowercase().lastIndexOf(e)}):t}},{key:"shuffleFilterItems",value:function(t){for(var e=Object(l.j)(t);t.length>1&&Object(l.g)(t,e);)e=Object(l.j)(t);return e}},{key:"render",value:function(t){var e=this,r=this.options.multifilterLogicalOperator;this.props.FilterItems.filter(function(t){var i=t.getCategories(),n=e.options.filter;return Array.isArray(n)?"or"===r?!Object(l.h)(i,n).length:!Object(l.b)(n,i):!Object(l.l)(i,n)}).forEach(function(t){t.filterOut(e.options.filterOutCss)});var i=Object(s.a)(this.options.layout,this);t.forEach(function(t,r){t.filterIn(i[r],e.options.filterInCss)})}},{key:"onTransitionEndCallback",value:function(){var t=this.props,e=t.filterizrState,r=t.FilterContainer;switch(e){case l.a.FILTERING:r.trigger("filteringEnd");break;case l.a.SORTING:r.trigger("sortingEnd");break;case l.a.SHUFFLING:r.trigger("shufflingEnd")}this.props.filterizrState=l.a.IDLE}},{key:"rebindFilterContainerEvents",value:function(){var t=this,e=this.props.FilterContainer,r=this.options,i=r.animationDuration,n=r.callbacks;e.unbindEvents(),e.bindEvents(n),e.bindTransitionEnd(function(){t.onTransitionEndCallback()},i)}},{key:"bindEvents",value:function(){var t=this,e=this.props.FilterContainer;this.rebindFilterContainerEvents(),$(window).on("resize.Filterizr",Object(l.f)(function(){e.updateWidth(),e.updateFilterItemsDimensions(),t.filter(t.options.filter)},250))}}]),t}();e.a=c},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=r(0),o=function(){function t(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"";i(this,t),this.props={Filterizr:e,selector:r},this.setupFilterControls(),this.setupShuffleControls(),this.setupSearchControls(),this.setupSortControls()}return o(t,[{key:"setupFilterControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-filter]").on("click.Filterizr",function(t){var r=$(t.target),i=r.attr("data-filter");e.setOptions({filter:i}),e.filter(e.options.filter)}),$(r+"[data-multifilter]").on("click.Filterizr",function(t){var r=$(t.target),i=r.attr("data-multifilter");e.toggleFilter(i)})}},{key:"setupShuffleControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-shuffle]").on("click.Filterizr",function(){e.shuffle()})}},{key:"setupSearchControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-search]").on("keyup.Filterizr",Object(n.f)(function(t){var r=$(t.target),i=r.val();e.props.searchTerm=i.toLowerCase(),e.search(e.props.searchTerm)},250))}},{key:"setupSortControls",value:function(){var t=this.props,e=t.Filterizr,r=t.selector;$(r+"[data-sortAsc]").on("click.Filterizr",function(){var t=$(r+"[data-sortOrder]").val();e.props.sortOrder="asc",e.sort(t,"asc")}),$(r+"[data-sortDesc]").on("click.Filterizr",function(){var t=$(r+"[data-sortOrder]").val();e.props.sortOrder="desc",e.sort(t,"desc")})}},{key:"destroy",value:function(){var t=this.props.selector;$(t+"[data-filter]").off("click.Filterizr"),$(t+"[data-multifilter]").off("click.Filterizr"),$(t+"[data-shuffle]").off("click.Filterizr"),$(t+"[data-search]").off("keyup.Filterizr"),$(t+"[data-sortAsc]").off("click.Filterizr"),$(t+"[data-sortDesc]").off("click.Filterizr")}}]),t}();e.a=s},function(t,e,r){"use strict";var i=r(9),n=r(10),o=r(11),s=r(12),a=r(13),l=r(14),u=function(t,e){switch(t){case"horizontal":return Object(i.a)(e);case"vertical":return Object(n.a)(e);case"sameHeight":return Object(o.a)(e);case"sameWidth":return Object(s.a)(e);case"sameSize":return Object(a.a)(e);case"packed":return Object(l.a)(e);default:return Object(a.a)(e)}};e.a=u},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=0,o=0,s=i.map(function(t){var e={left:n,top:0};return n+=t.props.w,t.props.h>o&&(o=t.props.h),e});return r.updateHeight(o),s};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=0,o=i.map(function(t){var e={left:0,top:n};return n+=t.props.h,e});return r.updateHeight(n),o};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=r.props.w,o=i[0].props.h,s=0,a=0,l=i.map(function(t){var e=t.props.w;a+e>n&&(s++,a=0);var r={left:a,top:o*s};return a+=e,r});return r.updateHeight((s+1)*i[0].props.h),l};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,o=r.calcColumns(),s=0,a=0,l=0,u=i.map(function(t,e){var r=t.props.h;return r>a&&(a=r),e%o==0&&e>=o&&(s++,l+=a,a=0),{left:(e-o*s)*t.props.w,top:n(i,o,e)}});return l+=a,r.updateHeight(l),u},n=function(t,e,r){var i=0;if(r=0;)i+=t[r].props.h,r-=e;return i};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,n=r.calcColumns(),o=0,s=i.map(function(t,e){return e%n==0&&e>=n&&o++,{left:(e-n*o)*t.props.w,top:o*t.props.h}});return r.updateHeight((o+1)*i[0].props.h),s};e.a=i},function(t,e,r){"use strict";var i=function(t){var e=t.props,r=e.FilterContainer,i=e.FilterItems,o=new n(r.props.w),s=i.map(function(t){return{w:t.props.w,h:t.props.h}});o.fit(s);var a=s.map(function(t){var e=t.fit;return{left:e.x,top:e.y}});return r.updateHeight(o.root.h),a},n=function(t){this.init(t)};n.prototype={init:function(t){this.root={x:0,y:0,w:t}},fit:function(t){var e,r,i,n=t.length,o=n>0?t[0].h:0;for(this.root.h=o,e=0;e { it('should return a new instance of the Filterizr class', () => { expect(filterizr instanceof Filterizr).toBe(true); }); + + it('should still work on containers with multiple class names', () => { + $('.filtr-container').addClass('randomclass1 randomclass2'); + const instantiateFreshFilterizr = () => { + new Filterizr('.filtr-container', DefaultOptions); + }; + expect(instantiateFreshFilterizr).not.toThrowError(); + }); }); describe('#destroy', () => {