sort after creating

This commit is contained in:
Carsten Otto 2015-04-16 23:10:36 +02:00
parent ead021b789
commit 0b00f36c60
4 changed files with 33 additions and 2 deletions

View file

@ -193,5 +193,21 @@ var TracksPages = {
/* fade flashes and alerts in automatically */
$(".alert").fadeOut(8000);
}, sort_container: function(container) {
function comparator(a, b) {
var contentA = $(a).attr('data-sort') || '';
var contentB = $(b).attr('data-sort') || '';
if (contentA > contentB) {
return 1;
}
if (contentB > contentA) {
return -1;
}
return 0;
}
var unsortedActions = container.children();
var sortedChildren = unsortedActions.sort(comparator);
container.append(sortedChildren);
}
};