NEWSBLUR.Models.Story = Backbone.Model.extend({ score: function() { if (NEWSBLUR.reader.active_feed == 'starred') { return 1; } else { return NEWSBLUR.utils.compute_story_score(this); } }, score_name: function(score) { score = !_.isUndefined(score) ? score : this.score(); var score_name = 'neutral'; if (score > 0) score_name = 'positive'; if (score < 0) score_name = 'negative'; return score_name; }, has_modifications: function() { if (this.get('story_content').indexOf('= unread_score; }); }, hidden: function() { var unread_score = NEWSBLUR.assets.preference('unread_view'); return this.select(function(story) { return story.score() < unread_view; }); }, // =========== // = Getters = // =========== get_next_story: function(direction) { if (direction == -1) return this.get_previous_story(); var visible_stories = this.visible(); if (!this.active_story) { return visible_stories[0]; } var current_index = _.indexOf(visible_stories, this.active_story); if (current_index+1 <= visible_stories.length) { return visible_stories[current_index+1]; } }, get_previous_story: function() { var visible_stories = this.visible(); if (!this.active_story) { return visible_stories[0]; } var current_index = _.indexOf(visible_stories, this.active_story); if (current_index-1 >= 0) { return visible_stories[current_index-1]; } }, // ========== // = Events = // ========== detect_selected_story: function(selected_story) { if (selected_story.get('selected')) { this.deselect(selected_story); this.active_story = selected_story; NEWSBLUR.reader.active_story = selected_story; if (!selected_story.get('read_status')) { this.mark_read(selected_story); } } } });