Browse Source

add jQuery filtering

pull/563/head
David DeSandro 11 years ago
parent
commit
9bc0be3868
  1. 18
      js/isotope.js
  2. 1
      notes.md

18
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 -------------------------- //

1
notes.md

@ -9,6 +9,7 @@ move munge sorter to separate file?
## tests
filter
jQuery filtering
updateSortData

Loading…
Cancel
Save