From a7104749040bc425d1170901c6e7d8d5a8045fb3 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 7 Sep 2015 14:56:27 -0400 Subject: list mailboxes --- public/assets/js/lib/views/mail/boxlist.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 public/assets/js/lib/views/mail/boxlist.js (limited to 'public/assets/js/lib/views/mail/boxlist.js') diff --git a/public/assets/js/lib/views/mail/boxlist.js b/public/assets/js/lib/views/mail/boxlist.js new file mode 100644 index 0000000..68494ac --- /dev/null +++ b/public/assets/js/lib/views/mail/boxlist.js @@ -0,0 +1,26 @@ +var BoxList = View.extend({ + el: "#boxes", + + initialize: function(){ + this.__super__.initialize.call(this) + this.template = this.$(".template").html() + this.$table = this.$("table") + }, + + load: function(data){ + data.forEach(this.appendBox.bind(this)) + }, + + appendBox: function(box){ + var $row = $( this.parseBox(box) ) + this.$table.append($row) + }, + + parseBox: function(box){ + var t = this.template + .replace(/{{box}}/g, box.mbox.split(".")[1]) + .replace(/{{count}}/g, box.count) + return t + }, + +}) \ No newline at end of file -- cgit v1.2.3-70-g09d2