Initial stab at Backbone-ifying the front-end. Added feed, folder, story, and story_title views with feed, folder, story, and feed_list models. Converted AssetModel to a Router.

This commit is contained in:
Samuel Clay 2012-05-17 18:40:46 -07:00
parent abe6ff2bf6
commit bfe7ee1634
33 changed files with 356 additions and 354 deletions

View file

@ -173,6 +173,7 @@ def load_feeds(request):
include_favicons = request.REQUEST.get('include_favicons', False)
flat = request.REQUEST.get('flat', False)
update_counts = request.REQUEST.get('update_counts', False)
version = int(request.REQUEST.get('v', 1))
if include_favicons == 'false': include_favicons = False
if update_counts == 'false': update_counts = False
@ -224,7 +225,7 @@ def load_feeds(request):
user.profile.save()
data = {
'feeds': feeds,
'feeds': feeds.values() if version == 2 else feeds,
'social_feeds': social_feeds,
'social_profile': social_profile,
'folders': json.decode(folders.folders),

View file

@ -6,7 +6,7 @@
// = Globals =
// ===========
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.story_view = 'page';
this.pages = {
'feeds' : $('#NB-page-feeds'),

View file

@ -1,55 +1,36 @@
NEWSBLUR.AssetModel = function() {
var _Reader = null;
var _Prefs = null;
return {
reader: function(){
if(!_Reader){
_Reader = new NEWSBLUR.AssetModel.Reader();
_Reader.init();
} else {
_Reader.init();
NEWSBLUR.AssetModel = Backbone.Router.extend({
initialize: function() {
this.defaults = {
classifiers: {
titles: {},
tags: {},
authors: {},
feeds: {}
}
return _Reader;
}
};
}();
};
this.feeds = new NEWSBLUR.Collections.Feeds();
this.social_feeds = new NEWSBLUR.Collections.SocialSubscriptions();
this.favicons = {};
this.folders = [];
this.stories = {};
this.story_keys = {};
this.queued_read_stories = {};
this.classifiers = {};
this.friends = {};
this.profile = {};
this.user_profile = new NEWSBLUR.Models.User();
this.user_profiles = new NEWSBLUR.Collections.Users();
this.follower_profiles = new NEWSBLUR.Collections.Users();
this.following_profiles = new NEWSBLUR.Collections.Users();
this.starred_stories = [];
this.starred_count = 0;
this.read_stories_river_count = 0;
this.flags = {
'favicons_fetching': false,
'has_chosen_feeds': false
};
NEWSBLUR.AssetModel.Reader = function() {
this.defaults = {
classifiers: {
titles: {},
tags: {},
authors: {},
feeds: {}
}
};
this.feeds = {};
this.social_feeds = new NEWSBLUR.Collections.SocialSubscriptions();
this.favicons = {};
this.folders = [];
this.stories = {};
this.story_keys = {};
this.queued_read_stories = {};
this.classifiers = {};
this.friends = {};
this.profile = {};
this.user_profile = new NEWSBLUR.Models.User();
this.user_profiles = new NEWSBLUR.Collections.Users();
this.follower_profiles = new NEWSBLUR.Collections.Users();
this.following_profiles = new NEWSBLUR.Collections.Users();
this.starred_stories = [];
this.starred_count = 0;
this.read_stories_river_count = 0;
this.flags = {
'favicons_fetching': false,
'has_chosen_feeds': false
};
};
NEWSBLUR.AssetModel.Reader.prototype = {
init: function() {
this.ajax = {};
this.ajax['rapid'] = $.manageAjax.create('rapid', {queue: false});
this.ajax['queue'] = $.manageAjax.create('queue', {queue: true});
@ -61,7 +42,6 @@ NEWSBLUR.AssetModel.Reader.prototype = {
domCompleteTrigger: true});
this.ajax['statistics'] = $.manageAjax.create('statistics', {queue: 'clear', abortOld: true});
$.ajaxSettings.traditional = true;
return;
},
make_request: function(url, data, callback, error_callback, options) {
@ -289,61 +269,45 @@ NEWSBLUR.AssetModel.Reader.prototype = {
this.user_profiles.add(profiles);
},
reset_feeds: function() {
this.feeds = {};
},
load_feeds: function(callback, error_callback) {
load_feeds: function(error_callback) {
var self = this;
var pre_callback = function(subscriptions) {
// NEWSBLUR.log(['subscriptions', subscriptions]);
var flat_feeds = function(feeds) {
var flattened = _.flatten(_.map(feeds, _.values));
return _.flatten(_.map(flattened, function(feed) {
if (!_.isNumber(feed) && feed) return flat_feeds(feed);
else return feed;
}));
};
var valid_feeds = flat_feeds({'root': subscriptions.folders});
_.each(subscriptions.feeds, function(feed, feed_id) {
if (_.contains(valid_feeds, parseInt(feed_id, 10))) {
feed.subscribed = true;
self.feeds[feed_id] = feed;
if (feed.favicon_fetching) self.flags['favicons_fetching'] = true;
}
});
var pre_callback = function(feeds, subscriptions) {
NEWSBLUR.log(['subscriptions', feeds, subscriptions]);
self.flags['favicons_fetching'] = self.feeds.any(function(feed) { return feed.get('favicons_fetching'); });
self.folders = subscriptions.folders;
self.starred_count = subscriptions.starred_count;
self.social_feeds.reset(subscriptions.social_feeds);
self.user_profile.set(subscriptions.social_profile);
if (!_.isEqual(self.favicons, {})) {
_.each(self.feeds, function(feed) {
self.feeds.each(function(feed) {
if (self.favicons[feed.id]) {
feed.favicon = self.favicons[feed.id];
feed.set('favicon', self.favicons[feed.id]);
}
});
}
self.detect_any_inactive_feeds();
callback();
};
var data = {};
var data = {
'v': 2
};
if (NEWSBLUR.Flags['start_import_from_google_reader']) {
data['include_favicons'] = true;
}
this.make_request('/reader/feeds', data, pre_callback, error_callback, {
ajax_group: 'feed',
request_type: 'GET'
if (this.feeds.length) this.feeds.destroy();
this.feeds.fetch({
success: pre_callback,
error: error_callback
});
},
detect_any_inactive_feeds: function() {
this.flags['has_chosen_feeds'] = _.any(this.feeds, function(feed) {
this.flags['has_chosen_feeds'] = this.feeds.any(function(feed) {
return feed.active;
});
},
@ -1285,6 +1249,4 @@ NEWSBLUR.AssetModel.Reader.prototype = {
}, this));
}
};
});

View file

@ -2,7 +2,7 @@ NEWSBLUR.Modal = function(options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
this.flags = {};
};

View file

@ -0,0 +1,26 @@
NEWSBLUR.Models.Feed = Backbone.Model.extend({
});
NEWSBLUR.Collections.Feeds = Backbone.Collection.extend({
model: NEWSBLUR.Models.Feed,
url: '/reader/feeds',
fetch: function(options) {
options = _.extend({
data: {
v: 2
}
}, options);
return Backbone.Collection.prototype.fetch.call(this, options);
},
parse: function(data) {
console.log(["parsing collection", data]);
return data.feeds;
}
});

View file

@ -0,0 +1,103 @@
NEWSBLUR.Views.FeedList = Backbone.View.extend({
initialize: function() {
this.$s = NEWSBLUR.reader.$s;
this.model = NEWSBLUR.reader.model;
if (!$('#feed_list').length) return;
$('.NB-callout-ftux .NB-callout-text').text('Loading feeds...');
this.$s.$feed_link_loader.css({'display': 'block'});
NEWSBLUR.reader.flags['favicons_downloaded'] = false;
NEWSBLUR.assets.feeds.bind('reset', _.bind(function() {
this.make_feeds();
this.make_social_feeds();
this.load_router();
callback && callback();
}, this));
NEWSBLUR.assets.load_feeds();
},
make_feeds: function() {
var self = this;
var $feed_list = this.$s.$feed_list;
var folders = this.model.folders;
var feeds = this.model.feeds;
// NEWSBLUR.log(['Making feeds', {'folders': folders, 'feeds': feeds}]);
$feed_list.empty();
this.$s.$story_taskbar.css({'display': 'block'});
var $feeds = this.make_feeds_folder(folders, 0);
$feed_list.css({
'display': 'block',
'opacity': 0
});
$feed_list.html($feeds);
this.count_collapsed_unread_stories();
$feed_list.animate({'opacity': 1}, {'duration': 700});
this.hover_over_feed_titles($feed_list);
this.$s.$feed_link_loader.fadeOut(250);
if (folders.length) {
$('.NB-task-manage').removeClass('NB-disabled');
$('.NB-callout-ftux').fadeOut(500);
}
this.open_dialog_after_feeds_loaded();
if (NEWSBLUR.Globals.is_authenticated && this.model.flags['has_chosen_feeds']) {
_.delay(_.bind(this.start_count_unreads_after_import, this), 1000);
this.flags['refresh_inline_feed_delay'] = true;
this.force_feeds_refresh($.rescope(this.finish_count_unreads_after_import, this), true);
}
if (folders.length) {
this.load_sortable_feeds();
this.update_header_counts();
_.delay(_.bind(this.update_starred_count, this), 250);
NEWSBLUR.reader.check_hide_getting_started();
}
if (this.flags['showing_feed_in_tryfeed_view'] || this.flags['showing_social_feed_in_tryfeed_view']) {
this.hide_tryfeed_view();
this.force_feed_refresh();
}
_.defer(_.bind(function() {
this.make_feed_favicons();
// this.model.load_feed_favicons($.rescope(this.make_feed_favicons, this), this.flags['favicons_downloaded'], this.model.flags['has_chosen_feeds']);
if (this.socket) {
this.send_socket_active_feeds();
} else {
var force_socket = NEWSBLUR.Globals.is_admin;
this.setup_socket_realtime_unread_counts(force_socket);
}
}, this));
},
make_social_feeds: function() {
var $social_feeds = this.$s.$social_feeds;
var profile = this.model.user_profile;
$social_feeds.empty();
var $feeds = "";
this.model.social_feeds.sort().each(_.bind(function(feed) {
var $feed = this.make_feed_title_template(feed.attributes, 'feed', 0);
$feeds += $feed;
}, this));
$social_feeds.css({
'display': 'block',
'opacity': 0
});
$social_feeds.html($feeds);
$social_feeds.animate({'opacity': 1}, {'duration': 700});
if (this.socket) {
this.send_socket_active_feeds();
}
$('.NB-module-stats-count-shared-stories .NB-module-stats-count-number').text(profile.get('shared_stories_count'));
$('.NB-module-stats-count-followers .NB-module-stats-count-number').text(profile.get('follower_count'));
$('.NB-module-stats-count-following .NB-module-stats-count-number').text(profile.get('following_count'));
}
});

View file

@ -0,0 +1,5 @@
NEWSBLUR.Models.Folder = Backbone.Model.extend({
});

View file

@ -0,0 +1,5 @@
NEWSBLUR.Models.Story = Backbone.Model.extend({
});

View file

@ -1,7 +1,5 @@
NEWSBLUR.Models.User = Backbone.Model.extend({
// idAttribute: 'user_id',
get: function(attr) {
var value = Backbone.Model.prototype.get.call(this, attr);
if (attr == 'photo_url' && !value) {

View file

@ -1,131 +1,133 @@
(function($) {
NEWSBLUR.Reader = function() {
// ===========
// = Globals =
// ===========
this.model = NEWSBLUR.AssetModel.reader();
this.story_view = 'page';
this.$s = {
$body: $('body'),
$feed_lists: $('.NB-feedlists'),
$feed_list: $('#feed_list'),
$social_feeds: $('.NB-socialfeeds'),
$story_titles: $('#story_titles'),
$content_pane: $('.content-pane'),
$story_taskbar: $('#story_taskbar'),
$story_pane: $('#story_pane .NB-story-pane-container'),
$feed_view: $('.NB-feed-story-view'),
$feed_stories: $('.NB-feed-stories'),
$feed_iframe: $('.NB-feed-iframe'),
$story_iframe: $('.NB-story-iframe'),
$intelligence_slider: $('.NB-intelligence-slider'),
$mouse_indicator: $('#mouse-indicator'),
$feed_link_loader: $('#NB-feeds-list-loader'),
$feeds_progress: $('#NB-progress'),
$dashboard: $('.NB-feeds-header-dashboard'),
$river_header: $('.NB-feeds-header-river'),
$starred_header: $('.NB-feeds-header-starred'),
$tryfeed_header: $('.NB-feeds-header-tryfeed'),
$taskbar: $('.taskbar_nav'),
$feed_floater: $('.NB-feed-story-view-floater')
};
this.flags = {
'feed_view_images_loaded': {},
'bouncing_callout': false,
'has_unfetched_feeds': false,
'count_unreads_after_import_working': false,
'import_from_google_reader_working': false,
'favicons_downloaded': false
};
this.locks = {};
this.counts = {
'page': 1,
'feature_page': 0,
'unfetched_feeds': 0,
'fetched_feeds': 0,
'page_fill_outs': 0,
'recommended_feed_page': 0,
'feed_view_positions_timer': 0,
'interactions_page': 1,
'activities_page': 1
};
this.cache = {
'iframe_stories': {},
'feed_view_stories': {},
'iframe_story_positions': {},
'feed_view_story_positions': {},
'iframe_story_positions_keys': [],
'feed_view_story_positions_keys': [],
'river_feeds_with_unreads': [],
'mouse_position_y': parseInt(this.model.preference('lock_mouse_indicator'), 10),
'$feed_in_feed_list': {},
'$feed_counts_in_feed_list': {},
'$feed_in_social_feed_list': {}
};
this.layout = {};
this.constants = {
FEED_REFRESH_INTERVAL: (1000 * 60) * 1, // 1 minute
FILL_OUT_PAGES: 50,
RIVER_STORIES_FOR_STANDARD_ACCOUNT: 12
};
// ==================
// = Event Handlers =
// ==================
$(window).bind('resize.reader', _.throttle($.rescope(this.resize_window, this), 1000));
this.$s.$body.bind('dblclick.reader', $.rescope(this.handle_dblclicks, this));
this.$s.$body.bind('click.reader', $.rescope(this.handle_clicks, this));
this.$s.$body.bind('keyup.reader', $.rescope(this.handle_keyup, this));
this.$s.$body.live('contextmenu.reader', $.rescope(this.handle_rightclicks, this));
this.$s.$story_titles.scroll($.rescope(this.handle_scroll_story_titles, this));
this.$s.$feed_stories.scroll($.rescope(this.handle_scroll_feed_view, this));
this.$s.$feed_stories.bind('mousemove', $.rescope(this.handle_mousemove_feed_view, this));
this.handle_keystrokes();
// ============
// = Bindings =
// ============
_.bindAll(this, 'show_stories_error', 'make_story_share_comment', 'sort_items');
// ==================
// = Initialization =
// ==================
var refresh_page = this.check_and_load_ssl();
if (refresh_page) return;
this.load_javascript_elements_on_page();
this.unload_feed_iframe();
this.unload_story_iframe();
this.apply_resizable_layout();
this.add_body_classes();
if (NEWSBLUR.Flags['start_import_from_google_reader']) {
this.start_import_from_google_reader();
} else {
this.load_feeds();
}
this.cornerize_buttons();
this.setup_feed_page_iframe_load();
this.load_intelligence_slider();
this.handle_mouse_indicator_hover();
this.position_mouse_indicator();
this.handle_login_and_signup_forms();
this.iframe_buster_buster();
this.apply_story_styling();
this.apply_tipsy_titles();
this.load_recommended_feeds();
this.setup_dashboard_graphs();
this.setup_feedback_table();
this.setup_howitworks_hovers();
this.setup_interactions_module();
this.setup_activities_module();
};
NEWSBLUR.Reader = Backbone.Router.extend({
init: function() {
// ===========
// = Globals =
// ===========
NEWSBLUR.assets = new NEWSBLUR.AssetModel();
this.model = NEWSBLUR.assets;
this.story_view = 'page';
this.$s = {
$body: $('body'),
$feed_lists: $('.NB-feedlists'),
$feed_list: $('#feed_list'),
$social_feeds: $('.NB-socialfeeds'),
$story_titles: $('#story_titles'),
$content_pane: $('.content-pane'),
$story_taskbar: $('#story_taskbar'),
$story_pane: $('#story_pane .NB-story-pane-container'),
$feed_view: $('.NB-feed-story-view'),
$feed_stories: $('.NB-feed-stories'),
$feed_iframe: $('.NB-feed-iframe'),
$story_iframe: $('.NB-story-iframe'),
$intelligence_slider: $('.NB-intelligence-slider'),
$mouse_indicator: $('#mouse-indicator'),
$feed_link_loader: $('#NB-feeds-list-loader'),
$feeds_progress: $('#NB-progress'),
$dashboard: $('.NB-feeds-header-dashboard'),
$river_header: $('.NB-feeds-header-river'),
$starred_header: $('.NB-feeds-header-starred'),
$tryfeed_header: $('.NB-feeds-header-tryfeed'),
$taskbar: $('.taskbar_nav'),
$feed_floater: $('.NB-feed-story-view-floater')
};
this.flags = {
'feed_view_images_loaded': {},
'bouncing_callout': false,
'has_unfetched_feeds': false,
'count_unreads_after_import_working': false,
'import_from_google_reader_working': false,
'favicons_downloaded': false
};
this.locks = {};
this.counts = {
'page': 1,
'feature_page': 0,
'unfetched_feeds': 0,
'fetched_feeds': 0,
'page_fill_outs': 0,
'recommended_feed_page': 0,
'feed_view_positions_timer': 0,
'interactions_page': 1,
'activities_page': 1
};
this.cache = {
'iframe_stories': {},
'feed_view_stories': {},
'iframe_story_positions': {},
'feed_view_story_positions': {},
'iframe_story_positions_keys': [],
'feed_view_story_positions_keys': [],
'river_feeds_with_unreads': [],
'mouse_position_y': parseInt(this.model.preference('lock_mouse_indicator'), 10),
'$feed_in_feed_list': {},
'$feed_counts_in_feed_list': {},
'$feed_in_social_feed_list': {}
};
this.layout = {};
this.constants = {
FEED_REFRESH_INTERVAL: (1000 * 60) * 1, // 1 minute
FILL_OUT_PAGES: 50,
RIVER_STORIES_FOR_STANDARD_ACCOUNT: 12
};
// ==================
// = Event Handlers =
// ==================
$(window).bind('resize.reader', _.throttle($.rescope(this.resize_window, this), 1000));
this.$s.$body.bind('dblclick.reader', $.rescope(this.handle_dblclicks, this));
this.$s.$body.bind('click.reader', $.rescope(this.handle_clicks, this));
this.$s.$body.bind('keyup.reader', $.rescope(this.handle_keyup, this));
this.$s.$body.live('contextmenu.reader', $.rescope(this.handle_rightclicks, this));
this.$s.$story_titles.scroll($.rescope(this.handle_scroll_story_titles, this));
this.$s.$feed_stories.scroll($.rescope(this.handle_scroll_feed_view, this));
this.$s.$feed_stories.bind('mousemove', $.rescope(this.handle_mousemove_feed_view, this));
this.handle_keystrokes();
// ============
// = Bindings =
// ============
_.bindAll(this, 'show_stories_error', 'make_story_share_comment', 'sort_items');
// ==================
// = Initialization =
// ==================
var refresh_page = this.check_and_load_ssl();
if (refresh_page) return;
this.load_javascript_elements_on_page();
this.unload_feed_iframe();
this.unload_story_iframe();
this.apply_resizable_layout();
this.add_body_classes();
if (NEWSBLUR.Flags['start_import_from_google_reader']) {
this.start_import_from_google_reader();
} else {
NEWSBLUR.app.feed_list = new NEWSBLUR.Views.FeedList();
}
this.cornerize_buttons();
this.setup_feed_page_iframe_load();
this.load_intelligence_slider();
this.handle_mouse_indicator_hover();
this.position_mouse_indicator();
this.handle_login_and_signup_forms();
this.iframe_buster_buster();
this.apply_story_styling();
this.apply_tipsy_titles();
this.load_recommended_feeds();
this.setup_dashboard_graphs();
this.setup_feedback_table();
this.setup_howitworks_hovers();
this.setup_interactions_module();
this.setup_activities_module();
},
NEWSBLUR.Reader.prototype = {
// ========
// = Page =
// ========
@ -1115,107 +1117,6 @@
// = Feed Pane =
// =============
load_feeds: function(callback) {
var self = this;
if ($('#feed_list').length) {
$('.NB-callout-ftux .NB-callout-text').text('Loading feeds...');
this.$s.$feed_link_loader.css({'display': 'block'});
this.flags['favicons_downloaded'] = false;
this.model.reset_feeds();
this.model.load_feeds(_.bind(function() {
this.make_feeds();
this.make_social_feeds();
this.load_router();
callback && callback();
}, this));
}
},
make_feeds: function() {
var self = this;
var $feed_list = this.$s.$feed_list;
var folders = this.model.folders;
var feeds = this.model.feeds;
// NEWSBLUR.log(['Making feeds', {'folders': folders, 'feeds': feeds}]);
$feed_list.empty();
this.$s.$story_taskbar.css({'display': 'block'});
var $feeds = this.make_feeds_folder(folders, 0);
$feed_list.css({
'display': 'block',
'opacity': 0
});
$feed_list.html($feeds);
this.count_collapsed_unread_stories();
$feed_list.animate({'opacity': 1}, {'duration': 700});
this.hover_over_feed_titles($feed_list);
this.$s.$feed_link_loader.fadeOut(250);
if (folders.length) {
$('.NB-task-manage').removeClass('NB-disabled');
$('.NB-callout-ftux').fadeOut(500);
}
this.open_dialog_after_feeds_loaded();
if (NEWSBLUR.Globals.is_authenticated && this.model.flags['has_chosen_feeds']) {
_.delay(_.bind(this.start_count_unreads_after_import, this), 1000);
this.flags['refresh_inline_feed_delay'] = true;
this.force_feeds_refresh($.rescope(this.finish_count_unreads_after_import, this), true);
}
if (folders.length) {
this.load_sortable_feeds();
this.update_header_counts();
_.delay(_.bind(this.update_starred_count, this), 250);
NEWSBLUR.reader.check_hide_getting_started();
}
if (this.flags['showing_feed_in_tryfeed_view'] || this.flags['showing_social_feed_in_tryfeed_view']) {
this.hide_tryfeed_view();
this.force_feed_refresh();
}
_.defer(_.bind(function() {
this.make_feed_favicons();
// this.model.load_feed_favicons($.rescope(this.make_feed_favicons, this), this.flags['favicons_downloaded'], this.model.flags['has_chosen_feeds']);
if (this.socket) {
this.send_socket_active_feeds();
} else {
var force_socket = NEWSBLUR.Globals.is_admin;
this.setup_socket_realtime_unread_counts(force_socket);
}
}, this));
},
make_social_feeds: function(callback) {
var $social_feeds = this.$s.$social_feeds;
var profile = this.model.user_profile;
$social_feeds.empty();
var $feeds = "";
this.model.social_feeds.sort().each(_.bind(function(feed) {
var $feed = this.make_feed_title_template(feed.attributes, 'feed', 0);
$feeds += $feed;
}, this));
$social_feeds.css({
'display': 'block',
'opacity': 0
});
$social_feeds.html($feeds);
$social_feeds.animate({'opacity': 1}, {'duration': 700});
if (this.socket) {
this.send_socket_active_feeds();
}
$('.NB-module-stats-count-shared-stories .NB-module-stats-count-number').text(profile.get('shared_stories_count'));
$('.NB-module-stats-count-followers .NB-module-stats-count-number').text(profile.get('follower_count'));
$('.NB-module-stats-count-following .NB-module-stats-count-number').text(profile.get('following_count'));
callback && callback();
},
load_router: function() {
if (!NEWSBLUR.router) {
NEWSBLUR.router = new NEWSBLUR.Router;
@ -5839,7 +5740,7 @@
var duplicate_feed = this.find_feed_in_feed_list(feed_id).length > 1;
this.model.unfollow_user(feed_id, function() {
NEWSBLUR.reader.make_social_feeds();
NEWSBLUR.app.feed_list.make_social_feeds();
});
},
@ -5964,7 +5865,7 @@
this.$s.$feed_list.css('opacity', 1).animate({'opacity': 0}, {
'duration': 100,
'complete': _.bind(function() {
this.make_feeds();
NEWSBLUR.app.feed_list.make_feeds();
}, this)
});
}, this), 250);
@ -6000,7 +5901,7 @@
this.$s.$feed_list.css('opacity', 1).animate({'opacity': 0}, {
'duration': 100,
'complete': _.bind(function() {
this.make_feeds();
NEWSBLUR.app.feed_list.make_feeds();
}, this)
});
}, this), 250);
@ -7253,9 +7154,8 @@
var self = this;
var socialsub = this.model.get_feed(feed_id);
this.model.follow_user(socialsub.user_id, function(data) {
NEWSBLUR.reader.make_social_feeds(function() {
self.open_social_stories(feed_id);
});
NEWSBLUR.app.feed_list.make_social_feeds();
self.open_social_stories(feed_id);
});
},
@ -8695,6 +8595,6 @@
});
}
};
});
})(jQuery);

View file

@ -8,7 +8,7 @@ NEWSBLUR.ReaderAccount = function(options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};

View file

@ -6,7 +6,7 @@ NEWSBLUR.ReaderAddFeed = function(options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};
@ -214,7 +214,7 @@ _.extend(NEWSBLUR.ReaderAddFeed.prototype, {
$submit.removeClass('NB-disabled');
if (data.code > 0) {
NEWSBLUR.reader.load_feeds();
NEWSBLUR.app.feed_list.fetch();
NEWSBLUR.reader.load_recommended_feed();
NEWSBLUR.reader.handle_mouse_indicator_hover();
$.modal.close();
@ -251,7 +251,7 @@ _.extend(NEWSBLUR.ReaderAddFeed.prototype, {
$submit.removeClass('NB-disabled');
if (data.code > 0) {
NEWSBLUR.reader.load_feeds();
NEWSBLUR.app.feed_list.fetch();
_.defer(function() {
NEWSBLUR.reader.open_add_feed_modal();
});

View file

@ -13,7 +13,7 @@ NEWSBLUR.ReaderClassifierTrainer = function(options) {
this.trainer_iterator = -1;
this.feed_id = null;
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner_trainer();
};
@ -33,7 +33,7 @@ NEWSBLUR.ReaderClassifierFeed = function(feed_id, options) {
this.feed_id = feed_id;
this.trainer_iterator = -1;
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner_feed();
};
@ -54,7 +54,7 @@ NEWSBLUR.ReaderClassifierStory = function(story_id, feed_id, options) {
this.feed_id = feed_id;
this.trainer_iterator = -1;
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner_story();
};

View file

@ -2,7 +2,7 @@ NEWSBLUR.ReaderFeedException = function(feed_id, options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.feed_id = feed_id;
this.feed = this.model.get_feed(feed_id);

View file

@ -2,7 +2,7 @@ NEWSBLUR.ReaderFeedchooser = function(options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};
@ -47,7 +47,7 @@ NEWSBLUR.ReaderFeedchooser.prototype = {
$.make('div', { className: 'NB-feedchooser-info-counts'}),
$.make('div', { className: 'NB-feedchooser-info-sort'}, 'Auto-Selected By Popularity')
]),
this.make_feeds(),
NEWSBLUR.app.feed_list.make_feeds(),
$.make('form', { className: 'NB-feedchooser-form' }, [
$.make('div', { className: 'NB-modal-submit' }, [
// $.make('div', { className: 'NB-modal-submit-or' }, 'or'),
@ -388,7 +388,7 @@ NEWSBLUR.ReaderFeedchooser.prototype = {
this.model.save_feed_chooser(approve_list, function() {
self.flags['has_saved'] = true;
NEWSBLUR.reader.hide_feed_chooser_button();
NEWSBLUR.reader.load_feeds();
NEWSBLUR.app.feed_list.fetch();
$.modal.close();
});
},

View file

@ -4,7 +4,7 @@ NEWSBLUR.ReaderFriends = function(options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};

View file

@ -2,7 +2,7 @@ NEWSBLUR.ReaderGoodies = function(options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};

View file

@ -3,7 +3,7 @@ NEWSBLUR.ReaderIntro = function(options) {
var intro_page = this.model.preference('intro_page');
_.bindAll(this, 'close', 'start_import_from_google_reader', 'post_connect');
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.options = $.extend({
'page_number': intro_page && _.isNumber(intro_page) && intro_page <= 4 ? intro_page : 1
}, defaults, options);
@ -422,7 +422,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
finish_import_from_google_reader: function() {
var $loading = $('.NB-intro-imports-progress .NB-loading', this.$modal);
NEWSBLUR.reader.load_feeds(_.bind(function() {
NEWSBLUR.app.feed_list.fetch(_.bind(function() {
$loading.removeClass('NB-active');
this.advance_import_carousel(2);
}, this));
@ -452,7 +452,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
url: NEWSBLUR.URLs['opml-upload'],
type: 'POST',
success: function (data, status) {
NEWSBLUR.reader.load_feeds(function() {
NEWSBLUR.app.feed_list.fetch(function() {
$loading.removeClass('NB-active');
self.advance_import_carousel(2);
});
@ -513,7 +513,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
$button.addClass('NB-active');
if (feed == 'blog') {
this.model.save_add_url(blog_url, "", function() {
NEWSBLUR.reader.load_feeds();
NEWSBLUR.app.feed_list.fetch();
}, {auto_active: false});
} else if (feed == 'popular') {
this.model.follow_user(popular_username, function() {
@ -524,11 +524,11 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
$button.removeClass('NB-active');
if (feed == 'blog') {
this.model.delete_feed_by_url(blog_url, "", function() {
NEWSBLUR.reader.load_feeds();
NEWSBLUR.app.feed_list.fetch();
});
} else if (feed == 'popular') {
this.model.unfollow_user(popular_username, function() {
NEWSBLUR.reader.make_social_feeds();
NEWSBLUR.app.feed_list.make_social_feeds();
});
}
}

View file

@ -4,7 +4,7 @@ NEWSBLUR.ReaderMarkRead = function(options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};

View file

@ -6,7 +6,7 @@ NEWSBLUR.ReaderPreferences = function(options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.runner();
};
@ -713,8 +713,8 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
NEWSBLUR.reader.update_header_counts();
if (self.original_preferences['feed_order'] != form['feed_order'] ||
self.original_preferences['folder_counts'] != form['folder_counts']) {
NEWSBLUR.reader.make_feeds();
NEWSBLUR.reader.make_social_feeds();
NEWSBLUR.app.feed_list.make_feeds();
NEWSBLUR.app.feed_list.make_social_feeds();
}
if (self.original_preferences['story_pane_anchor'] != form['story_pane_anchor']) {
NEWSBLUR.reader.apply_resizable_layout(true);

View file

@ -4,7 +4,7 @@ NEWSBLUR.ReaderProfileEditor = function(options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.profile = this.model.user_profile;
this.runner();

View file

@ -2,7 +2,7 @@ NEWSBLUR.ReaderRecommendFeed = function(feed_id, options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.feed_id = feed_id;
this.feed = this.model.get_feed(feed_id);
this.feeds = this.model.get_feeds();

View file

@ -4,7 +4,7 @@ NEWSBLUR.ReaderSendEmail = function(story_id, options) {
_.bindAll(this, 'close', 'save_callback', 'error');
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.story_id = story_id;
this.story = this.model.get_story(story_id);
this.feed_id = this.story.story_feed_id;

View file

@ -4,7 +4,7 @@ NEWSBLUR.ReaderSocialProfile = function(user_id, options) {
};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.profiles = new NEWSBLUR.Collections.Users();
user_id = parseInt(_.string.ltrim(user_id, 'social:'), 10);
console.log(["user_id", user_id]);

View file

@ -2,7 +2,7 @@ NEWSBLUR.ReaderStatistics = function(feed_id, options) {
var defaults = {};
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.feed_id = feed_id;
this.feed = this.model.get_feed(feed_id);
this.feeds = this.model.get_feeds();

View file

@ -6,7 +6,7 @@ NEWSBLUR.ReaderTutorial = function(options) {
this.options = $.extend({
'page_number': 1
}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.model = NEWSBLUR.assets;
this.page_number = this.options.page_number;
this.slider_value = 0;

View file

View file

View file

@ -110,7 +110,7 @@ NEWSBLUR.Views.SocialProfileBadge = Backbone.View.extend({
$button.removeClass('NB-profile-badge-action-follow')
.addClass('NB-profile-badge-action-unfollow');
NEWSBLUR.reader.make_social_feeds();
NEWSBLUR.app.feed_list.make_social_feeds();
}, this));
},
@ -127,7 +127,7 @@ NEWSBLUR.Views.SocialProfileBadge = Backbone.View.extend({
$button.removeClass('NB-profile-badge-action-unfollow')
.addClass('NB-profile-badge-action-follow');
NEWSBLUR.reader.make_social_feeds();
NEWSBLUR.app.feed_list.make_social_feeds();
}, this));
},

View file

View file

View file

@ -71,6 +71,7 @@
NEWSBLUR.Models = {};
NEWSBLUR.Collections = {};
NEWSBLUR.Views = {};
NEWSBLUR.app = {};
</script>
{% include_stylesheets "common" %}

View file

@ -7,6 +7,7 @@
$(document).ready(function() {
NEWSBLUR.reader = new NEWSBLUR.Reader();
NEWSBLUR.reader.init();
});
</script>