diff --git a/js/isotope.js b/js/isotope.js index a5969f6..60e6fea 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -8,6 +8,10 @@ 'use strict'; +// -------------------------- vars -------------------------- // + +var jQuery = window.jQuery; + // -------------------------- helpers -------------------------- // // extend objects @@ -124,7 +128,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode var hiddenMatched = []; var visibleUnmatched = []; - var test = getFilterTest( filter ); + var test = this._getFilterTest( filter ); // test each item for ( var i=0, len = items.length; i < len; i++ ) { @@ -163,10 +167,14 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode return matches; }; - // get a function or a matchesSelector test given the filter - function getFilterTest( filter ) { + // get a jQuery, function, or a matchesSelector test given the filter + Isotope.prototype._getFilterTest = function( filter ) { var test; - if ( typeof filter === 'function' ) { + if ( jQuery && this.options.isJQueryFiltering ) { + test = function( item ) { + return jQuery( item.element ).is( filter ); + }; + } else if ( typeof filter === 'function' ) { test = function( item ) { return filter( item.element ); }; @@ -176,7 +184,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode }; } return test; - } + }; // -------------------------- sorting -------------------------- // diff --git a/notes.md b/notes.md index 2377b74..eab3d35 100644 --- a/notes.md +++ b/notes.md @@ -9,6 +9,7 @@ move munge sorter to separate file? ## tests filter + jQuery filtering updateSortData