From f59ad8b96799114ea0e33d06dc1263c07800148b Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Tue, 19 Jun 2012 14:21:43 -0700 Subject: [PATCH] Fetching story positions when expanding a story's comments. --- media/js/newsblur/views/original_tab_view.js | 7 ++++++- media/js/newsblur/views/story_comment_view.js | 9 +++++---- .../js/newsblur/views/story_comments_view.js | 2 +- media/js/newsblur/views/story_detail_view.js | 1 + media/js/newsblur/views/story_list_view.js | 2 +- media/js/newsblur/views/story_share_view.js | 19 +++++++++++++------ 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/media/js/newsblur/views/original_tab_view.js b/media/js/newsblur/views/original_tab_view.js index 25486bd56..a45e1ffc4 100644 --- a/media/js/newsblur/views/original_tab_view.js +++ b/media/js/newsblur/views/original_tab_view.js @@ -216,8 +216,10 @@ NEWSBLUR.Views.OriginalTabView = Backbone.View.extend({ var stories = NEWSBLUR.assets.stories; var $iframe = this.$el.contents(); var prefetch_tries_left = 3; - this.cache['prefetch_iteration'] += 1; + if (!this.flags['iframe_loaded']) return; + + this.cache['prefetch_iteration'] += 1; NEWSBLUR.log(['Prefetching Original', !this.flags['iframe_fetching_story_locations'], !this.flags['iframe_story_locations_fetched']]); if (!this.flags['iframe_fetching_story_locations'] && !this.flags['iframe_story_locations_fetched']) { @@ -357,6 +359,7 @@ NEWSBLUR.Views.OriginalTabView = Backbone.View.extend({ }); $.extend(this.flags, { + 'iframe_loaded': false, 'iframe_scroll_snapback_check': false, 'iframe_view_not_busting': false, 'iframe_fetching_story_locations': false, @@ -376,6 +379,8 @@ NEWSBLUR.Views.OriginalTabView = Backbone.View.extend({ this.unload_feed_iframe(); + this.flags['iframe_loaded'] = true; + var page_url = '/reader/page/'+feed_id; if (NEWSBLUR.reader.flags['social_view']) { var feed = NEWSBLUR.assets.get_feed(feed_id); diff --git a/media/js/newsblur/views/story_comment_view.js b/media/js/newsblur/views/story_comment_view.js index b2b6968de..881547ef9 100644 --- a/media/js/newsblur/views/story_comment_view.js +++ b/media/js/newsblur/views/story_comment_view.js @@ -101,7 +101,8 @@ NEWSBLUR.Views.StoryComment = Backbone.View.extend({ this.remove_social_comment_reply_form(); }, this)); $('input', $form).focus(); - // this.fetch_story_locations_in_feed_view(); + + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); }, remove_social_comment_reply_form: function() { @@ -118,7 +119,7 @@ NEWSBLUR.Views.StoryComment = Backbone.View.extend({ if (!comment_reply || comment_reply.length <= 1) { this.remove_social_comment_reply_form(); - // this.fetch_story_locations_in_feed_view(); + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); return; } @@ -133,7 +134,7 @@ NEWSBLUR.Views.StoryComment = Backbone.View.extend({ _.bind(function(data) { this.model.set(data.comment); this.render(); - // this.fetch_story_locations_in_feed_view(); + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); }, this), _.bind(function(data) { var message = data && data.message || "Sorry, this reply could not be posted. Probably a bug."; if (!NEWSBLUR.Globals.is_authenticated) { @@ -143,7 +144,7 @@ NEWSBLUR.Views.StoryComment = Backbone.View.extend({ $submit.removeClass('NB-disabled').text('Post'); $form.find('.NB-error').remove(); $form.append($error); - // this.fetch_story_locations_in_feed_view(); + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); }, this)); } diff --git a/media/js/newsblur/views/story_comments_view.js b/media/js/newsblur/views/story_comments_view.js index 2205a76a6..2f22349b5 100644 --- a/media/js/newsblur/views/story_comments_view.js +++ b/media/js/newsblur/views/story_comments_view.js @@ -111,7 +111,7 @@ NEWSBLUR.Views.StoryCommentsView = Backbone.View.extend({ }, this)); this.$('.NB-story-comments-public-teaser-wrapper').replaceWith($comments); - // this.fetch_story_locations_in_feed_view(); + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); }, this)); } diff --git a/media/js/newsblur/views/story_detail_view.js b/media/js/newsblur/views/story_detail_view.js index 2f8e8e262..f05d6b283 100644 --- a/media/js/newsblur/views/story_detail_view.js +++ b/media/js/newsblur/views/story_detail_view.js @@ -364,6 +364,7 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({ } $button.css('opacity', 1).fadeOut(400); $button.tipsy('hide').tipsy('disable'); + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); }, open_feed: function() { diff --git a/media/js/newsblur/views/story_list_view.js b/media/js/newsblur/views/story_list_view.js index bdbabf558..6d8174032 100644 --- a/media/js/newsblur/views/story_list_view.js +++ b/media/js/newsblur/views/story_list_view.js @@ -236,7 +236,7 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({ }, this)); this.flags['feed_view_positions_calculated'] = true; - NEWSBLUR.log(['Feed view entirely loaded', NEWSBLUR.assets.stories.length + " stories", this.counts['feed_view_positions_timer']/1000 + " sec delay"]); + // NEWSBLUR.log(['Feed view entirely loaded', NEWSBLUR.assets.stories.length + " stories", this.counts['feed_view_positions_timer']/1000 + " sec delay"]); this.counts['feed_view_positions_timer'] = Math.max(this.counts['feed_view_positions_timer']*2, 1000); clearTimeout(this.flags['next_fetch']); diff --git a/media/js/newsblur/views/story_share_view.js b/media/js/newsblur/views/story_share_view.js index e204eadef..b92a891b5 100644 --- a/media/js/newsblur/views/story_share_view.js +++ b/media/js/newsblur/views/story_share_view.js @@ -59,8 +59,10 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ }, { 'duration': 300, 'easing': 'easeInOutQuint', - 'queue': false - // 'complete': _.bind(this.fetch_story_locations_in_feed_view, this, {'reset_timer': true}) + 'queue': false, + 'complete': function() { + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); + } }); $story_content.removeData('original_height'); } @@ -100,8 +102,10 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ }, { 'duration': 350, 'easing': 'easeInOutQuint', - 'queue': false - // 'complete': _.bind(this.fetch_story_locations_in_feed_view, this, {'reset_timer': true}) + 'queue': false, + 'complete': function() { + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); + } }).data('original_height', original_height); } this.update_share_button_label(); @@ -109,7 +113,10 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ e.preventDefault(); this.mark_story_as_shared({'source': 'sideoption'}); }, this); - $('.NB-sideoption-share-comments', $share).bind('keydown', 'ctrl+return,meta+return', share); + var $comments = $('.NB-sideoption-share-comments', $share); + $comments.unbind('keydown') + .bind('keydown', 'ctrl+return', share) + .bind('keydown', 'meta+return', share); } }, @@ -157,7 +164,7 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ tipsy.disable(); } }, 850); - // this.fetch_story_locations_in_feed_view({'reset_timer': true}); + NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view(); }, this), _.bind(function(data) { var message = data && data.message || "Sorry, this story could not be shared. Probably a bug."; if (!NEWSBLUR.Globals.is_authenticated) {