Browse Source

getSorter; getText for IE8

pull/563/head
David DeSandro 12 years ago
parent
commit
d904c7d2c7
  1. 3
      examples/filter-sort.html
  2. 23
      isotope.js
  3. 11
      notes.md

3
examples/filter-sort.html

@ -193,7 +193,8 @@ docReady( function() {
if ( key === 'filter' && value === 'number-greater-than-50' ) { if ( key === 'filter' && value === 'number-greater-than-50' ) {
value = function( elem ) { value = function( elem ) {
return parseInt( elem.querySelector('.number').textContent, 10 ) > 40; var numberText = getText( elem.querySelector('.number') );
return parseInt( numberText, 10 ) > 40;
}; };
} }
console.log( key, value ); console.log( key, value );

23
isotope.js

@ -181,9 +181,20 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, layoutMode
} }
// concat all sortBy and sortHistory // concat all sortBy and sortHistory
var sortBys = [].concat.apply( sortByOpt, this.sortHistory ); var sortBys = [].concat.apply( sortByOpt, this.sortHistory );
var sortAsc = this.options.sortAscending;
// sort magic // sort magic
this.filteredItems.sort( function sorter( itemA, itemB ) { var sorter = getSorter( sortBys, this.options.sortAscending );
this.filteredItems.sort( sorter );
// keep track of sortBy History
var lastSortBy = this.sortHistory[ this.sortHistory.length - 1 ];
if ( sortByOpt !== lastSortBy ) {
// add to front, oldest goes in last
this.sortHistory.unshift( sortByOpt );
}
};
// returns a function used for sorting
function getSorter( sortBys, sortAsc ) {
return function sorter( itemA, itemB ) {
// cycle through all sortKeys // cycle through all sortKeys
for ( var i = 0, len = sortBys.length; i < len; i++ ) { for ( var i = 0, len = sortBys.length; i < len; i++ ) {
var sortBy = sortBys[i]; var sortBy = sortBys[i];
@ -197,14 +208,8 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, layoutMode
} }
} }
return 0; return 0;
});
// keep track of sortBy History
var lastSortBy = this.sortHistory[ this.sortHistory.length - 1 ];
if ( sortByOpt !== lastSortBy ) {
// add to front, oldest goes in last
this.sortHistory.unshift( sortByOpt );
}
}; };
}
// -------------------------- methods -------------------------- // // -------------------------- methods -------------------------- //

11
notes.md

@ -6,13 +6,6 @@ getSortData shorthand
filter filter
## bugs updateSortData
transitionDuration = '2s'
hide most
reveal,
then while transitioning, sort
items jump into place :(
- could be problem with EventEmitter
## bugs

Loading…
Cancel
Save