1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 01:44:13 +00:00

file sorting alternation

This commit is contained in:
patrickgao
2015-07-09 17:16:10 +08:00
parent c90394bb08
commit f9282585b8
5 changed files with 34 additions and 27 deletions

View File

@@ -173,10 +173,10 @@
</th> </th>
<th class="star"></th> <th class="star"></th>
<th class="dirent-icon"></th> <th class="dirent-icon"></th>
<th><span class="dirent-name">{% trans "Name"%} <span id="by-name" class="icon-caret-up cspt"></span></span></th> <th class="by-name cspt"><span class="dirent-name">{% trans "Name"%} <span class="sort-icon icon-caret-up"></span></span></th>
<th class="dirent-op"></th> <th class="dirent-op"></th>
<th class="dirent-size">{% trans "Size"%}</th> <th class="dirent-size">{% trans "Size"%}</th>
<th class="dirent-update">{% trans "Last Update" %} <span id="by-time" class="icon-caret-down cspt"></span></th> <th class="dirent-update by-time cspt">{% trans "Last Update" %} <span class="sort-icon icon-caret-down hide"></span></th>
</tr> </tr>
</script> </script>
<script type="text/template" id="dirent-tmpl"> <script type="text/template" id="dirent-tmpl">
@@ -719,19 +719,19 @@
<script type="text/template" id="my-repos-hd-tmpl"> <script type="text/template" id="my-repos-hd-tmpl">
<tr> <tr>
<th width="4%"><!--icon--></th> <th width="4%"><!--icon--></th>
<th width="46%">{% trans "Name" %} <span class="by-name icon-caret-up cspt"></span></th> <th class="by-name cspt" width="46%">{% trans "Name" %} <span class="sort-icon icon-caret-down hide"></span></th>
<th width="10%"><!--op--></th> <th width="10%"><!--op--></th>
<th width="20%">{% trans "Size" %}</th> <th width="20%">{% trans "Size" %}</th>
<th width="20%">{% trans "Last Update" %} <span class="by-time icon-caret-down cspt"></span></th> <th class="by-time cspt" width="20%">{% trans "Last Update" %} <span class="sort-icon icon-caret-up"></span></th>
</tr> </tr>
</script> </script>
<script type="text/template" id="shared-repos-hd-tmpl"> <script type="text/template" id="shared-repos-hd-tmpl">
<tr> <tr>
<th width="4%"><!--icon--></th> <th width="4%"><!--icon--></th>
<th width="40%">{% trans "Name" %} <span class="by-name icon-caret-up cspt"></span></th> <th class="by-name cspt" width="40%">{% trans "Name" %} <span class="sort-icon icon-caret-down hide"></span></th>
<th width="8%"><!--op--></th> <th width="8%"><!--op--></th>
<th width="14%">{% trans "Size" %}</th> <th width="14%">{% trans "Size" %}</th>
<th width="18%">{% trans "Last Update" %} <span class="by-time icon-caret-down cspt"></span></th> <th class="by-time cspt" width="18%">{% trans "Last Update" %} <span class="sort-icon icon-caret-up"></span></th>
<th width="16%">{% trans "Shared By" %}</th> <th width="16%">{% trans "Shared By" %}</th>
</tr> </tr>
</script> </script>

View File

@@ -293,8 +293,8 @@ define([
'click #mv-dirents': 'mv', 'click #mv-dirents': 'mv',
'click #cp-dirents': 'cp', 'click #cp-dirents': 'cp',
'click #del-dirents': 'del', 'click #del-dirents': 'del',
'click #by-name': 'sortByName', 'click .by-name': 'sortByName',
'click #by-time': 'sortByTime' 'click .by-time': 'sortByTime'
}, },
newDir: function() { newDir: function() {
@@ -450,8 +450,9 @@ define([
}, },
sortByName: function() { sortByName: function() {
$('.by-time .sort-icon').hide();
var dirents = this.dir; var dirents = this.dir;
var el = $('#by-name'); var el = $('.by-name .sort-icon');
dirents.comparator = function(a, b) { dirents.comparator = function(a, b) {
if (a.get('is_dir') && b.get('is_file')) { if (a.get('is_dir') && b.get('is_file')) {
@@ -467,17 +468,17 @@ define([
return result; return result;
} }
}; };
dirents.sort(); dirents.sort();
this.$dirent_list.empty(); this.$dirent_list.empty();
dirents.each(this.addOne, this); 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; dirents.comparator = null;
}, },
sortByTime: function () { sortByTime: function () {
$('.by-name .sort-icon').hide();
var dirents = this.dir; var dirents = this.dir;
var el = $('#by-time'); var el = $('.by-time .sort-icon');
dirents.comparator = function(a, b) { dirents.comparator = function(a, b) {
if (a.get('is_dir') && b.get('is_file')) { if (a.get('is_dir') && b.get('is_file')) {
return -1; return -1;
@@ -491,7 +492,7 @@ define([
dirents.sort(); dirents.sort();
this.$dirent_list.empty(); this.$dirent_list.empty();
dirents.each(this.addOne, this); 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; dirents.comparator = null;
}, },

View File

@@ -18,8 +18,8 @@ define([
events: { events: {
'click .repo-create': 'createRepo', 'click .repo-create': 'createRepo',
'click #grp-repos .by-name': 'sortByName', 'click .by-name': 'sortByName',
'click #grp-repos .by-time': 'sortByTime' 'click .by-time': 'sortByTime'
}, },
initialize: function(options) { initialize: function(options) {
@@ -131,8 +131,9 @@ define([
}, },
sortByName: function() { sortByName: function() {
$('.by-time .sort-icon').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')) {
@@ -144,14 +145,15 @@ 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').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;
@@ -162,7 +164,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;
}, },

View File

@@ -114,8 +114,9 @@ define([
}, },
sortByName: function() { sortByName: function() {
$('.by-time .sort-icon').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')) {
@@ -127,13 +128,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').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;
@@ -144,7 +146,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;
} }

View File

@@ -139,8 +139,9 @@ define([
}, },
sortByName: function() { sortByName: function() {
$('.by-time .sort-icon').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')) {
@@ -152,13 +153,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').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;
@@ -169,7 +171,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;
}, },