From 8631c4ba8e68fc6d29962597cc86ff06606037a5 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 25 Jan 2018 02:30:55 +0100 Subject: more on profile --- public/assets/js/lib/views/details/files.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'public/assets/js/lib/views/details/files.js') diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js index a074e2a..b6f1794 100644 --- a/public/assets/js/lib/views/details/files.js +++ b/public/assets/js/lib/views/details/files.js @@ -41,32 +41,42 @@ var FilesView = FormView.extend({ files: [], sortedFiles: [], currentSort: 'name', - reverse: false, + reversed: false, + reverse: function(e){ + if (this.currentSort === 'name') { + this.sortByName() + } + else { + this.sortByDate() + } + }, sortByName: function(e){ e && e.preventDefault() if (this.currentSort !== 'name') { this.currentSort = 'name' - this.reverse = false + this.reversed = false } else { - this.reverse = !this.reverse + this.reversed = !this.reversed } this.sort((a,b) => cmp(a.filename, b.filename)) + return this }, sortByDate: function(e){ e && e.preventDefault() if (this.currentSort !== 'date') { this.currentSort = 'date' - this.reverse = true + this.reversed = true } else { - this.reverse = !this.reverse + this.reversed = !this.reversed } this.sort((a,b) => cmp(a.date, b.date)) + return this }, sort: function(f){ this.$el.empty() - this.sortedFiles = this.reverse ? this.files.sort(f) : this.files.sort(f).reverse() + this.sortedFiles = this.reversed ? this.files.sort(f) : this.files.sort(f).reverse() this.sortedFiles.forEach(file => { this.appendFile(file) }) -- cgit v1.2.3-70-g09d2