Filter & sort magical layouts http://isotope.metafizzy.co
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 lines
1.4 KiB

( function() {
'use strict';
function getItemsText( iso ) {
var texts = [];
for ( var i=0, len = iso.filteredItems.length; i < len; i++ ) {
var item = iso.filteredItems[i];
texts.push( getText( item.element ) );
}
return texts.join(',');
}
test( 'sorting', function() {
// sorting with history
( function() {
var iso = new Isotope( '#sorting1', {
layoutMode: 'fitRows',
transitionDuration: 0,
getSortData: {
letter: 'b',
number: 'i'
},
sortBy: 'number'
});
iso.arrange({ sortBy: 'letter' });
var texts = getItemsText( iso );
equal( texts, 'A1,A2,A3,A4,B1,B2,B4', 'items sorted by letter, then number, via history' );
iso.destroy();
})();
// sorting with array
( function() {
var iso = new Isotope( '#sorting1', {
layoutMode: 'fitRows',
transitionDuration: 0,
getSortData: {
letter: 'b',
number: 'i'
},
sortBy: [ 'letter', 'number' ]
});
equal( getItemsText( iso ), 'A1,A2,A3,A4,B1,B2,B4', 'sortBy array' );
iso.arrange({
sortAscending: false
});
equal( getItemsText( iso ), 'B4,B2,B1,A4,A3,A2,A1', 'sortAscending false' );
iso.arrange({
sortAscending: {
letter: true,
number: false
}
});
equal( getItemsText( iso ), 'A4,A3,A2,A1,B4,B2,B1', 'sortAscending with object' );
iso.destroy();
})();
});
})();