From ebac7f79d32c524de750adc3bcf1cc539625d552 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 7 Sep 2015 14:04:18 -0400 Subject: split up partials and stub in mailbox frontend --- public/assets/js/lib/views/index/threadbox.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'public/assets/js/lib/views/index/threadbox.js') diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js index bcaaceb..eee7a5c 100644 --- a/public/assets/js/lib/views/index/threadbox.js +++ b/public/assets/js/lib/views/index/threadbox.js @@ -1,11 +1,3 @@ -/* -age_class -views_class -comments_class -size_class -files_class -*/ - var ThreadBox = View.extend({ el: ".threads", @@ -15,10 +7,15 @@ var ThreadBox = View.extend({ initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() + this.keywordTemplate = this.$(".keywordTemplate").html() }, - load: function(threads){ - threads.forEach(this.appendThread.bind(this)) + load: function(data){ + if (data.keyword) { + var $row = this.parseKeyword(data.keyword) + this.$el.append($row) + } + data.threads.forEach(this.appendThread.bind(this)) }, parse: function(thread){ @@ -52,6 +49,12 @@ var ThreadBox = View.extend({ return t }, + parseKeyword: function(keyword){ + var t = this.keywordTemplate + .replace(/{{keyword}}/g, keyword.keyword) + return t + }, + prependThread: function(thread){ var $row = $( this.parse(thread) ) this.$el.prepend($row) -- cgit v1.2.3-70-g09d2