Fix numberSorter js error & add test

This commit is contained in:
Mottie 2014-03-13 18:47:40 -05:00
parent 99f53cd26b
commit e9bbec48b9
2 changed files with 6 additions and 3 deletions

View File

@ -729,7 +729,7 @@
}
// fall back to built-in numeric sort
// var sort = $.tablesorter["sort" + s](table, a[c], b[c], c, colMax[c], dir);
sort = c.numberSorter ? c.numberSorter(x[col], y[col], dir, colMax[col], table) :
sort = c.numberSorter ? c.numberSorter(a[col], b[col], dir, colMax[col], table) :
ts[ 'sortNumeric' + (dir ? 'Asc' : 'Desc') ](a[col], b[col], num, colMax[col], col, table);
} else {
// set a & b depending on sort direction

View File

@ -94,7 +94,7 @@ Core plugin tested
OPTIONS:
cssAsc, cssChildRow, cssDesc, cssHeader, cssHeaderRow, cssInfoBlock, dateFormat, emptyTo, headerList,
headers, ignoreCase, initialized, parsers, sortList, sortLocaleCompare, sortReset, stringTo, tableClass,
usNumberFormat, widgets (just zebra), sortAppend, sortForce, sortMultiSortKey, sortResetKey
usNumberFormat, widgets (just zebra), sortAppend, sortForce, sortMultiSortKey, sortResetKey, numberSorter
METHODS:
addRows, applyWidgets, destroy, sorton, sortReset, update/updateRow, updateAll, updateCell
@ -186,6 +186,9 @@ $(function(){
e.which = 1;
e.shiftKey = true;
c.$headers.eq(5).trigger(e);
},
numberSorter: function(a, b, dir){
return dir ? a-b : b-a;
}
});
@ -520,7 +523,7 @@ $(function(){
/************************************************
test sortForce, sortAppend, sortMultiSortKey and sortResetKey options
************************************************/
asyncTest( "sortForce, sortAppend, sortMultiSortKey & sortResetKey", function(){
asyncTest( "sortForce, sortAppend, sortMultiSortKey & sortResetKey; and numberSorter option", function(){
expect(3);
var count = 0;
tester.cacheCompare( table4, 3, [ 2, 1, 7, 6, 5, 3, 4, 8, 9, 10 ], 'force x2 + sorted x2 + append x2, ascending' );