Showing empty explainers.

This commit is contained in:
Samuel Clay 2013-07-11 15:09:00 -07:00
parent 23214e5996
commit e52adf8989
8 changed files with 132 additions and 47 deletions

View file

@ -1941,9 +1941,9 @@ class MStarredStory(mongo.Document):
total += stat['stories']
print " ---> %20.20s: %-20.20s %s stories" % (user and user.profile.last_seen_on or "Deleted",
user and user.username or " -",
user and user.username or " - ",
stat['stories'])
if not dryrun:
if not dryrun and stat['_id']:
cls.objects.filter(user_id=stat['_id']).delete()
print " ---> Deleted %s stories in total." % total

View file

@ -459,12 +459,10 @@ body {
box-sizing: border-box;
}
.NB-story-list-empty {
background: transparent url("/media/embed/reader/big_world.png") no-repeat center 0;
background-size: 64px;
color: rgba(0, 0, 0, .4);
opacity: .4;
font-size: 16px;
padding: 78px 24px 0;
padding: 0 24px;
position: absolute;
text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
top: 40%;
@ -478,6 +476,19 @@ body {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.NB-story-list-empty .NB-world {
background: transparent url("/media/embed/reader/big_world.png") no-repeat center 0;
background-size: 64px;
width: 100%;
height: 64px;
margin: 24px 0;
}
.NB-story-list-empty-subtitle {
font-size: 13px;
color: rgba(0, 0, 0, .3);
}
.NB-feedlists ::-moz-selection {
background: transparent;
@ -2806,6 +2817,10 @@ background: transparent;
.NB-story-share-profiles.NB-story-share-profiles-shares .NB-story-share-profile {
float: right;
}
.NB-story-share-profiles .NB-story-share-profiles-shares-public,
.NB-story-share-profiles .NB-story-share-profiles-shares-friends {
display: inline;
}
.NB-story-share-profiles .NB-story-share-profiles-comments-public,
.NB-story-share-profiles .NB-story-share-profiles-shares-public {
opacity: .5;

View file

@ -185,8 +185,13 @@
skip_save_type: flag,
resize: true
});
NEWSBLUR.app.story_titles.fill_out();
if (_.contains(['split', 'list'], NEWSBLUR.assets.preference('story_layout'))) {
NEWSBLUR.app.story_titles.fill_out();
} else {
NEWSBLUR.app.story_list.fill_out();
}
this.flags.fetch_story_locations_in_feed_view = this.flags.fetch_story_locations_in_feed_view ||
_.throttle(function() {
NEWSBLUR.app.story_list.reset_story_positions();
@ -549,7 +554,7 @@
},
show_next_unread_story: function() {
var unread_count = this.get_unread_count(true);
var unread_count = this.get_total_unread_count();
if (unread_count) {
var next_story = NEWSBLUR.assets.stories.get_next_unread_story();
@ -570,7 +575,7 @@
},
open_next_unread_story_across_feeds: function(force_next_feed) {
var unread_count = !force_next_feed && this.active_feed && this.get_unread_count(true);
var unread_count = !force_next_feed && this.active_feed && this.get_total_unread_count();
if (!unread_count) {
if (this.flags.river_view && !this.flags.social_view) {
@ -599,7 +604,7 @@
},
show_last_unread_story: function() {
var unread_count = this.get_unread_count(true);
var unread_count = this.get_total_unread_count();
if (unread_count) {
var last_story = NEWSBLUR.assets.stories.get_last_unread_story(unread_count);
@ -1429,7 +1434,11 @@
_.defer(function() {
NEWSBLUR.app.story_titles.scroll_to_selected_story();
NEWSBLUR.app.story_list.scroll_to_selected_story();
NEWSBLUR.app.story_titles.fill_out();
if (_.contains(['split', 'list'], NEWSBLUR.assets.preference('story_layout'))) {
NEWSBLUR.app.story_titles.fill_out();
} else {
NEWSBLUR.app.story_list.fill_out();
}
});
},
@ -2771,7 +2780,7 @@
} else if (type == 'feed') {
var feed = this.model.get_feed(feed_id);
if (!feed) return;
var unread_count = this.get_unread_count(true, feed_id);
var unread_count = this.get_total_unread_count(feed_id);
var tab_unread_count = Math.min(25, unread_count);
$manage_menu = $.make('ul', { className: 'NB-menu-manage NB-menu-manage-feed' }, [
$.make('li', { className: 'NB-menu-separator-inverse' }),
@ -2847,7 +2856,7 @@
} else if (type == 'socialfeed') {
var feed = this.model.get_feed(feed_id);
if (!feed) return;
var unread_count = this.get_unread_count(true, feed_id);
var unread_count = this.get_total_unread_count(feed_id);
var tab_unread_count = Math.min(25, unread_count);
$manage_menu = $.make('ul', { className: 'NB-menu-manage NB-menu-manage-feed' }, [
$.make('li', { className: 'NB-menu-separator-inverse' }),
@ -3814,7 +3823,7 @@
: 'neutral');
},
get_unread_count: function(visible_only, feed_id) {
get_unread_count: function(feed_id) {
var total = 0;
feed_id = feed_id || this.active_feed;
var feed = this.model.get_feed(feed_id);
@ -3822,19 +3831,7 @@
if (feed_id == 'starred') {
// Umm, no. Not yet.
} else if (feed) {
if (!visible_only) {
total = feed.get('ng') + feed.get('nt') + feed.get('ps');
} else {
var unread_view_name = this.get_unread_view_name();
if (unread_view_name == 'positive') {
total = feed.get('ps');
} else if (unread_view_name == 'neutral') {
total = feed.get('ps') + feed.get('nt');
} else if (unread_view_name == 'negative') {
total = feed.get('ps') + feed.get('nt') + feed.get('ng');
}
}
return total;
return feed.unread_counts();
} else if (this.flags['river_view'] && !this.flags['social_view']) {
var collection;
if (!this.active_folder.folder_view) {
@ -3843,12 +3840,24 @@
} else {
collection = this.active_folder.folders;
}
return collection.unread_counts(true);
return collection.unread_counts();
} else if (this.flags['river_view'] && this.flags['social_view']) {
var unread_score = this.get_unread_view_score();
return NEWSBLUR.assets.social_feeds.reduce(function(m, feed) {
return m + feed.get('ps') + (unread_score >= 0 && feed.get('nt'));
}, 0);
return NEWSBLUR.assets.social_feeds.unread_counts();
}
return {};
},
get_total_unread_count: function(feed_id) {
var counts = this.get_unread_count(feed_id);
var unread_view_name = this.get_unread_view_name();
if (unread_view_name == 'positive') {
return counts['ps'];
} else if (unread_view_name == 'neutral') {
return counts['ps'] + counts['nt'];
} else if (unread_view_name == 'negative') {
return counts['ps'] + counts['nt'] + counts['ng'];
}
},
@ -3879,9 +3888,16 @@
NEWSBLUR.app.story_list.reset_story_positions();
}, 500);
}
NEWSBLUR.app.story_list.show_correct_explainer();
// NEWSBLUR.log(['Showing correct stories', this.story_view, unread_view_name, $stories_show.length, $stories_hide.length]);
NEWSBLUR.app.story_titles.fill_out();
if (_.contains(['split', 'list'], NEWSBLUR.assets.preference('story_layout'))) {
NEWSBLUR.app.story_titles.fill_out();
} else {
NEWSBLUR.app.story_list.fill_out();
}
if (options.follow && this.active_story) {
NEWSBLUR.app.story_list.scroll_to_selected_story(self.active_story);
NEWSBLUR.app.story_titles.scroll_to_selected_story(self.active_story);

View file

@ -51,7 +51,7 @@ NEWSBLUR.Views.ReaderTaskbarInfo = Backbone.View.extend({
var $bar = $('.NB-river-progress-bar', $progress);
var unreads;
if (feeds_loading) unreads = feeds_loading;
else unreads = NEWSBLUR.reader.get_unread_count(false) / 10;
else unreads = NEWSBLUR.reader.get_total_unread_count(false) / 10;
NEWSBLUR.reader.animate_progress_bar($bar, unreads / 10);
$('.NB-river-progress-text', $progress).text(message);

View file

@ -49,8 +49,9 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
collection: collection
}).render();
});
if (NEWSBLUR.assets.preference('feed_view_single_story')) {
this.show_explainer_single_story_mode();
this.show_correct_explainer();
} else {
this.$el.html(_.pluck(stories, 'el'));
}
@ -80,6 +81,7 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
this.stories = this.stories.concat(stories);
_.defer(this.check_feed_view_scrolled_to_bottom);
this.show_correct_explainer();
} else {
this.show_no_more_stories();
}
@ -88,21 +90,67 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
},
clear: function() {
// console.log(["Clearing story list"]);
_.invoke(this.stories, 'destroy');
this.$el.empty();
this.clear_explainer();
},
clear_explainer: function() {
var $container = this.$el.closest(".NB-feed-stories-container");
$(".NB-story-list-empty", $container).remove();
},
show_correct_explainer: function() {
if (NEWSBLUR.assets.preference('feed_view_single_story') &&
NEWSBLUR.assets.stories.visible().length) {
this.show_explainer_single_story_mode();
} else if (!NEWSBLUR.assets.stories.visible().length) {
this.show_explainer_no_stories();
} else {
this.clear_explainer();
}
},
show_explainer_single_story_mode: function() {
var $container = this.$el.closest(".NB-feed-stories-container");
$(".NB-story-list-empty", $container).remove();
this.clear_explainer();
if (NEWSBLUR.reader.active_story) return;
var $empty = $.make("div", { className: "NB-story-list-empty" }, [
$.make('div', { className: 'NB-world' }),
'Select a story to read'
]);
var $container = this.$el.closest(".NB-feed-stories-container");
$container.append($empty);
},
show_explainer_no_stories: function() {
this.clear_explainer();
if (NEWSBLUR.reader.active_story) return;
if (!NEWSBLUR.assets.flags['no_more_stories']) return;
var counts = NEWSBLUR.reader.get_unread_count();
var unread_view_score = NEWSBLUR.reader.get_unread_view_score();
var hidden_stories = false;
if (unread_view_score > 0 && (counts['nt'] || counts['ng'])) {
hidden_stories = counts['nt'] + counts['ng'];
} else if (unread_view_score >= 0 && counts['ng']) {
hidden_stories = counts['ng'];
}
var $empty = $.make("div", { className: "NB-story-list-empty" }, [
'No stories to read',
$.make('div', { className: 'NB-world' }),
(hidden_stories && $.make('div', { className: 'NB-story-list-empty-subtitle' }, [
'There ',
Inflector.pluralize('is', hidden_stories),
' ',
Inflector.pluralize('hidden story', hidden_stories, true)
]))
]);
var $container = this.$el.closest(".NB-feed-stories-container");
$container.append($empty);
},
@ -147,12 +195,11 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
},
show_only_selected_story: function() {
var $container = this.$el.closest(".NB-feed-stories-container");
$(".NB-story-list-empty", $container).remove();
if (!NEWSBLUR.assets.preference('feed_view_single_story')) return;
if (!_.contains(['split', 'full'], NEWSBLUR.assets.preference('story_layout'))) return;
this.clear_explainer();
this.collection.any(_.bind(function(story) {
if (story && story.get('selected') && story.story_view) {
this.$el.html(story.story_view.el);
@ -167,12 +214,17 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
show_no_more_stories: function() {
if (!NEWSBLUR.assets.flags['no_more_stories']) return;
if (!NEWSBLUR.assets.stories.visible().length) {
this.show_explainer_no_stories();
return;
}
var pane_height = NEWSBLUR.reader.$s.$story_pane.height();
var indicator_position = NEWSBLUR.assets.preference('lock_mouse_indicator');
var endbar_height = 20;
if (indicator_position) {
var last_visible_story = _.last(NEWSBLUR.assets.stories.visible());
var last_story_height = last_visible_story && last_visible_story.story_view.$el.height() || 100;
var last_story_height = last_visible_story && last_visible_story.story_view && last_visible_story.story_view.$el.height() || 100;
var last_story_offset = _.last(this.cache.feed_view_story_positions_keys);
endbar_height = pane_height - indicator_position - last_story_height;
if (endbar_height <= 20) endbar_height = 20;
@ -246,8 +298,8 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
fill_out: function(options) {
if (NEWSBLUR.assets.flags['no_more_stories'] ||
!NEWSBLUR.assets.stories.length ||
!NEWSBLUR.reader.flags.story_titles_closed) {
this.show_no_more_stories();
return;
}

View file

@ -46,6 +46,7 @@ NEWSBLUR.Views.StoryTabView = Backbone.View.extend({
show_explainer_single_story_mode: function() {
var $empty = $.make("div", { className: "NB-story-list-empty" }, [
$.make('div', { className: 'NB-world' }),
'Select a story to read'
]);

View file

@ -127,13 +127,13 @@ NEWSBLUR.Views.StoryTitlesHeader = Backbone.View.extend({
var $indicator = this.$('.NB-story-title-indicator');
var unread_hidden_stories;
if (NEWSBLUR.reader.flags['river_view']) {
unread_hidden_stories = NEWSBLUR.reader.active_folder.folders.unread_counts &&
unread_hidden_stories = NEWSBLUR.reader.active_folder.folders &&
NEWSBLUR.reader.active_folder.folders.unread_counts &&
NEWSBLUR.reader.active_folder.folders.unread_counts().ng;
} else {
unread_hidden_stories = NEWSBLUR.assets.active_feed.unread_counts().ng;
}
var hidden_stories = unread_hidden_stories || !!NEWSBLUR.assets.stories.hidden().length;
// console.log(["show_feed_hidden_story_title_indicator", unread_hidden_stories, hidden_stories, is_feed_load]);
if (!hidden_stories) {
$indicator.hide();
return;

View file

@ -134,6 +134,7 @@ NEWSBLUR.Views.TextTabView = Backbone.View.extend({
show_explainer_single_story_mode: function() {
var $empty = $.make("div", { className: "NB-story-list-empty" }, [
$.make('div', { className: 'NB-world' }),
'Select a story to read'
]);