1

Sorting arrows

This commit is contained in:
Alex Yatskov 2015-03-27 12:46:59 +09:00
parent 18458b83c0
commit d509008bc1
2 changed files with 37 additions and 7 deletions

View File

@ -96,13 +96,34 @@
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<thead> <thead>
<tr> <tr>
<th><a href="javascript:sortReviewsBy('name');">Name</a></th> <th>
<th><a href="javascript:sortReviewsBy('distanceToUser');">Distance to user</a></th> <a href="javascript:sortReviewsBy('name');">Name</a>
<th><a href="javascript:sortReviewsBy('closestStn');">Closest station</a></th> <span class="sort-icon glyphicon text-muted" data-sort="name"></span>
<th><a href="javascript:sortReviewsBy('distanceToStn');">Distance to station</a></th> </th>
<th><a href="javascript:sortReviewsBy('compatibility');">Compatibility</a></th> <th>
<th><a href="javascript:sortReviewsBy('score');">Score</a></th> <a href="javascript:sortReviewsBy('distanceToUser');">Distance to user</a>
<th><a href="javascript:sortReviewsBy('accessCount');">Access count</a></th> <span class="sort-icon glyphicon text-muted" data-sort="distanceToUser"></span>
</th>
<th>
<a href="javascript:sortReviewsBy('closestStn');">Closest station</a>
<span class="sort-icon glyphicon text-muted" data-sort="closestStn"></span>
</th>
<th>
<a href="javascript:sortReviewsBy('distanceToStn');">Distance to station</a>
<span class="sort-icon glyphicon text-muted" data-sort="distanceToStn"></span>
</th>
<th>
<a href="javascript:sortReviewsBy('compatibility');">Compatibility</a>
<span class="sort-icon glyphicon text-muted" data-sort="compatibility"></span>
</th>
<th>
<a href="javascript:sortReviewsBy('score');">Score</a>
<span class="sort-icon glyphicon text-muted" data-sort="score"></span>
</th>
<th>
<a href="javascript:sortReviewsBy('accessCount');">Access count</a>
<span class="sort-icon glyphicon text-muted" data-sort="accessCount"></span>
</th>
</tr> </tr>
</thead> </thead>
{{#each records}} {{#each records}}

View File

@ -157,6 +157,15 @@
$('#records').empty(); $('#records').empty();
$('#records').append(template({records: results.records})); $('#records').append(template({records: results.records}));
$('span.sort-icon').css('visibility', 'hidden');
var currentColumn = $('span.sort-icon[data-sort="' + _ctx.sortKey + '"]').css('visibility', 'visible');
if (_ctx.sortAsc) {
currentColumn.removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
}
else {
currentColumn.removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
}
if (results.records.length === 0) { if (results.records.length === 0) {
$('#resultPanel').slideUp(); $('#resultPanel').slideUp();
} }