Re-rendering dashboard rivers when changing feeds. Doesn't work yet.

This commit is contained in:
Samuel Clay 2021-01-12 20:15:42 -05:00
parent ab2d9804ef
commit aa2171e470
14 changed files with 209 additions and 115 deletions

View file

@ -12454,7 +12454,9 @@ form.opml_import_form input {
.NB-filter-popover .segmented-control .NB-focus-icon {
height: 17px;
}
.NB-filter-popover .NB-modal-feed-chooser {
width: 100%;
}
.NB-feedbar-options-stat {
position: relative;
padding-left: 22px;

View file

@ -76,6 +76,8 @@ NEWSBLUR.Modal.prototype = {
make_feed_chooser: function (options) {
options = options || {};
options.selected_folder_title = this.model.folder_title;
options.feed_id = this.feed_id;
return NEWSBLUR.utils.make_feed_chooser(options);
},

View file

@ -33,6 +33,11 @@ NEWSBLUR.Models.DashboardRiver = Backbone.Model.extend({
}
return url;
},
change_feed: function (feed_id) {
this.set('feed_id', feed_id);
this.initialize();
}
});
@ -50,6 +55,20 @@ NEWSBLUR.Collections.DashboardRivers = Backbone.Collection.extend({
count_sides: function () {
return this.countBy(function () { return this.get('river_side'); });
},
left_side_rivers: function () {
return this.side('left');
},
left_side_rivers: function () {
return this.side('right');
},
side: function(side) {
return this.select(function (river) {
return river.get('river_side') == side;
});
}
});

View file

@ -125,18 +125,18 @@ $(function() {
if ($payextra.is(':checked')) {
$label2.hide();
$label3.show();
// $radio2.attr('checked', false);
// $radio2.prop('checked', false);
$radio3.prop('checked', true);
} else {
$label2.show();
$label3.hide();
// $radio3.attr('checked', false);
// $radio3.prop('checked', false);
$radio2.prop('checked', true);
}
};
$("input[name=payextra]").on('change', change_payextra);
if ($radio3.is(':checked')) {
$payextra.attr('checked', 'checked').change();
$payextra.prop('checked', 'checked').change();
} else {
$payextra.change();
}

View file

@ -5,7 +5,7 @@
init: function(options) {
var defaults = {};
if (console && console.clear && _.isFunction(console.clear)) console.clear();
// if (console && console.clear && _.isFunction(console.clear)) console.clear();
// ===========
// = Globals =
@ -4320,7 +4320,7 @@
$('select', $confirm).focus().select();
$('option', $select).each(function() {
if ($(this).attr('value') == in_folder) {
$(this).attr('selected', 'selected');
$(this).prop('selected', 'selected');
return false;
}
});
@ -4681,16 +4681,10 @@
}
if (!force && NEWSBLUR.app.dashboard_rivers) return;
NEWSBLUR.app.dashboard_rivers = NEWSBLUR.assets.dashboard_rivers.map(function (river, r) {
return new NEWSBLUR.Views.DashboardRiver({
el: '.NB-module-'+river.get('river_side')+'-river-' + river.get('river_order'),
active_feed: river.get('river_id'),
active_folder: NEWSBLUR.assets.folders,
dashboard_stories: new NEWSBLUR.Collections.Stories(),
side: river.get('river_side'),
model: river
});
});
NEWSBLUR.app.dashboard_rivers = {
'left': new NEWSBLUR.Views.DashboardRivers({ side: 'left' }),
'right': new NEWSBLUR.Views.DashboardRivers({ side: 'right' })
};
},
choose_dashboard_rivers: function() {
@ -4836,7 +4830,8 @@
NEWSBLUR.assets.folders.update_all_folder_visibility();
NEWSBLUR.app.feed_list.scroll_to_selected();
if (NEWSBLUR.app.dashboard_rivers) {
NEWSBLUR.app.dashboard_rivers.map(function (r) { return r.load_stories(); });
NEWSBLUR.app.dashboard_rivers['left'].load_all_stories();
NEWSBLUR.app.dashboard_rivers['right'].load_all_stories();
}
this.force_feeds_refresh();
$('.NB-active', $slider).removeClass('NB-active');
@ -5083,7 +5078,8 @@
var timestamp = message.split(',')[1];
NEWSBLUR.log(['Real-time new story', feed_id, story_hash, timestamp, message]);
if (NEWSBLUR.app.dashboard_rivers) {
NEWSBLUR.app.dashboard_rivers.map(function (r) { r.new_story(story_hash, timestamp); });
NEWSBLUR.app.dashboard_rivers['left'].new_story(story_hash, timestamp);
NEWSBLUR.app.dashboard_rivers['right'].new_story(story_hash, timestamp);
}
}, this));
@ -5154,18 +5150,16 @@
var story_hash = message.replace('story:read:', '');
NEWSBLUR.assets.stories.mark_read_pubsub(story_hash);
if (NEWSBLUR.app.dashboard_rivers) {
NEWSBLUR.app.dashboard_rivers.forEach(function (river) {
river.options.dashboard_stories.mark_read_pubsub(story_hash);
});
NEWSBLUR.app.dashboard_rivers['left'].mark_read_pubsub(story_hash);
NEWSBLUR.app.dashboard_rivers['right'].mark_read_pubsub(story_hash);
}
} else if (_.string.startsWith(message, 'story:unread')) {
NEWSBLUR.log(['Real-time user update for unread story', username, message]);
var story_hash = message.replace('story:unread:', '');
NEWSBLUR.assets.stories.mark_unread_pubsub(story_hash);
if (NEWSBLUR.app.dashboard_rivers) {
NEWSBLUR.app.dashboard_rivers.forEach(function (river) {
river.options.dashboard_stories.mark_unread_pubsub(story_hash);
});
NEWSBLUR.app.dashboard_rivers['left'].mark_unread_pubsub(story_hash);
NEWSBLUR.app.dashboard_rivers['right'].mark_unread_pubsub(story_hash);
}
} else if (_.string.startsWith(message, 'story:starred') ||
_.string.startsWith(message, 'story:unstarred')) {

View file

@ -248,21 +248,21 @@ _.extend(NEWSBLUR.ReaderAccount.prototype, {
var $months = $.make('select', { name: 'month' });
_.each(NEWSBLUR.utils.monthNames, function(name, i) {
var $option = $.make('option', { value: i+"" }, name);
if (this_month == i) $option.attr('selected', 'selected');
if (this_month == i) $option.prop('selected', true);
$months.append($option);
});
var $days = $.make('select', { name: 'day' });
_.each(_.range(0, 31), function(name, i) {
var $option = $.make('option', { value: i+1+"" }, i+1);
if (this_day == i+1) $option.attr('selected', 'selected');
if (this_day == i+1) $option.prop('selected', true);
$days.append($option);
});
var $years = $.make('select', { name: 'year' });
_.each(_.range(2009, this_year+1), function(name, i) {
var $option = $.make('option', { value: name+"" }, name);
if (this_year == name) $option.attr('selected', 'selected');
if (this_year == name) $option.prop('selected', true);
$years.append($option);
});
@ -400,7 +400,7 @@ _.extend(NEWSBLUR.ReaderAccount.prototype, {
var pref = this.model.preference;
$('input[name=send_emails]', this.$modal).each(function() {
if ($(this).val() == ""+pref('send_emails')) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});

View file

@ -57,13 +57,13 @@ _.extend(NEWSBLUR.ReaderFeedException.prototype, {
$('input[name=view_settings]', this.$modal).each(function() {
if ($(this).val() == view_setting) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=story_layout]', this.$modal).each(function() {
if ($(this).val() == story_layout) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
@ -574,4 +574,4 @@ _.extend(NEWSBLUR.ReaderFeedException.prototype, {
});
}
});
});

View file

@ -125,10 +125,10 @@ NEWSBLUR.ReaderPopover = Backbone.View.extend({
create: function(options) {
if (NEWSBLUR.ReaderPopover._popover && NEWSBLUR.ReaderPopover._popover._open) {
NEWSBLUR.ReaderPopover._popover.close();
} else {
NEWSBLUR.ReaderPopover._popover = new this(options);
}
NEWSBLUR.ReaderPopover._popover = new this(options);
},
close: function() {
@ -141,4 +141,4 @@ NEWSBLUR.ReaderPopover = Backbone.View.extend({
return NEWSBLUR.ReaderPopover._popover && NEWSBLUR.ReaderPopover._popover._open;
}
});
});

View file

@ -972,7 +972,7 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
if (NEWSBLUR.Preferences.timezone) {
$('select[name=timezone] option', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.timezone) {
$(this).attr('selected', true);
$(this).prop('selected', true);
return false;
}
});
@ -980,193 +980,193 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
$('select[name=default_folder] option', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.default_folder) {
$(this).attr('selected', true);
$(this).prop('selected', true);
return false;
}
});
$('input[name=story_layout]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.story_layout) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=default_view]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.default_view) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=new_window]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.new_window) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=feed_order]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.feed_order) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=ssl]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.ssl) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=autoopen_folder]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.autoopen_folder) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=title_counts]', $modal).each(function() {
if (NEWSBLUR.Preferences.title_counts) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=show_global_shared_stories]', $modal).each(function() {
if (NEWSBLUR.Preferences.show_global_shared_stories) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=show_infrequent_site_stories]', $modal).each(function() {
if (NEWSBLUR.Preferences.show_infrequent_site_stories) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=open_feed_action]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.open_feed_action) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=mark_read_on_scroll_titles]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.mark_read_on_scroll_titles) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=show_content_preview]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.show_content_preview) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=show_image_preview]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.show_image_preview) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=doubleclick_feed]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.doubleclick_feed) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=doubleclick_unread]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.doubleclick_unread) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=mark_read_river_confirm]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.mark_read_river_confirm) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=markread_nextfeed]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.markread_nextfeed) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=read_story_delay]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.read_story_delay) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=full_width_story]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.full_width_story) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=truncate_story]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.truncate_story) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=animations]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.animations) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=dateformat]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.dateformat) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=folder_counts]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.folder_counts) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=show_tooltips]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.show_tooltips) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=show_contextmenus]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.show_contextmenus) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=hide_public_comments]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.hide_public_comments) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=story_button_placement]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.story_button_placement) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=highlights]', $modal).each(function() {
if ($(this).val() == ""+NEWSBLUR.Preferences.highlights) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=keyboard_verticalarrows]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.keyboard_verticalarrows) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=keyboard_horizontalarrows]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.keyboard_horizontalarrows) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
$('input[name=space_bar_action]', $modal).each(function() {
if ($(this).val() == NEWSBLUR.Preferences.space_bar_action) {
$(this).attr('checked', true);
$(this).prop('checked', true);
return false;
}
});
@ -1185,7 +1185,7 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
});
_.each(share_preferences, function(share) {
var share_name = share.match(/story_share_(.*)/)[1];
$('input#NB-preference-story-share-'+share_name, $modal).attr('checked', NEWSBLUR.Preferences[share]);
$('input#NB-preference-story-share-'+share_name, $modal).prop('checked', NEWSBLUR.Preferences[share]);
});
$(".NB-tangle-readstorydelay", $modal).slider({
@ -1224,7 +1224,7 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
(NEWSBLUR.Preferences.read_story_delay > 0 ? NEWSBLUR.Preferences.read_story_delay : 1);
$(".NB-tangle-seconds", this.$modal).text(value == 1 ? value + ' second.' : value + ' seconds.');
if (NEWSBLUR.Preferences.read_story_delay > 0 || ui) {
$("#NB-preference-readstorydelay-2", this.$modal).attr('checked', true).val(value);
$("#NB-preference-readstorydelay-2", this.$modal).prop('checked', true).val(value);
if (ui) {
this.enable_save();
}
@ -1239,7 +1239,7 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
$(".NB-tangle-arrowscrollspacing", this.$modal).text(value);
$("input[name=arrow_scroll_spacing]", this.$modal).val(value);
if (NEWSBLUR.Preferences.keyboard_verticalarrows == 'scroll' || ui) {
$("#NB-preference-keyboard-verticalarrows-2", this.$modal).attr('checked', true);
$("#NB-preference-keyboard-verticalarrows-2", this.$modal).prop('checked', true);
if (ui) {
this.enable_save();
}
@ -1425,4 +1425,4 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
$('.NB-modal-submit-button', this.$modal).attr('disabled', true).addClass('NB-disabled').text('Make changes above...');
}
});
});

