Fixing tag and author inline classifier changes to not lose hover behavior when switching scores.

This commit is contained in:
Samuel Clay 2012-07-01 12:00:30 -07:00
parent 232d98cf55
commit f557abb47c
3 changed files with 17 additions and 27 deletions

View file

@ -2445,7 +2445,6 @@ background: transparent;
opacity: .4;
cursor: pointer;
-webkit-filter: grayscale(100%);
display: none;
}
.NB-sideoption-share .NB-sideoption-share-crosspost-twitter:hover,
.NB-sideoption-share .NB-sideoption-share-crosspost-facebook:hover {

View file

@ -1173,7 +1173,8 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
this.make_request('/oauth/unfollow_twitter_account', {'username': username}, callback);
},
recalculate_story_scores: function(feed_id) {
recalculate_story_scores: function(feed_id, options) {
options = options || {};
this.stories.each(_.bind(function(story, i) {
if (story.get('story_feed_id') != feed_id) return;
var intelligence = {
@ -1183,35 +1184,35 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
title: 0
};
_.each(this.classifiers[feed_id].titles, _.bind(function(classifier_score, classifier_title) {
_.each(this.classifiers[feed_id].titles, function(classifier_score, classifier_title) {
if (intelligence.title <= 0 &&
story.get('story_title', '').indexOf(classifier_title) != -1) {
intelligence.title = classifier_score;
}
}, this));
});
_.each(this.classifiers[feed_id].authors, _.bind(function(classifier_score, classifier_author) {
_.each(this.classifiers[feed_id].authors, function(classifier_score, classifier_author) {
if (intelligence.author <= 0 &&
story.get('story_authors', '').indexOf(classifier_author) != -1) {
intelligence.author = classifier_score;
}
}, this));
});
_.each(this.classifiers[feed_id].tags, _.bind(function(classifier_score, classifier_tag) {
_.each(this.classifiers[feed_id].tags, function(classifier_score, classifier_tag) {
if (intelligence.tags <= 0 &&
story.get('story_tags') && _.contains(story.get('story_tags'), classifier_tag)) {
intelligence.tags = classifier_score;
}
}, this));
});
_.each(this.classifiers[feed_id].feeds, _.bind(function(classifier_score, classifier_feed_id) {
_.each(this.classifiers[feed_id].feeds, function(classifier_score, classifier_feed_id) {
if (intelligence.feed <= 0 &&
story.get('story_feed_id') == classifier_feed_id) {
intelligence.feed = classifier_score;
}
}, this));
});
story.set('intelligence', intelligence);
story.set('intelligence', intelligence, options);
}, this));
}

View file

@ -59,7 +59,7 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
return this;
},
render_header: function() {
render_header: function(model, value, options) {
var params = this.get_render_params();
this.$('.NB-feed-story-header').replaceWith($(this.story_header_template(params)));
this.generate_gradients();
@ -280,11 +280,11 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
.one('mouseleave', function() {
$tag.removeClass('NB-score-now-'+score);
});
_.defer(function() {
$tag.one('mouseenter', function() {
$tag.removeClass('NB-score-now-'+score);
});
_.delay(function() {
$tag.one('mouseenter', function() {
$tag.removeClass('NB-score-now-'+score);
});
}, 100);
},
toggle_starred: function() {
@ -394,21 +394,11 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
}
NEWSBLUR.assets.classifiers[feed_id][classifier_type+'s'][value] = score;
NEWSBLUR.assets.recalculate_story_scores(feed_id);
NEWSBLUR.assets.recalculate_story_scores(feed_id, {story_view: this});
NEWSBLUR.assets.save_classifier(data, function(resp) {
NEWSBLUR.reader.force_feeds_refresh(null, true, feed_id);
});
NEWSBLUR.assets.stories.each(function(story) {
if (classifier_type == 'tag' &&
_.contains(story.get('story_tags'), value)) {
story.trigger('change:intelligence');
} else if (classifier_type == 'author' &&
story.get('story_authors') == value) {
story.trigger('change:intelligence');
}
});
this.preserve_classifier_color(classifier_type, value, score);
},