mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Major intelligence refactoring to hide/show stories on training.
This commit is contained in:
parent
a7e670a5ed
commit
de76448c9c
5 changed files with 81 additions and 120 deletions
|
@ -1390,9 +1390,9 @@ background: transparent;
|
|||
-ms-transition: opacity .12s ease-out;
|
||||
}
|
||||
|
||||
.NB-intelligence-positive .NB-story-title.NB-story-neutral.NB-story-hidden-visible .NB-hidden-fade,
|
||||
.NB-intelligence-positive .NB-story-title.NB-story-negative.NB-story-hidden-visible .NB-hidden-fade,
|
||||
.NB-intelligence-neutral .NB-story-title.NB-story-negative.NB-story-hidden-visible .NB-hidden-fade {
|
||||
.NB-intelligence-positive .NB-story-title.NB-story-neutral .NB-hidden-fade,
|
||||
.NB-intelligence-positive .NB-story-title.NB-story-negative .NB-hidden-fade,
|
||||
.NB-intelligence-neutral .NB-story-title.NB-story-negative .NB-hidden-fade {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
|
@ -1925,25 +1925,6 @@ background: transparent;
|
|||
background-color: #F8F8F6;
|
||||
}
|
||||
|
||||
.NB-feed-story-header-info .NB-feed-story-header-collapse {
|
||||
display: none;
|
||||
}
|
||||
.NB-story-titles .NB-feed-story-header-info .NB-feed-story-header-collapse {
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
top: 6px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: transparent url('/media/embed/reader/toggle_minus.png') no-repeat 0 0;
|
||||
background-size: 16px;
|
||||
cursor: pointer;
|
||||
opacity: .6;
|
||||
}
|
||||
.NB-story-titles .NB-feed-story-header-info .NB-feed-story-header-collapse:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.NB-feed-story-header-feed {
|
||||
background: #404040 url('/media/embed/reader/feed_view_feed_background.png') repeat-x 0 0;
|
||||
background-image: -webkit-gradient(
|
||||
|
@ -2247,7 +2228,7 @@ background: transparent;
|
|||
}
|
||||
.NB-feed-story .NB-feed-story-tag.NB-score-now-0:hover {
|
||||
/* Grey, active */
|
||||
background-color: #D8DEE2;
|
||||
background-color: rgba(0, 0, 0, .1);
|
||||
color: #9D9A95;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
|
||||
opacity: 1;
|
||||
|
|
|
@ -1254,7 +1254,7 @@
|
|||
|
||||
this.flags['opening_feed'] = false;
|
||||
NEWSBLUR.app.story_titles_header.show_feed_hidden_story_title_indicator(first_load);
|
||||
this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
// this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
||||
this.show_next_unread_story(true);
|
||||
} else if (this.counts['find_last_unread_on_page_of_feed_stories_load']) {
|
||||
|
@ -1448,7 +1448,7 @@
|
|||
if (first_load) {
|
||||
this.find_story_with_action_preference_on_open_feed();
|
||||
}
|
||||
this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
// this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
this.flags['story_titles_loaded'] = true;
|
||||
}
|
||||
},
|
||||
|
@ -1533,7 +1533,7 @@
|
|||
}
|
||||
this.flags['opening_feed'] = false;
|
||||
NEWSBLUR.app.story_titles_header.show_feed_hidden_story_title_indicator(first_load);
|
||||
this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
// this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
this.flags['story_titles_loaded'] = true;
|
||||
if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
||||
this.show_next_unread_story(true);
|
||||
|
@ -1637,7 +1637,7 @@
|
|||
}
|
||||
this.flags['opening_feed'] = false;
|
||||
NEWSBLUR.app.story_titles_header.show_feed_hidden_story_title_indicator(first_load);
|
||||
this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
// this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
this.flags['story_titles_loaded'] = true;
|
||||
if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
||||
this.show_next_unread_story(true);
|
||||
|
@ -1742,7 +1742,7 @@
|
|||
|
||||
if (this.active_feed && NEWSBLUR.utils.is_feed_social(this.active_feed)) {
|
||||
this.flags['opening_feed'] = false;
|
||||
this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
// this.show_story_titles_above_intelligence_level({'animate': false});
|
||||
NEWSBLUR.app.story_titles_header.show_feed_hidden_story_title_indicator(first_load);
|
||||
this.flags['story_titles_loaded'] = true;
|
||||
if (this.counts['select_story_in_feed'] || this.flags['select_story_in_feed']) {
|
||||
|
@ -3688,6 +3688,10 @@
|
|||
.removeClass('unread_threshold_neutral')
|
||||
.removeClass('unread_threshold_negative')
|
||||
.addClass('unread_threshold_'+unread_view_name);
|
||||
|
||||
NEWSBLUR.assets.stories.each(function(story){
|
||||
story.unset('visible');
|
||||
});
|
||||
},
|
||||
|
||||
get_unread_view_score: function() {
|
||||
|
@ -3768,54 +3772,16 @@
|
|||
var self = this;
|
||||
var $story_titles = this.$s.$story_titles;
|
||||
var unread_view_name = options['unread_view_name'] || this.get_unread_view_name();
|
||||
var $stories_show, $stories_hide;
|
||||
|
||||
if (this.model.stories.length > 18) {
|
||||
options['animate'] = false;
|
||||
}
|
||||
|
||||
if (this.flags['unread_threshold_temporarily']) {
|
||||
options['temporary'] = true;
|
||||
}
|
||||
|
||||
if (unread_view_name == 'positive') {
|
||||
$stories_show = $('.NB-story-title,.NB-feed-story').filter('.NB-story-positive');
|
||||
$stories_hide = $('.NB-story-title,.NB-feed-story')
|
||||
.filter('.NB-story-neutral,.NB-story-negative');
|
||||
} else if (unread_view_name == 'neutral') {
|
||||
$stories_show = $('.NB-story-title,.NB-feed-story')
|
||||
.filter('.NB-story-positive,.NB-story-neutral');
|
||||
$stories_hide = $('.NB-story-title,.NB-feed-story').filter('.NB-story-negative');
|
||||
if (options['temporary']) {
|
||||
$stories_show.filter('.NB-story-neutral');
|
||||
} else {
|
||||
$stories_show.filter('.NB-story-hidden-visible');
|
||||
}
|
||||
} else if (unread_view_name == 'negative') {
|
||||
$stories_show = $('.NB-story-title,.NB-feed-story')
|
||||
.filter('.NB-story-positive,.NB-story-neutral,.NB-story-negative');
|
||||
$stories_hide = $();
|
||||
if (options['temporary']) {
|
||||
$stories_show.filter('.NB-story-negative,.NB-story-neutral:not(:visible)');
|
||||
} else {
|
||||
$stories_show.filter('.NB-story-hidden-visible');
|
||||
}
|
||||
options['temporary'] = true;
|
||||
}
|
||||
|
||||
// console.log(["show_story_titles_above_intelligence_level", $stories_show]);
|
||||
if ((this.story_view == 'feed' || this.flags['page_view_showing_feed_view']) &&
|
||||
NEWSBLUR.assets.preference('feed_view_single_story')) {
|
||||
// No need to show/hide feed view stories under single_story preference.
|
||||
// If the user switches to feed/page, then no animation is happening
|
||||
// and this will work anyway.
|
||||
var active_story = this.active_story;
|
||||
var $active_story = this.active_story && this.active_story.story_view && this.active_story.story_view.$el;
|
||||
if ($active_story && $active_story.length || true) {
|
||||
$stories_show = $stories_show.not('.NB-feed-story');
|
||||
$stories_hide = $stories_hide.not('.NB-feed-story');
|
||||
}
|
||||
NEWSBLUR.log(["single story", $stories_show.length, $stories_hide.length, this.active_story, active_story && active_story.id]);
|
||||
}
|
||||
NEWSBLUR.assets.stories.trigger('render:intelligence', options);
|
||||
|
||||
if (!NEWSBLUR.assets.preference('feed_view_single_story')) {
|
||||
_.delay(function() {
|
||||
|
@ -3823,19 +3789,11 @@
|
|||
}, 500);
|
||||
}
|
||||
|
||||
if (($stories_hide.length || $stories_show.length)) {
|
||||
// NEWSBLUR.log(['Showing correct stories', this.story_view, unread_view_name, $stories_show.length, $stories_hide.length]);
|
||||
$stories_show.addClass('NB-story-hidden-visible')
|
||||
.removeClass('NB-hidden');
|
||||
$stories_hide.removeClass('NB-story-hidden-visible')
|
||||
.addClass('NB-hidden');
|
||||
// $stories_hide.css({'display': 'none'});
|
||||
// $stories_show.css({'display': 'block'});
|
||||
NEWSBLUR.app.story_titles.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);
|
||||
}
|
||||
// NEWSBLUR.log(['Showing correct stories', this.story_view, unread_view_name, $stories_show.length, $stories_hide.length]);
|
||||
NEWSBLUR.app.story_titles.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);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -890,12 +890,10 @@ var classifier_prototype = {
|
|||
|
||||
this.update_opinions();
|
||||
NEWSBLUR.assets.recalculate_story_scores(feed_id);
|
||||
NEWSBLUR.assets.stories.trigger('render:intelligence');
|
||||
this.model.save_classifier(data, function() {
|
||||
if (!keep_modal_open) {
|
||||
NEWSBLUR.reader.feed_unread_count(feed_id);
|
||||
// NEWSBLUR.reader.force_feed_refresh();
|
||||
// NEWSBLUR.reader.open_feed(self.feed_id, true);
|
||||
// TODO: Update counts in active feed.
|
||||
$.modal.close();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -24,8 +24,7 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
"click .NB-feed-story-train" : "open_story_trainer",
|
||||
"click .NB-feed-story-save" : "star_story",
|
||||
"click .NB-story-comments-label" : "scroll_to_comments",
|
||||
"click .NB-story-content-expander" : "expand_story",
|
||||
"click .NB-feed-story-header-collapse" : "collapse_story"
|
||||
"click .NB-story-content-expander" : "expand_story"
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
@ -35,9 +34,10 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
this.model.bind('change:selected', this.toggle_selected, this);
|
||||
this.model.bind('change:starred', this.toggle_starred, this);
|
||||
this.model.bind('change:intelligence', this.render_header, this);
|
||||
this.model.bind('change:intelligence', this.toggle_score, this);
|
||||
this.model.bind('change:intelligence', this.toggle_intelligence, this);
|
||||
this.model.bind('change:shared', this.render_comments, this);
|
||||
this.model.bind('change:comments', this.render_comments, this);
|
||||
this.collection.bind('render:intelligence', this.render_intelligence, this);
|
||||
|
||||
// Binding directly instead of using event delegation. Need for speed.
|
||||
// this.$el.bind('mouseenter', this.mouseenter);
|
||||
|
@ -80,7 +80,7 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
this.setup_classes();
|
||||
this.toggle_classes();
|
||||
this.toggle_read_status();
|
||||
this.toggle_score();
|
||||
this.toggle_intelligence();
|
||||
this.generate_gradients();
|
||||
this.render_comments();
|
||||
this.attach_audio_handler_to_stories();
|
||||
|
@ -159,7 +159,6 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
<% if (story.get("starred_date")) { %>\
|
||||
<span class="NB-feed-story-starred-date"><%= story.get("starred_date") %></span>\
|
||||
<% } %>\
|
||||
<div class="NB-feed-story-header-collapse"></div>\
|
||||
</div>\
|
||||
</div>\
|
||||
'),
|
||||
|
@ -261,6 +260,19 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
this.remove();
|
||||
},
|
||||
|
||||
render_intelligence: function(options) {
|
||||
options = options || {};
|
||||
var score = this.model.score();
|
||||
var unread_view = NEWSBLUR.reader.get_unread_view_score();
|
||||
|
||||
if (score >= unread_view || this.model.get('visible')) {
|
||||
this.$el.removeClass('NB-hidden');
|
||||
this.model.set('visible', true);
|
||||
} else {
|
||||
this.$el.addClass('NB-hidden');
|
||||
}
|
||||
},
|
||||
|
||||
// ============
|
||||
// = Bindings =
|
||||
// ============
|
||||
|
@ -283,13 +295,14 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
setup_classes: function() {
|
||||
var story = this.model;
|
||||
var unread_view = NEWSBLUR.reader.get_unread_view_score();
|
||||
var score = story.score();
|
||||
|
||||
this.$el.toggleClass('NB-river-story', NEWSBLUR.reader.flags.river_view ||
|
||||
NEWSBLUR.reader.flags.social_view);
|
||||
this.$el.toggleClass('NB-story-starred', !!story.get('starred'));
|
||||
this.$el.toggleClass('NB-story-shared', !!story.get('shared'));
|
||||
|
||||
this.toggle_intelligence();
|
||||
this.render_intelligence();
|
||||
|
||||
if (NEWSBLUR.assets.preference('show_tooltips')) {
|
||||
this.$('.NB-story-sentiment').tipsy({
|
||||
delayIn: 375,
|
||||
|
@ -304,12 +317,11 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
toggle_read_status: function() {
|
||||
this.$el.toggleClass('read', !!this.model.get('read_status'));
|
||||
},
|
||||
|
||||
toggle_score: function() {
|
||||
var story = this.model;
|
||||
|
||||
|
||||
toggle_intelligence: function() {
|
||||
var score = this.model.score();
|
||||
this.$el.removeClass('NB-story-negative NB-story-neutral NB-story-postiive')
|
||||
.addClass('NB-story-'+story.score_name(story.score()));
|
||||
.addClass('NB-story-'+this.model.score_name(score));
|
||||
},
|
||||
|
||||
toggle_selected: function(model, selected, options) {
|
||||
|
@ -327,7 +339,7 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
(NEWSBLUR.reader.story_view == 'feed' ||
|
||||
(NEWSBLUR.reader.story_view == 'page' &&
|
||||
NEWSBLUR.reader.flags['page_view_showing_feed_view']))) {
|
||||
NEWSBLUR.app.story_list.show_stories_preference_in_feed_view();
|
||||
// NEWSBLUR.app.story_list.show_stories_preference_in_feed_view();
|
||||
NEWSBLUR.app.story_list.scroll_to_selected_story(model, options);
|
||||
}
|
||||
|
||||
|
@ -428,11 +440,6 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
|
||||
},
|
||||
|
||||
collapse_story: function() {
|
||||
this.model.set('selected', false);
|
||||
NEWSBLUR.app.story_titles.fill_out();
|
||||
},
|
||||
|
||||
// ===========
|
||||
// = Actions =
|
||||
// ===========
|
||||
|
@ -453,13 +460,15 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
.removeClass('NB-score-now-0')
|
||||
.addClass('NB-score-now-'+score)
|
||||
.one('mouseleave', function() {
|
||||
console.log(["leave", score]);
|
||||
$tag.removeClass('NB-score-now-'+score);
|
||||
_.delay(function() {
|
||||
$tag.one('mouseenter', function() {
|
||||
console.log(["enter", score]);
|
||||
$tag.removeClass('NB-score-now-'+score);
|
||||
});
|
||||
}, 100);
|
||||
});
|
||||
_.delay(function() {
|
||||
$tag.one('mouseenter', function() {
|
||||
$tag.removeClass('NB-score-now-'+score);
|
||||
});
|
||||
}, 100);
|
||||
},
|
||||
|
||||
toggle_starred: function() {
|
||||
|
|
|
@ -18,6 +18,7 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
|||
this.model.bind('change:selected', this.toggle_selected, this);
|
||||
this.model.bind('change:starred', this.toggle_starred, this);
|
||||
this.model.bind('change:intelligence', this.toggle_intelligence, this);
|
||||
this.collection.bind('render:intelligence', this.render_intelligence, this);
|
||||
this.model.story_title_view = this;
|
||||
},
|
||||
|
||||
|
@ -83,13 +84,9 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
|||
this.$(".NB-story-detail").html(this.story_detail.$el);
|
||||
this.story_detail.watch_images_for_story_height();
|
||||
}
|
||||
|
||||
this.$st.hide();
|
||||
},
|
||||
|
||||
destroy_inline_story_detail: function() {
|
||||
this.$st.show();
|
||||
|
||||
if (this.story_detail) {
|
||||
this.story_detail.destroy();
|
||||
}
|
||||
|
@ -98,6 +95,24 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
collapse_story: function() {
|
||||
this.model.set('selected', false);
|
||||
NEWSBLUR.app.story_titles.fill_out();
|
||||
},
|
||||
|
||||
render_intelligence: function(options) {
|
||||
options = options || {};
|
||||
var score = this.model.score();
|
||||
var unread_view = NEWSBLUR.reader.get_unread_view_score();
|
||||
|
||||
if (score >= unread_view || this.model.get('visible')) {
|
||||
this.$st.removeClass('NB-hidden');
|
||||
this.model.set('visible', true);
|
||||
} else {
|
||||
this.$st.addClass('NB-hidden');
|
||||
}
|
||||
},
|
||||
|
||||
// ============
|
||||
// = Bindings =
|
||||
// ============
|
||||
|
@ -121,17 +136,12 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
|||
|
||||
var story = this.model;
|
||||
var unread_view = NEWSBLUR.reader.get_unread_view_score();
|
||||
var score = story.score();
|
||||
|
||||
this.$st.toggleClass('NB-story-starred', !!story.get('starred'));
|
||||
this.$st.toggleClass('NB-story-shared', !!story.get('shared'));
|
||||
this.$st.removeClass('NB-story-negative NB-story-neutral NB-story-postiive')
|
||||
.addClass('NB-story-'+story.score_name(score));
|
||||
|
||||
if (unread_view > score) {
|
||||
this.$st.addClass("NB-hidden");
|
||||
}
|
||||
|
||||
this.toggle_intelligence();
|
||||
this.render_intelligence();
|
||||
|
||||
if (NEWSBLUR.assets.preference('show_tooltips')) {
|
||||
this.$('.NB-story-sentiment').tipsy({
|
||||
delayIn: 375,
|
||||
|
@ -266,7 +276,12 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
|||
e.stopPropagation();
|
||||
if (e.which == 1 && $('.NB-menu-manage-container:visible').length) return;
|
||||
|
||||
this.model.set('selected', true, {'click_on_story_title': true});
|
||||
if (NEWSBLUR.assets.preference('story_layout') == 'list' &&
|
||||
this.model.get('selected')) {
|
||||
this.collapse_story();
|
||||
} else {
|
||||
this.model.set('selected', true, {'click_on_story_title': true});
|
||||
}
|
||||
|
||||
if (NEWSBLUR.hotkeys.command) {
|
||||
this.model.open_story_in_new_tab();
|
||||
|
|
Loading…
Add table
Reference in a new issue