|
|
@ -402,20 +402,28 @@ var trim = String.prototype.trim ? |
|
|
|
|
|
|
|
|
|
|
|
// sort filteredItem order
|
|
|
|
// sort filteredItem order
|
|
|
|
proto._sort = function() { |
|
|
|
proto._sort = function() { |
|
|
|
var sortByOpt = this.options.sortBy; |
|
|
|
if ( !this.options.sortBy ) { |
|
|
|
if ( !sortByOpt ) { |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// concat all sortBy and sortHistory
|
|
|
|
// keep track of sortBy History
|
|
|
|
var sortBys = [].concat.apply( sortByOpt, this.sortHistory ); |
|
|
|
var sortBys = utils.makeArray( this.options.sortBy ); |
|
|
|
|
|
|
|
if ( !this._getIsSameSortBy( sortBys ) ) { |
|
|
|
|
|
|
|
// concat all sortBy and sortHistory, add to front, oldest goes in last
|
|
|
|
|
|
|
|
this.sortHistory = sortBys.concat( this.sortHistory ); |
|
|
|
|
|
|
|
} |
|
|
|
// sort magic
|
|
|
|
// sort magic
|
|
|
|
var itemSorter = getItemSorter( sortBys, this.options.sortAscending ); |
|
|
|
var itemSorter = getItemSorter( this.sortHistory, this.options.sortAscending ); |
|
|
|
this.filteredItems.sort( itemSorter ); |
|
|
|
this.filteredItems.sort( itemSorter ); |
|
|
|
// keep track of sortBy History
|
|
|
|
}; |
|
|
|
if ( sortByOpt != this.sortHistory[0] ) { |
|
|
|
|
|
|
|
// add to front, oldest goes in last
|
|
|
|
// check if sortBys is same as start of sortHistory
|
|
|
|
this.sortHistory.unshift( sortByOpt ); |
|
|
|
proto._getIsSameSortBy = function( sortBys ) { |
|
|
|
|
|
|
|
for ( var i=0; i < sortBys.length; i++ ) { |
|
|
|
|
|
|
|
if ( sortBys[i] != this.sortHistory[i] ) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// returns a function used for sorting
|
|
|
|
// returns a function used for sorting
|
|
|
|