diaspora/public/javascripts/widgets/stream.js
2011-08-23 23:00:55 -07:00

30 lines
No EOL
734 B
JavaScript

(function() {
var Stream = function() {
var self = this;
this.subscribe("widget/ready", function(evt, stream) {
$.extend(self, {
stream: $(stream),
streamElements: {}
});
$.each(self.stream.find(".stream_element"), function() {
self.addPost($(this));
});
});
this.globalSubscribe("stream/reloaded stream/scrolled", function() {
self.publish("widget/ready", self.stream);
});
this.globalSubscribe("stream/post/added", function(evt, post) {
self.addPost(post);
});
this.addPost = function(post) {
self.streamElements[post.attr("id")] = self.instantiate("StreamElement", post);
};
};
Diaspora.Widgets.Stream = Stream;
})();