View file

@ -236,7 +236,7 @@ _.extend(NEWSBLUR.ReaderProfileEditor.prototype, {
$('textarea[name=custom_css]', this.$modal).val(this.profile.get('custom_css'));
$('input[name=bb_permalink_direct]', this.$modal).each(function() {
if ($(this).val() == ""+profile.get('bb_permalink_direct')) {
$(this).attr('checked', true);
$(this).prop('checked', true);
}
});
},
@ -285,7 +285,7 @@ _.extend(NEWSBLUR.ReaderProfileEditor.prototype, {
]);
if (service == this.profile.get('photo_service') ||
(service == 'nothing' && !this.profile.get('photo_service'))) {
$('input[type=radio]', $profile).attr('checked', true);
$('input[type=radio]', $profile).prop('checked', true);
}
$profiles.append($profile);
}, this));
@ -648,4 +648,4 @@ _.extend(NEWSBLUR.ReaderProfileEditor.prototype, {
.text('Saved!');
}
});
});

View file

@ -160,7 +160,7 @@ NEWSBLUR.utils = {
var $feeds_optgroup = $.make('optgroup', { label: "Sites" });
var $social_feeds_optgroup = $.make('optgroup', { label: "Blurblogs" });
var $starred_feeds_optgroup = $.make('optgroup', { label: "Saved Tags" });
var current_feed_id = this.feed_id;
var current_feed_id = options.feed_id;
var make_feed_option = function(feed) {
if (!feed.get('feed_title')) return;
@ -171,7 +171,7 @@ NEWSBLUR.utils = {
$feeds_optgroup);
if (feed.id == current_feed_id) {
$option.attr('selected', true);
$option.prop('selected', true);
}
};
@ -189,7 +189,7 @@ NEWSBLUR.utils = {
}
if (options.include_folders) {
var $folders = NEWSBLUR.utils.make_folders(options.selected_folder_title, options);
var $folders = NEWSBLUR.utils.make_folders(options.feed_id, options.toplevel, options.name, options.include_special_folders);
$('option', $folders).each(function () {
$(this).appendTo($folders_optgroup);
});
@ -211,26 +211,39 @@ NEWSBLUR.utils = {
if (!options.skip_starred) {
$chooser.append($starred_feeds_optgroup);
}
return $chooser;
},
make_folders: function(selected_folder_title, options) {
options = options || {};
make_folders: function(selected_folder_title, toplevel, select_name, include_special_folders) {
var folders = NEWSBLUR.assets.get_folders();
var $options = $.make('select', { className: 'NB-folders', name: options.name });
var $options = $.make('select', { className: 'NB-folders', name: select_name });
if (options.include_special_folders) {
if (include_special_folders) {
var $option = $.make('option', { value: 'river:global' }, "Global Shared Stories");
$options.append($option);
$options.append($option);
if (selected_folder_title == "river:global") {
$option.prop('selected', true);
}
var $option = $.make('option', { value: 'river:blurblogs' }, "All Shared Stories");
$options.append($option);
if (selected_folder_title == "river:blurblogs") {
$option.prop('selected', true);
}
var $option = $.make('option', { value: 'river:infrequent' }, "Infrequent Site Stories");
$options.append($option);
if (selected_folder_title == "river:infrequent") {
$option.prop('selected', true);
}
}
var $option = $.make('option', { value: '' }, options.toplevel || "Top Level");
var $option = $.make('option', { value: 'river:' }, toplevel || "Top Level");
$options.append($option);
if (selected_folder_title == "river:") {
$option.prop('selected', true);
}
$options = this.make_folder_options($options, folders, '   ', selected_folder_title);
@ -246,7 +259,7 @@ NEWSBLUR.utils = {
}, depth + ' ' + item.get('folder_title'));
$options.append($option);
if (item.get('folder_title') == selected_folder_title) {
$option.attr('selected', true);
$option.prop('selected', true);
}
$options = self.make_folder_options($options, item.folders, depth+'   ', selected_folder_title);
}

View file

@ -8,15 +8,10 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
},
initialize: function () {
var $dashboard_side = $(".NB-dashboard-rivers-" + this.model.get('river_side'));
var $river_on_dashboard = $dashboard_side.find(".NB-dashboard-river-order-" + this.model.get('river_order'));
var $river = this.template();
if ($river_on_dashboard.length) {
$river_on_dashboard.replaceWith($river);
} else {
$dashboard_side.append($river);
}
this.$el = $river;
console.log(['Initialize dashboard river', this.model])
var $river_on_dashboard = $(".NB-dashboard-rivers-" + this.model.get('river_side') + " .NB-dashboard-river-order-" + this.model.get('river_order'));
this.setElement($river_on_dashboard);
this.$el.html(this.template());
this.$stories = this.$(".NB-module-item .NB-story-titles");
@ -34,23 +29,28 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
story_hashes: []
};
if (this.options.active_feed == "river:infrequent") {
if (this.model.get('river_id') == "river:infrequent") {
this.options.infrequent = NEWSBLUR.assets.preference('infrequent_stories_per_month');
} else if (this.options.active_feed == "river:global") {
} else if (this.model.get('river_id') == "river:global") {
this.options.global_feed = true;
}
NEWSBLUR.assets.feeds.unbind(null, null, this);
NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
NEWSBLUR.assets.stories.unbind(null, null, this);
NEWSBLUR.assets.stories.bind('change:read_status', this.check_read_stories, this);
// NEWSBLUR.assets.stories.bind('change:selected', this.check_read_stories, this);
this.model.bind('change:feed_id', _.bind(this.initialize, this));
this.setup_dashboard_refresh();
this.load_stories();
this.options_template();
return this;
},
template: function () {
var $river = $(_.template('<div class="NB-module NB-module-river NB-dashboard-river">\
var $river = $(_.template('<div class="NB-module NB-module-river NB-dashboard-river NB-dashboard-river-order-<%= river_order %>">\
<h5 class="NB-module-header">\
<div class="NB-module-river-settings NB-javascript"></div>\
<div class="NB-module-river-title"><%= river_title %></div>\
@ -63,7 +63,8 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
</div>\
</div>\
', {
river_title: NEWSBLUR.reader.feed_title(this.model.get('river_id'))
river_title: NEWSBLUR.reader.feed_title(this.model.get('river_id')),
river_order: this.model.get('river_order')
}));
return $river;
@ -78,7 +79,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
<%= NEWSBLUR.assets.view_setting(feed_id, "order") %>\
</span>\
</div>', {
feed_id: this.options.active_feed
feed_id: this.model.get('river_id')
}));
this.$(".NB-module-river-settings").html($options);
@ -86,7 +87,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
feeds: function() {
var feeds;
var visible_only = NEWSBLUR.assets.view_setting(this.options.active_feed, 'read_filter') == 'unread';
var visible_only = NEWSBLUR.assets.view_setting(this.model.get('river_id'), 'read_filter') == 'unread';
if (visible_only) {
feeds = _.pluck(this.options.active_folder.feeds_with_unreads(), 'id');
if (!feeds.length) {
@ -113,7 +114,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
clearTimeout(this.refresh_interval);
this.refresh_interval = setTimeout(_.bind(function() {
if (NEWSBLUR.reader.active_feed == this.options.active_feed) {
if (NEWSBLUR.reader.active_feed == this.model.get('river_id')) {
// Currently reading the river, so don't reload because it'll break the cache.
console.log(['Currently reading river, so not reloading dashboard river', NEWSBLUR.reader.active_feed]);
this.setup_dashboard_refresh();
@ -143,7 +144,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
// console.log(['dashboard river load_stories', this.model.get('river_id'), this.page, feeds.length, options]);
this.page = 1;
this.story_titles.show_loading();
NEWSBLUR.assets.fetch_dashboard_stories(this.options.active_feed, feeds, this.page, this.options.dashboard_stories, options,
NEWSBLUR.assets.fetch_dashboard_stories(this.model.get('river_id'), feeds, this.page, this.options.dashboard_stories, options,
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
this.setup_dashboard_refresh();
@ -205,7 +206,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
var feeds = this.feeds();
this.page += 1;
this.story_titles.show_loading();
NEWSBLUR.assets.fetch_dashboard_stories(this.options.active_feed, feeds, this.page, this.options.dashboard_stories, options,
NEWSBLUR.assets.fetch_dashboard_stories(this.model.get('river_id'), feeds, this.page, this.options.dashboard_stories, options,
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
},
@ -225,29 +226,29 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
open_story: function(story) {
console.log(['Opening dashboard story', story, this.options]);
if (this.options.query) {
console.log('Saved search', NEWSBLUR.assets.searches_feeds.get(this.options.active_feed))
console.log('Saved search', NEWSBLUR.assets.searches_feeds.get(this.model.get('river_id')))
NEWSBLUR.reader.flags.searching = true;
NEWSBLUR.reader.flags.search = this.options.query;
NEWSBLUR.reader.open_saved_search({
search_model: NEWSBLUR.assets.searches_feeds.get(this.options.active_feed),
feed_id: this.options.active_feed,
search_model: NEWSBLUR.assets.searches_feeds.get(this.model.get('river_id')),
feed_id: this.model.get('river_id'),
dashboard_transfer: this.options.dashboard_stories,
story_id: story.id,
query: this.options.query
});
} else if (this.options.active_feed == "river:infrequent") {
} else if (this.model.get('river_id') == "river:infrequent") {
NEWSBLUR.reader.open_river_stories(null, null, {
dashboard_transfer: this.options.dashboard_stories,
infrequent: this.options.infrequent,
story_id: story.id
});
} else if (this.options.active_feed == "river:global") {
} else if (this.model.get('river_id') == "river:global") {
NEWSBLUR.reader.open_river_blurblogs_stories({
global: true,
dashboard_transfer: this.options.dashboard_stories,
story_id: story.id
});
} else if (_.string.startsWith(this.options.active_feed, 'river:')) {
} else if (_.string.startsWith(this.model.get('river_id'), 'river:')) {
NEWSBLUR.reader.open_river_stories(null, null, {
dashboard_transfer: this.options.dashboard_stories,
story_id: story.id
@ -262,7 +263,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
complete_fill: function() {
var feeds = this.feeds();
NEWSBLUR.assets.complete_river(this.options.active_feed, feeds, this.page);
NEWSBLUR.assets.complete_river(this.model.get('river_id'), feeds, this.page);
},
new_story: function(story_hash, timestamp) {
@ -278,7 +279,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
var last_timestamp = parseInt(oldest_story.get('story_timestamp'), 10);
timestamp = parseInt(timestamp, 10);
if (NEWSBLUR.assets.view_setting(this.options.active_feed, 'order') == 'newest') {
if (NEWSBLUR.assets.view_setting(this.model.get('river_id'), 'order') == 'newest') {
if (timestamp < last_timestamp) {
// console.log(['New story older than last/oldest dashboard story', timestamp, '<', last_timestamp]);
return;
@ -323,7 +324,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
open_options_popover: function(e) {
NEWSBLUR.FeedOptionsPopover.create({
anchor: this.$(".NB-feedbar-options"),
feed_id: this.options.active_feed,
feed_id: this.model.get('river_id'),
on_dashboard: this
});
},

View file

@ -0,0 +1,46 @@
NEWSBLUR.Views.DashboardRivers = Backbone.View.extend({
el: ".NB-dashboard-rivers",
options: {
side: 'left'
},
initialize: function () {
var side = this.options.side;
this.setElement($(".NB-dashboard-rivers-" + side));
this.rivers = NEWSBLUR.assets.dashboard_rivers.side(side).map(_.bind(function (river, r) {
var river_view = new NEWSBLUR.Views.DashboardRiver({
el: '.NB-module-' + river.get('river_side') + '-river-' + river.get('river_order'),
active_folder: NEWSBLUR.assets.folders,
dashboard_stories: new NEWSBLUR.Collections.Stories(),
side: river.get('river_side'),
model: river
});
console.log(['Adding river', side, river.get('river_id'), river_view, river_view.$el, this.$el])
this.$el.append(river_view.$el);
}, this));
},
load_all_stories: function () {
this.rivers.each(function (r) { return r.load_stories(); });
},
new_story: function (story_hash, timestamp) {
this.rivers.each(function (r) { r.new_story(story_hash, timestamp); });
},
mark_read_pubsub: function (story_hash) {
this.rivers.each(function (r) {
r.options.dashboard_stories.mark_read_pubsub(story_hash);
});
},
mark_unread_pubsub: function (story_hash) {
this.rivers.each(function (r) {
r.options.dashboard_stories.mark_unread_pubsub(story_hash);
});
}
});

View file

@ -20,7 +20,8 @@ NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
"click .NB-view-setting-option": "change_view_setting",
"click .NB-filter-popover-filter-icon": "open_site_settings",
"click .NB-filter-popover-stats-icon": "open_site_statistics",
"click .NB-filter-popover-notifications-icon": "open_notifications"
"click .NB-filter-popover-notifications-icon": "open_notifications",
"change .NB-modal-feed-chooser": "change_feed"
},
initialize: function(options) {
@ -55,6 +56,9 @@ NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
render: function() {
var self = this;
var feed = NEWSBLUR.assets.active_feed;
if (this.options.feed_id) {
feed = NEWSBLUR.assets.get_feed(this.options.feed_id)
}
var is_feed = feed && feed.is_feed();
NEWSBLUR.ReaderPopover.prototype.render.call(this);
@ -63,7 +67,8 @@ NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
$.make('div', { className: 'NB-popover-section' }, [
(this.options.on_dashboard && $.make('div', { className: 'NB-modal-feed-chooser-container'}, [
NEWSBLUR.utils.make_feed_chooser({
folder_title: this.options.feed_id,
feed_id: this.options.feed_id,
selected_folder_title: this.options.feed_id,
include_folders: true,
toplevel: "All Site Stories",
include_special_folders: true
@ -151,6 +156,7 @@ NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
if (this.options.on_dashboard) {
this.options.on_dashboard.$(".NB-feedbar-options").addClass('NB-active');
this.$('option[value="' + this.options.feed_id + '"]').attr('selected', true);
} else {
NEWSBLUR.app.story_titles_header.$(".NB-feedbar-options").addClass('NB-active');
}
@ -201,7 +207,11 @@ NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
var changed = NEWSBLUR.assets.view_setting(this.options.feed_id, setting);
if (!changed) return;
NEWSBLUR.reader.reload_feed(setting);
if (this.options.on_dashboard) {
this.options.on_dashboard.initialize();
} else {
NEWSBLUR.reader.reload_feed(setting);
}
},
open_site_settings: function() {
@ -221,6 +231,13 @@ NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
this.close(_.bind(function() {
NEWSBLUR.reader.open_notifications_modal(this.options.feed_id);
}, this));
},
change_feed: function () {
var feed_id = this.$(".NB-modal-feed-chooser").val();
console.log(['Changing feed', feed_id])
this.options.on_dashboard.model.change_feed(feed_id);
this.close();
}