1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-10-21 19:00:12 +00:00

[sort] new interaction for 'myhome shared libs'

This commit is contained in:
llj
2015-07-14 11:46:20 +08:00
parent 1a406f9b26
commit b29974901c

View File

@@ -100,8 +100,9 @@ define([
}, },
sortByName: function() { sortByName: function() {
$('.by-time .sort-icon', this.$table).hide();
var repos = this.repos; var repos = this.repos;
var el = $('.by-name', this.$table); var el = $('.by-name .sort-icon', this.$table);
repos.comparator = function(a, b) { // a, b: model repos.comparator = function(a, b) { // a, b: model
var result = Common.compareTwoWord(a.get('name'), b.get('name')); var result = Common.compareTwoWord(a.get('name'), b.get('name'));
if (el.hasClass('icon-caret-up')) { if (el.hasClass('icon-caret-up')) {
@@ -113,13 +114,14 @@ define([
repos.sort(); repos.sort();
this.$tableBody.empty(); this.$tableBody.empty();
repos.each(this.addOne, this); repos.each(this.addOne, this);
el.toggleClass('icon-caret-up icon-caret-down'); el.toggleClass('icon-caret-up icon-caret-down').show();
repos.comparator = null; repos.comparator = null;
}, },
sortByTime: function() { sortByTime: function() {
$('.by-name .sort-icon', this.$table).hide();
var repos = this.repos; var repos = this.repos;
var el = $('.by-time', this.$table); var el = $('.by-time .sort-icon', this.$table);
repos.comparator = function(a, b) { // a, b: model repos.comparator = function(a, b) { // a, b: model
if (el.hasClass('icon-caret-down')) { if (el.hasClass('icon-caret-down')) {
return a.get('mtime') < b.get('mtime') ? 1 : -1; return a.get('mtime') < b.get('mtime') ? 1 : -1;
@@ -130,7 +132,7 @@ define([
repos.sort(); repos.sort();
this.$tableBody.empty(); this.$tableBody.empty();
repos.each(this.addOne, this); repos.each(this.addOne, this);
el.toggleClass('icon-caret-up icon-caret-down'); el.toggleClass('icon-caret-up icon-caret-down').show();
repos.comparator = null; repos.comparator = null;
} }