diff options
Diffstat (limited to 'public/assets/js/lib/views')
| -rw-r--r-- | public/assets/js/lib/views/details/files.js | 22 | ||||
| -rw-r--r-- | public/assets/js/lib/views/index/threadbox.js | 9 | ||||
| -rw-r--r-- | public/assets/js/lib/views/profile/profile.js | 7 |
3 files changed, 29 insertions, 9 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) }) diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js index 01d1de4..157b672 100644 --- a/public/assets/js/lib/views/index/threadbox.js +++ b/public/assets/js/lib/views/index/threadbox.js @@ -9,6 +9,7 @@ var ThreadBox = View.extend({ this.template = this.$(".template").html() this.keywordTemplate = this.$(".keywordTemplate").html() this.welcomeTemplate = this.$(".welcomeTemplate").html() + this.profileTemplate = this.$(".profileTemplate").html() }, load: function(data){ @@ -19,6 +20,10 @@ var ThreadBox = View.extend({ this.appendKeyword(data.keyword) this.appendThreads(data.threads) } + else if (data.user) { + this.appendProfile(data.user) + this.appendThreads(data.threads) + } else { if (this.options.latest) { var latest = data.threads.sort( (a,b) => { @@ -123,4 +128,8 @@ var ThreadBox = View.extend({ this.$el.append(this.welcomeTemplate) }, + appendProfile: function(user){ + this.$el.append(this.profileTemplate.replace(/{{username}}/g, user.username)) + }, + }) diff --git a/public/assets/js/lib/views/profile/profile.js b/public/assets/js/lib/views/profile/profile.js index 4396414..14511f9 100644 --- a/public/assets/js/lib/views/profile/profile.js +++ b/public/assets/js/lib/views/profile/profile.js @@ -24,9 +24,10 @@ var ProfileView = View.extend({ this.populate(user) // this.populateComments(topComments) // this.comments.load(data.comments, data.thread) - this.gallery.load(data.files) - this.files.load(data.files) - this.threadbox.load({ threads: data.threads }) + this.gallery.load(files) + this.files.load(files) + this.files.sortByDate().reverse() + this.threadbox.load({ threads, user }) }, populate: function(user){ |
