This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/views/user/user_stream_view.js
2013-07-23 18:03:35 -04:00

50 lines
1.2 KiB
JavaScript

/**
This view handles rendering of a user's stream
@class UserStreamView
@extends Discourse.View
@namespace Discourse
@uses Discourse.Scrolling
@module Discourse
**/
Discourse.UserStreamView = Ember.CollectionView.extend(Discourse.Scrolling, {
loading: false,
elementId: 'user-stream',
content: Em.computed.alias('controller.stream.content'),
itemViewClass: Ember.View.extend({ templateName: 'user/stream_item' }),
scrolled: function(e) {
var eyeline = this.get('eyeline');
if (eyeline) { eyeline.update(); }
},
loadMore: function() {
var userStreamView = this;
if (userStreamView.get('loading')) { return; }
var stream = this.get('stream');
stream.findItems().then(function() {
userStreamView.set('loading', false);
userStreamView.get('eyeline').flushRest();
});
},
willDestroyElement: function() {
this.unbindScrolling();
},
didInsertElement: function() {
this.bindScrolling();
var eyeline = new Discourse.Eyeline('#user-stream .item');
this.set('eyeline', eyeline);
var userStreamView = this;
eyeline.on('sawBottom', function() {
userStreamView.loadMore();
});
}
});
Discourse.View.registerHelper('userStream', Discourse.UserStreamView);