2013-01-25 17:29:38 -08:00
|
|
|
NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
|
|
|
|
|
|
|
|
className: "NB-filter-popover",
|
|
|
|
|
|
|
|
options: {
|
2016-11-21 20:21:44 -08:00
|
|
|
'width': 304,
|
2013-01-25 17:29:38 -08:00
|
|
|
'anchor': '.NB-feedbar-options',
|
2016-11-21 20:21:44 -08:00
|
|
|
'placement': 'bottom right',
|
2013-02-11 16:07:08 -08:00
|
|
|
'offset': {
|
2013-09-13 23:35:47 -07:00
|
|
|
top: 18,
|
2016-11-21 20:21:44 -08:00
|
|
|
left: -110
|
2013-02-11 12:48:20 -08:00
|
|
|
},
|
2013-09-13 23:35:47 -07:00
|
|
|
'overlay_top': true,
|
2014-06-11 15:04:46 -07:00
|
|
|
'popover_class': 'NB-filter-popover-container',
|
|
|
|
'show_readfilter': true,
|
|
|
|
'show_order': true
|
2013-01-25 17:29:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
2013-02-11 16:07:08 -08:00
|
|
|
"click .NB-view-setting-option": "change_view_setting",
|
|
|
|
"click .NB-filter-popover-filter-icon": "open_site_settings",
|
2016-11-21 20:21:44 -08:00
|
|
|
"click .NB-filter-popover-stats-icon": "open_site_statistics",
|
|
|
|
"click .NB-filter-popover-notifications-icon": "open_notifications"
|
2013-01-25 17:29:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function(options) {
|
|
|
|
this.options = _.extend({}, this.options, options);
|
2020-12-21 20:26:58 -05:00
|
|
|
this.options.offset.left = -1 * $(this.options.anchor).width() - 31;
|
2016-11-21 20:21:44 -08:00
|
|
|
|
2014-06-11 15:04:46 -07:00
|
|
|
if (NEWSBLUR.reader.active_feed == "read") {
|
|
|
|
this.options['show_readfilter'] = false;
|
|
|
|
}
|
2017-11-05 14:01:25 -08:00
|
|
|
if (NEWSBLUR.reader.active_feed == "river:infrequent") {
|
|
|
|
this.options['show_infrequent'] = true;
|
|
|
|
}
|
2014-06-11 15:20:59 -07:00
|
|
|
if (NEWSBLUR.reader.flags['starred_view']) {
|
|
|
|
this.options.feed_id = "starred"; // Ignore tags
|
|
|
|
this.options['show_readfilter'] = false;
|
|
|
|
}
|
2013-02-11 12:35:42 -08:00
|
|
|
NEWSBLUR.ReaderPopover.prototype.initialize.call(this, this.options);
|
2013-01-25 17:29:38 -08:00
|
|
|
this.model = NEWSBLUR.assets;
|
2013-01-29 18:35:24 -08:00
|
|
|
this.render();
|
2013-01-25 17:29:38 -08:00
|
|
|
this.show_correct_feed_view_options_in_menu();
|
|
|
|
},
|
2013-01-29 16:47:44 -08:00
|
|
|
|
2020-12-21 20:26:58 -05:00
|
|
|
close: function () {
|
|
|
|
if (this.options.on_dashboard) {
|
|
|
|
this.options.on_dashboard.$(".NB-feedbar-options").removeClass('NB-active');
|
|
|
|
} else {
|
|
|
|
NEWSBLUR.app.story_titles_header.$(".NB-feedbar-options").removeClass('NB-active');
|
|
|
|
}
|
2013-02-11 16:07:08 -08:00
|
|
|
NEWSBLUR.ReaderPopover.prototype.close.apply(this, arguments);
|
2013-01-29 16:47:44 -08:00
|
|
|
},
|
2013-01-25 17:29:38 -08:00
|
|
|
|
2013-01-29 18:35:24 -08:00
|
|
|
render: function() {
|
2013-01-25 17:29:38 -08:00
|
|
|
var self = this;
|
2013-02-11 16:07:08 -08:00
|
|
|
var feed = NEWSBLUR.assets.active_feed;
|
2017-11-05 14:49:48 -08:00
|
|
|
var is_feed = feed && feed.is_feed();
|
2013-01-25 17:29:38 -08:00
|
|
|
|
2013-01-29 18:35:24 -08:00
|
|
|
NEWSBLUR.ReaderPopover.prototype.render.call(this);
|
|
|
|
|
2013-01-25 17:29:38 -08:00
|
|
|
this.$el.html($.make('div', [
|
2013-02-11 16:07:08 -08:00
|
|
|
$.make('div', { className: 'NB-popover-section' }, [
|
2021-01-11 20:39:38 -05:00
|
|
|
(this.options.on_dashboard && $.make('div', { className: 'NB-modal-feed-chooser-container'}, [
|
2020-12-21 20:26:58 -05:00
|
|
|
this.make_feed_chooser({include_folders: true})
|
2021-01-11 20:39:38 -05:00
|
|
|
])),
|
2017-11-05 14:49:48 -08:00
|
|
|
(is_feed && $.make('div', { className: 'NB-section-icon NB-filter-popover-filter-icon' })),
|
2013-02-11 16:07:08 -08:00
|
|
|
$.make('div', { className: 'NB-popover-section-title' }, 'Filter Options'),
|
2014-06-11 15:04:46 -07:00
|
|
|
(this.options.show_readfilter && $.make('ul', { className: 'segmented-control NB-menu-manage-view-setting-readfilter' }, [
|
2013-02-11 16:07:08 -08:00
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-readfilter-all NB-active' }, 'All stories'),
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-readfilter-unread' }, 'Unread only')
|
2014-06-11 15:04:46 -07:00
|
|
|
])),
|
|
|
|
(this.options.show_order && $.make('ul', { className: 'segmented-control NB-menu-manage-view-setting-order' }, [
|
2013-02-11 16:07:08 -08:00
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-order-newest NB-active' }, 'Newest first'),
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-order-oldest' }, 'Oldest')
|
2017-11-05 14:01:25 -08:00
|
|
|
])),
|
|
|
|
(this.options.show_infrequent && $.make('div', { className: 'NB-popover-section-title' }, 'Infrequent stories per month')),
|
|
|
|
(this.options.show_infrequent && $.make('ul', { className: 'segmented-control NB-menu-manage-view-setting-infrequent' }, [
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-infrequent-5' }, '5'),
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-infrequent-15' }, '15'),
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-infrequent-30 NB-active' }, '< 30 stories/month'),
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-infrequent-60' }, '60'),
|
|
|
|
$.make('li', { className: 'NB-view-setting-option NB-view-setting-infrequent-90' }, '90')
|
2014-06-11 15:04:46 -07:00
|
|
|
]))
|
2013-01-25 17:29:38 -08:00
|
|
|
]),
|
2017-11-05 14:49:48 -08:00
|
|
|
(is_feed && $.make('div', { className: 'NB-popover-section' }, [
|
2013-02-11 16:07:08 -08:00
|
|
|
$.make('div', { className: 'NB-section-icon NB-filter-popover-stats-icon' }),
|
|
|
|
$.make('div', { className: 'NB-popover-section-title' }, 'Site Stats'),
|
|
|
|
$.make('div', { className: 'NB-feedbar-options-stat NB-stat-subscribers' }, [
|
|
|
|
$.make('div', { className: 'NB-icon' }),
|
|
|
|
$.make('div', { className: 'NB-stat' }, Inflector.pluralize('subscriber', feed.get('num_subscribers'), true))
|
|
|
|
]),
|
2013-02-11 17:09:38 -08:00
|
|
|
(feed.get('is_push') && $.make('div', { className: 'NB-feedbar-options-stat NB-stat-realtime' }, [
|
|
|
|
$.make('div', { className: 'NB-icon' }),
|
|
|
|
$.make('div', { className: 'NB-stat' }, "Stories arrive in real-time")
|
|
|
|
])),
|
2016-11-21 20:21:44 -08:00
|
|
|
(feed.get('average_stories_per_month') && $.make('div', { className: 'NB-feedbar-options-stat NB-stat-average' }, [
|
|
|
|
$.make('div', { className: 'NB-icon' }),
|
|
|
|
$.make('div', { className: 'NB-stat' }, Inflector.pluralize("story", feed.get('average_stories_per_month'), true) + " per month")
|
|
|
|
])),
|
2013-02-11 16:07:08 -08:00
|
|
|
(feed.get('updated') && $.make('div', { className: 'NB-feedbar-options-stat NB-stat-updated' }, [
|
|
|
|
$.make('div', { className: 'NB-icon' }),
|
|
|
|
$.make('div', { className: 'NB-stat' }, "Updated " + feed.get('updated') + ' ago')
|
|
|
|
])),
|
|
|
|
(feed.get('min_to_decay') && $.make('div', { className: 'NB-feedbar-options-stat NB-stat-decay' }, [
|
|
|
|
$.make('div', { className: 'NB-icon' }),
|
|
|
|
$.make('div', { className: 'NB-stat' }, "Fetched every " + NEWSBLUR.utils.calculate_update_interval(feed.get('min_to_decay')))
|
|
|
|
]))
|
2016-11-21 20:21:44 -08:00
|
|
|
])),
|
2017-11-05 14:49:48 -08:00
|
|
|
(is_feed && $.make('div', { className: 'NB-popover-section' }, [
|
2016-11-21 20:21:44 -08:00
|
|
|
$.make('div', { className: 'NB-section-icon NB-filter-popover-notifications-icon' }),
|
|
|
|
$.make('div', { className: 'NB-popover-section-title' }, 'Notifications'),
|
|
|
|
$.make('div', { className: 'NB-feedbar-options-notifications' }, [
|
|
|
|
new NEWSBLUR.Views.FeedNotificationView({model: feed, popover: true}).render().$el
|
|
|
|
])
|
2013-02-11 16:07:08 -08:00
|
|
|
]))
|
2013-01-25 17:29:38 -08:00
|
|
|
]));
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
show_correct_feed_view_options_in_menu: function() {
|
|
|
|
var order = NEWSBLUR.assets.view_setting(this.options.feed_id, 'order');
|
|
|
|
var read_filter = NEWSBLUR.assets.view_setting(this.options.feed_id, 'read_filter');
|
2017-11-05 14:01:25 -08:00
|
|
|
var infrequent = parseInt(NEWSBLUR.assets.preference('infrequent_stories_per_month'), 10);
|
|
|
|
|
2013-01-25 17:29:38 -08:00
|
|
|
var $oldest = this.$('.NB-view-setting-order-oldest');
|
|
|
|
var $newest = this.$('.NB-view-setting-order-newest');
|
|
|
|
var $unread = this.$('.NB-view-setting-readfilter-unread');
|
|
|
|
var $all = this.$('.NB-view-setting-readfilter-all');
|
|
|
|
|
|
|
|
$oldest.toggleClass('NB-active', order == 'oldest');
|
|
|
|
$newest.toggleClass('NB-active', order != 'oldest');
|
|
|
|
$oldest.text('Oldest' + (order == 'oldest' ? ' first' : ''));
|
|
|
|
$newest.text('Newest' + (order != 'oldest' ? ' first' : ''));
|
|
|
|
$unread.toggleClass('NB-active', read_filter == 'unread');
|
|
|
|
$all.toggleClass('NB-active', read_filter != 'unread');
|
2017-11-05 14:01:25 -08:00
|
|
|
|
|
|
|
var frequencies = [5, 15, 30, 60, 90];
|
|
|
|
for (var f in frequencies) {
|
|
|
|
var freq = frequencies[f];
|
|
|
|
var $infrequent = this.$('.NB-view-setting-infrequent-' + freq);
|
|
|
|
$infrequent.toggleClass('NB-active', infrequent == freq);
|
|
|
|
$infrequent.text(infrequent == freq ? '< '+freq+' stories/month' : freq);
|
|
|
|
}
|
|
|
|
|
2020-12-21 20:26:58 -05:00
|
|
|
if (this.options.on_dashboard) {
|
|
|
|
this.options.on_dashboard.$(".NB-feedbar-options").addClass('NB-active');
|
|
|
|
} else {
|
|
|
|
NEWSBLUR.app.story_titles_header.$(".NB-feedbar-options").addClass('NB-active');
|
|
|
|
}
|
2013-01-25 17:29:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// ==========
|
|
|
|
// = Events =
|
|
|
|
// ==========
|
|
|
|
|
|
|
|
change_view_setting: function(e) {
|
|
|
|
var $target = $(e.target);
|
2014-04-16 17:37:39 -07:00
|
|
|
var options = {};
|
2013-01-25 17:29:38 -08:00
|
|
|
|
|
|
|
if ($target.hasClass("NB-view-setting-order-newest")) {
|
2014-04-16 17:37:39 -07:00
|
|
|
options = {order: 'newest'};
|
2013-01-25 17:29:38 -08:00
|
|
|
} else if ($target.hasClass("NB-view-setting-order-oldest")) {
|
2014-04-16 17:37:39 -07:00
|
|
|
options = {order: 'oldest'};
|
2013-01-25 17:29:38 -08:00
|
|
|
} else if ($target.hasClass("NB-view-setting-readfilter-all")) {
|
2014-04-16 17:37:39 -07:00
|
|
|
options = {read_filter: 'all'};
|
2013-01-25 17:29:38 -08:00
|
|
|
} else if ($target.hasClass("NB-view-setting-readfilter-unread")) {
|
2014-04-16 17:37:39 -07:00
|
|
|
options = {read_filter: 'unread'};
|
2017-11-05 14:01:25 -08:00
|
|
|
} else if ($target.hasClass("NB-view-setting-infrequent-5")) {
|
|
|
|
NEWSBLUR.assets.preference('infrequent_stories_per_month', 5);
|
|
|
|
NEWSBLUR.reader.reload_feed();
|
|
|
|
} else if ($target.hasClass("NB-view-setting-infrequent-15")) {
|
|
|
|
NEWSBLUR.assets.preference('infrequent_stories_per_month', 15);
|
|
|
|
NEWSBLUR.reader.reload_feed();
|
|
|
|
} else if ($target.hasClass("NB-view-setting-infrequent-30")) {
|
|
|
|
NEWSBLUR.assets.preference('infrequent_stories_per_month', 30);
|
|
|
|
NEWSBLUR.reader.reload_feed();
|
|
|
|
} else if ($target.hasClass("NB-view-setting-infrequent-60")) {
|
|
|
|
NEWSBLUR.assets.preference('infrequent_stories_per_month', 60);
|
|
|
|
NEWSBLUR.reader.reload_feed();
|
|
|
|
} else if ($target.hasClass("NB-view-setting-infrequent-90")) {
|
|
|
|
NEWSBLUR.assets.preference('infrequent_stories_per_month', 90);
|
|
|
|
NEWSBLUR.reader.reload_feed();
|
2013-01-25 17:29:38 -08:00
|
|
|
}
|
|
|
|
|
2014-04-16 17:37:39 -07:00
|
|
|
if (NEWSBLUR.reader.flags.search) {
|
|
|
|
options.search = NEWSBLUR.reader.flags.search;
|
|
|
|
}
|
|
|
|
this.update_feed(options);
|
2013-01-29 16:47:44 -08:00
|
|
|
this.show_correct_feed_view_options_in_menu();
|
2013-01-25 17:29:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
update_feed: function(setting) {
|
|
|
|
var changed = NEWSBLUR.assets.view_setting(this.options.feed_id, setting);
|
|
|
|
if (!changed) return;
|
|
|
|
|
2014-04-16 17:37:39 -07:00
|
|
|
NEWSBLUR.reader.reload_feed(setting);
|
2013-02-11 16:07:08 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
open_site_settings: function() {
|
|
|
|
this.close(function() {
|
|
|
|
NEWSBLUR.reader.open_feed_exception_modal();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
open_site_statistics: function() {
|
|
|
|
this.close(function() {
|
|
|
|
console.log(["stats"]);
|
|
|
|
NEWSBLUR.reader.open_feed_statistics_modal();
|
|
|
|
});
|
2016-11-21 20:21:44 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
open_notifications: function() {
|
|
|
|
this.close(_.bind(function() {
|
|
|
|
NEWSBLUR.reader.open_notifications_modal(this.options.feed_id);
|
|
|
|
}, this));
|
2013-01-25 17:29:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-21 20:26:58 -05:00
|
|
|
});
|