make infscroll, publisher, stream use pub/sub to listen for the stream being reloaded, random cleanups and fix aspect-filters.js spec

This commit is contained in:
Dan Hansen 2011-04-15 18:49:31 -05:00
parent 296824c92b
commit 7ed21930b4
4 changed files with 10 additions and 13 deletions

View file

@ -48,7 +48,7 @@ var AspectFilters = {
// select correct aspect in filter list & deselect others
$("#aspect_nav li").removeClass('selected');
link.addClass('selected');
aspectLi.addClass('selected');
AspectFilters.fadeOut();
@ -168,14 +168,11 @@ var AspectFilters = {
for(var key in photos){
$("#publisher textarea").addClass("with_attachments");
photos_html = photos_html + "<li style='position:relative;'> " + ("<img src='" + photos[key] +"' data-id='" + key + "'>") + "</li>";
};
}
// reinit listeners on stream
photozone.html(photos_html);
Stream.initialize();
InfiniteScroll.initialize();
Publisher.initialize();
Diaspora.widgets.publish("stream/reloaded");
// fade contents back in
if(AspectFilters.requests == 0){

View file

@ -24,12 +24,13 @@ var InfiniteScroll = {
},
postScrollCallbacks: [],
initialize: function(){
Diaspora.widgets.subscribe("stream/reloaded", InfiniteScroll.initialize);
$('#main_stream').infinitescroll(InfiniteScroll.options, InfiniteScroll.postScrollCallback);
},
postScroll: function( callback ){
InfiniteScroll.postScrollCallbacks.push(callback);
}
}
};
$(document).ready(function() {
InfiniteScroll.initialize();

View file

@ -346,10 +346,7 @@ var Publisher = {
});
},
initialize: function() {
Publisher.cachedForm = false;
Publisher.cachedInput = false;
Publisher.cachedHiddenInput = false;
Publisher.cachedSubmit = false;
Diaspora.widgets.subscribe("stream/reloaded", Publisher.initialize);
Publisher.bindServiceIcons();
Publisher.bindPublicIcon();
@ -357,7 +354,7 @@ var Publisher = {
if ($("#status_message_fake_text").val() == "") {
Publisher.close();
};
}
Publisher.autocompletion.initialize();
Publisher.hiddenInput().val(Publisher.input().val());

View file

@ -6,12 +6,14 @@
var Stream = {
initialize: function() {
var $stream = $(".stream");
var $publisher = $("#publisher");
$(".status_message_delete").tipsy({trigger: 'hover', gravity: 'n'});
Diaspora.widgets.subscribe("stream/reloaded", Stream.initialized);
Diaspora.widgets.timeago.updateTimeAgo();
Diaspora.widgets.directionDetector.updateBinds();
$stream.not(".show").delegate("a.show_post_comments", "click", Stream.toggleComments);
//audio linx
Stream.setUpAudioLinks();