2013-01-25 17:29:38 -08:00
|
|
|
NEWSBLUR.FeedOptionsPopover = NEWSBLUR.ReaderPopover.extend({
|
|
|
|
|
|
|
|
className: "NB-filter-popover",
|
|
|
|
|
|
|
|
options: {
|
2013-02-11 16:07:08 -08:00
|
|
|
'width': 246,
|
2013-01-25 17:29:38 -08:00
|
|
|
'anchor': '.NB-feedbar-options',
|
2013-02-11 12:35:42 -08:00
|
|
|
'placement': 'bottom right',
|
2013-02-11 16:07:08 -08:00
|
|
|
'offset': {
|
|
|
|
top: 16,
|
2013-02-11 12:35:42 -08:00
|
|
|
left: -100
|
2013-02-11 12:48:20 -08:00
|
|
|
},
|
2013-02-11 16:07:08 -08:00
|
|
|
'overlay_top': true,
|
|
|
|
'popover_class': 'NB-filter-popover-container'
|
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",
|
|
|
|
"click .NB-filter-popover-stats-icon": "open_site_statistics"
|
2013-01-25 17:29:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function(options) {
|
2013-02-11 13:17:49 -08:00
|
|
|
if (NEWSBLUR.assets.preference('story_layout') == 'split' &&
|
2013-02-11 12:35:42 -08:00
|
|
|
NEWSBLUR.assets.preference('story_pane_anchor') == 'south') {
|
|
|
|
this.options.placement = 'top right';
|
|
|
|
this.options.offset = {
|
|
|
|
top: 10,
|
|
|
|
left: -100
|
|
|
|
};
|
2013-02-11 12:48:20 -08:00
|
|
|
this.options.overlay_top = false;
|
2013-02-11 12:35:42 -08:00
|
|
|
}
|
|
|
|
|
2013-01-25 17:29:38 -08:00
|
|
|
this.options = _.extend({}, this.options, options);
|
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
|
|
|
|
|
|
|
close: function() {
|
|
|
|
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;
|
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' }, [
|
2013-03-19 09:55:21 -07:00
|
|
|
(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'),
|
|
|
|
$.make('ul', { className: 'segmented-control NB-menu-manage-view-setting-readfilter' }, [
|
|
|
|
$.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')
|
|
|
|
]),
|
|
|
|
$.make('ul', { className: 'segmented-control NB-menu-manage-view-setting-order' }, [
|
|
|
|
$.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')
|
|
|
|
])
|
2013-01-25 17:29:38 -08:00
|
|
|
]),
|
2013-02-11 16:07:08 -08:00
|
|
|
(feed && $.make('div', { className: 'NB-popover-section' }, [
|
|
|
|
$.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")
|
|
|
|
])),
|
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')))
|
|
|
|
]))
|
|
|
|
]))
|
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');
|
|
|
|
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');
|
2013-01-29 16:47:44 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if ($target.hasClass("NB-view-setting-order-newest")) {
|
|
|
|
this.update_feed({order: 'newest'});
|
|
|
|
} else if ($target.hasClass("NB-view-setting-order-oldest")) {
|
|
|
|
this.update_feed({order: 'oldest'});
|
|
|
|
} else if ($target.hasClass("NB-view-setting-readfilter-all")) {
|
|
|
|
this.update_feed({read_filter: 'all'});
|
|
|
|
} else if ($target.hasClass("NB-view-setting-readfilter-unread")) {
|
|
|
|
this.update_feed({read_filter: 'unread'});
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2013-02-05 16:03:55 -08:00
|
|
|
NEWSBLUR.reader.reload_feed();
|
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();
|
|
|
|
});
|
2013-01-25 17:29:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|