Logic finished for showing/hiding the show hidden stories button based on stories at and below the threshold on load and on clicks.

This commit is contained in:
Samuel Clay 2011-01-04 08:21:47 -05:00
parent f9282bfd1f
commit 4239564586
2 changed files with 72 additions and 34 deletions

View file

@ -1066,31 +1066,51 @@ background: transparent;
display: block;
}
/* ============================= */
/* = Story Titles Hidden Count = */
/* ============================= */
#story_titles .NB-story-title-indicator {
clear: both;
border-bottom: 1px solid #505050;
height: 10px;
font-size: 9px;
background-color: #606060;
overflow: hidden;
cursor: pointer;
background-color: #3090cf;
color: #F0F0F0;
cursor: pointer;
position: absolute;
right: 205px;
top: 2px;
font-size: 9px;
line-height: 15px;
font-weight: bold;
margin: 3px 11px 2px;
padding: 0 4px;
text-transform: uppercase;
overflow: hidden;
}
#story_titles .NB-story-title-indicator:hover {
background-color: #00609f;
}
#story_titles .NB-story-title-indicator.unread_threshold_negative {
display: none;
}
#story_titles .NB-story-title-indicator .feed_counts_floater {
float: left;
padding: 0 0 0 4px;
padding: 2px 0 0;
text-align: center;
}
#story_titles .NB-story-title-indicator .unread_count_neutral,
#story_titles .NB-story-title-indicator .unread_count_negative {
#story_titles .NB-story-title-indicator .unread_count_positive.unread_count_full,
#story_titles .NB-story-title-indicator .unread_count_neutral.unread_count_full,
#story_titles .NB-story-title-indicator .unread_count_negative.unread_count_full {
display: none;
opacity: .3;
}
#story_titles .NB-story-title-indicator.unread_threshold_positive .unread_count_neutral.unread_count_full,
#story_titles .NB-story-title-indicator.unread_threshold_positive .unread_count_negative.unread_count_full,
#story_titles .NB-story-title-indicator.unread_threshold_neutral .unread_count_negative.unread_count_full {
display: block;
}
#story_titles .NB-story-title-indicator.unread_threshold_positive:hover .unread_count_neutral {
opacity: 1;
}
@ -1099,26 +1119,26 @@ background: transparent;
}
#story_titles .NB-story-title-indicator .NB-story-title-indicator-text {
color: #B0B0B0;
text-shadow: 1px 1px 0 #202020;
opacity: .8;
font-weight: bold;
text-transform: uppercase;
font-size: 9px;
padding: 0 0 0 44px;
line-height: 10px;
color: #F0F0F0;
float: left;
text-align: right;
display: block;
padding: 0 0 0 2px;
}
#story_titles .NB-story-title-indicator:hover .NB-story-title-indicator-text {
color: #D0D0D0;
color: #D0F0D0;
}
#story_titles .NB-story-title-indicator .feed_counts_floater .unread_count {
padding: 0 3px;
padding: 0 3px 1px;
margin: 0 2px 0 0;
line-height: 10px;
}
/* ======================== */
/* = Story Titles - Story = */
/* ======================== */
#story_titles .story {
overflow: hidden;
position: relative;

View file

@ -2343,13 +2343,17 @@
var feed_id = this.active_feed;
var feed = this.model.get_feed(feed_id);
var unread_view_name = this.get_unread_view_name();
var hidden_stories = _.any(this.model.stories, _.bind(function(story) {
var score = this.compute_story_score(story);
if (unread_view_name == 'positive') return score <= 0;
else if (unread_view_name == 'neutral') return score < 0;
}, this));
if ((feed.nt > 0 && unread_view_name == 'positive') ||
(feed.ng > 0 && unread_view_name == 'neutral') ||
(feed.ng > 0 && unread_view_name == 'postiive')) {
if (hidden_stories) {
var $indicator = $.make('div', { className: 'NB-story-title-indicator' }, [
this.make_feed_counts_floater(feed.ps, feed.nt, feed.ng),
$.make('span', { className: 'NB-story-title-indicator-text' }, 'hidden stories')
$.make('span', { className: 'NB-story-title-indicator-text' }, 'show hidden stories')
]);
$indicator.removeClass('unread_threshold_positive')
@ -2357,14 +2361,13 @@
.removeClass('unread_threshold_negative')
.addClass('unread_threshold_'+unread_view_name)
.css({
'height': 0,
'opacity': 0
});
$('.NB-story-title-indicator', $story_titles).remove();
$('.NB-feedbar', this.$story_titles).after($indicator);
$('.NB-feedbar .feed', this.$story_titles).append($indicator);
_.delay(function() {
$indicator.animate({'height': 10, 'opacity': 1}, {'duration': 400, 'easing': 'easeOutQuint'});
$indicator.animate({'opacity': 1}, {'duration': 1000, 'easing': 'easeOutCubic'});
}, 500);
}
},
@ -2373,25 +2376,40 @@
var feed_id = this.active_feed;
var feed = this.model.get_feed(feed_id);
var $indicator = $('.NB-story-title-indicator', this.$s.$story_titles);
var unread_view_name = $indicator.hasClass('unread_threshold_positive') ?
'positive' :
'neutral';
var hidden_stories_at_threshold = _.any(this.model.stories, _.bind(function(story) {
var score = this.compute_story_score(story);
if (unread_view_name == 'positive') return score == 0;
else if (unread_view_name == 'neutral') return score < 0;
}, this));
var hidden_stories_below_threshold = unread_view_name == 'positive' &&
_.any(this.model.stories, _.bind(function(story) {
var score = this.compute_story_score(story);
return score < 0;
}, this));
// NEWSBLUR.log(['show_hidden_story_titles', hidden_stories_at_threshold, hidden_stories_below_threshold, unread_view_name]);
// First click, open neutral. Second click, open negative.
if ($indicator.hasClass('unread_threshold_positive') && feed.nt > 0 && feed.ng > 0) {
if (unread_view_name == 'positive' && hidden_stories_at_threshold && hidden_stories_below_threshold) {
this.show_story_titles_above_intelligence_level({
'unread_view_name': 'neutral',
'animate': true,
'follow': true
});
$indicator.removeClass('unread_threshold_positive').addClass('unread_threshold_neutral');
} else if ($indicator.hasClass('unread_threshold_neutral') || feed.ng == 0) {
} else {
this.show_story_titles_above_intelligence_level({
'unread_view_name': (feed.ng > 0 ? 'negative' : 'neutral'),
'unread_view_name': 'negative',
'animate': true,
'follow': true
});
$indicator.removeClass('unread_threshold_positive')
.removeClass('unread_threshold_neutral')
.addClass('unread_threshold_negative');
$indicator.slideUp(500);
$indicator.animate({'opacity': 0}, {'duration': 500});
}
},
@ -3407,7 +3425,7 @@
var $next_story_button = $('.task_story_next_unread');
var $story_title_indicator = $('.NB-story-title-indicator', this.$story_titles);
var $hidereadfeeds_button = $('.NB-feeds-header-sites');
$feed_list.removeClass('unread_view_positive')
.removeClass('unread_view_neutral')
.removeClass('unread_view_negative')