2014-07-22 08:55:26 -10:00
|
|
|
var Whisper = Whisper || {};
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Whisper.MessageListView = Whisper.ListView.extend({
|
|
|
|
tagName: 'ul',
|
2014-07-27 12:12:59 -10:00
|
|
|
className: 'discussion',
|
2014-11-10 23:16:46 -08:00
|
|
|
itemView: Whisper.MessageView,
|
|
|
|
events: {
|
2014-11-20 15:43:51 -08:00
|
|
|
'add': 'scrollToBottom',
|
|
|
|
'update *': 'scrollToBottom'
|
2014-11-10 23:16:46 -08:00
|
|
|
},
|
|
|
|
scrollToBottom: function() {
|
2014-11-20 15:43:51 -08:00
|
|
|
// TODO: Avoid scrolling if user has manually scrolled up?
|
2014-11-10 23:16:46 -08:00
|
|
|
this.$el.scrollTop(this.el.scrollHeight);
|
|
|
|
},
|
2014-11-13 14:35:37 -08:00
|
|
|
addAll: function() {
|
2014-11-20 16:30:52 -08:00
|
|
|
Whisper.ListView.prototype.addAll.apply(this, arguments); // super()
|
2014-11-16 15:30:40 -08:00
|
|
|
this.scrollToBottom();
|
2014-11-13 14:35:37 -08:00
|
|
|
},
|
2014-07-22 08:55:26 -10:00
|
|
|
});
|
|
|
|
})();
|