mirror of
https://github.com/haiwen/seahub.git
synced 2025-10-21 10:51:17 +00:00
file sorting alternation
This commit is contained in:
@@ -293,8 +293,8 @@ define([
|
||||
'click #mv-dirents': 'mv',
|
||||
'click #cp-dirents': 'cp',
|
||||
'click #del-dirents': 'del',
|
||||
'click #by-name': 'sortByName',
|
||||
'click #by-time': 'sortByTime'
|
||||
'click .by-name': 'sortByName',
|
||||
'click .by-time': 'sortByTime'
|
||||
},
|
||||
|
||||
newDir: function() {
|
||||
@@ -450,8 +450,9 @@ define([
|
||||
},
|
||||
|
||||
sortByName: function() {
|
||||
$('.by-time .sort-icon').hide();
|
||||
var dirents = this.dir;
|
||||
var el = $('#by-name');
|
||||
var el = $('.by-name .sort-icon');
|
||||
|
||||
dirents.comparator = function(a, b) {
|
||||
if (a.get('is_dir') && b.get('is_file')) {
|
||||
@@ -467,17 +468,17 @@ define([
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
dirents.sort();
|
||||
this.$dirent_list.empty();
|
||||
dirents.each(this.addOne, this);
|
||||
el.toggleClass('icon-caret-up icon-caret-down');
|
||||
el.toggleClass('icon-caret-up icon-caret-down').show();
|
||||
dirents.comparator = null;
|
||||
},
|
||||
|
||||
sortByTime: function () {
|
||||
$('.by-name .sort-icon').hide();
|
||||
var dirents = this.dir;
|
||||
var el = $('#by-time');
|
||||
var el = $('.by-time .sort-icon');
|
||||
dirents.comparator = function(a, b) {
|
||||
if (a.get('is_dir') && b.get('is_file')) {
|
||||
return -1;
|
||||
@@ -491,7 +492,7 @@ define([
|
||||
dirents.sort();
|
||||
this.$dirent_list.empty();
|
||||
dirents.each(this.addOne, this);
|
||||
el.toggleClass('icon-caret-up icon-caret-down');
|
||||
el.toggleClass('icon-caret-up icon-caret-down').show();
|
||||
dirents.comparator = null;
|
||||
},
|
||||
|
||||
|
@@ -18,8 +18,8 @@ define([
|
||||
|
||||
events: {
|
||||
'click .repo-create': 'createRepo',
|
||||
'click #grp-repos .by-name': 'sortByName',
|
||||
'click #grp-repos .by-time': 'sortByTime'
|
||||
'click .by-name': 'sortByName',
|
||||
'click .by-time': 'sortByTime'
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
@@ -131,8 +131,9 @@ define([
|
||||
},
|
||||
|
||||
sortByName: function() {
|
||||
$('.by-time .sort-icon').hide();
|
||||
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
|
||||
var result = Common.compareTwoWord(a.get('name'), b.get('name'));
|
||||
if (el.hasClass('icon-caret-up')) {
|
||||
@@ -144,14 +145,15 @@ define([
|
||||
repos.sort();
|
||||
this.$tableBody.empty();
|
||||
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;
|
||||
|
||||
},
|
||||
|
||||
sortByTime: function() {
|
||||
$('.by-name .sort-icon').hide();
|
||||
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
|
||||
if (el.hasClass('icon-caret-down')) {
|
||||
return a.get('mtime') < b.get('mtime') ? 1 : -1;
|
||||
@@ -162,7 +164,7 @@ define([
|
||||
repos.sort();
|
||||
this.$tableBody.empty();
|
||||
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;
|
||||
},
|
||||
|
||||
|
@@ -114,8 +114,9 @@ define([
|
||||
},
|
||||
|
||||
sortByName: function() {
|
||||
$('.by-time .sort-icon').hide();
|
||||
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
|
||||
var result = Common.compareTwoWord(a.get('name'), b.get('name'));
|
||||
if (el.hasClass('icon-caret-up')) {
|
||||
@@ -127,13 +128,14 @@ define([
|
||||
repos.sort();
|
||||
this.$tableBody.empty();
|
||||
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;
|
||||
},
|
||||
|
||||
sortByTime: function() {
|
||||
$('.by-name .sort-icon').hide();
|
||||
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
|
||||
if (el.hasClass('icon-caret-down')) {
|
||||
return a.get('mtime') < b.get('mtime') ? 1 : -1;
|
||||
@@ -144,7 +146,7 @@ define([
|
||||
repos.sort();
|
||||
this.$tableBody.empty();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -139,8 +139,9 @@ define([
|
||||
},
|
||||
|
||||
sortByName: function() {
|
||||
$('.by-time .sort-icon').hide();
|
||||
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
|
||||
var result = Common.compareTwoWord(a.get('name'), b.get('name'));
|
||||
if (el.hasClass('icon-caret-up')) {
|
||||
@@ -152,13 +153,14 @@ define([
|
||||
repos.sort();
|
||||
this.$tableBody.empty();
|
||||
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;
|
||||
},
|
||||
|
||||
sortByTime: function() {
|
||||
$('.by-name .sort-icon').hide();
|
||||
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
|
||||
if (el.hasClass('icon-caret-down')) {
|
||||
return a.get('mtime') < b.get('mtime') ? 1 : -1;
|
||||
@@ -169,7 +171,7 @@ define([
|
||||
repos.sort();
|
||||
this.$tableBody.empty();
|
||||
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;
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user