From 4f4fd3f86c06e5168a1a0400f5d8f1c9e5baa98f Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Tue, 10 Feb 2015 17:04:32 -0800 Subject: [PATCH] Correctly re-rendering story titles when switch into and out of grid layout. --- media/css/reader.css | 6 +++++- media/js/newsblur/reader/reader.js | 22 ++++++++++---------- media/js/newsblur/views/story_list_view.js | 2 +- media/js/newsblur/views/story_title_view.js | 4 +++- media/js/newsblur/views/story_titles_view.js | 1 - 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/media/css/reader.css b/media/css/reader.css index 31aee1c2f..ed08a3f8f 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -1891,22 +1891,26 @@ a img { position: absolute; left: 20px; top: 0; - height: 12px; + height: 14px; overflow: hidden; width: 100px; line-height: 1.3em; } .NB-theme-feed-size-xs #story_titles .NB-story-title .NB-story-feed .feed_title { font-size: 9px; + height: 12px; } .NB-theme-feed-size-m #story_titles .NB-story-title .NB-story-feed .feed_title { font-size: 11px; + height: 15px; } .NB-theme-feed-size-l #story_titles .NB-story-title .NB-story-feed .feed_title { font-size: 12px; + height: 15px; } .NB-theme-feed-size-xl #story_titles .NB-story-title .NB-story-feed .feed_title { font-size: 12px; + height: 15px; } #story_titles .NB-story-title.NB-selected .NB-story-feed .feed_title { diff --git a/media/js/newsblur/reader/reader.js b/media/js/newsblur/reader/reader.js index b76c1fe48..50016517b 100644 --- a/media/js/newsblur/reader/reader.js +++ b/media/js/newsblur/reader/reader.js @@ -1542,7 +1542,7 @@ var original_layout = this.story_layout; story_layout = story_layout || feed_layout || active_layout; - console.log(['switch_story_layout', active_layout, feed_layout, story_layout, this.active_feed, story_layout == active_layout]); + // console.log(['switch_story_layout', active_layout, feed_layout, story_layout, this.active_feed, story_layout == active_layout]); if (story_layout == active_layout) return; this.story_layout = story_layout; @@ -1554,30 +1554,30 @@ this.set_correct_story_view_for_feed(); this.apply_resizable_layout({right_side: true}); + if (original_layout == 'grid' || story_layout == 'grid') { + NEWSBLUR.app.story_titles.render(); + } if (story_layout == 'list') { if (this.active_story) { - this.active_story.story_title_view.render_inline_story_detail(); + this.active_story.story_title_view.toggle_selected(); } NEWSBLUR.app.story_list.clear(); } else if (story_layout == 'grid') { if (this.active_story) { - this.active_story.story_title_view.render_inline_story_detail(); + this.active_story.story_title_view.toggle_selected(); } NEWSBLUR.app.story_list.clear(); } else if (story_layout == 'split') { NEWSBLUR.app.story_list.render(); if (this.active_story) { - this.active_story.story_title_view.destroy_inline_story_detail(); + this.active_story.story_title_view.toggle_selected(); } } else if (story_layout == 'full') { NEWSBLUR.app.story_list.render(); if (this.active_story) { - this.active_story.story_title_view.destroy_inline_story_detail(); + this.active_story.story_title_view.toggle_selected(); } } - if (original_layout == 'grid' || story_layout == 'grid') { - NEWSBLUR.app.story_titles.render(); - } this.switch_to_correct_view(); this.make_feed_title_in_stories(); @@ -2785,7 +2785,7 @@ }); NEWSBLUR.app.story_list.reset_story_positions(); - if (this.active_story && + if (!options.resize && this.active_story && _.contains(['list', 'grid'], NEWSBLUR.assets.view_setting(NEWSBLUR.reader.active_feed, 'layout'))) { NEWSBLUR.app.text_tab_view.unload(); @@ -2807,7 +2807,7 @@ if (!this.active_story) { NEWSBLUR.app.text_tab_view.show_explainer_single_story_mode(); } - } else if (this.active_story && + } else if (!options.resize && this.active_story && _.contains(['list', 'grid'], NEWSBLUR.assets.view_setting(NEWSBLUR.reader.active_feed, 'layout'))) { this.active_story.story_title_view.render_inline_story_detail(); @@ -4200,7 +4200,7 @@ }); } $(".NB-feeds-list-empty").remove(); - console.log(["toggle_focus_in_slider", unread_view, view_not_empty, starred_mode]); + // console.log(["toggle_focus_in_slider", unread_view, view_not_empty, starred_mode]); if (!view_not_empty && !all_mode && !starred_mode) { var $empty = $.make("div", { className: "NB-feeds-list-empty" }, [ 'You have no unread stories', diff --git a/media/js/newsblur/views/story_list_view.js b/media/js/newsblur/views/story_list_view.js index 9a6052b02..0e1c7fccf 100644 --- a/media/js/newsblur/views/story_list_view.js +++ b/media/js/newsblur/views/story_list_view.js @@ -419,7 +419,7 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({ ]); this.$('.NB-feed-story-premium-only').remove(); this.$(".NB-end-line").append($notice); - console.log(["append_search_premium_only_notification", this.$(".NB-end-line")]); + // console.log(["append_search_premium_only_notification", this.$(".NB-end-line")]); }, append_search_premium_only_notification: function() { diff --git a/media/js/newsblur/views/story_title_view.js b/media/js/newsblur/views/story_title_view.js index e1655513a..ebb09caa6 100644 --- a/media/js/newsblur/views/story_title_view.js +++ b/media/js/newsblur/views/story_title_view.js @@ -25,6 +25,7 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({ render: function() { var template_name = !this.model.get('selected') && this.options.is_grid ? 'grid_template' : 'template'; + // console.log(['render story title', template_name, this.$el[0]]); this.$el.html(this[template_name]({ story : this.model, feed : (NEWSBLUR.reader.flags.river_view || NEWSBLUR.reader.flags.social_view) && @@ -133,6 +134,7 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({ tagName: 'div', inline_story_title: true }).render(); + // console.log(['render_inline_story_detail', this.$(".NB-story-detail")]); this.$(".NB-story-detail").html(this.story_detail.$el); this.story_detail.attach_handlers(); } @@ -298,7 +300,7 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({ this.$st.toggleClass('NB-selected', !!this.model.get('selected')); this.$el.toggleClass('NB-selected', !!this.model.get('selected')); - if (selected) { + if (!!this.model.get('selected')) { if (_.contains(['list', 'grid'], NEWSBLUR.assets.view_setting(NEWSBLUR.reader.active_feed, 'layout'))) { this.render_inline_story_detail(); } diff --git a/media/js/newsblur/views/story_titles_view.js b/media/js/newsblur/views/story_titles_view.js index 0ae6e7029..7c5023d0e 100644 --- a/media/js/newsblur/views/story_titles_view.js +++ b/media/js/newsblur/views/story_titles_view.js @@ -75,7 +75,6 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({ override_grid: function() { if (NEWSBLUR.assets.view_setting(NEWSBLUR.reader.active_feed, 'layout') != 'grid') return; - console.log(['override_grid', NEWSBLUR.assets.preference('grid_columns')]); var columns = NEWSBLUR.assets.preference('grid_columns'); var $layout = NEWSBLUR.reader.$s.$story_titles; $layout.removeClass('NB-grid-columns-1')