diaspora/public/javascripts/widgets/stream.js
danielgrippi ae6fa5bebb don't use Diaspora widget system or stream.js when backbone is active;
migrating like actions over to backbone; some cleanup; bump jquery to
1.7.1
2012-01-07 14:23:22 -08:00

50 lines
1.3 KiB
JavaScript

(function() {
var Stream = function() {
var self = this;
this.streamElements = {};
this.subscribe("widget/ready", function(evt, stream) {
if( Diaspora.backboneEnabled() ){ return }
$.extend(self, {
stream: $(stream),
mainStream: $(stream).find('#main_stream'),
headerTitle: $(stream).find('#aspect_stream_header > h3')
});
$.each(self.stream.find(".stream_element"), function() {
var post = $(this);
if(typeof self.streamElements[post.attr("id")] === "undefined") {
self.addPost(post);
}
});
});
this.globalSubscribe("stream/reloaded", function() {
self.streamElements = {};
});
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);
};
this.empty = function() {
self.mainStream.empty();
self.headerTitle.text(Diaspora.I18n.t('stream.no_aspects'));
};
this.setHeaderTitle = function(newTitle) {
self.headerTitle.text(newTitle);
};
};
Diaspora.Widgets.Stream = Stream;
})();