diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-01-25 02:30:55 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-01-25 02:30:55 +0100 |
| commit | 8631c4ba8e68fc6d29962597cc86ff06606037a5 (patch) | |
| tree | 96038ee2b31d6c411ce4d92551bcea4bb7e39e2b /public/assets/js/lib/views/details/files.js | |
| parent | 6a902c4dd6af4a903f80477fa05f9e698e8f2144 (diff) | |
more on profile
Diffstat (limited to 'public/assets/js/lib/views/details/files.js')
| -rw-r--r-- | public/assets/js/lib/views/details/files.js | 22 |
1 files changed, 16 insertions, 6 deletions
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) }) |
