2011-11-04 18:12:28 -07:00
|
|
|
(function($) {
|
2012-02-14 10:34:10 -08:00
|
|
|
|
2012-05-17 18:40:46 -07:00
|
|
|
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,
|
2012-05-18 18:13:45 -07:00
|
|
|
'import_from_google_reader_working': false
|
2012-05-17 18:40:46 -07:00
|
|
|
};
|
|
|
|
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': {},
|
|
|
|
'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_social_feed_list': {}
|
|
|
|
};
|
2012-05-23 14:11:42 -07:00
|
|
|
this.views = {};
|
2012-05-17 18:40:46 -07:00
|
|
|
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));
|
2012-05-25 20:52:30 -07:00
|
|
|
// this.$s.$body.bind('dblclick.reader', $.rescope(this.handle_dblclicks, this));
|
2012-05-17 18:40:46 -07:00
|
|
|
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));
|
2012-05-25 16:42:41 -07:00
|
|
|
// 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));
|
2012-05-17 18:40:46 -07:00
|
|
|
this.handle_keystrokes();
|
|
|
|
|
|
|
|
// ============
|
|
|
|
// = Bindings =
|
|
|
|
// ============
|
|
|
|
|
2012-06-02 16:33:44 -07:00
|
|
|
_.bindAll(this, 'show_stories_error');
|
2012-05-17 18:40:46 -07:00
|
|
|
|
|
|
|
// ==================
|
|
|
|
// = 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();
|
|
|
|
}
|
2012-05-24 17:32:01 -07:00
|
|
|
NEWSBLUR.app.feed_list_header = new NEWSBLUR.Views.FeedListHeader({collection: NEWSBLUR.assets.feeds});
|
|
|
|
NEWSBLUR.app.feed_list = new NEWSBLUR.Views.FeedList();
|
|
|
|
NEWSBLUR.app.story_titles = new NEWSBLUR.Views.StoryTitlesView({collection: NEWSBLUR.assets.stories});
|
|
|
|
NEWSBLUR.app.story_list = new NEWSBLUR.Views.StoryListView({collection: NEWSBLUR.assets.stories});
|
2012-05-17 18:40:46 -07:00
|
|
|
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();
|
|
|
|
},
|
2010-06-08 11:19:41 -04:00
|
|
|
|
|
|
|
// ========
|
|
|
|
// = Page =
|
|
|
|
// ========
|
2011-03-04 12:27:31 -05:00
|
|
|
|
2012-02-29 17:18:55 -08:00
|
|
|
check_and_load_ssl: function() {
|
|
|
|
if (window.location.protocol == 'http:' && this.model.preference('ssl')) {
|
|
|
|
window.location.href = window.location.href.replace('http:', 'https:');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-03-04 12:27:31 -05:00
|
|
|
load_javascript_elements_on_page: function() {
|
|
|
|
$('.NB-javascript').removeClass('NB-javascript');
|
|
|
|
},
|
|
|
|
|
2011-02-22 19:11:29 -05:00
|
|
|
resize_window: function() {
|
|
|
|
var flag;
|
|
|
|
var view = this.story_view;
|
|
|
|
|
|
|
|
if (this.flags['page_view_showing_feed_view']) {
|
|
|
|
view = 'feed';
|
|
|
|
flag = 'page';
|
|
|
|
} else if (this.flags['feed_view_showing_story_view']) {
|
|
|
|
view = 'story';
|
|
|
|
flag = 'story';
|
|
|
|
}
|
2012-02-24 16:14:24 -08:00
|
|
|
|
|
|
|
this.counts['feed_view_positions_timer'] = 0;
|
2011-09-29 22:12:46 -07:00
|
|
|
this.flags.scrolling_by_selecting_story_title = true;
|
|
|
|
clearTimeout(this.locks.scrolling);
|
|
|
|
this.locks.scrolling = _.delay(_.bind(function() {
|
|
|
|
this.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
}, this), 1000);
|
|
|
|
|
2011-02-22 19:11:29 -05:00
|
|
|
this.switch_taskbar_view(view, flag);
|
2011-09-27 22:16:09 -07:00
|
|
|
this.check_story_titles_last_story();
|
2012-06-05 12:23:17 -07:00
|
|
|
// this.flags.fetch_story_locations_in_feed_view = this.flags.fetch_story_locations_in_feed_view ||
|
|
|
|
// _.throttle(_.bind(this.fetch_story_locations_in_feed_view, this), 2000);
|
|
|
|
// this.flags.fetch_story_locations_in_feed_view();
|
2011-02-22 19:11:29 -05:00
|
|
|
},
|
|
|
|
|
2011-09-29 09:53:55 -07:00
|
|
|
apply_resizable_layout: function(refresh) {
|
2011-09-26 10:27:21 -07:00
|
|
|
var story_anchor = this.model.preference('story_pane_anchor');
|
2011-09-29 22:12:46 -07:00
|
|
|
var right_pane_hidden = !$('.right-pane').is(':visible');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-09-29 09:53:55 -07:00
|
|
|
if (refresh) {
|
|
|
|
this.layout.contentLayout && this.layout.contentLayout.destroy();
|
|
|
|
this.layout.rightLayout && this.layout.rightLayout.destroy();
|
2011-09-29 22:12:46 -07:00
|
|
|
this.layout.leftCenterLayout && this.layout.leftCenterLayout.destroy();
|
|
|
|
this.layout.leftLayout && this.layout.leftLayout.destroy();
|
|
|
|
this.layout.outerLayout && this.layout.outerLayout.destroy();
|
|
|
|
|
2011-09-29 09:53:55 -07:00
|
|
|
var feed_stories_bin = $.make('div').append(this.$s.$feed_stories.children());
|
|
|
|
var story_titles_bin = $.make('div').append(this.$s.$story_titles.children());
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-09-29 09:53:55 -07:00
|
|
|
$('.right-pane').removeClass('NB-story-pane-west')
|
|
|
|
.removeClass('NB-story-pane-north')
|
|
|
|
.removeClass('NB-story-pane-south')
|
|
|
|
.addClass('NB-story-pane-'+story_anchor);
|
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
this.layout.outerLayout = this.$s.$body.layout({
|
2010-06-13 18:57:20 -04:00
|
|
|
closable: true,
|
|
|
|
center__paneSelector: ".right-pane",
|
|
|
|
west__paneSelector: ".left-pane",
|
2010-08-13 19:50:56 -04:00
|
|
|
west__size: this.model.preference('feed_pane_size'),
|
2012-02-08 18:11:08 -08:00
|
|
|
west__minSize: 240,
|
2010-08-13 19:50:56 -04:00
|
|
|
west__onresize_end: $.rescope(this.save_feed_pane_size, this),
|
2010-06-13 18:57:20 -04:00
|
|
|
spacing_open: 4,
|
2011-03-09 18:23:55 -05:00
|
|
|
resizerDragOpacity: 0.6,
|
2011-09-26 10:27:21 -07:00
|
|
|
resizeWhileDragging: true,
|
2011-03-09 18:23:55 -05:00
|
|
|
enableCursorHotkey: false
|
2010-06-13 18:57:20 -04:00
|
|
|
});
|
|
|
|
|
2012-02-08 18:11:08 -08:00
|
|
|
if (this.model.preference('feed_pane_size') < 240) {
|
|
|
|
this.layout.outerLayout.resizeAll();
|
|
|
|
}
|
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
this.layout.leftLayout = $('.left-pane').layout({
|
2010-06-13 18:57:20 -04:00
|
|
|
closable: false,
|
2011-09-26 10:27:21 -07:00
|
|
|
resizeWhileDragging: true,
|
2010-12-10 09:32:06 -05:00
|
|
|
fxName: "scale",
|
|
|
|
fxSettings: { duration: 500, easing: "easeInOutQuint" },
|
2011-03-13 16:24:49 -04:00
|
|
|
north__paneSelector: ".left-north",
|
|
|
|
north__size: 18,
|
|
|
|
north__resizeable: false,
|
|
|
|
north__spacing_open: 0,
|
2010-06-13 18:57:20 -04:00
|
|
|
center__paneSelector: ".left-center",
|
|
|
|
center__resizable: false,
|
|
|
|
south__paneSelector: ".left-south",
|
2010-08-11 23:02:17 -04:00
|
|
|
south__size: 31,
|
2010-06-13 18:57:20 -04:00
|
|
|
south__resizable: false,
|
2011-03-09 18:23:55 -05:00
|
|
|
south__spacing_open: 0,
|
|
|
|
enableCursorHotkey: false
|
2010-06-13 18:57:20 -04:00
|
|
|
});
|
2010-11-22 10:44:52 -05:00
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
this.layout.leftCenterLayout = $('.left-center').layout({
|
2010-11-22 10:44:52 -05:00
|
|
|
closable: false,
|
|
|
|
slidable: false,
|
2011-09-26 10:27:21 -07:00
|
|
|
resizeWhileDragging: true,
|
2010-11-22 10:44:52 -05:00
|
|
|
center__paneSelector: ".left-center-content",
|
|
|
|
center__resizable: false,
|
|
|
|
south__paneSelector: ".left-center-footer",
|
2010-11-24 13:16:10 -05:00
|
|
|
south__size: 'auto',
|
2010-11-22 10:44:52 -05:00
|
|
|
south__resizable: false,
|
|
|
|
south__slidable: true,
|
|
|
|
south__spacing_open: 0,
|
|
|
|
south__spacing_closed: 0,
|
|
|
|
south__closable: true,
|
|
|
|
south__initClosed: true,
|
2010-12-10 09:32:06 -05:00
|
|
|
fxName: "slide",
|
|
|
|
fxSpeed: 1000,
|
2011-03-09 18:23:55 -05:00
|
|
|
fxSettings: { duration: 1000, easing: "easeInOutQuint" },
|
|
|
|
enableCursorHotkey: false
|
2010-11-22 10:44:52 -05:00
|
|
|
});
|
2011-09-26 10:27:21 -07:00
|
|
|
|
|
|
|
var rightLayoutOptions = {
|
|
|
|
resizeWhileDragging: true,
|
2010-06-13 18:57:20 -04:00
|
|
|
center__paneSelector: ".content-pane",
|
2011-09-27 22:16:09 -07:00
|
|
|
spacing_open: story_anchor == 'west' ? 4 : 10,
|
2011-03-09 18:23:55 -05:00
|
|
|
resizerDragOpacity: 0.6,
|
|
|
|
enableCursorHotkey: false
|
2011-09-26 10:27:21 -07:00
|
|
|
};
|
|
|
|
rightLayoutOptions[story_anchor+'__paneSelector'] = '.right-north';
|
|
|
|
rightLayoutOptions[story_anchor+'__size'] = this.model.preference('story_titles_pane_size');
|
|
|
|
rightLayoutOptions[story_anchor+'__onresize_end'] = $.rescope(this.save_story_titles_pane_size, this);
|
2011-09-27 22:16:09 -07:00
|
|
|
this.layout.rightLayout = $('.right-pane').layout(rightLayoutOptions);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-09-26 10:27:21 -07:00
|
|
|
var contentLayoutOptions = {
|
|
|
|
resizeWhileDragging: true,
|
2010-06-13 18:57:20 -04:00
|
|
|
center__paneSelector: ".content-center",
|
|
|
|
spacing_open: 0,
|
2011-03-09 18:23:55 -05:00
|
|
|
resizerDragOpacity: 0.6,
|
|
|
|
enableCursorHotkey: false
|
2011-09-26 10:27:21 -07:00
|
|
|
};
|
2011-09-27 22:16:09 -07:00
|
|
|
if (story_anchor == 'west') {
|
|
|
|
contentLayoutOptions['north__paneSelector'] = '.content-north';
|
|
|
|
contentLayoutOptions['north__size'] = 30;
|
|
|
|
} else {
|
|
|
|
contentLayoutOptions[story_anchor+'__paneSelector'] = '.content-north';
|
|
|
|
contentLayoutOptions[story_anchor+'__size'] = 30;
|
|
|
|
}
|
|
|
|
this.layout.contentLayout = this.$s.$content_pane.layout(contentLayoutOptions);
|
2011-09-29 22:12:46 -07:00
|
|
|
|
2011-09-29 09:53:55 -07:00
|
|
|
if (!refresh) {
|
|
|
|
$('.right-pane').hide();
|
|
|
|
} else {
|
|
|
|
this.$s.$feed_stories.append(feed_stories_bin.children());
|
|
|
|
this.$s.$story_titles.append(story_titles_bin.children());
|
|
|
|
this.resize_window();
|
2011-09-29 22:12:46 -07:00
|
|
|
if (right_pane_hidden) {
|
|
|
|
$('.right-pane').hide();
|
|
|
|
}
|
2011-09-29 09:53:55 -07:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-02-22 19:11:29 -05:00
|
|
|
apply_tipsy_titles: function() {
|
2011-05-01 20:22:54 -04:00
|
|
|
if (this.model.preference('show_tooltips')) {
|
|
|
|
$('.NB-taskbar-sidebar-toggle-close').tipsy({
|
|
|
|
gravity: 'se',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
$('.NB-taskbar-sidebar-toggle-open').tipsy({
|
|
|
|
gravity: 'sw',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
$('.NB-task-add').tipsy({
|
|
|
|
gravity: 'sw',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
$('.NB-task-manage').tipsy({
|
|
|
|
gravity: 's',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('.NB-taskbar-sidebar-toggle-close').tipsy('disable');
|
|
|
|
$('.NB-taskbar-sidebar-toggle-open').tipsy('disable');
|
|
|
|
$('.NB-task-add').tipsy('disable');
|
|
|
|
$('.NB-task-manage').tipsy('disable');
|
|
|
|
}
|
2012-04-02 18:48:41 -07:00
|
|
|
$('.NB-module-content-account-realtime').tipsy({
|
|
|
|
gravity: 's',
|
|
|
|
delayIn: 0
|
|
|
|
});
|
2011-02-22 19:11:29 -05:00
|
|
|
},
|
|
|
|
|
2010-08-13 19:50:56 -04:00
|
|
|
save_feed_pane_size: function(w, pane, $pane, state, options, name) {
|
2011-03-14 21:44:04 -04:00
|
|
|
var feed_pane_size = state.size;
|
|
|
|
|
2011-05-09 18:30:11 -04:00
|
|
|
$('#NB-splash').css('left', feed_pane_size);
|
2011-09-26 10:27:21 -07:00
|
|
|
this.flags.set_feed_pane_size = this.flags.set_feed_pane_size || _.debounce( _.bind(function() {
|
2011-09-27 22:16:09 -07:00
|
|
|
var feed_pane_size = this.layout.outerLayout.state.west.size;
|
2011-09-26 10:27:21 -07:00
|
|
|
this.model.preference('feed_pane_size', feed_pane_size);
|
|
|
|
this.flags.set_feed_pane_size = null;
|
|
|
|
}, this), 1000);
|
|
|
|
this.flags.set_feed_pane_size();
|
2010-08-13 19:50:56 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
save_story_titles_pane_size: function(w, pane, $pane, state, options, name) {
|
2011-09-29 22:12:46 -07:00
|
|
|
this.flags.scrolling_by_selecting_story_title = true;
|
|
|
|
clearTimeout(this.locks.scrolling);
|
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
var offset = 0;
|
|
|
|
if (this.story_view == 'feed') {
|
|
|
|
offset = this.$s.$feed_iframe.width();
|
|
|
|
} else if (this.story_view == 'story') {
|
|
|
|
offset = 2 * this.$s.$feed_iframe.width();
|
|
|
|
}
|
|
|
|
this.$s.$story_pane.css('left', -1 * offset);
|
2011-09-29 22:12:46 -07:00
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
this.flags.set_story_titles_size = this.flags.set_story_titles_size || _.debounce( _.bind(function() {
|
|
|
|
var story_titles_size = this.layout.rightLayout.state[this.model.preference('story_pane_anchor')].size;
|
|
|
|
this.model.preference('story_titles_pane_size', story_titles_size);
|
|
|
|
this.flags.set_story_titles_size = null;
|
2011-09-29 22:12:46 -07:00
|
|
|
this.locks.scrolling = _.delay(_.bind(function() {
|
|
|
|
this.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
}, this), 100);
|
2011-09-27 22:16:09 -07:00
|
|
|
}, this), 1000);
|
|
|
|
this.flags.set_story_titles_size();
|
2011-09-29 22:12:46 -07:00
|
|
|
|
|
|
|
this.flags.resize_window = this.flags.resize_window || _.debounce( _.bind(function() {
|
|
|
|
this.resize_window();
|
|
|
|
this.flags.resize_window = null;
|
|
|
|
}, this), 10);
|
|
|
|
this.flags.resize_window();
|
|
|
|
|
2010-08-13 19:50:56 -04:00
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
cornerize_buttons: function() {
|
|
|
|
$('.button').corner();
|
|
|
|
},
|
|
|
|
|
2011-01-25 09:17:15 -05:00
|
|
|
add_body_classes: function() {
|
2012-05-25 16:42:41 -07:00
|
|
|
this.$s.$body.toggleClass('NB-is-premium', NEWSBLUR.Globals.is_premium);
|
|
|
|
this.$s.$body.toggleClass('NB-is-anonymous', NEWSBLUR.Globals.is_anonymous);
|
|
|
|
this.$s.$body.toggleClass('NB-is-authenticated', NEWSBLUR.Globals.is_authenticated);
|
|
|
|
this.$s.$body.toggleClass('NB-pref-hide-changes', !!this.model.preference('hide_story_changes'));
|
2011-01-25 09:17:15 -05:00
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
hide_splash_page: function() {
|
2010-08-13 19:21:29 -04:00
|
|
|
var self = this;
|
2012-03-14 17:48:28 -07:00
|
|
|
var resize = false;
|
|
|
|
if (!$('.right-pane').is(':visible')) {
|
|
|
|
resize = true;
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
$('.right-pane').show();
|
|
|
|
$('#NB-splash').hide();
|
2011-04-02 19:41:22 -04:00
|
|
|
$('.NB-splash-info').hide();
|
2010-06-08 11:19:41 -04:00
|
|
|
$('#NB-splash-overlay').hide();
|
2011-03-15 23:42:27 -04:00
|
|
|
this.$s.$dashboard.addClass('NB-active');
|
2012-03-14 17:48:28 -07:00
|
|
|
|
|
|
|
if (resize) {
|
|
|
|
this.$s.$body.layout().resizeAll();
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
if (NEWSBLUR.Globals.is_anonymous) {
|
|
|
|
this.setup_ftux_signup_callout();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-01-18 17:39:00 -08:00
|
|
|
show_splash_page: function(skip_router) {
|
2010-11-22 10:44:52 -05:00
|
|
|
this.reset_feed();
|
2010-12-06 10:41:24 -05:00
|
|
|
this.unload_feed_iframe();
|
|
|
|
this.unload_story_iframe();
|
2010-06-08 11:19:41 -04:00
|
|
|
$('.right-pane').hide();
|
2011-04-02 19:41:22 -04:00
|
|
|
$('.NB-splash-info').show();
|
2010-06-08 11:19:41 -04:00
|
|
|
$('#NB-splash').show();
|
|
|
|
$('#NB-splash-overlay').show();
|
2011-03-15 23:42:27 -04:00
|
|
|
this.$s.$dashboard.removeClass('NB-active');
|
2012-01-18 17:39:00 -08:00
|
|
|
if (!skip_router) {
|
|
|
|
NEWSBLUR.router.navigate('');
|
|
|
|
}
|
2012-04-21 18:20:49 -07:00
|
|
|
this.model.preference('dashboard_date', new Date);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-08-13 19:21:29 -04:00
|
|
|
iframe_buster_buster: function() {
|
|
|
|
var self = this;
|
|
|
|
var prevent_bust = 0;
|
2010-10-06 18:44:53 -04:00
|
|
|
window.onbeforeunload = function() {
|
2010-10-06 19:12:20 -04:00
|
|
|
prevent_bust++;
|
2010-10-06 18:44:53 -04:00
|
|
|
};
|
2011-01-11 19:33:55 -05:00
|
|
|
clearInterval(this.locks.iframe_buster_buster);
|
|
|
|
this.locks.iframe_buster_buster = setInterval(function() {
|
2010-08-13 19:21:29 -04:00
|
|
|
if (prevent_bust > 0) {
|
|
|
|
prevent_bust -= 2;
|
2011-04-01 22:05:56 -04:00
|
|
|
if (!self.flags['iframe_view_loaded'] &&
|
|
|
|
!self.flags['iframe_view_not_busting'] &&
|
|
|
|
_.contains(['page', 'story'], self.story_view) &&
|
|
|
|
self.active_feed) {
|
2010-10-06 19:12:20 -04:00
|
|
|
$('.task_view_feed').click();
|
|
|
|
$('.NB-feed-frame').attr('src', '');
|
2010-10-06 19:26:04 -04:00
|
|
|
window.top.location = '/reader/buster';
|
2010-10-06 19:12:20 -04:00
|
|
|
}
|
2010-08-13 19:21:29 -04:00
|
|
|
}
|
|
|
|
}, 1);
|
|
|
|
},
|
2011-02-01 03:35:11 +01:00
|
|
|
|
2011-02-25 13:07:08 -05:00
|
|
|
add_url_from_querystring: function() {
|
2011-03-11 20:05:41 -05:00
|
|
|
if (this.flags['added_url_from_querystring']) return;
|
|
|
|
|
2011-02-25 13:07:08 -05:00
|
|
|
var url = $.getQueryString('url');
|
2011-03-11 20:05:41 -05:00
|
|
|
this.flags['added_url_from_querystring'] = true;
|
2011-02-25 13:07:08 -05:00
|
|
|
|
|
|
|
if (url) {
|
|
|
|
this.open_add_feed_modal({url: url});
|
2011-02-01 03:35:11 +01:00
|
|
|
}
|
|
|
|
},
|
2010-08-13 19:21:29 -04:00
|
|
|
|
2011-01-31 19:51:39 -05:00
|
|
|
animate_progress_bar: function($bar, seconds, percentage) {
|
|
|
|
var self = this;
|
|
|
|
percentage = percentage || 0;
|
2011-01-31 20:50:33 -05:00
|
|
|
seconds = parseFloat(Math.max(1, parseInt(seconds, 10)), 10);
|
2011-01-31 19:51:39 -05:00
|
|
|
|
|
|
|
if (percentage > 90) {
|
|
|
|
time = seconds / 5;
|
|
|
|
} else if (percentage > 80) {
|
|
|
|
time = seconds / 12;
|
|
|
|
} else if (percentage > 70) {
|
|
|
|
time = seconds / 30;
|
|
|
|
} else if (percentage > 60) {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 80;
|
2011-01-31 19:51:39 -05:00
|
|
|
} else if (percentage > 50) {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 120;
|
2011-01-31 19:51:39 -05:00
|
|
|
} else if (percentage > 40) {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 160;
|
2011-01-31 19:51:39 -05:00
|
|
|
} else if (percentage > 30) {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 200;
|
2011-01-31 19:51:39 -05:00
|
|
|
} else if (percentage > 20) {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 300;
|
2011-01-31 19:51:39 -05:00
|
|
|
} else if (percentage > 10) {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 400;
|
2011-01-31 19:51:39 -05:00
|
|
|
} else {
|
2011-02-01 00:23:44 -05:00
|
|
|
time = seconds / 500;
|
2011-01-31 19:51:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (percentage <= 100) {
|
|
|
|
this.locks['animate_progress_bar'] = setTimeout(function() {
|
2011-02-01 00:23:44 -05:00
|
|
|
percentage += 1;
|
|
|
|
$bar.progressbar({value: percentage});
|
|
|
|
self.animate_progress_bar($bar, seconds, percentage);
|
2011-01-31 19:51:39 -05:00
|
|
|
}, time * 1000);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-27 17:44:00 -07:00
|
|
|
blur_to_page: function() {
|
|
|
|
$(':focus').blur();
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// =======================
|
|
|
|
// = Getters and Finders =
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
find_feed_in_feed_list: function(feed_id) {
|
2012-02-10 19:33:31 -08:00
|
|
|
var $feed_list = this.$s.$feed_list.parent();
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feeds = $([]);
|
2012-02-14 10:34:10 -08:00
|
|
|
if (feed_id) {
|
|
|
|
$('.feed', $feed_list).each(function() {
|
|
|
|
var data_id = $(this).data('id');
|
2012-04-03 17:48:24 -07:00
|
|
|
if (data_id == feed_id ||
|
|
|
|
(!_.string.contains(data_id, 'social:') && parseInt(data_id, 10) == feed_id)) {
|
2012-02-14 10:34:10 -08:00
|
|
|
$feeds.push($(this).get(0));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
return $feeds;
|
|
|
|
},
|
|
|
|
|
2010-09-14 20:49:28 -04:00
|
|
|
find_folder_in_feed_list: function(folder_name) {
|
|
|
|
var $feed_list = this.$s.$feed_list;
|
|
|
|
var $folders = $([]);
|
|
|
|
$('.folder_title_text', $feed_list).each(function() {
|
|
|
|
if ($(this).text() == folder_name) {
|
|
|
|
$folders.push($(this).parents('li.folder').eq(0)[0]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return $folders;
|
|
|
|
},
|
|
|
|
|
2010-12-30 18:37:29 -05:00
|
|
|
find_story_in_story_titles: function(story_id) {
|
2012-04-11 15:20:57 -07:00
|
|
|
var story = story_id && this.model.get_story(story_id);
|
|
|
|
if (!story_id) story = this.active_story;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $stories = $('.story', this.$s.$story_titles);
|
|
|
|
var $story_title;
|
|
|
|
|
|
|
|
if (story) {
|
|
|
|
$stories.each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
if ($this.data('story_id') == story.id) {
|
|
|
|
$story_title = $this;
|
2012-04-27 17:44:00 -07:00
|
|
|
// NEWSBLUR.log(['Finding story in story titles', $this, story_id, story]);
|
2010-06-14 13:17:38 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return $story_title;
|
|
|
|
},
|
|
|
|
|
2011-11-15 18:37:42 -08:00
|
|
|
find_story_in_feed_view: function(story_id) {
|
|
|
|
if (!story_id) return;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
var $feed_view = this.$s.$feed_view;
|
|
|
|
var $stories = $('.NB-feed-story', $feed_view);
|
|
|
|
var $story;
|
|
|
|
|
|
|
|
for (var s=0, s_count = $stories.length; s < s_count; s++) {
|
2011-11-15 18:37:42 -08:00
|
|
|
if ($stories.eq(s).data('story') == story_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
$story = $stories.eq(s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $story;
|
|
|
|
},
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
find_story_in_feed_iframe: function(story, $iframe) {
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!story) return $([]);
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
$iframe = $iframe || this.$s.$feed_iframe.contents();
|
2010-06-14 13:17:38 -04:00
|
|
|
var $stories = $([]);
|
|
|
|
|
2011-10-03 18:19:50 -07:00
|
|
|
if (this.flags['iframe_story_locations_fetched'] || story.id in this.cache.iframe_stories) {
|
2010-06-14 13:17:38 -04:00
|
|
|
return this.cache.iframe_stories[story.id];
|
|
|
|
}
|
|
|
|
|
2012-05-25 18:54:04 -07:00
|
|
|
var title = story.get('story_title', '').replace(/ |[^a-z0-9-,]/gi, '');
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
var search_document = function(node, title) {
|
|
|
|
var skip = 0;
|
|
|
|
|
|
|
|
if (node && node.nodeType == 3) {
|
|
|
|
var pos = node.data.replace(/ |[^a-z0-9-,]/gi, '')
|
|
|
|
.indexOf(title);
|
|
|
|
if (pos >= 0) {
|
|
|
|
$stories.push($(node).parent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (node && node.nodeType == 1 && node.childNodes && !(/(script|style)/i.test(node.tagName))) {
|
|
|
|
for (var i = 0; i < node.childNodes.length; ++i) {
|
|
|
|
i += search_document(node.childNodes[i], title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
};
|
|
|
|
|
|
|
|
search_document($iframe.find('body')[0], title);
|
|
|
|
|
|
|
|
$stories = $stories.filter(function() {
|
|
|
|
return $(this).is(':visible');
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!$stories.length) {
|
|
|
|
// Not found straight, so check all header tags with styling children removed.
|
2010-11-06 12:53:42 -04:00
|
|
|
this.cache.iframe['headers'] = this.cache.iframe['headers']
|
|
|
|
|| $('h1,h2,h3,h4,h5,h6', $iframe).filter(':visible');
|
|
|
|
this.cache.iframe['headers'].each(function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
pos = $(this).text().replace(/ |[^a-z0-9-,]/gi, '')
|
|
|
|
.indexOf(title);
|
|
|
|
// NEWSBLUR.log(['Search headers', title, pos, $(this), $(this).text()]);
|
|
|
|
if (pos >= 0) {
|
|
|
|
$stories.push($(this));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$stories.length) {
|
|
|
|
// Still not found, so check Tumblr style .post's
|
2010-11-06 12:53:42 -04:00
|
|
|
this.cache.iframe['posts'] = this.cache.iframe['posts']
|
|
|
|
|| $('.entry,.post,.postProp,#postContent,.article',
|
|
|
|
$iframe).filter(':visible');
|
|
|
|
this.cache.iframe['posts'].each(function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
pos = $(this).text().replace(/ |[^a-z0-9-,]/gi, '')
|
|
|
|
.indexOf(title);
|
|
|
|
// NEWSBLUR.log(['Search .post', title, pos, $(this), $(this).text().replace(/ |[^a-z0-9-,]/gi, '')]);
|
|
|
|
if (pos >= 0) {
|
|
|
|
$stories.push($(this));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2010-07-02 11:14:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// Find the story with the biggest font size
|
|
|
|
var max_size = 0;
|
2010-07-02 11:14:41 -04:00
|
|
|
var $same_size_stories = $([]);
|
2010-06-14 13:17:38 -04:00
|
|
|
$stories.each(function() {
|
2010-07-02 11:14:41 -04:00
|
|
|
var $this = $(this);
|
|
|
|
var size = parseInt($this.css('font-size'), 10);
|
2010-06-14 13:17:38 -04:00
|
|
|
if (size > max_size) {
|
|
|
|
max_size = size;
|
2010-07-02 11:14:41 -04:00
|
|
|
$same_size_stories = $([]);
|
|
|
|
}
|
|
|
|
if (size == max_size) {
|
|
|
|
$same_size_stories.push($this);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-05-25 18:54:04 -07:00
|
|
|
// NEWSBLUR.log(['Found stories', $stories.length, $same_size_stories.length, $same_size_stories, story.get('story_title')]);
|
2010-07-02 11:14:41 -04:00
|
|
|
|
|
|
|
// Multiple stories at the same big font size? Determine story title overlap,
|
|
|
|
// and choose the smallest difference in title length.
|
|
|
|
var $story = $([]);
|
|
|
|
if ($same_size_stories.length > 1) {
|
|
|
|
var story_similarity = 100;
|
|
|
|
$same_size_stories.each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
var story_text = $this.text();
|
2012-05-25 18:54:04 -07:00
|
|
|
var overlap = Math.abs(story_text.length - story.get('story_title').length);
|
2010-07-02 11:14:41 -04:00
|
|
|
if (overlap < story_similarity) {
|
|
|
|
story_similarity = overlap;
|
|
|
|
$story = $this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$story.length) {
|
|
|
|
$story = $same_size_stories[0];
|
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if ($story && $story.length) {
|
2012-01-31 10:15:11 -08:00
|
|
|
// Check for NB-mark above and use that.
|
|
|
|
if ($story.closest('.NB-mark').length) {
|
|
|
|
$story = $story.closest('.NB-mark');
|
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
this.cache.iframe_stories[story.id] = $story;
|
|
|
|
var position_original = parseInt($story.offset().top, 10);
|
|
|
|
// var position_offset = parseInt($story.offsetParent().scrollTop(), 10);
|
|
|
|
var position = position_original; // + position_offset;
|
|
|
|
this.cache.iframe_story_positions[position] = story;
|
|
|
|
this.cache.iframe_story_positions_keys.push(position);
|
2012-01-31 10:15:11 -08:00
|
|
|
|
|
|
|
|
2010-12-04 23:26:52 -05:00
|
|
|
if (!this.flags['iframe_view_not_busting']) {
|
|
|
|
var feed_id = this.active_feed;
|
2012-01-31 10:15:11 -08:00
|
|
|
_.delay(_.bind(function() {
|
|
|
|
if (feed_id == this.active_feed) {
|
|
|
|
this.flags['iframe_view_not_busting'] = true;
|
2010-12-04 23:26:52 -05:00
|
|
|
}
|
2012-01-31 10:15:11 -08:00
|
|
|
}, this), 200);
|
2010-12-04 23:26:52 -05:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NEWSBLUR.log(['Found story', $story]);
|
|
|
|
return $story;
|
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
// ==============
|
|
|
|
// = Navigation =
|
|
|
|
// ==============
|
|
|
|
|
|
|
|
show_next_story: function(direction) {
|
2012-05-25 20:52:30 -07:00
|
|
|
var story = NEWSBLUR.assets.stories.get_next_story(direction);
|
|
|
|
if (story) {
|
|
|
|
story.set('selected', true);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-04-12 11:02:02 -04:00
|
|
|
show_next_unread_story: function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var $current_story = $('.selected', $story_titles);
|
2010-06-08 11:19:41 -04:00
|
|
|
var $next_story;
|
|
|
|
var unread_count = this.get_unread_count(true);
|
|
|
|
|
2012-03-01 17:08:41 -08:00
|
|
|
// NEWSBLUR.log(['show_next_unread_story', unread_count, $current_story]);
|
2011-01-10 09:49:26 -05:00
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
if (unread_count) {
|
|
|
|
if (!$current_story.length) {
|
|
|
|
// Nothing selected, choose first unread.
|
2010-06-14 13:17:38 -04:00
|
|
|
$next_story = $('.story:not(.read):visible:first', $story_titles);
|
2010-06-08 11:19:41 -04:00
|
|
|
} else {
|
|
|
|
// Start searching below, then search above current story.
|
|
|
|
$next_story = $current_story.nextAll('.story:not(.read):visible').eq(0);
|
|
|
|
if (!$next_story.length) {
|
|
|
|
$next_story = $current_story.prevAll('.story:not(.read):visible').eq(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($next_story && $next_story.length) {
|
2011-04-12 11:02:02 -04:00
|
|
|
this.counts['find_next_unread_on_page_of_feed_stories_load'] = 0;
|
2010-06-08 11:19:41 -04:00
|
|
|
var story_id = $next_story.data('story_id');
|
|
|
|
if (story_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = this.model.get_story(story_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.push_current_story_on_history();
|
|
|
|
this.open_story(story, $next_story);
|
|
|
|
this.scroll_story_titles_to_show_selected_story_title($next_story);
|
|
|
|
}
|
2012-02-17 18:36:33 -08:00
|
|
|
} else if (this.counts['find_next_unread_on_page_of_feed_stories_load'] < this.constants.FILL_OUT_PAGES &&
|
2012-05-25 16:42:41 -07:00
|
|
|
!this.model.flags['no_more_stories']) {
|
2010-06-08 11:19:41 -04:00
|
|
|
// Nothing up, nothing down, but still unread. Load 1 page then find it.
|
2011-04-12 11:02:02 -04:00
|
|
|
this.counts['find_next_unread_on_page_of_feed_stories_load'] += 1;
|
2010-06-08 11:19:41 -04:00
|
|
|
this.load_page_of_feed_stories();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2011-04-12 11:02:02 -04:00
|
|
|
open_next_unread_story_across_feeds: function() {
|
2011-11-02 08:49:58 -07:00
|
|
|
var unread_count = this.active_feed && this.get_unread_count(true);
|
|
|
|
|
|
|
|
if (!unread_count) {
|
|
|
|
if (this.flags.river_view && false) {
|
|
|
|
// TODO: Make this work
|
|
|
|
// var $next_folder = this.get_next_unread_folder(1);
|
|
|
|
// var $folder = $next_folder.closest('li.folder');
|
|
|
|
// var folder_title = $folder.find('.folder_title_text').text();
|
|
|
|
// this.open_river_stories($folder, folder_title);
|
|
|
|
} else {
|
|
|
|
// Find next feed with unreads
|
|
|
|
var $next_feed = this.get_next_unread_feed(1);
|
2012-05-09 16:56:32 -07:00
|
|
|
var next_feed_id = $next_feed.data('id');
|
|
|
|
if (NEWSBLUR.utils.is_feed_social(next_feed_id)) {
|
|
|
|
this.open_social_stories(next_feed_id, {force: true, $feed_link: $next_feed});
|
|
|
|
} else {
|
|
|
|
next_feed_id = parseInt(next_feed_id, 10);
|
|
|
|
this.open_feed(next_feed_id, {force: true, $feed_link: $next_feed});
|
|
|
|
}
|
2011-11-02 08:49:58 -07:00
|
|
|
}
|
|
|
|
}
|
2012-03-01 17:08:41 -08:00
|
|
|
|
2011-04-12 11:02:02 -04:00
|
|
|
this.show_next_unread_story();
|
|
|
|
},
|
|
|
|
|
2011-11-02 09:43:06 -07:00
|
|
|
show_last_unread_story: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var $current_story = $('.selected', $story_titles);
|
|
|
|
var $next_story;
|
|
|
|
var unread_count = this.get_unread_count(true);
|
|
|
|
|
2012-05-09 21:11:48 -07:00
|
|
|
// NEWSBLUR.log(['show_last_unread_story', unread_count, $current_story]);
|
2011-11-02 09:43:06 -07:00
|
|
|
|
|
|
|
if (unread_count) {
|
|
|
|
var unread_stories_visible = $('.story:not(.read):visible', $story_titles).length;
|
|
|
|
if (unread_stories_visible >= unread_count) {
|
|
|
|
// Choose the last unread story
|
|
|
|
$next_story = $('.story:not(.read):visible:last', $story_titles);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($next_story && $next_story.length) {
|
|
|
|
this.counts['find_last_unread_on_page_of_feed_stories_load'] = 0;
|
|
|
|
var story_id = $next_story.data('story_id');
|
|
|
|
if (story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
this.push_current_story_on_history();
|
|
|
|
this.open_story(story, $next_story);
|
|
|
|
this.scroll_story_titles_to_show_selected_story_title($next_story);
|
|
|
|
}
|
2012-02-17 18:36:33 -08:00
|
|
|
} else if (this.counts['find_last_unread_on_page_of_feed_stories_load'] < this.constants.FILL_OUT_PAGES &&
|
2012-05-25 16:42:41 -07:00
|
|
|
!this.model.flags['no_more_stories']) {
|
2011-11-02 09:43:06 -07:00
|
|
|
// Nothing up, nothing down, but still unread. Load 1 page then find it.
|
|
|
|
this.counts['find_last_unread_on_page_of_feed_stories_load'] += 1;
|
|
|
|
this.load_page_of_feed_stories();
|
|
|
|
}
|
|
|
|
}
|
2011-04-12 11:02:02 -04:00
|
|
|
},
|
|
|
|
|
2012-04-11 15:20:57 -07:00
|
|
|
show_story_in_feed: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var story_id = this.flags['show_story_in_feed'];
|
|
|
|
var $story = this.find_story_in_story_titles(story_id);
|
2012-05-09 21:11:48 -07:00
|
|
|
// NEWSBLUR.log(['show_story_in_feed', story_id, $story, this.story_view, this.counts['show_story_in_feed'], this.flags['no_more_stories']]);
|
2012-04-11 15:20:57 -07:00
|
|
|
|
|
|
|
if ($story && $story.length) {
|
|
|
|
this.counts['show_story_in_feed'] = 0;
|
|
|
|
this.flags['show_story_in_feed'] = null;
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
_.delay(_.bind(function() {
|
2012-04-19 15:01:01 -07:00
|
|
|
this.open_story(story, $story, {story_id: story_id});
|
2012-04-11 15:20:57 -07:00
|
|
|
this.scroll_story_titles_to_show_selected_story_title($story);
|
2012-04-19 15:01:01 -07:00
|
|
|
}, this), 800);
|
2012-04-11 15:20:57 -07:00
|
|
|
} else if (this.counts['show_story_in_feed'] < this.constants.FILL_OUT_PAGES &&
|
2012-05-25 16:42:41 -07:00
|
|
|
!this.model.flags['no_more_stories']) {
|
2012-04-11 15:20:57 -07:00
|
|
|
// Nothing up, nothing down, but still not found. Load 1 page then find it.
|
|
|
|
this.counts['show_story_in_feed'] += 1;
|
|
|
|
this.load_page_of_feed_stories();
|
|
|
|
} else {
|
|
|
|
this.counts['show_story_in_feed'] = 0;
|
|
|
|
this.flags['show_story_in_feed'] = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
show_previous_story: function() {
|
|
|
|
if (this.cache['previous_stories_stack'].length) {
|
|
|
|
var $previous_story = this.cache['previous_stories_stack'].pop();
|
|
|
|
if ($previous_story.length && !$previous_story.is(':visible')) {
|
|
|
|
this.show_previous_story();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var story_id = $previous_story.data('story_id');
|
|
|
|
if (story_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = this.model.get_story(story_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.open_story(story, $previous_story);
|
|
|
|
this.scroll_story_titles_to_show_selected_story_title($previous_story);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
scroll_story_titles_to_show_selected_story_title: function($story) {
|
2011-12-06 19:12:45 -08:00
|
|
|
var $story = $story || this.find_story_in_story_titles();
|
2012-05-10 09:45:07 -07:00
|
|
|
if (!$story || !$story.length) return;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var story_title_visisble = $story_titles.isScrollVisible($story);
|
2010-06-08 11:19:41 -04:00
|
|
|
if (!story_title_visisble) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var container_offset = $story_titles.position().top;
|
2010-06-08 11:19:41 -04:00
|
|
|
var scroll = $story.position().top;
|
2010-06-14 13:17:38 -04:00
|
|
|
var container = $story_titles.scrollTop();
|
|
|
|
var height = $story_titles.outerHeight();
|
|
|
|
$story_titles.scrollTop(scroll+container-height/5);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-10-21 18:52:25 -04:00
|
|
|
show_next_feed: function(direction, $current_feed) {
|
2012-05-09 16:56:32 -07:00
|
|
|
var $feed_list = this.$s.$feed_list.add(this.$s.$social_feeds);
|
2011-04-12 11:02:02 -04:00
|
|
|
var $next_feed = this.get_next_feed(direction, $current_feed);
|
|
|
|
|
2012-05-09 16:56:32 -07:00
|
|
|
var next_feed_id = $next_feed.data('id');
|
|
|
|
if (next_feed_id && next_feed_id == this.active_feed) {
|
2011-04-12 11:02:02 -04:00
|
|
|
this.show_next_feed(direction, $next_feed);
|
2012-05-09 16:56:32 -07:00
|
|
|
} else if (NEWSBLUR.utils.is_feed_social(next_feed_id)) {
|
|
|
|
this.open_social_stories(next_feed_id, {force: true, $feed_link: $next_feed});
|
|
|
|
} else {
|
|
|
|
next_feed_id = parseInt(next_feed_id, 10);
|
|
|
|
this.open_feed(next_feed_id, {force: true, $feed_link: $next_feed});
|
2011-04-12 11:02:02 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
get_next_feed: function(direction, $current_feed) {
|
2010-11-24 13:16:10 -05:00
|
|
|
var self = this;
|
2012-05-09 16:56:32 -07:00
|
|
|
var $feed_list = this.$s.$feed_list.add(this.$s.$social_feeds);
|
2010-10-21 18:52:25 -04:00
|
|
|
var $current_feed = $current_feed || $('.selected', $feed_list);
|
2010-06-08 11:19:41 -04:00
|
|
|
var $next_feed,
|
|
|
|
scroll;
|
2011-03-19 11:22:10 -04:00
|
|
|
var $feeds = $('.feed:visible:not(.NB-empty)', $feed_list).add('.feed.selected');
|
2010-06-08 11:19:41 -04:00
|
|
|
if (!$current_feed.length) {
|
2011-03-20 20:12:21 -04:00
|
|
|
$current_feed = $('.feed:visible:not(.NB-empty)', $feed_list)[direction==1?'first':'last']();
|
2010-06-08 11:19:41 -04:00
|
|
|
$next_feed = $current_feed;
|
2010-10-21 18:52:25 -04:00
|
|
|
} else {
|
|
|
|
$feeds.each(function(i) {
|
|
|
|
if (this == $current_feed[0]) {
|
|
|
|
current_feed = i;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2011-03-20 20:12:21 -04:00
|
|
|
$next_feed = $feeds.eq((current_feed+direction) % ($feeds.length));
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2011-04-12 11:02:02 -04:00
|
|
|
|
|
|
|
return $next_feed;
|
|
|
|
},
|
|
|
|
|
|
|
|
get_next_unread_feed: function(direction, $current_feed) {
|
|
|
|
var self = this;
|
2012-05-09 16:56:32 -07:00
|
|
|
var $feed_list = this.$s.$feed_list.add(this.$s.$social_feeds);
|
2011-04-12 11:02:02 -04:00
|
|
|
$current_feed = $current_feed || $('.selected', $feed_list);
|
|
|
|
var unread_view = this.get_unread_view_name();
|
|
|
|
var $next_feed;
|
|
|
|
var $feeds = $('.feed:visible:not(.NB-empty)', $feed_list).filter(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
if (unread_view == 'positive') {
|
|
|
|
return $this.is('.unread_positive');
|
|
|
|
} else if (unread_view == 'neutral') {
|
|
|
|
return $this.is('.unread_positive,.unread_neutral');
|
|
|
|
} else if (unread_view == 'negative') {
|
|
|
|
return $this.is('.unread_positive,.unread_neutral,.unread_negative');
|
|
|
|
}
|
|
|
|
}).add('.feed.selected');
|
|
|
|
if (!$current_feed.length) {
|
|
|
|
$next_feed = $feeds.first();
|
|
|
|
} else {
|
|
|
|
$feeds.each(function(i) {
|
|
|
|
if (this == $current_feed[0]) {
|
|
|
|
current_feed = i;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$next_feed = $feeds.eq((current_feed+direction) % ($feeds.length));
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2011-04-12 11:02:02 -04:00
|
|
|
|
|
|
|
return $next_feed;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
navigate_story_titles_to_story: function(story) {
|
2011-01-10 09:49:26 -05:00
|
|
|
if (!story) return;
|
2010-12-30 18:37:29 -05:00
|
|
|
var $next_story_title = this.find_story_in_story_titles(story.id);
|
2010-12-14 18:48:52 -05:00
|
|
|
if ($next_story_title &&
|
|
|
|
$next_story_title.length &&
|
|
|
|
$next_story_title.is(':visible') &&
|
|
|
|
!$next_story_title.hasClass('selected')) {
|
|
|
|
// NEWSBLUR.log(['navigate_story_titles_to_story', story, $next_story_title]);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-14 18:48:52 -05:00
|
|
|
this.scroll_story_titles_to_show_selected_story_title($next_story_title);
|
|
|
|
if (this.active_story != story) {
|
|
|
|
this.push_current_story_on_history();
|
|
|
|
this.active_story = story;
|
|
|
|
this.mark_story_title_as_selected($next_story_title);
|
2010-12-30 19:24:52 -05:00
|
|
|
this.mark_story_as_read(story.id);
|
2010-12-14 18:48:52 -05:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
page_in_story: function(amount, direction) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var page_height = this.$s.$story_pane.height();
|
2010-06-08 11:19:41 -04:00
|
|
|
var scroll_height = parseInt(page_height * amount, 10);
|
|
|
|
var dir = '+';
|
|
|
|
if (direction == -1) {
|
|
|
|
dir = '-';
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['page_in_story', this.$s.$story_pane, direction, page_height, scroll_height]);
|
2010-06-08 11:19:41 -04:00
|
|
|
if (this.story_view == 'page') {
|
2011-11-25 11:06:07 -05:00
|
|
|
this.$s.$feed_iframe.scrollTo({top:dir+'='+scroll_height, left:'+=0'}, 230, {queue: false});
|
2010-12-08 20:53:45 -05:00
|
|
|
} else if (this.story_view == 'feed') {
|
2011-11-25 11:06:07 -05:00
|
|
|
this.$s.$feed_stories.scrollTo({top:dir+'='+scroll_height, left:'+=0'}, 340, {queue: false});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
push_current_story_on_history: function() {
|
2012-05-25 20:52:30 -07:00
|
|
|
this.cache['previous_stories_stack'].push(this.active_story);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2012-02-17 18:36:33 -08:00
|
|
|
find_story_with_action_preference_on_open_feed: function() {
|
|
|
|
var open_feed_action = this.model.preference('open_feed_action');
|
2012-02-24 12:47:39 -08:00
|
|
|
|
2012-02-17 18:36:33 -08:00
|
|
|
if (this.counts['page'] != 1) return;
|
|
|
|
|
2012-04-19 22:38:00 -07:00
|
|
|
if (open_feed_action == 'newest') {
|
2012-02-17 18:36:33 -08:00
|
|
|
this.show_next_unread_story();
|
|
|
|
} else if (open_feed_action == 'oldest') {
|
|
|
|
this.show_last_unread_story();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
// =============
|
|
|
|
// = Feed Pane =
|
|
|
|
// =============
|
|
|
|
|
2011-03-30 09:30:45 -04:00
|
|
|
sort_feeds: function($feeds) {
|
2012-05-18 16:59:39 -07:00
|
|
|
$('.feed', $feeds).tsort('', {sortFunction: NEWSBLUR.Collections.Folders.comparator});
|
2011-03-30 09:30:45 -04:00
|
|
|
$('.folder', $feeds).tsort('.folder_title_text');
|
|
|
|
},
|
|
|
|
|
2010-07-10 17:59:17 -04:00
|
|
|
load_sortable_feeds: function() {
|
|
|
|
var self = this;
|
|
|
|
|
2010-11-03 21:27:52 -04:00
|
|
|
this.$s.$feed_list.sortable({
|
2011-02-08 09:44:24 -05:00
|
|
|
items: '.feed,li.folder',
|
|
|
|
connectWith: 'ul.folder,.feed.NB-empty',
|
2010-07-10 17:59:17 -04:00
|
|
|
placeholder: 'NB-feeds-list-highlight',
|
|
|
|
axis: 'y',
|
2010-12-10 09:32:06 -05:00
|
|
|
distance: 4,
|
2010-07-11 11:10:45 -04:00
|
|
|
cursor: 'move',
|
2012-05-09 16:56:32 -07:00
|
|
|
containment: '#feed_list',
|
2010-12-10 09:32:06 -05:00
|
|
|
tolerance: 'pointer',
|
2010-12-25 23:04:43 -05:00
|
|
|
scrollSensitivity: 35,
|
2010-07-10 17:59:17 -04:00
|
|
|
start: function(e, ui) {
|
|
|
|
self.flags['sorting_feed'] = true;
|
|
|
|
ui.placeholder.attr('class', ui.item.attr('class') + ' NB-feeds-list-highlight');
|
2012-05-18 18:13:45 -07:00
|
|
|
NEWSBLUR.app.feed_list.start_sorting();
|
2010-07-10 17:59:17 -04:00
|
|
|
ui.item.addClass('NB-feed-sorting');
|
2012-01-14 18:54:59 -08:00
|
|
|
ui.placeholder.data('id', ui.item.data('id'));
|
2010-12-16 23:57:05 -05:00
|
|
|
if (ui.item.is('.folder')) {
|
|
|
|
ui.placeholder.html(ui.item.children().clone());
|
|
|
|
ui.item.data('previously_collapsed', ui.item.data('collapsed'));
|
|
|
|
self.collapse_folder(ui.item.children('.folder_title'), true);
|
|
|
|
self.collapse_folder(ui.placeholder.children('.folder_title'), true);
|
|
|
|
ui.item.css('height', ui.item.children('.folder_title').outerHeight(true) + 'px');
|
2010-12-25 23:04:43 -05:00
|
|
|
ui.helper.css('height', ui.helper.children('.folder_title').outerHeight(true) + 'px');
|
2010-11-03 21:27:52 -04:00
|
|
|
} else {
|
|
|
|
ui.placeholder.html(ui.item.children().clone());
|
2010-09-05 18:08:08 -07:00
|
|
|
}
|
2010-07-10 17:59:17 -04:00
|
|
|
},
|
2010-11-01 19:28:57 -04:00
|
|
|
change: function(e, ui) {
|
2011-04-25 20:53:29 -04:00
|
|
|
var $feeds = ui.placeholder.closest('ul.folder');
|
|
|
|
self.sort_feeds($feeds);
|
2010-07-10 17:59:17 -04:00
|
|
|
},
|
|
|
|
stop: function(e, ui) {
|
|
|
|
setTimeout(function() {
|
|
|
|
self.flags['sorting_feed'] = false;
|
|
|
|
}, 100);
|
|
|
|
ui.item.removeClass('NB-feed-sorting');
|
2012-05-18 18:13:45 -07:00
|
|
|
NEWSBLUR.app.feed_list.end_sorting();
|
2011-04-25 20:53:29 -04:00
|
|
|
self.sort_feeds(e.target);
|
2010-07-10 17:59:17 -04:00
|
|
|
self.save_feed_order();
|
|
|
|
ui.item.css({'backgroundColor': '#D7DDE6'})
|
2010-08-03 09:19:38 -04:00
|
|
|
.animate({'backgroundColor': '#F0F076'}, {'duration': 800})
|
2010-07-10 17:59:17 -04:00
|
|
|
.animate({'backgroundColor': '#D7DDE6'}, {'duration': 1000});
|
2010-12-16 23:57:05 -05:00
|
|
|
if (ui.item.is('.folder') && !ui.item.data('previously_collapsed')) {
|
|
|
|
self.collapse_folder(ui.item.children('.folder_title'));
|
|
|
|
self.collapse_folder(ui.placeholder.children('.folder_title'));
|
2010-09-05 18:08:08 -07:00
|
|
|
}
|
2010-07-10 17:59:17 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save_feed_order: function() {
|
2010-07-11 11:10:45 -04:00
|
|
|
var combine_folders = function($folder) {
|
|
|
|
var folders = [];
|
|
|
|
var $items = $folder.children('li.folder, .feed');
|
|
|
|
|
|
|
|
for (var i=0, i_count=$items.length; i < i_count; i++) {
|
|
|
|
var $item = $items.eq(i);
|
|
|
|
|
|
|
|
if ($item.hasClass('feed')) {
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = parseInt($item.data('id'), 10);
|
2010-12-10 09:32:06 -05:00
|
|
|
if (feed_id) {
|
|
|
|
folders.push(feed_id);
|
|
|
|
}
|
2010-07-11 11:10:45 -04:00
|
|
|
} else if ($item.hasClass('folder')) {
|
2010-09-05 18:08:08 -07:00
|
|
|
var folder_title = $item.find('.folder_title_text').eq(0).text();
|
2010-07-11 11:10:45 -04:00
|
|
|
var child_folders = {};
|
|
|
|
child_folders[folder_title] = combine_folders($item.children('ul.folder').eq(0));
|
|
|
|
folders.push(child_folders);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return folders;
|
|
|
|
};
|
2010-07-10 17:59:17 -04:00
|
|
|
|
2010-07-11 11:10:45 -04:00
|
|
|
var combined_folders = combine_folders(this.$s.$feed_list);
|
2010-10-30 00:27:52 -04:00
|
|
|
// NEWSBLUR.log(['Save new folder/feed order', {'combined': combined_folders}]);
|
2010-07-11 11:10:45 -04:00
|
|
|
this.model.save_feed_order(combined_folders);
|
2010-07-10 17:59:17 -04:00
|
|
|
},
|
|
|
|
|
2011-03-30 09:30:45 -04:00
|
|
|
count_collapsed_unread_stories: function() {
|
2011-10-31 19:44:36 -07:00
|
|
|
var self = this;
|
2011-11-01 00:20:06 -07:00
|
|
|
|
2011-03-30 09:30:45 -04:00
|
|
|
_.each(NEWSBLUR.Preferences.collapsed_folders, _.bind(function(folder) {
|
2011-11-01 00:20:06 -07:00
|
|
|
var $folder_title = $('.folder_title_text', this.$s.$feed_list).filter(function() {
|
|
|
|
return $.trim($(this).text()) == $.trim(folder);
|
|
|
|
}).closest('.folder_title');
|
2011-03-30 09:30:45 -04:00
|
|
|
this.collapse_folder($folder_title, true);
|
2011-11-01 00:20:06 -07:00
|
|
|
var $folder = $folder_title.parent('li.folder');
|
|
|
|
var $children = $folder.children('ul.folder');
|
|
|
|
this.show_collapsed_folder_count($folder_title, $children, {'skip_animation': true});
|
2011-03-30 09:30:45 -04:00
|
|
|
}, this));
|
2011-11-01 00:20:06 -07:00
|
|
|
|
2011-10-31 19:44:36 -07:00
|
|
|
if (this.model.preference('folder_counts')) {
|
|
|
|
var $folder_titles = $('.folder_title', this.$s.$feed_list);
|
|
|
|
$folder_titles.each(function() {
|
|
|
|
var $folder_title = $(this);
|
2011-11-01 00:20:06 -07:00
|
|
|
if (!_.contains(NEWSBLUR.Preferences.collapsed_folders, $folder_title.text())) {
|
|
|
|
var $folder = $folder_title.parent('li.folder');
|
|
|
|
var $children = $folder.children('ul.folder');
|
|
|
|
self.show_collapsed_folder_count($folder_title, $children, {'skip_animation': true});
|
|
|
|
}
|
2011-03-30 09:30:45 -04:00
|
|
|
});
|
2011-10-31 19:44:36 -07:00
|
|
|
}
|
2011-03-30 09:30:45 -04:00
|
|
|
},
|
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
collapse_folder: function($folder_title, force_collapse) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-09-05 18:08:08 -07:00
|
|
|
var $feed_list = this.$s.$feed_list;
|
2010-12-25 23:04:43 -05:00
|
|
|
var $folder = $folder_title.parent('li.folder');
|
|
|
|
var $children = $folder.children('ul.folder');
|
2010-09-05 18:08:08 -07:00
|
|
|
|
|
|
|
// Hiding / Collapsing
|
|
|
|
if (force_collapse ||
|
|
|
|
($children.length &&
|
|
|
|
$children.eq(0).is(':visible') &&
|
|
|
|
!$folder.data('collapsed'))) {
|
|
|
|
this.model.collapsed_folders($('.folder_title_text', $folder_title).text(), true);
|
2011-05-16 11:34:05 -04:00
|
|
|
$folder.data('collapsed', true).addClass('NB-folder-collapsed');
|
2010-09-05 18:08:08 -07:00
|
|
|
$children.animate({'opacity': 0}, {
|
|
|
|
'queue': false,
|
|
|
|
'duration': force_collapse ? 0 : 200,
|
|
|
|
'complete': function() {
|
|
|
|
self.show_collapsed_folder_count($folder_title, $children);
|
|
|
|
$children.slideUp({
|
2010-12-25 23:04:43 -05:00
|
|
|
'duration': 270,
|
|
|
|
'easing': 'easeOutQuart'
|
2010-09-05 18:08:08 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// Showing / Expanding
|
|
|
|
else if ($children.length &&
|
|
|
|
($folder.data('collapsed') || !$children.eq(0).is(':visible'))) {
|
|
|
|
this.model.collapsed_folders($('.folder_title_text', $folder_title).text(), false);
|
2011-05-16 11:34:05 -04:00
|
|
|
$folder.data('collapsed', false).removeClass('NB-folder-collapsed');
|
2011-10-31 19:44:36 -07:00
|
|
|
if (!this.model.preference('folder_counts')) {
|
|
|
|
this.hide_collapsed_folder_count($folder_title);
|
|
|
|
}
|
2010-09-05 18:08:08 -07:00
|
|
|
$children.css({'opacity': 0}).slideDown({
|
|
|
|
'duration': 240,
|
2010-12-25 23:04:43 -05:00
|
|
|
'easing': 'easeInOutCubic',
|
2010-09-05 18:08:08 -07:00
|
|
|
'complete': function() {
|
|
|
|
$children.animate({'opacity': 1}, {'queue': false, 'duration': 200});
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-09-05 18:08:08 -07:00
|
|
|
},
|
|
|
|
|
2011-11-01 00:20:06 -07:00
|
|
|
show_collapsed_folder_count: function($folder_title, $children, options) {
|
|
|
|
options = options || {};
|
2010-09-05 18:08:08 -07:00
|
|
|
var $counts = $('.feed_counts_floater', $folder_title);
|
|
|
|
$counts.remove();
|
2010-10-06 09:42:59 -04:00
|
|
|
$children = $('li.feed', $children).not('.NB-feed-inactive');
|
2011-10-31 18:04:25 -07:00
|
|
|
var $river = $('.NB-feedlist-collapse-icon', $folder_title);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
var positive_count = 0;
|
|
|
|
var neutral_count = 0;
|
|
|
|
var negative_count = 0;
|
|
|
|
$('.unread_count_positive.unread_count_full', $children).each(function() {
|
|
|
|
positive_count += parseInt($(this).text(), 10);
|
|
|
|
});
|
|
|
|
$('.unread_count_neutral.unread_count_full', $children).each(function() {
|
|
|
|
neutral_count += parseInt($(this).text(), 10);
|
|
|
|
});
|
|
|
|
$('.unread_count_negative.unread_count_full', $children).each(function() {
|
|
|
|
negative_count += parseInt($(this).text(), 10);
|
|
|
|
});
|
2010-12-12 20:06:32 -05:00
|
|
|
|
|
|
|
if ($folder_title.hasClass('NB-hover')) {
|
2011-11-01 00:20:06 -07:00
|
|
|
$river.animate({'opacity': 0}, {'duration': options.skip_animation ? 0 : 100});
|
2010-12-12 20:06:32 -05:00
|
|
|
$folder_title.addClass('NB-feedlist-folder-title-recently-collapsed');
|
|
|
|
$folder_title.one('mouseover', function() {
|
|
|
|
$river.css({'opacity': ''});
|
|
|
|
$folder_title.removeClass('NB-feedlist-folder-title-recently-collapsed');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
var $counts = this.make_feed_counts_floater(positive_count, neutral_count, negative_count);
|
|
|
|
$folder_title.prepend($counts.css({
|
|
|
|
'opacity': 0
|
|
|
|
}));
|
2011-11-01 00:20:06 -07:00
|
|
|
$counts.animate({'opacity': 1}, {'duration': options.skip_animation ? 0 : 400});
|
2010-09-05 18:08:08 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
hide_collapsed_folder_count: function($folder_title) {
|
|
|
|
var $counts = $('.feed_counts_floater', $folder_title);
|
2011-10-31 18:04:25 -07:00
|
|
|
var $river = $('.NB-feedlist-collapse-icon', $folder_title);
|
2010-12-12 20:06:32 -05:00
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
$counts.animate({'opacity': 0}, {
|
|
|
|
'duration': 300
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
2010-12-12 20:06:32 -05:00
|
|
|
|
|
|
|
$river.animate({'opacity': .6}, {'duration': 400});
|
|
|
|
$folder_title.removeClass('NB-feedlist-folder-title-recently-collapsed');
|
|
|
|
$folder_title.one('mouseover', function() {
|
|
|
|
$river.css({'opacity': ''});
|
|
|
|
// $folder_title.removeClass('NB-feedlist-folder-title-recently-collapsed');
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-09-28 18:53:57 -04:00
|
|
|
show_feed_chooser_button: function() {
|
|
|
|
var self = this;
|
|
|
|
var $progress = this.$s.$feeds_progress;
|
|
|
|
var $bar = $('.NB-progress-bar', $progress);
|
|
|
|
var percentage = 0;
|
|
|
|
|
|
|
|
$('.NB-progress-title', $progress).text('Get Started');
|
|
|
|
$('.NB-progress-counts', $progress).hide();
|
|
|
|
$('.NB-progress-percentage', $progress).hide();
|
2010-10-02 17:05:55 -04:00
|
|
|
$progress.addClass('NB-progress-error').addClass('NB-progress-big');
|
2012-03-12 12:33:54 -07:00
|
|
|
$('.NB-progress-link', $progress).html($.make('div', {
|
|
|
|
className: 'NB-modal-submit-button NB-modal-submit-green NB-menu-manage-feedchooser'
|
|
|
|
}, ['Choose your 64 sites']));
|
2010-09-28 18:53:57 -04:00
|
|
|
|
|
|
|
this.show_progress_bar();
|
|
|
|
},
|
|
|
|
|
2010-10-02 17:05:55 -04:00
|
|
|
hide_feed_chooser_button: function() {
|
|
|
|
var $progress = this.$s.$feeds_progress;
|
|
|
|
var $bar = $('.NB-progress-bar', $progress);
|
|
|
|
$progress.removeClass('NB-progress-error').removeClass('NB-progress-big');
|
|
|
|
|
|
|
|
this.hide_progress_bar();
|
|
|
|
},
|
|
|
|
|
2012-03-12 12:33:54 -07:00
|
|
|
open_dialog_after_feeds_loaded: function() {
|
|
|
|
if (!NEWSBLUR.Globals.is_authenticated) return;
|
|
|
|
|
2012-05-18 18:13:45 -07:00
|
|
|
if (!NEWSBLUR.assets.folders.length || !NEWSBLUR.assets.preference('has_setup_feeds')) {
|
|
|
|
if (NEWSBLUR.assets.preference('has_setup_feeds')) {
|
2012-03-19 14:15:38 -07:00
|
|
|
this.setup_ftux_add_feed_callout();
|
2012-03-19 16:35:56 -07:00
|
|
|
} else if (!NEWSBLUR.intro || !NEWSBLUR.intro.flags.open) {
|
|
|
|
_.defer(_.bind(this.open_intro_modal, this), 100);
|
2012-03-19 14:15:38 -07:00
|
|
|
}
|
2012-05-18 18:13:45 -07:00
|
|
|
} else if (!NEWSBLUR.assets.flags['has_chosen_feeds'] && NEWSBLUR.assets.folders.length) {
|
2012-03-12 12:33:54 -07:00
|
|
|
_.defer(_.bind(this.open_feedchooser_modal, this), 100);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-11-22 10:44:52 -05:00
|
|
|
// ================
|
|
|
|
// = Progress Bar =
|
|
|
|
// ================
|
|
|
|
|
|
|
|
check_feed_fetch_progress: function() {
|
|
|
|
$.extend(this.counts, {
|
|
|
|
'unfetched_feeds': 0,
|
|
|
|
'fetched_feeds': 0
|
|
|
|
});
|
|
|
|
|
|
|
|
if (this.flags['has_unfetched_feeds']) {
|
|
|
|
var counts = this.model.count_unfetched_feeds();
|
|
|
|
this.counts['unfetched_feeds'] = counts['unfetched_feeds'];
|
|
|
|
this.counts['fetched_feeds'] = counts['fetched_feeds'];
|
|
|
|
|
|
|
|
if (this.counts['unfetched_feeds'] == 0) {
|
|
|
|
this.flags['has_unfetched_feeds'] = false;
|
|
|
|
this.hide_unfetched_feed_progress();
|
|
|
|
} else {
|
|
|
|
this.flags['has_unfetched_feeds'] = true;
|
|
|
|
this.show_unfetched_feed_progress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
show_progress_bar: function() {
|
2010-11-24 15:01:35 -05:00
|
|
|
var $layout = this.$s.$feeds_progress.parents('.left-center').layout();
|
2010-11-22 10:44:52 -05:00
|
|
|
if (!this.flags['showing_progress_bar']) {
|
|
|
|
this.flags['showing_progress_bar'] = true;
|
2010-11-24 13:16:10 -05:00
|
|
|
$layout.open('south');
|
2010-11-22 10:44:52 -05:00
|
|
|
}
|
2010-11-24 15:01:35 -05:00
|
|
|
$layout.sizePane('south');
|
2010-11-22 10:44:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
hide_progress_bar: function(permanent) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
if (permanent) {
|
|
|
|
this.model.preference('hide_fetch_progress', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.flags['showing_progress_bar'] = false;
|
|
|
|
this.$s.$feeds_progress.parents('.left-center').layout().close('south');
|
|
|
|
},
|
|
|
|
|
|
|
|
show_unfetched_feed_progress: function() {
|
|
|
|
var self = this;
|
|
|
|
var $progress = this.$s.$feeds_progress;
|
|
|
|
var percentage = parseInt(this.counts['fetched_feeds'] / (this.counts['unfetched_feeds'] + this.counts['fetched_feeds']) * 100, 10);
|
|
|
|
|
|
|
|
$('.NB-progress-title', $progress).text('Fetching your feeds');
|
|
|
|
$('.NB-progress-counts', $progress).show();
|
|
|
|
$('.NB-progress-counts-fetched', $progress).text(this.counts['fetched_feeds']);
|
|
|
|
$('.NB-progress-counts-total', $progress).text(this.counts['unfetched_feeds'] + this.counts['fetched_feeds']);
|
|
|
|
$('.NB-progress-percentage', $progress).show().text(percentage + '%');
|
|
|
|
$('.NB-progress-bar', $progress).progressbar({
|
|
|
|
value: percentage
|
|
|
|
});
|
|
|
|
|
2011-03-19 11:22:10 -04:00
|
|
|
if (!$progress.is(':visible') && !this.model.preference('hide_fetch_progress')) {
|
2010-11-22 10:44:52 -05:00
|
|
|
setTimeout(function() {
|
|
|
|
self.show_progress_bar();
|
|
|
|
}, 1000);
|
|
|
|
}
|
2011-02-05 15:34:43 -05:00
|
|
|
|
|
|
|
this.setup_feed_refresh(true);
|
2010-11-22 10:44:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
hide_unfetched_feed_progress: function(permanent) {
|
|
|
|
if (permanent) {
|
|
|
|
this.model.preference('hide_fetch_progress', true);
|
|
|
|
}
|
|
|
|
|
2011-01-30 21:48:17 -05:00
|
|
|
this.setup_feed_refresh();
|
2010-11-22 10:44:52 -05:00
|
|
|
this.hide_progress_bar();
|
|
|
|
},
|
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
// ===============================
|
|
|
|
// = Feed bar - Individual Feeds =
|
|
|
|
// ===============================
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
reset_feed: function() {
|
2010-07-02 12:02:10 -04:00
|
|
|
$.extend(this.flags, {
|
|
|
|
'iframe_story_locations_fetched': false,
|
|
|
|
'iframe_view_loaded': false,
|
2010-12-04 23:26:52 -05:00
|
|
|
'iframe_view_not_busting': false,
|
2010-07-02 12:02:10 -04:00
|
|
|
'feed_view_images_loaded': {},
|
|
|
|
'feed_view_positions_calculated': false,
|
|
|
|
'scrolling_by_selecting_story_title': false,
|
|
|
|
'switching_to_feed_view': false,
|
|
|
|
'page_view_showing_feed_view': false,
|
2010-12-07 09:52:14 -05:00
|
|
|
'feed_view_showing_story_view': false,
|
2010-07-02 12:02:10 -04:00
|
|
|
'iframe_fetching_story_locations': false,
|
2010-07-06 18:30:16 -04:00
|
|
|
'story_titles_loaded': false,
|
2010-08-30 22:42:44 -04:00
|
|
|
'iframe_prevented_from_loading': false,
|
2010-09-12 13:50:27 -04:00
|
|
|
'pause_feed_refreshing': false,
|
2011-01-04 19:27:00 -05:00
|
|
|
'feed_list_showing_manage_menu': false,
|
2011-01-19 08:54:59 -05:00
|
|
|
'unread_threshold_temporarily': null,
|
2011-02-13 14:49:13 -05:00
|
|
|
'river_view': false,
|
2012-01-31 10:15:11 -08:00
|
|
|
'social_view': false,
|
2012-02-17 18:36:33 -08:00
|
|
|
'non_premium_river_view': false,
|
2012-04-11 15:20:57 -07:00
|
|
|
'show_story_in_feed': null
|
2010-07-02 12:02:10 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
$.extend(this.cache, {
|
2010-11-06 12:53:42 -04:00
|
|
|
'iframe': {},
|
2010-06-08 11:19:41 -04:00
|
|
|
'iframe_stories': {},
|
|
|
|
'iframe_story_positions': {},
|
|
|
|
'feed_view_story_positions': {},
|
|
|
|
'iframe_story_positions_keys': [],
|
|
|
|
'feed_view_story_positions_keys': [],
|
|
|
|
'previous_stories_stack': [],
|
2010-12-12 22:52:15 -05:00
|
|
|
'river_feeds_with_unreads': [],
|
2010-11-06 12:53:42 -04:00
|
|
|
'mouse_position_y': parseInt(this.model.preference('lock_mouse_indicator'), 10),
|
|
|
|
'prefetch_last_story': 0,
|
2011-01-25 22:59:38 -05:00
|
|
|
'prefetch_iteration': 0,
|
|
|
|
'feed_title_floater_feed_id': null,
|
|
|
|
'feed_title_floater_story_id': null,
|
2012-05-07 15:11:10 -07:00
|
|
|
'last_read_story_id': null,
|
2012-01-25 09:52:34 -08:00
|
|
|
'$feed_in_social_feed_list': {}
|
2010-07-02 12:02:10 -04:00
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-03-09 09:48:24 -05:00
|
|
|
$.extend(this.counts, {
|
2012-02-17 18:36:33 -08:00
|
|
|
'page': 1,
|
2011-04-12 11:02:02 -04:00
|
|
|
'page_fill_outs': 0,
|
2011-11-02 09:43:06 -07:00
|
|
|
'find_next_unread_on_page_of_feed_stories_load': 0,
|
2012-04-11 15:20:57 -07:00
|
|
|
'find_last_unread_on_page_of_feed_stories_load': 0,
|
|
|
|
'show_story_in_feed': 0
|
2010-07-02 12:02:10 -04:00
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2012-05-25 16:42:41 -07:00
|
|
|
this.model.flags['no_more_stories'] = false;
|
2012-05-24 11:54:10 -07:00
|
|
|
this.$s.$feed_stories.scrollTop(0);
|
2010-12-02 11:09:09 -05:00
|
|
|
this.$s.$starred_header.removeClass('NB-selected');
|
2010-12-10 15:26:50 -05:00
|
|
|
this.$s.$river_header.removeClass('NB-selected');
|
2011-03-15 23:42:27 -04:00
|
|
|
this.$s.$tryfeed_header.removeClass('NB-selected');
|
2012-05-21 20:08:27 -07:00
|
|
|
this.model.feeds.deselect();
|
2012-05-24 11:54:10 -07:00
|
|
|
if (_.string.contains(this.active_feed, 'social:')) {
|
|
|
|
this.model.social_feeds.deselect();
|
|
|
|
}
|
|
|
|
if (_.string.contains(this.active_feed, 'river:')) {
|
|
|
|
this.model.folders.deselect();
|
|
|
|
}
|
2010-12-12 22:52:15 -05:00
|
|
|
this.$s.$body.removeClass('NB-view-river');
|
2011-02-27 21:44:47 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).removeClass('NB-disabled');
|
2012-05-07 16:26:31 -07:00
|
|
|
$('.task_view_story', this.$s.$taskbar).removeClass('NB-disabled');
|
2011-02-02 14:10:24 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).removeClass('NB-task-return');
|
2012-01-13 10:46:56 -08:00
|
|
|
// $('.feed_counts_floater').remove();
|
2012-02-17 17:41:20 -08:00
|
|
|
clearTimeout(this.flags['next_fetch']);
|
|
|
|
this.counts['feed_view_positions_timer'] = 0;
|
2011-03-15 23:42:27 -04:00
|
|
|
|
2012-03-15 11:33:00 -07:00
|
|
|
if (this.flags['showing_feed_in_tryfeed_view'] || this.flags['showing_social_feed_in_tryfeed_view']) {
|
2011-03-15 23:42:27 -04:00
|
|
|
this.hide_tryfeed_view();
|
|
|
|
}
|
2012-05-21 20:08:27 -07:00
|
|
|
|
2012-05-24 11:54:10 -07:00
|
|
|
this.active_feed = null;
|
|
|
|
this.active_story = null;
|
2012-05-25 22:13:50 -07:00
|
|
|
|
|
|
|
NEWSBLUR.assets.stories.reset();
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2012-05-21 14:36:54 -07:00
|
|
|
open_feed: function(feed_id, options) {
|
2012-01-16 17:55:13 -08:00
|
|
|
options = options || {};
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
2012-05-21 14:36:54 -07:00
|
|
|
var feed = this.model.get_feed(feed_id) || options.feed;
|
2012-05-19 10:29:27 -07:00
|
|
|
var temp = feed.get('temp') || !feed.get('subscribed');
|
2012-05-04 15:27:53 -07:00
|
|
|
|
2012-05-04 15:49:39 -07:00
|
|
|
if (!feed || (temp && !options.try_feed)) {
|
2012-05-04 15:27:53 -07:00
|
|
|
return this.load_feed_in_tryfeed_view(feed_id, options);
|
|
|
|
}
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
this.flags['opening_feed'] = true;
|
|
|
|
|
2012-05-19 10:29:27 -07:00
|
|
|
if (options.try_feed || feed) {
|
2010-06-08 11:19:41 -04:00
|
|
|
this.reset_feed();
|
|
|
|
this.hide_splash_page();
|
2012-04-16 11:21:52 -07:00
|
|
|
if (options.story_id) {
|
|
|
|
this.flags['show_story_in_feed'] = options.story_id;
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2012-05-19 10:29:27 -07:00
|
|
|
this.active_feed = feed.id;
|
|
|
|
this.next_feed = feed.id;
|
2011-01-31 20:50:33 -05:00
|
|
|
|
2012-05-24 11:54:10 -07:00
|
|
|
feed.set('selected', true, options);
|
|
|
|
if (NEWSBLUR.app.story_unread_counter) {
|
|
|
|
NEWSBLUR.app.story_unread_counter.remove();
|
|
|
|
}
|
2012-05-25 22:13:50 -07:00
|
|
|
|
2012-05-29 11:48:40 -07:00
|
|
|
NEWSBLUR.app.story_titles.show_loading(options);
|
2012-05-24 11:54:10 -07:00
|
|
|
// this.show_stories_progress_bar();
|
2010-06-08 11:19:41 -04:00
|
|
|
this.iframe_scroll = null;
|
2012-05-19 10:29:27 -07:00
|
|
|
this.set_correct_story_view_for_feed(feed.id);
|
|
|
|
this.make_feed_title_in_stories(feed.id);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.switch_taskbar_view(this.story_view);
|
2010-11-24 13:16:10 -05:00
|
|
|
|
|
|
|
_.delay(_.bind(function() {
|
2012-05-19 10:29:27 -07:00
|
|
|
if (!options.delay || feed.id == self.next_feed) {
|
|
|
|
this.model.load_feed(feed.id, 1, true, $.rescope(this.post_open_feed, this),
|
2012-01-08 14:15:22 -08:00
|
|
|
this.show_stories_error);
|
2010-11-24 13:16:10 -05:00
|
|
|
}
|
2012-01-16 17:55:13 -08:00
|
|
|
}, this), options.delay || 0);
|
2011-02-27 21:44:47 -05:00
|
|
|
|
|
|
|
if (!this.story_view || this.story_view == 'page') {
|
2010-11-24 13:16:10 -05:00
|
|
|
_.delay(_.bind(function() {
|
2012-05-19 10:29:27 -07:00
|
|
|
if (!options.delay || feed.id == this.next_feed) {
|
|
|
|
this.load_feed_iframe(feed.id);
|
2010-11-24 13:16:10 -05:00
|
|
|
}
|
2012-01-16 17:55:13 -08:00
|
|
|
}, this), options.delay || 0);
|
2010-07-06 18:30:16 -04:00
|
|
|
} else {
|
2010-12-06 10:41:24 -05:00
|
|
|
this.unload_feed_iframe();
|
2010-07-06 18:30:16 -04:00
|
|
|
this.flags['iframe_prevented_from_loading'] = true;
|
|
|
|
}
|
2010-12-02 11:09:09 -05:00
|
|
|
this.setup_mousemove_on_views();
|
2012-02-10 19:33:31 -08:00
|
|
|
|
|
|
|
if (!options.silent) {
|
2012-05-19 10:29:27 -07:00
|
|
|
var slug = _.string.words(_.string.clean(feed.get('feed_title').replace(/[^a-z0-9\. ]/ig, ''))).join('-').toLowerCase();
|
|
|
|
var url = "site/" + feed.id + "/" + slug;
|
2012-02-10 19:33:31 -08:00
|
|
|
if (!_.string.include(window.location.pathname, url)) {
|
2012-05-24 13:31:23 -07:00
|
|
|
// console.log(["Navigating to url", url]);
|
2012-02-10 19:33:31 -08:00
|
|
|
NEWSBLUR.router.navigate(url);
|
|
|
|
}
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
post_open_feed: function(e, data, first_load) {
|
2010-10-06 20:26:42 -04:00
|
|
|
if (!data) {
|
2012-04-19 22:38:00 -07:00
|
|
|
console.log(["No data from feed, trying again..."]);
|
2012-01-16 17:55:13 -08:00
|
|
|
return this.open_feed(this.active_feed, {force: true});
|
2010-10-06 20:26:42 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
var stories = data.stories;
|
|
|
|
var tags = data.tags;
|
2010-10-25 20:44:52 -04:00
|
|
|
var feed_id = data.feed_id;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-01-14 00:59:51 -05:00
|
|
|
if (data.dupe_feed_id && this.active_feed == data.dupe_feed_id) {
|
|
|
|
this.active_feed = data.feed_id;
|
|
|
|
}
|
|
|
|
|
2011-06-07 12:57:14 -04:00
|
|
|
// NEWSBLUR.log(['post_open_feed', data.stories, this.flags]);
|
|
|
|
this.flags['opening_feed'] = false;
|
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
2012-02-17 17:41:20 -08:00
|
|
|
this.counts['feed_view_positions_timer'] = 0;
|
2012-05-24 17:32:01 -07:00
|
|
|
// this.create_story_titles(stories);
|
|
|
|
// this.make_story_feed_entries(stories, first_load);
|
2012-02-17 18:36:33 -08:00
|
|
|
this.find_story_with_action_preference_on_open_feed();
|
2011-06-07 12:57:14 -04:00
|
|
|
this.show_feed_hidden_story_title_indicator(true);
|
2012-05-24 17:32:01 -07:00
|
|
|
// this.show_story_titles_above_intelligence_level({'animate': false});
|
|
|
|
// this.scroll_story_titles_to_show_selected_story_title();
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.fill_out_story_titles();
|
2011-06-07 12:57:14 -04:00
|
|
|
if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
|
|
|
this.show_next_unread_story(true);
|
2011-11-02 09:43:06 -07:00
|
|
|
} else if (this.counts['find_last_unread_on_page_of_feed_stories_load']) {
|
|
|
|
this.show_last_unread_story(true);
|
2012-04-19 22:38:00 -07:00
|
|
|
} else if (this.counts['show_story_in_feed'] || this.flags['show_story_in_feed']) {
|
|
|
|
this.show_story_in_feed();
|
2011-06-07 12:57:14 -04:00
|
|
|
}
|
|
|
|
this.flags['story_titles_loaded'] = true;
|
|
|
|
if (!first_load) {
|
|
|
|
var stories_count = this.cache['iframe_story_positions_keys'].length;
|
2011-10-03 18:19:50 -07:00
|
|
|
this.flags['iframe_story_locations_fetched'] = false;
|
2011-06-07 12:57:14 -04:00
|
|
|
var $iframe = this.$s.$feed_iframe.contents();
|
|
|
|
this.fetch_story_locations_in_story_frame(stories_count, false, $iframe);
|
2011-06-09 19:03:27 -04:00
|
|
|
if (this.story_view == 'feed' || this.flags['page_view_showing_feed_view']) {
|
2012-06-02 16:33:44 -07:00
|
|
|
// this.prefetch_story_locations_in_feed_view();
|
2010-12-14 17:08:52 -05:00
|
|
|
}
|
2011-06-07 12:57:14 -04:00
|
|
|
} else {
|
|
|
|
if (this.story_view == 'page') {
|
|
|
|
if (this.flags['iframe_view_loaded']) {
|
|
|
|
// NEWSBLUR.log(['Titles loaded, iframe loaded']);
|
|
|
|
var $iframe = this.$s.$feed_iframe.contents();
|
|
|
|
this.fetch_story_locations_in_story_frame(0, true, $iframe);
|
|
|
|
} else {
|
|
|
|
// NEWSBLUR.log(['Titles loaded, iframe NOT loaded -- prefetching now']);
|
|
|
|
_.delay(_.bind(function() {
|
|
|
|
this.prefetch_story_locations_in_story_frame();
|
2011-06-09 20:51:48 -04:00
|
|
|
}, this), 250);
|
2011-06-07 12:57:14 -04:00
|
|
|
}
|
|
|
|
} else if (this.story_view == 'feed') {
|
2012-06-02 16:33:44 -07:00
|
|
|
// this.prefetch_story_locations_in_feed_view();
|
2012-03-01 17:08:41 -08:00
|
|
|
} else if (this.story_view == 'story' && !this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
2011-06-07 12:57:14 -04:00
|
|
|
this.show_next_story(1);
|
2011-03-15 23:42:27 -04:00
|
|
|
}
|
2012-05-23 14:11:42 -07:00
|
|
|
|
|
|
|
this.make_content_pane_feed_counter(feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2011-06-07 12:57:14 -04:00
|
|
|
this.hide_stories_progress_bar();
|
|
|
|
if (this.flags['showing_feed_in_tryfeed_view']) {
|
|
|
|
this.show_tryfeed_add_button();
|
2012-04-19 22:38:00 -07:00
|
|
|
this.correct_tryfeed_title();
|
2011-06-07 12:57:14 -04:00
|
|
|
}
|
2011-12-24 14:45:19 -08:00
|
|
|
},
|
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
setup_mousemove_on_views: function() {
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe_contents = this.$s.$feed_iframe.contents();
|
2010-12-02 11:09:09 -05:00
|
|
|
$iframe_contents
|
|
|
|
.unbind('scroll')
|
2010-12-06 10:41:24 -05:00
|
|
|
.scroll($.rescope(this.handle_scroll_feed_iframe, this));
|
2010-12-02 11:09:09 -05:00
|
|
|
this.hide_mouse_indicator();
|
|
|
|
$iframe_contents
|
|
|
|
.unbind('mousemove.reader')
|
|
|
|
.bind('mousemove.reader', $.rescope(this.handle_mousemove_iframe_view, this));
|
|
|
|
this.$s.$content_pane
|
|
|
|
.unbind('mouseleave.reader')
|
|
|
|
.bind('mouseleave.reader', $.rescope(this.hide_mouse_indicator, this));
|
|
|
|
this.$s.$content_pane
|
|
|
|
.unbind('mouseenter.reader')
|
|
|
|
.bind('mouseenter.reader', $.rescope(this.show_mouse_indicator, this));
|
|
|
|
},
|
|
|
|
|
|
|
|
set_correct_story_view_for_feed: function(feed_id, view) {
|
2012-05-09 12:09:23 -07:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2012-05-14 15:26:56 -07:00
|
|
|
var $original_tabs = $('.task_view_page, .task_view_story');
|
2012-05-09 12:09:23 -07:00
|
|
|
view = view || this.model.view_setting(feed_id);
|
|
|
|
|
2012-05-21 14:36:54 -07:00
|
|
|
if (feed && feed.get('disabled_page')) {
|
2012-05-09 12:09:23 -07:00
|
|
|
view = 'feed';
|
2012-05-14 15:26:56 -07:00
|
|
|
$original_tabs.addClass('NB-disabled-page')
|
|
|
|
.addClass('NB-disabled')
|
|
|
|
.attr('title', 'The original page has been disabled by the publisher.')
|
|
|
|
.tipsy({
|
|
|
|
gravity: 's',
|
|
|
|
fade: true,
|
|
|
|
delayIn: 200
|
|
|
|
});
|
|
|
|
$original_tabs.each(function() {
|
|
|
|
$(this).tipsy('enable');
|
|
|
|
});
|
2012-05-21 14:36:54 -07:00
|
|
|
} else if (feed && feed.get('has_exception') && feed.get('exception_type') == 'page') {
|
2012-05-09 12:09:23 -07:00
|
|
|
if (view == 'page') {
|
|
|
|
view = 'feed';
|
|
|
|
}
|
|
|
|
$('.task_view_page').addClass('NB-exception-page');
|
|
|
|
} else {
|
2012-05-14 15:26:56 -07:00
|
|
|
$original_tabs.removeClass('NB-disabled-page')
|
|
|
|
.removeClass('NB-disabled')
|
|
|
|
.removeClass('NB-exception-page');
|
|
|
|
$original_tabs.each(function() {
|
|
|
|
$(this).tipsy('disable');
|
|
|
|
});
|
2010-10-28 18:17:14 -04:00
|
|
|
}
|
|
|
|
|
2012-05-09 12:09:23 -07:00
|
|
|
this.story_view = view;
|
2010-10-28 18:17:14 -04:00
|
|
|
},
|
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
// ===============
|
|
|
|
// = Feed Header =
|
|
|
|
// ===============
|
|
|
|
|
|
|
|
update_starred_count: function() {
|
|
|
|
var starred_count = this.model.starred_count;
|
2011-03-14 21:44:04 -04:00
|
|
|
var $starred_count = $('.NB-feeds-header-count', this.$s.$starred_header);
|
|
|
|
var $starred_container = this.$s.$starred_header.closest('.NB-feeds-header-container');
|
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
if (starred_count <= 0) {
|
|
|
|
this.$s.$starred_header.addClass('NB-empty');
|
|
|
|
$starred_count.text('');
|
|
|
|
$starred_container.slideUp(350);
|
|
|
|
} else if (starred_count > 0) {
|
|
|
|
$starred_count.text(starred_count);
|
|
|
|
this.$s.$starred_header.removeClass('NB-empty');
|
|
|
|
$starred_container.slideDown(350);
|
2010-09-05 18:08:08 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-11 15:53:53 -07:00
|
|
|
open_starred_stories: function(options) {
|
|
|
|
options = options || {};
|
2010-12-02 11:09:09 -05:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
|
|
|
|
this.reset_feed();
|
|
|
|
this.hide_splash_page();
|
2010-12-04 13:32:13 -05:00
|
|
|
this.active_feed = 'starred';
|
2012-04-11 15:53:53 -07:00
|
|
|
if (options.story_id) {
|
|
|
|
this.flags['show_story_in_feed'] = options.story_id;
|
|
|
|
}
|
2011-03-14 21:44:04 -04:00
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
this.iframe_scroll = null;
|
2011-01-31 00:06:40 -05:00
|
|
|
this.show_correct_feed_in_feed_title_floater();
|
2010-12-02 11:09:09 -05:00
|
|
|
this.$s.$starred_header.addClass('NB-selected');
|
2010-12-12 22:52:15 -05:00
|
|
|
this.$s.$body.addClass('NB-view-river');
|
2011-01-19 08:54:59 -05:00
|
|
|
this.flags.river_view = true;
|
2010-12-04 21:53:39 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).addClass('NB-disabled');
|
2012-01-02 12:41:37 -08:00
|
|
|
var explicit_view_setting = this.model.view_setting(this.active_feed);
|
2010-12-04 13:32:13 -05:00
|
|
|
if (!explicit_view_setting) {
|
|
|
|
explicit_view_setting = 'feed';
|
|
|
|
}
|
|
|
|
this.set_correct_story_view_for_feed(this.active_feed, explicit_view_setting);
|
2010-12-02 11:09:09 -05:00
|
|
|
this.switch_taskbar_view(this.story_view);
|
|
|
|
this.setup_mousemove_on_views();
|
|
|
|
|
2011-11-15 18:19:09 -08:00
|
|
|
this.model.fetch_starred_stories(1, _.bind(this.post_open_starred_stories, this),
|
2012-01-08 14:15:22 -08:00
|
|
|
this.show_stories_error, true);
|
2010-12-02 11:09:09 -05:00
|
|
|
},
|
|
|
|
|
2010-12-02 20:18:33 -05:00
|
|
|
post_open_starred_stories: function(data, first_load) {
|
2010-12-04 13:32:13 -05:00
|
|
|
if (this.active_feed == 'starred') {
|
2010-12-12 23:22:53 -05:00
|
|
|
// NEWSBLUR.log(['post_open_starred_stories', data.stories.length, first_load]);
|
2012-02-24 12:47:39 -08:00
|
|
|
this.flags['opening_feed'] = false;
|
2010-12-02 20:18:33 -05:00
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
2012-02-17 17:41:20 -08:00
|
|
|
this.counts['feed_view_positions_timer'] = 0;
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.create_story_titles(data.stories, {'river_stories': true});
|
2012-05-29 11:48:40 -07:00
|
|
|
// this.make_story_feed_entries(data.stories, first_load, {'river_stories': true});
|
2012-04-11 15:20:57 -07:00
|
|
|
this.find_story_with_action_preference_on_open_feed();
|
2012-04-19 22:38:00 -07:00
|
|
|
if (this.counts['show_story_in_feed'] || this.flags['show_story_in_feed']) {
|
2012-04-11 15:53:53 -07:00
|
|
|
this.show_story_in_feed();
|
|
|
|
}
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({'animate': false});
|
2010-12-02 20:18:33 -05:00
|
|
|
this.flags['story_titles_loaded'] = true;
|
2012-06-02 16:33:44 -07:00
|
|
|
// this.prefetch_story_locations_in_feed_view();
|
2011-12-14 21:56:27 -08:00
|
|
|
this.scroll_story_titles_to_show_selected_story_title();
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.fill_out_story_titles();
|
2010-09-14 20:49:28 -04:00
|
|
|
}
|
2010-12-02 11:09:09 -05:00
|
|
|
},
|
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
// =================
|
|
|
|
// = River of News =
|
|
|
|
// =================
|
|
|
|
|
2010-12-12 22:52:15 -05:00
|
|
|
open_river_stories: function($folder, folder_title) {
|
2010-12-10 15:26:50 -05:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-12-12 22:52:15 -05:00
|
|
|
$folder = $folder || this.$s.$feed_list;
|
2012-05-24 11:54:10 -07:00
|
|
|
var folder_view = NEWSBLUR.assets.folders.get_view($folder);
|
2010-09-14 20:49:28 -04:00
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
this.reset_feed();
|
|
|
|
this.hide_splash_page();
|
2010-12-12 20:06:32 -05:00
|
|
|
if (!folder_title) {
|
2010-12-12 22:52:15 -05:00
|
|
|
this.active_feed = 'river:';
|
2010-12-12 20:06:32 -05:00
|
|
|
this.$s.$river_header.addClass('NB-selected');
|
|
|
|
} else {
|
|
|
|
this.active_feed = 'river:' + folder_title;
|
2012-05-24 11:54:10 -07:00
|
|
|
folder_view.model.set('selected', true);
|
2010-12-12 20:06:32 -05:00
|
|
|
}
|
2010-11-24 13:16:10 -05:00
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
this.iframe_scroll = null;
|
2011-02-01 00:23:44 -05:00
|
|
|
this.flags['opening_feed'] = true;
|
2011-01-30 23:00:22 -05:00
|
|
|
this.show_correct_feed_in_feed_title_floater();
|
2010-12-10 15:26:50 -05:00
|
|
|
this.$s.$body.addClass('NB-view-river');
|
2011-01-19 08:54:59 -05:00
|
|
|
this.flags.river_view = true;
|
2011-01-31 20:50:33 -05:00
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).addClass('NB-disabled');
|
2012-01-02 12:41:37 -08:00
|
|
|
var explicit_view_setting = this.model.view_setting(this.active_feed);
|
2012-01-23 09:42:05 -08:00
|
|
|
if (!explicit_view_setting || explicit_view_setting == 'page') {
|
2010-12-10 15:26:50 -05:00
|
|
|
explicit_view_setting = 'feed';
|
|
|
|
}
|
|
|
|
this.set_correct_story_view_for_feed(this.active_feed, explicit_view_setting);
|
|
|
|
this.switch_taskbar_view(this.story_view);
|
|
|
|
this.setup_mousemove_on_views();
|
|
|
|
|
2012-05-24 11:54:10 -07:00
|
|
|
NEWSBLUR.router.navigate('');
|
2011-01-31 20:08:07 -05:00
|
|
|
var feeds = this.list_feeds_with_unreads_in_folder($folder, false, true);
|
2011-02-04 09:56:15 -05:00
|
|
|
this.cache['river_feeds_with_unreads'] = feeds;
|
2011-01-31 20:53:30 -05:00
|
|
|
this.show_stories_progress_bar(feeds.length);
|
2011-06-12 23:22:58 -04:00
|
|
|
this.model.fetch_river_stories(this.active_feed, feeds, 1,
|
2012-01-08 14:15:22 -08:00
|
|
|
_.bind(this.post_open_river_stories, this), this.show_stories_error, true);
|
2010-12-10 15:26:50 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
post_open_river_stories: function(data, first_load) {
|
2011-02-04 09:56:15 -05:00
|
|
|
// NEWSBLUR.log(['post_open_river_stories', data, this.active_feed]);
|
2011-11-15 18:19:09 -08:00
|
|
|
if (!data) {
|
|
|
|
return this.show_stories_error();
|
|
|
|
}
|
|
|
|
|
2011-02-04 09:56:15 -05:00
|
|
|
if (this.active_feed && this.active_feed.indexOf('river:') != -1) {
|
2011-02-13 14:49:13 -05:00
|
|
|
if (!NEWSBLUR.Globals.is_premium &&
|
2011-02-22 23:07:49 -05:00
|
|
|
NEWSBLUR.Globals.is_authenticated &&
|
2011-02-13 14:49:13 -05:00
|
|
|
this.flags['river_view'] &&
|
|
|
|
this.active_feed.indexOf('river:') != -1) {
|
|
|
|
this.flags['non_premium_river_view'] = true;
|
|
|
|
}
|
2011-02-01 00:23:44 -05:00
|
|
|
this.flags['opening_feed'] = false;
|
2010-12-10 15:26:50 -05:00
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
2012-02-17 17:41:20 -08:00
|
|
|
this.counts['feed_view_positions_timer'] = 0;
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.create_story_titles(data.stories, {'river_stories': true});
|
2012-05-29 11:48:40 -07:00
|
|
|
// this.make_story_feed_entries(data.stories, first_load, {'river_stories': true});
|
2012-02-17 18:36:33 -08:00
|
|
|
this.find_story_with_action_preference_on_open_feed();
|
2010-12-10 15:26:50 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({'animate': false});
|
|
|
|
this.flags['story_titles_loaded'] = true;
|
2011-04-12 11:02:02 -04:00
|
|
|
if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
2011-01-11 19:33:55 -05:00
|
|
|
this.show_next_unread_story(true);
|
2011-11-02 09:43:06 -07:00
|
|
|
} else if (this.counts['find_last_unread_on_page_of_feed_stories_load']) {
|
|
|
|
this.show_last_unread_story(true);
|
2012-04-19 22:38:00 -07:00
|
|
|
} else if (this.counts['show_story_in_feed'] || this.flags['show_story_in_feed']) {
|
|
|
|
this.show_story_in_feed();
|
2011-01-11 19:33:55 -05:00
|
|
|
}
|
2011-12-14 21:56:27 -08:00
|
|
|
this.scroll_story_titles_to_show_selected_story_title();
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.fill_out_story_titles();
|
2012-06-02 16:33:44 -07:00
|
|
|
// this.prefetch_story_locations_in_feed_view();
|
2011-01-31 20:50:33 -05:00
|
|
|
this.hide_stories_progress_bar();
|
2010-12-10 15:26:50 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-01-31 20:08:07 -05:00
|
|
|
list_feeds_with_unreads_in_folder: function($folder, counts_only, visible_only) {
|
2010-12-12 22:52:15 -05:00
|
|
|
var model = this.model;
|
2011-01-10 09:49:26 -05:00
|
|
|
var unread_view = this.get_unread_view_name();
|
2010-12-12 22:52:15 -05:00
|
|
|
$folder = $folder || this.$s.$feed_list;
|
|
|
|
|
|
|
|
var $feeds = $('.feed:not(.NB-empty)', $folder);
|
|
|
|
var feeds = _.compact(_.map($('.feed:not(.NB-empty)', $folder), function(o) {
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = parseInt($(o).data('id'), 10);
|
2010-12-12 22:52:15 -05:00
|
|
|
var feed = model.get_feed(feed_id);
|
2011-06-12 23:16:59 -04:00
|
|
|
if (!feed) {
|
|
|
|
return;
|
|
|
|
} else if (counts_only && !visible_only) {
|
2012-05-21 14:36:54 -07:00
|
|
|
return feed.get('ps') + feed.get('nt') + feed.get('ng');
|
2011-01-31 20:08:07 -05:00
|
|
|
} else if (counts_only && visible_only) {
|
2012-05-21 14:36:54 -07:00
|
|
|
if (unread_view == 'positive') return feed.get('ps');
|
|
|
|
if (unread_view == 'neutral') return feed.get('ps') + feed.get('nt');
|
|
|
|
if (unread_view == 'negative') return feed.get('ps') + feed.get('nt') + feed.get('ng');
|
2011-04-12 11:02:02 -04:00
|
|
|
} else if (!counts_only && visible_only) {
|
2012-05-21 14:36:54 -07:00
|
|
|
if (unread_view == 'positive') return feed.get('ps') && feed_id;
|
|
|
|
if (unread_view == 'neutral') return (feed.get('ps') || feed.get('nt')) && feed_id;
|
|
|
|
if (unread_view == 'negative') return (feed.get('ps') || feed.get('nt') || feed.get('ng')) && feed_id;
|
2011-01-10 09:49:26 -05:00
|
|
|
} else {
|
2012-05-21 14:36:54 -07:00
|
|
|
return (feed.get('ps') || feed.get('nt') || feed.get('ng')) && feed_id;
|
2011-01-10 09:49:26 -05:00
|
|
|
}
|
2010-12-12 22:52:15 -05:00
|
|
|
}));
|
2010-12-10 15:26:50 -05:00
|
|
|
|
2010-12-12 22:52:15 -05:00
|
|
|
return feeds;
|
2010-09-14 20:49:28 -04:00
|
|
|
},
|
|
|
|
|
2012-01-25 09:52:34 -08:00
|
|
|
|
|
|
|
// ==================
|
|
|
|
// = Social Stories =
|
|
|
|
// ==================
|
|
|
|
|
2012-01-31 10:15:11 -08:00
|
|
|
open_social_stories: function(feed_id, options) {
|
2012-04-11 15:20:57 -07:00
|
|
|
// console.log(["open_social_stories", feed_id, options]);
|
2012-01-31 10:15:11 -08:00
|
|
|
options = options || {};
|
2012-04-11 15:20:57 -07:00
|
|
|
if (_.isNumber(feed_id)) feed_id = "social:" + feed_id;
|
|
|
|
|
2012-01-26 08:43:46 -08:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2012-01-25 09:52:34 -08:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
2012-01-26 08:43:46 -08:00
|
|
|
var $social_feed = this.find_social_feed_with_feed_id(feed_id);
|
|
|
|
|
2012-01-25 09:52:34 -08:00
|
|
|
this.reset_feed();
|
|
|
|
this.hide_splash_page();
|
2012-04-11 15:20:57 -07:00
|
|
|
|
2012-01-26 08:43:46 -08:00
|
|
|
this.active_feed = feed.id;
|
2012-03-14 12:38:59 -07:00
|
|
|
this.next_feed = feed.id;
|
2012-05-29 11:48:40 -07:00
|
|
|
this.flags.river_view = true;
|
2012-04-11 15:20:57 -07:00
|
|
|
if (options.story_id) {
|
|
|
|
this.flags['show_story_in_feed'] = options.story_id;
|
|
|
|
}
|
|
|
|
|
2012-01-25 09:52:34 -08:00
|
|
|
this.iframe_scroll = null;
|
|
|
|
this.flags['opening_feed'] = true;
|
2012-05-21 20:08:27 -07:00
|
|
|
feed.set('selected', true);
|
2012-01-26 08:43:46 -08:00
|
|
|
this.make_feed_title_in_stories(feed.id);
|
2012-01-25 09:52:34 -08:00
|
|
|
this.show_correct_feed_in_feed_title_floater();
|
|
|
|
this.$s.$body.addClass('NB-view-river');
|
2012-01-31 10:15:11 -08:00
|
|
|
this.flags.social_view = true;
|
2012-01-25 09:52:34 -08:00
|
|
|
|
|
|
|
var explicit_view_setting = this.model.view_setting(this.active_feed);
|
|
|
|
this.set_correct_story_view_for_feed(this.active_feed, explicit_view_setting);
|
2012-04-24 11:45:32 -07:00
|
|
|
this.switch_taskbar_view('feed');
|
2012-01-25 09:52:34 -08:00
|
|
|
this.setup_mousemove_on_views();
|
|
|
|
|
|
|
|
this.show_stories_progress_bar();
|
2012-05-25 16:42:41 -07:00
|
|
|
this.model.fetch_social_stories(this.active_feed, 1,
|
2012-01-25 09:52:34 -08:00
|
|
|
_.bind(this.post_open_social_stories, this), this.show_stories_error, true);
|
2012-05-29 11:48:40 -07:00
|
|
|
|
|
|
|
if (this.story_view == 'page') {
|
|
|
|
_.delay(_.bind(function() {
|
|
|
|
if (!options.delay || feed_id == this.next_feed) {
|
|
|
|
this.load_feed_iframe();
|
|
|
|
}
|
|
|
|
}, this), options.delay || 0);
|
|
|
|
}
|
2012-03-14 12:38:59 -07:00
|
|
|
|
2012-05-21 14:36:54 -07:00
|
|
|
if (!options.silent && feed.get('feed_title')) {
|
|
|
|
var slug = _.string.words(_.string.clean(feed.get('feed_title').replace(/[^a-z0-9\. ]/ig, ''))).join('-').toLowerCase();
|
|
|
|
var url = "social/" + feed.get('user_id') + "/" + slug;
|
2012-02-10 19:33:31 -08:00
|
|
|
if (!_.string.include(window.location.pathname, url)) {
|
2012-05-24 13:31:23 -07:00
|
|
|
// console.log(["Navigating to social", url, window.location.pathname]);
|
2012-02-10 19:33:31 -08:00
|
|
|
NEWSBLUR.router.navigate(url);
|
|
|
|
}
|
2012-05-21 14:36:54 -07:00
|
|
|
} else if (!feed.get('feed_title')) {
|
2012-04-11 15:20:57 -07:00
|
|
|
console.log(["No feed title on social", feed]);
|
2012-03-14 12:38:59 -07:00
|
|
|
NEWSBLUR.router.navigate('');
|
2012-02-10 19:33:31 -08:00
|
|
|
}
|
2012-01-25 09:52:34 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
post_open_social_stories: function(data, first_load) {
|
2012-04-11 15:20:57 -07:00
|
|
|
// NEWSBLUR.log(['post_open_river_stories', data, this.active_feed, this.flags['show_story_in_feed']]);
|
2012-01-25 09:52:34 -08:00
|
|
|
if (!data) {
|
|
|
|
return this.show_stories_error();
|
|
|
|
}
|
|
|
|
|
2012-02-22 09:11:35 -08:00
|
|
|
if (this.active_feed && NEWSBLUR.utils.is_feed_social(this.active_feed)) {
|
2012-01-25 09:52:34 -08:00
|
|
|
this.flags['opening_feed'] = false;
|
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
2012-02-17 17:41:20 -08:00
|
|
|
this.counts['feed_view_positions_timer'] = 0;
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.create_story_titles(data.stories, {'river_stories': true});
|
2012-05-29 11:48:40 -07:00
|
|
|
// this.make_story_feed_entries(data.stories, first_load, {'river_stories': true});
|
2012-04-11 15:20:57 -07:00
|
|
|
this.find_story_with_action_preference_on_open_feed();
|
2012-01-25 09:52:34 -08:00
|
|
|
this.show_story_titles_above_intelligence_level({'animate': false});
|
|
|
|
this.flags['story_titles_loaded'] = true;
|
2012-04-19 22:38:00 -07:00
|
|
|
if (this.counts['show_story_in_feed'] || this.flags['show_story_in_feed']) {
|
2012-04-11 15:20:57 -07:00
|
|
|
this.show_story_in_feed();
|
|
|
|
} else if (this.counts['find_next_unread_on_page_of_feed_stories_load']) {
|
2012-01-25 09:52:34 -08:00
|
|
|
this.show_next_unread_story(true);
|
|
|
|
} else if (this.counts['find_last_unread_on_page_of_feed_stories_load']) {
|
|
|
|
this.show_last_unread_story(true);
|
|
|
|
}
|
|
|
|
this.scroll_story_titles_to_show_selected_story_title();
|
2012-05-25 16:42:41 -07:00
|
|
|
// this.fill_out_story_titles();
|
2012-05-29 11:48:40 -07:00
|
|
|
// this.prefetch_story_locations_in_feed_view();
|
2012-01-25 09:52:34 -08:00
|
|
|
this.hide_stories_progress_bar();
|
2012-01-31 10:15:11 -08:00
|
|
|
|
2012-03-15 11:33:00 -07:00
|
|
|
if (this.flags['showing_social_feed_in_tryfeed_view']) {
|
|
|
|
this.show_tryfeed_follow_button();
|
2012-05-10 09:45:07 -07:00
|
|
|
this.correct_tryfeed_title();
|
2012-03-15 11:33:00 -07:00
|
|
|
}
|
2012-01-25 09:52:34 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-01-26 08:43:46 -08:00
|
|
|
find_social_feed_with_feed_id: function(feed_id) {
|
|
|
|
if (_.contains(this.cache.$feed_in_social_feed_list, feed_id)) {
|
|
|
|
return this.cache.$feed_in_social_feed_list[feed_id];
|
2012-01-25 09:52:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
var $social_feeds = this.$s.$social_feeds;
|
|
|
|
var $feeds = $([]);
|
|
|
|
|
|
|
|
$('.feed', $social_feeds).each(function() {
|
2012-02-10 19:33:31 -08:00
|
|
|
if ($(this).data('id') == feed_id) {
|
2012-01-25 09:52:34 -08:00
|
|
|
$feeds.push($(this).get(0));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-01-26 08:43:46 -08:00
|
|
|
this.cache.$feed_in_social_feed_list[feed_id] = $feeds;
|
2012-01-25 09:52:34 -08:00
|
|
|
|
|
|
|
return $feeds;
|
|
|
|
},
|
|
|
|
|
|
|
|
// =================
|
|
|
|
// = Story loading =
|
|
|
|
// =================
|
|
|
|
|
2011-01-31 20:53:30 -05:00
|
|
|
show_stories_progress_bar: function(feeds_loading) {
|
2011-11-15 18:19:09 -08:00
|
|
|
this.hide_stories_error();
|
2012-05-23 14:11:42 -07:00
|
|
|
if (NEWSBLUR.app.story_unread_counter) {
|
|
|
|
NEWSBLUR.app.story_unread_counter.remove();
|
|
|
|
}
|
2011-11-15 18:19:09 -08:00
|
|
|
|
2011-01-31 19:51:39 -05:00
|
|
|
var $progress = $.make('div', { className: 'NB-river-progress' }, [
|
|
|
|
$.make('div', { className: 'NB-river-progress-text' }),
|
|
|
|
$.make('div', { className: 'NB-river-progress-bar' })
|
2011-01-31 20:50:33 -05:00
|
|
|
]).css({'opacity': 0});
|
|
|
|
|
|
|
|
this.$s.$story_taskbar.append($progress);
|
2011-01-31 19:51:39 -05:00
|
|
|
|
2011-01-31 20:50:33 -05:00
|
|
|
$progress.animate({'opacity': 1}, {'duration': 500, 'queue': false});
|
2011-01-31 19:51:39 -05:00
|
|
|
|
2011-01-31 20:08:07 -05:00
|
|
|
var $bar = $('.NB-river-progress-bar', $progress);
|
2011-01-31 20:53:30 -05:00
|
|
|
var unreads;
|
|
|
|
if (feeds_loading) unreads = feeds_loading;
|
|
|
|
else unreads = this.get_unread_count(false) / 10;
|
|
|
|
this.animate_progress_bar($bar, unreads);
|
2011-01-31 20:50:33 -05:00
|
|
|
|
|
|
|
$('.NB-river-progress-text', $progress).text('Fetching stories');
|
|
|
|
// Center the progress bar
|
|
|
|
var i_width = $progress.width();
|
|
|
|
var o_width = this.$s.$story_taskbar.width();
|
|
|
|
var left = (o_width / 2.0) - (i_width / 2.0);
|
|
|
|
$progress.css({'left': left});
|
2011-01-31 19:51:39 -05:00
|
|
|
},
|
|
|
|
|
2011-01-31 20:50:33 -05:00
|
|
|
hide_stories_progress_bar: function() {
|
|
|
|
var $progress = $('.NB-river-progress', this.$s.$story_taskbar);
|
2011-03-15 23:42:27 -04:00
|
|
|
$progress.stop().animate({'opacity': 0}, {
|
|
|
|
'duration': 250,
|
|
|
|
'queue': false,
|
|
|
|
'complete': function() {
|
|
|
|
$progress.remove();
|
|
|
|
}
|
|
|
|
});
|
2011-01-31 19:51:39 -05:00
|
|
|
},
|
|
|
|
|
2011-11-15 18:19:09 -08:00
|
|
|
show_stories_error: function() {
|
2011-11-22 12:08:18 -05:00
|
|
|
console.log(["show_stories_error", arguments]);
|
2011-11-15 18:19:09 -08:00
|
|
|
this.hide_stories_progress_bar();
|
|
|
|
|
2012-01-25 09:52:34 -08:00
|
|
|
this.flags['iframe_view_not_busting'] = true;
|
2012-05-25 16:42:41 -07:00
|
|
|
this.model.flags['no_more_stories'] = true;
|
2012-01-25 09:52:34 -08:00
|
|
|
|
2011-11-15 18:19:09 -08:00
|
|
|
var $error = $.make('div', { className: 'NB-feed-error' }, [
|
|
|
|
$.make('div', { className: 'NB-feed-error-icon' }),
|
|
|
|
$.make('div', { className: 'NB-feed-error-text' }, 'Oh no! There was an error!')
|
|
|
|
]).css({'opacity': 0});
|
|
|
|
|
|
|
|
this.$s.$story_taskbar.append($error);
|
|
|
|
|
|
|
|
$error.animate({'opacity': 1}, {'duration': 500, 'queue': false});
|
|
|
|
// Center the progress bar
|
|
|
|
var i_width = $error.width();
|
|
|
|
var o_width = this.$s.$story_taskbar.width();
|
|
|
|
var left = (o_width / 2.0) - (i_width / 2.0);
|
|
|
|
$error.css({'left': left});
|
|
|
|
|
2012-05-25 16:42:41 -07:00
|
|
|
NEWSBLUR.app.story_titles.end_loading();
|
2011-11-15 18:19:09 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
hide_stories_error: function() {
|
|
|
|
var $error = $('.NB-feed-error', this.$s.$story_taskbar);
|
|
|
|
$error.animate({'opacity': 0}, {
|
|
|
|
'duration': 250,
|
|
|
|
'queue': false,
|
|
|
|
'complete': function() {
|
|
|
|
$error.remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ==========================
|
|
|
|
// = Story Pane - All Views =
|
|
|
|
// ==========================
|
|
|
|
|
2012-04-19 15:01:01 -07:00
|
|
|
open_story: function(story, $story_title, options) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var self = this;
|
|
|
|
var feed_position;
|
|
|
|
var iframe_position;
|
2012-04-19 15:01:01 -07:00
|
|
|
options = options || {};
|
2012-04-19 22:38:00 -07:00
|
|
|
// NEWSBLUR.log(['open_story', this.story_view, story, options]);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2012-04-19 15:01:01 -07:00
|
|
|
if (this.active_story != story || options.story_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
this.active_story = story;
|
2010-12-14 18:48:52 -05:00
|
|
|
this.mark_story_title_as_selected($story_title);
|
2011-09-30 18:02:48 -07:00
|
|
|
this.unload_story_iframe();
|
2011-01-10 19:34:27 -05:00
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
// Used when auto-tracking the user as they move over the feed/page.
|
|
|
|
// No need to find the story, since they have already found it.
|
2010-12-14 18:48:52 -05:00
|
|
|
clearTimeout(this.locks.scrolling);
|
2011-02-23 19:41:05 -05:00
|
|
|
if (_.contains(['feed', 'page'], this.story_view)) {
|
|
|
|
this.flags['scrolling_by_selecting_story_title'] = true;
|
|
|
|
}
|
2010-12-14 18:48:52 -05:00
|
|
|
|
|
|
|
// User clicks on story, scroll them to it.
|
2011-11-15 18:37:42 -08:00
|
|
|
var $feed_story = this.find_story_in_feed_view(story.id);
|
2010-12-14 18:48:52 -05:00
|
|
|
|
|
|
|
if (this.story_view == 'page') {
|
|
|
|
var $iframe_story = this.find_story_in_feed_iframe(story);
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!$iframe_story || !$iframe_story.length || !this.flags['story_titles_loaded']) {
|
|
|
|
// If the iframe has not yet loaded, we can't touch it.
|
|
|
|
// So just assume story not found.
|
|
|
|
this.switch_to_correct_view(false);
|
2012-04-19 15:01:01 -07:00
|
|
|
feed_position = this.scroll_to_story_in_story_feed(story, $feed_story, options);
|
2011-11-04 18:12:28 -07:00
|
|
|
this.show_stories_preference_in_feed_view(true);
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
|
|
|
iframe_position = this.scroll_to_story_in_iframe(story, $iframe_story);
|
|
|
|
this.switch_to_correct_view(iframe_position);
|
|
|
|
}
|
2010-12-14 18:48:52 -05:00
|
|
|
} else if (this.story_view == 'feed') {
|
|
|
|
this.switch_to_correct_view();
|
2012-04-19 15:01:01 -07:00
|
|
|
feed_position = this.scroll_to_story_in_story_feed(story, $feed_story, options);
|
2010-12-14 18:48:52 -05:00
|
|
|
this.show_stories_preference_in_feed_view(true);
|
|
|
|
} else if (this.story_view == 'story') {
|
|
|
|
this.open_story_in_story_view(story);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2011-01-10 19:34:27 -05:00
|
|
|
_.defer(_.bind(this.mark_story_as_read, this, story.id));
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
switch_to_correct_view: function(found_story_in_page) {
|
2011-07-13 09:50:02 -07:00
|
|
|
// NEWSBLUR.log(['Found story', this.story_view, found_story_in_page, this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
|
2010-06-14 13:17:38 -04:00
|
|
|
if (found_story_in_page === false) {
|
|
|
|
// Story not found, show in feed view with link to page view
|
|
|
|
if (this.story_view == 'page' && !this.flags['page_view_showing_feed_view']) {
|
2010-12-07 20:04:37 -05:00
|
|
|
// console.log(['turn on feed view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
|
2010-06-14 13:17:38 -04:00
|
|
|
this.flags['page_view_showing_feed_view'] = true;
|
2010-12-07 18:52:01 -05:00
|
|
|
this.flags['feed_view_showing_story_view'] = false;
|
2010-12-06 10:41:24 -05:00
|
|
|
this.switch_taskbar_view('feed', 'page');
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_stories_preference_in_feed_view();
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
2010-12-07 09:52:14 -05:00
|
|
|
if (this.story_view == 'page' && this.flags['page_view_showing_feed_view']) {
|
2010-12-07 20:04:37 -05:00
|
|
|
// console.log(['turn off feed view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
|
2010-12-07 09:52:14 -05:00
|
|
|
this.flags['page_view_showing_feed_view'] = false;
|
2010-12-07 18:52:01 -05:00
|
|
|
this.flags['feed_view_showing_story_view'] = false;
|
2010-12-07 09:52:14 -05:00
|
|
|
this.switch_taskbar_view('page');
|
|
|
|
} else if (this.flags['feed_view_showing_story_view']) {
|
2010-12-07 20:04:37 -05:00
|
|
|
// console.log(['turn off story view', this.flags['page_view_showing_feed_view'], this.flags['feed_view_showing_story_view']]);
|
2010-12-07 09:52:14 -05:00
|
|
|
this.flags['page_view_showing_feed_view'] = false;
|
|
|
|
this.flags['feed_view_showing_story_view'] = false;
|
2010-12-07 20:04:37 -05:00
|
|
|
this.switch_taskbar_view(this.story_view, true);
|
2010-12-07 09:52:14 -05:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
scroll_to_story_in_iframe: function(story, $story, skip_scroll) {
|
2010-12-09 18:47:06 -05:00
|
|
|
var self = this;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe = this.$s.$feed_iframe;
|
2011-06-07 12:57:34 -04:00
|
|
|
|
|
|
|
if (!this.model.preference('animations')) skip_scroll = true;
|
2011-07-13 09:50:02 -07:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if ($story && $story.length) {
|
|
|
|
if (skip_scroll
|
|
|
|
|| this.story_view == 'feed'
|
|
|
|
|| this.story_view == 'story'
|
|
|
|
|| this.flags['page_view_showing_feed_view']) {
|
2011-07-13 09:50:02 -07:00
|
|
|
$iframe.scrollTo($story, { duration: 0, axis: 'y', offset: -24 }); // Do this at story_view switch
|
2011-07-12 10:07:57 -07:00
|
|
|
self.locks.scrolling = setTimeout(function() {
|
|
|
|
self.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
}, 100);
|
2010-06-14 13:17:38 -04:00
|
|
|
} else if (this.story_view == 'page') {
|
|
|
|
$iframe.scrollable().stop();
|
2011-07-13 09:50:02 -07:00
|
|
|
$iframe.scrollTo($story, {
|
|
|
|
duration: 380,
|
2011-07-12 10:07:57 -07:00
|
|
|
axis: 'y',
|
|
|
|
easing: 'easeInOutQuint',
|
|
|
|
offset: -24,
|
|
|
|
queue: false,
|
|
|
|
onAfter: function() {
|
|
|
|
self.locks.scrolling = setTimeout(function() {
|
|
|
|
self.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
var parent_scroll = $story.parents('.NB-feed-story-view').scrollTop();
|
|
|
|
var story_offset = $story.offset().top;
|
2011-07-13 09:50:02 -07:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
return story_offset + parent_scroll;
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
return false;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
prefetch_story_locations_in_story_frame: function() {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
var stories = this.model.stories;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe = this.$s.$feed_iframe.contents();
|
2010-11-08 19:39:27 -05:00
|
|
|
var prefetch_tries_left = 3;
|
2010-11-06 12:53:42 -04:00
|
|
|
this.cache['prefetch_iteration'] += 1;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['Prefetching', !this.flags['iframe_fetching_story_locations']]);
|
|
|
|
if (!this.flags['iframe_fetching_story_locations']
|
|
|
|
&& !this.flags['iframe_story_locations_fetched']) {
|
2010-12-06 10:41:24 -05:00
|
|
|
$iframe.unbind('scroll').scroll($.rescope(this.handle_scroll_feed_iframe, this));
|
2010-06-15 18:29:13 -04:00
|
|
|
$iframe
|
|
|
|
.unbind('mousemove.reader')
|
|
|
|
.bind('mousemove.reader', $.rescope(this.handle_mousemove_iframe_view, this));
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-11-06 12:53:42 -04:00
|
|
|
var last_story_index = this.cache.iframe_story_positions_keys.length;
|
|
|
|
var last_story_position = _.last(this.cache.iframe_story_positions_keys);
|
|
|
|
var last_story = this.cache.iframe_story_positions[last_story_position];
|
|
|
|
var $last_story;
|
|
|
|
if (last_story) {
|
2010-12-06 10:41:24 -05:00
|
|
|
$last_story = this.find_story_in_feed_iframe(last_story, $iframe);
|
2010-11-06 12:53:42 -04:00
|
|
|
}
|
|
|
|
// NEWSBLUR.log(['last_story', last_story_index, last_story_position, last_story, $last_story]);
|
|
|
|
var last_story_same_position;
|
|
|
|
if ($last_story && $last_story.length) {
|
|
|
|
last_story_same_position = parseInt($last_story.offset().top, 10)==last_story_position;
|
|
|
|
if (!last_story_same_position) {
|
|
|
|
$.extend(this.cache, {
|
|
|
|
'iframe_stories': {},
|
|
|
|
'iframe_story_positions': {},
|
|
|
|
'iframe_story_positions_keys': []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
for (var s in stories) {
|
2010-11-06 12:53:42 -04:00
|
|
|
if (last_story_same_position && parseInt(s, 10) < last_story_index) continue;
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = stories[s];
|
2010-12-06 10:41:24 -05:00
|
|
|
var $story = this.find_story_in_feed_iframe(story, $iframe);
|
2012-05-25 18:54:04 -07:00
|
|
|
// NEWSBLUR.log(['Pre-fetching', parseInt(s, 10), last_story_index, last_story_same_position, $story, story.get('story_title')]);
|
2010-11-06 12:53:42 -04:00
|
|
|
if (!$story ||
|
|
|
|
!$story.length ||
|
|
|
|
this.flags['iframe_fetching_story_locations'] ||
|
2010-11-08 19:39:27 -05:00
|
|
|
this.flags['iframe_story_locations_fetched'] ||
|
2011-06-09 20:51:48 -04:00
|
|
|
parseInt($story.offset().top, 10) > this.cache['prefetch_iteration']*2000) {
|
2010-11-06 12:53:42 -04:00
|
|
|
if ($story && $story.length) {
|
2011-02-04 00:22:58 -05:00
|
|
|
// NEWSBLUR.log(['Prefetch break on position too far', parseInt($story.offset().top, 10), this.cache['prefetch_iteration']*4000]);
|
2010-11-08 19:39:27 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!prefetch_tries_left) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
prefetch_tries_left -= 1;
|
2010-11-06 12:53:42 -04:00
|
|
|
}
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
if (!this.flags['iframe_fetching_story_locations']
|
|
|
|
&& !this.flags['iframe_story_locations_fetched']) {
|
|
|
|
setTimeout(function() {
|
2010-11-08 19:39:27 -05:00
|
|
|
if (!self.flags['iframe_fetching_story_locations']
|
|
|
|
&& !self.flags['iframe_story_locations_fetched']) {
|
2010-06-14 13:17:38 -04:00
|
|
|
self.prefetch_story_locations_in_story_frame();
|
|
|
|
}
|
2011-06-09 20:51:48 -04:00
|
|
|
}, 1000);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
fetch_story_locations_in_story_frame: function(s, clear_cache, $iframe) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
var stories = this.model.stories;
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!s) s = 0;
|
|
|
|
var story = stories[s];
|
2010-12-06 10:41:24 -05:00
|
|
|
if (!$iframe) $iframe = this.$s.$feed_iframe.contents();
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
this.flags['iframe_fetching_story_locations'] = true;
|
2011-10-03 18:19:50 -07:00
|
|
|
this.flags['iframe_story_locations_fetched'] = false;
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
if (clear_cache) {
|
|
|
|
$.extend(this.cache, {
|
2010-06-14 13:17:38 -04:00
|
|
|
'iframe_stories': {},
|
|
|
|
'iframe_story_positions': {},
|
|
|
|
'iframe_story_positions_keys': []
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-02-10 19:45:49 -08:00
|
|
|
if (story && (story['story_feed_id'] == this.active_feed ||
|
|
|
|
"social:" + story['social_user_id'] == this.active_feed)) {
|
2010-12-06 10:41:24 -05:00
|
|
|
var $story = this.find_story_in_feed_iframe(story, $iframe);
|
2012-05-25 18:54:04 -07:00
|
|
|
// NEWSBLUR.log(['Fetching story', s, story.get('story_title'), $story]);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
setTimeout(function() {
|
|
|
|
if ((stories.length-1) >= (s+1)
|
|
|
|
&& (s < 3
|
|
|
|
|| ((self.cache.iframe_stories[stories[s].id]
|
|
|
|
&& self.cache.iframe_stories[stories[s].id].length)
|
|
|
|
|| (self.cache.iframe_stories[stories[s-1].id]
|
|
|
|
&& self.cache.iframe_stories[stories[s-1].id].length)
|
|
|
|
|| (self.cache.iframe_stories[stories[s-2].id]
|
|
|
|
&& self.cache.iframe_stories[stories[s-2].id].length)))) {
|
|
|
|
self.fetch_story_locations_in_story_frame(s+1, false, $iframe);
|
2011-10-03 18:19:50 -07:00
|
|
|
self.flags['iframe_story_locations_fetched'] = false;
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
2012-01-23 21:56:42 -08:00
|
|
|
// NEWSBLUR.log(['iFrame view entirely loaded', (s-2) + ' stories', self.cache.iframe_stories]);
|
2010-06-14 13:17:38 -04:00
|
|
|
self.flags['iframe_story_locations_fetched'] = true;
|
|
|
|
self.flags['iframe_fetching_story_locations'] = false;
|
2010-07-24 18:22:23 -04:00
|
|
|
clearInterval(self.flags['iframe_scroll_snapback_check']);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-11-06 13:27:52 -04:00
|
|
|
}, 20);
|
2012-02-10 19:45:49 -08:00
|
|
|
} else if (story && story['story_feed_id'] != this.active_feed &&
|
|
|
|
"social:" + story['social_user_id'] != this.active_feed) {
|
|
|
|
NEWSBLUR.log(['Switched off iframe early', this.active_feed, story['story_feed_id'], story['social_user_id']]);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-05-07 18:24:05 -07:00
|
|
|
update_read_count: function(story_id, feed_id, options) {
|
|
|
|
options = options || {};
|
2012-05-23 17:21:06 -07:00
|
|
|
|
2012-05-07 18:24:05 -07:00
|
|
|
if (options.previously_read) return;
|
2010-12-30 19:24:52 -05:00
|
|
|
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2012-05-25 20:52:30 -07:00
|
|
|
var story = this.model.get_story(story_id);
|
2010-12-30 19:24:52 -05:00
|
|
|
var $feed_list = this.$s.$feed_list;
|
|
|
|
var $content_pane = this.$s.$content_pane;
|
2012-05-23 14:11:42 -07:00
|
|
|
var story_unread_counter = NEWSBLUR.app.story_unread_counter;
|
2011-04-12 18:23:04 -04:00
|
|
|
var unread_view = this.get_unread_view_name();
|
2011-03-02 17:58:12 -05:00
|
|
|
|
2012-05-25 20:52:30 -07:00
|
|
|
if (story.score() > 0) {
|
2012-05-21 14:36:54 -07:00
|
|
|
var count = Math.max(feed.get('ps') + (options.unread?1:-1), 0);
|
2012-05-22 15:02:37 -07:00
|
|
|
feed.set('ps', count, {instant: true});
|
2012-05-25 20:52:30 -07:00
|
|
|
} else if (story.score() == 0) {
|
2012-05-22 15:02:37 -07:00
|
|
|
var count = Math.max(feed.get('nt') + (options.unread?1:-1), 0);
|
|
|
|
feed.set('nt', count, {instant: true});
|
2012-05-25 20:52:30 -07:00
|
|
|
} else if (story.score() < 0) {
|
2012-05-22 15:02:37 -07:00
|
|
|
var count = Math.max(feed.get('ng') + (options.unread?1:-1), 0);
|
|
|
|
feed.set('ng', count, {instant: true});
|
2010-12-30 19:24:52 -05:00
|
|
|
}
|
|
|
|
|
2012-05-24 11:54:10 -07:00
|
|
|
if (story_unread_counter) {
|
|
|
|
story_unread_counter.flash();
|
|
|
|
}
|
2012-05-23 14:11:42 -07:00
|
|
|
|
|
|
|
// if ((unread_view == 'positive' && feed.get('ps') == 0) ||
|
|
|
|
// (unread_view == 'neutral' && feed.get('ps') == 0 && feed.get('nt') == 0) ||
|
|
|
|
// (unread_view == 'negative' && feed.get('ps') == 0 && feed.get('nt') == 0 && feed.get('ng') == 0)) {
|
|
|
|
// story_unread_counter.fall();
|
|
|
|
// }
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
mark_feed_as_read: function(feed_id) {
|
2010-07-24 00:04:14 -04:00
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-09-16 10:35:36 -04:00
|
|
|
this.mark_feed_as_read_update_counts(feed_id);
|
|
|
|
|
|
|
|
this.model.mark_feed_as_read([feed_id]);
|
2012-05-24 11:54:10 -07:00
|
|
|
|
|
|
|
// if (this.model.preference('folder_counts')) {
|
|
|
|
// var $feed = this.find_feed_in_feed_list(feed_id);
|
|
|
|
// var $folder_title = $feed.closest('li.folder:visible').children('.folder_title');
|
|
|
|
// var $children = $folder_title.closest('li.folder').children('ul.folder, .feed');
|
|
|
|
// this.show_collapsed_folder_count($folder_title, $children);
|
|
|
|
// }
|
2010-09-16 10:35:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
mark_folder_as_read: function(folder_name, $folder) {
|
2012-05-23 21:22:48 -07:00
|
|
|
var folder_view = NEWSBLUR.assets.folders.get_view($folder);
|
|
|
|
var feeds = folder_view.model.feed_ids_in_folder($folder);
|
2011-11-23 16:45:36 -05:00
|
|
|
|
2010-09-16 10:35:36 -04:00
|
|
|
_.each(feeds, _.bind(function(feed_id) {
|
|
|
|
this.mark_feed_as_read_update_counts(feed_id);
|
|
|
|
}, this));
|
|
|
|
this.model.mark_feed_as_read(feeds);
|
|
|
|
},
|
|
|
|
|
2012-05-22 15:02:37 -07:00
|
|
|
mark_feed_as_read_update_counts: function(feed_id) {
|
2010-09-16 10:35:36 -04:00
|
|
|
if (feed_id) {
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2011-10-31 18:50:39 -07:00
|
|
|
if (!feed) return;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2012-05-21 14:36:54 -07:00
|
|
|
feed.set('ps', 0);
|
|
|
|
feed.set('nt', 0);
|
|
|
|
feed.set('ng', 0);
|
2010-09-16 10:35:36 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-03-06 21:33:06 -05:00
|
|
|
open_story_trainer: function(story_id, feed_id) {
|
2012-05-25 20:52:30 -07:00
|
|
|
story_id = story_id || this.active_story && this.active_story.id;
|
|
|
|
feed_id = feed_id || (story_id && this.model.get_story(story_id).get('story_feed_id'));
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2011-10-30 22:15:04 -07:00
|
|
|
if (story_id && feed_id) {
|
|
|
|
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierStory(story_id, feed_id, {
|
|
|
|
'feed_loaded': !this.flags['river_view']
|
|
|
|
});
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
2012-04-24 10:38:23 -07:00
|
|
|
|
2012-06-02 16:33:44 -07:00
|
|
|
// ===========
|
|
|
|
// = Send To =
|
|
|
|
// ===========
|
2012-03-16 20:40:48 -07:00
|
|
|
|
2010-12-31 10:34:31 -05:00
|
|
|
send_story_to_instapaper: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
2011-01-07 16:36:46 -05:00
|
|
|
var url = 'http://www.instapaper.com/edit';
|
|
|
|
var instapaper_url = [
|
|
|
|
url,
|
|
|
|
'?url=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2011-01-07 16:36:46 -05:00
|
|
|
'&title=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title'))
|
2011-01-07 16:36:46 -05:00
|
|
|
].join('');
|
|
|
|
window.open(instapaper_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-02-15 21:31:33 -05:00
|
|
|
send_story_to_readitlater: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
2012-04-17 11:01:52 -07:00
|
|
|
var url = 'https://getpocket.com/save';
|
2011-02-15 21:31:33 -05:00
|
|
|
var readitlater_url = [
|
|
|
|
url,
|
|
|
|
'?url=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2011-02-15 21:31:33 -05:00
|
|
|
'&title=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title'))
|
2011-02-15 21:31:33 -05:00
|
|
|
].join('');
|
|
|
|
window.open(readitlater_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-02-15 21:31:33 -05:00
|
|
|
},
|
|
|
|
|
2012-01-13 10:46:56 -08:00
|
|
|
send_story_to_tumblr: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
var url = 'http://www.tumblr.com/share';
|
|
|
|
var tumblr_url = [
|
|
|
|
url,
|
|
|
|
'?v=3&u=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2012-01-13 10:46:56 -08:00
|
|
|
'&t=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title'))
|
2012-01-13 10:46:56 -08:00
|
|
|
].join('');
|
|
|
|
window.open(tumblr_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2012-01-13 10:46:56 -08:00
|
|
|
},
|
|
|
|
|
2012-05-06 16:26:54 -07:00
|
|
|
send_story_to_delicious: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
var url = 'http://www.delicious.com/save';
|
|
|
|
var delicious_url = [
|
|
|
|
url,
|
|
|
|
'?v=6&url=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2012-05-06 16:26:54 -07:00
|
|
|
'&title=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title'))
|
2012-05-06 16:26:54 -07:00
|
|
|
].join('');
|
|
|
|
window.open(delicious_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2012-05-06 16:26:54 -07:00
|
|
|
},
|
|
|
|
|
2011-02-16 20:45:37 -05:00
|
|
|
send_story_to_readability: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
2012-03-19 20:12:57 -07:00
|
|
|
var url = 'http://www.readability.com/save';
|
2011-02-16 20:45:37 -05:00
|
|
|
var readability_url = [
|
|
|
|
url,
|
|
|
|
'?url=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2011-02-16 20:45:37 -05:00
|
|
|
'&title=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title'))
|
2011-02-16 20:45:37 -05:00
|
|
|
].join('');
|
|
|
|
window.open(readability_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-02-16 20:45:37 -05:00
|
|
|
},
|
|
|
|
|
2011-02-04 00:22:58 -05:00
|
|
|
send_story_to_twitter: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
var url = 'http://twitter.com/';
|
|
|
|
var twitter_url = [
|
|
|
|
url,
|
|
|
|
'?status=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title')),
|
2011-02-04 00:22:58 -05:00
|
|
|
': ',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink'))
|
2011-02-04 00:22:58 -05:00
|
|
|
].join('');
|
|
|
|
window.open(twitter_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-02-04 00:22:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
send_story_to_facebook: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
2011-02-04 00:30:33 -05:00
|
|
|
var url = 'http://www.facebook.com/sharer.php?src=newsblur&v=3.14159265&i=1.61803399';
|
2011-02-04 00:22:58 -05:00
|
|
|
var facebook_url = [
|
|
|
|
url,
|
|
|
|
'&u=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2011-02-04 00:22:58 -05:00
|
|
|
'&t=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title'))
|
2011-02-04 00:22:58 -05:00
|
|
|
].join('');
|
|
|
|
window.open(facebook_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-02-04 00:22:58 -05:00
|
|
|
},
|
|
|
|
|
2011-11-07 18:21:38 -08:00
|
|
|
send_story_to_pinboard: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
var url = 'http://pinboard.in/add/?';
|
|
|
|
var pinboard_url = [
|
|
|
|
url,
|
|
|
|
'url=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2011-11-07 18:21:38 -08:00
|
|
|
'&title=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title')),
|
2011-11-07 18:21:38 -08:00
|
|
|
'&tags=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_tags').join(', '))
|
2011-11-07 18:21:38 -08:00
|
|
|
].join('');
|
|
|
|
window.open(pinboard_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-11-07 18:21:38 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
send_story_to_googleplus: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
var url = 'https://plusone.google.com/_/+1/confirm'; //?hl=en&url=${url}
|
|
|
|
var googleplus_url = [
|
|
|
|
url,
|
|
|
|
'?hl=en&url=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_permalink')),
|
2011-11-07 18:21:38 -08:00
|
|
|
'&title=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_title')),
|
2011-11-07 18:21:38 -08:00
|
|
|
'&tags=',
|
2012-05-25 18:54:04 -07:00
|
|
|
encodeURIComponent(story.get('story_tags').join(', '))
|
2011-11-07 18:21:38 -08:00
|
|
|
].join('');
|
|
|
|
window.open(googleplus_url, '_blank');
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-11-07 18:21:38 -08:00
|
|
|
},
|
|
|
|
|
2011-05-03 11:40:38 -04:00
|
|
|
send_story_to_email: function(story_id) {
|
2011-05-03 20:59:07 -04:00
|
|
|
NEWSBLUR.reader_send_email = new NEWSBLUR.ReaderSendEmail(story_id);
|
2012-05-25 20:52:30 -07:00
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2011-05-03 11:40:38 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// =====================
|
|
|
|
// = Story Titles Pane =
|
|
|
|
// =====================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
make_content_pane_feed_counter: function(feed_id) {
|
2010-06-15 18:29:13 -04:00
|
|
|
var $content_pane = this.$s.$content_pane;
|
2011-03-17 22:08:21 -04:00
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-06-14 13:17:38 -04:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2012-05-23 14:11:42 -07:00
|
|
|
if (NEWSBLUR.app.story_unread_counter) {
|
|
|
|
NEWSBLUR.app.story_unread_counter.remove();
|
|
|
|
}
|
|
|
|
NEWSBLUR.app.story_unread_counter = new NEWSBLUR.Views.FeedCount({model: feed}).render();
|
|
|
|
|
|
|
|
NEWSBLUR.app.story_unread_counter.$el.css({'opacity': 0});
|
|
|
|
this.$s.$story_taskbar.append(NEWSBLUR.app.story_unread_counter.$el);
|
2011-02-01 00:23:44 -05:00
|
|
|
_.delay(function() {
|
2012-05-23 14:11:42 -07:00
|
|
|
NEWSBLUR.app.story_unread_counter.center();
|
|
|
|
NEWSBLUR.app.story_unread_counter.$el.animate({'opacity': .2}, {'duration': 1000, 'queue': false});
|
2011-02-01 00:23:44 -05:00
|
|
|
}, 500);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
make_story_title: function(story, options) {
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
return $story_title;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
hover_story_titles: function() {
|
2011-09-27 23:06:49 -07:00
|
|
|
var $story_titles = $('#story_titles .story,.NB-feedbar .feed');
|
2011-09-27 22:16:09 -07:00
|
|
|
$story_titles.unbind('mouseenter').unbind('mouseleave');
|
|
|
|
|
|
|
|
$story_titles.hover(function() {
|
|
|
|
var $this = $(this);
|
2011-11-11 12:09:20 -08:00
|
|
|
var menu_height = $this.hasClass('story') ? 190 : 270;
|
2011-09-29 09:53:55 -07:00
|
|
|
|
2011-09-27 23:06:49 -07:00
|
|
|
if ($this.offset().top > $(window).height() - menu_height) {
|
2011-09-27 22:16:09 -07:00
|
|
|
$this.addClass('NB-hover-inverse');
|
|
|
|
}
|
|
|
|
}, function() {
|
|
|
|
$(this).removeClass('NB-hover-inverse');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2011-02-27 19:42:22 -05:00
|
|
|
recalculate_story_scores: function(feed_id) {
|
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
|
|
|
|
this.model.recalculate_story_scores(feed_id);
|
2011-02-27 16:13:22 -05:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// =================================
|
|
|
|
// = Story Pane - iFrame/Page View =
|
|
|
|
// =================================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
unload_feed_iframe: function() {
|
|
|
|
var $feed_iframe = this.$s.$feed_iframe;
|
2010-11-24 13:16:10 -05:00
|
|
|
var $taskbar_view_page = $('.NB-taskbar .task_view_page');
|
2011-02-02 14:10:24 -05:00
|
|
|
$taskbar_view_page.removeClass('NB-task-return');
|
2010-07-06 18:43:06 -04:00
|
|
|
|
2010-07-06 18:30:16 -04:00
|
|
|
this.flags['iframe_view_loaded'] = false;
|
|
|
|
this.flags['iframe_story_locations_fetched'] = false;
|
|
|
|
this.flags['iframe_prevented_from_loading'] = false;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$.extend(this.cache, {
|
|
|
|
'iframe_stories': {},
|
|
|
|
'iframe_story_positions': {},
|
|
|
|
'iframe_story_positions_keys': []
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.removeAttr('src');
|
2011-09-30 18:02:48 -07:00
|
|
|
$feed_iframe.empty();
|
|
|
|
|
2012-01-16 17:55:13 -08:00
|
|
|
var $new_iframe = $.make('iframe', { className: this.$s.$feed_iframe.attr('class'), src: 'about:blank'});
|
|
|
|
this.$s.$feed_iframe.replaceWith($new_iframe);
|
|
|
|
this.$s.$feed_iframe = $new_iframe;
|
|
|
|
$feed_iframe = this.$s.$feed_iframe;
|
2012-02-10 19:33:31 -08:00
|
|
|
|
|
|
|
clearInterval(this.iframe_link_attacher);
|
2010-07-06 18:43:06 -04:00
|
|
|
},
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
load_feed_iframe: function(feed_id) {
|
2010-11-06 13:27:52 -04:00
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-07-06 18:43:06 -04:00
|
|
|
var self = this;
|
|
|
|
var $feed_view = this.$s.$story_pane;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_iframe = this.$s.$feed_iframe;
|
2012-05-29 11:48:40 -07:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
this.unload_feed_iframe();
|
2010-07-06 18:43:06 -04:00
|
|
|
|
2012-02-10 19:33:31 -08:00
|
|
|
$feed_iframe.data('feed_id', feed_id);
|
2012-01-31 10:15:11 -08:00
|
|
|
var page_url = '/reader/page/'+feed_id;
|
|
|
|
if (this.flags['social_view']) {
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2012-05-21 14:36:54 -07:00
|
|
|
page_url = feed.get('page_url');
|
2012-01-31 10:15:11 -08:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
this.flags.iframe_scroll_snap_back_prepared = true;
|
|
|
|
this.iframe_link_attacher_num_links = 0;
|
2012-03-15 11:33:00 -07:00
|
|
|
|
2012-01-31 10:15:11 -08:00
|
|
|
var $new_iframe = $.make('iframe', {
|
|
|
|
className: this.$s.$feed_iframe.attr('class'),
|
|
|
|
src: page_url
|
|
|
|
});
|
2012-01-16 17:55:13 -08:00
|
|
|
this.$s.$feed_iframe.replaceWith($new_iframe);
|
|
|
|
this.$s.$feed_iframe = $new_iframe;
|
|
|
|
$feed_iframe = this.$s.$feed_iframe;
|
2012-02-10 19:33:31 -08:00
|
|
|
this.setup_feed_page_iframe_load();
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-11-06 13:27:52 -04:00
|
|
|
if (this.flags['iframe_view_loaded']) {
|
|
|
|
// NEWSBLUR.log(['Titles loaded, iframe loaded']);
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe = this.$s.$feed_iframe.contents();
|
2010-11-06 13:27:52 -04:00
|
|
|
this.fetch_story_locations_in_story_frame(0, true, $iframe);
|
|
|
|
} else {
|
|
|
|
// NEWSBLUR.log(['Titles loaded, iframe NOT loaded -- prefetching now']);
|
2010-11-08 19:39:27 -05:00
|
|
|
_.delay(_.bind(function() {
|
|
|
|
this.prefetch_story_locations_in_story_frame();
|
|
|
|
}, this), 500);
|
2010-11-06 13:27:52 -04:00
|
|
|
}
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.ready(function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
setTimeout(function() {
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.load(function() {
|
2010-07-24 18:22:23 -04:00
|
|
|
self.return_to_snapback_position(true);
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
|
|
|
}, 50);
|
2010-07-24 18:22:23 -04:00
|
|
|
self.flags['iframe_scroll_snapback_check'] = setInterval(function() {
|
2010-07-25 15:34:50 -04:00
|
|
|
// NEWSBLUR.log(['Checking scroll', self.iframe_scroll, self.flags.iframe_scroll_snap_back_prepared]);
|
2010-07-24 18:22:23 -04:00
|
|
|
if (self.iframe_scroll && self.flags.iframe_scroll_snap_back_prepared) {
|
|
|
|
self.return_to_snapback_position();
|
|
|
|
} else {
|
|
|
|
clearInterval(self.flags['iframe_scroll_snapback_check']);
|
|
|
|
}
|
|
|
|
}, 500);
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2012-03-15 11:33:00 -07:00
|
|
|
// NEWSBLUR.log(['iFrame domain', $feed_iframe, $feed_iframe.attr('src')]);
|
2012-05-21 14:36:54 -07:00
|
|
|
var feed_iframe_src = $feed_iframe.attr('src');
|
|
|
|
if (feed_iframe_src && feed_iframe_src.indexOf('/reader/page/'+feed_id) != -1) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var iframe_link_attacher = function() {
|
2010-12-06 10:41:24 -05:00
|
|
|
var num_links = $feed_iframe.contents().find('a').length;
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['Finding links', self.iframe_link_attacher_num_links, num_links]);
|
|
|
|
if (self.iframe_link_attacher_num_links != num_links) {
|
|
|
|
// NEWSBLUR.log(['Found new links', num_links, self.iframe_link_attacher_num_links]);
|
|
|
|
self.iframe_link_attacher_num_links = num_links;
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.contents().find('a')
|
2010-06-14 13:17:38 -04:00
|
|
|
.unbind('click.NB-taskbar')
|
|
|
|
.bind('click.NB-taskbar', function() {
|
|
|
|
self.taskbar_show_return_to_page();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
clearInterval(self.iframe_link_attacher);
|
|
|
|
self.iframe_link_attacher = setInterval(iframe_link_attacher, 2000);
|
|
|
|
iframe_link_attacher();
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.load(function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
clearInterval(self.iframe_link_attacher);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-07-24 18:22:23 -04:00
|
|
|
return_to_snapback_position: function(iframe_loaded) {
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_iframe = this.$s.$feed_iframe;
|
2010-07-24 18:22:23 -04:00
|
|
|
|
|
|
|
if (this.iframe_scroll
|
|
|
|
&& this.flags.iframe_scroll_snap_back_prepared
|
2010-12-06 10:41:24 -05:00
|
|
|
&& $feed_iframe.contents().scrollTop() == 0) {
|
2010-07-25 15:34:50 -04:00
|
|
|
// NEWSBLUR.log(['Snap back, loaded, scroll', this.iframe_scroll]);
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.contents().scrollTop(this.iframe_scroll);
|
2010-07-24 18:22:23 -04:00
|
|
|
if (iframe_loaded) {
|
|
|
|
this.flags.iframe_scroll_snap_back_prepared = false;
|
|
|
|
clearInterval(self.flags['iframe_scroll_snapback_check']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
setup_feed_page_iframe_load: function() {
|
|
|
|
var self = this;
|
|
|
|
var $story_pane = this.$s.$story_pane;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_iframe = this.$s.$feed_iframe;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2012-02-10 19:33:31 -08:00
|
|
|
$feed_iframe.load(function() {
|
2012-03-15 11:33:00 -07:00
|
|
|
// console.log(["iframe load", self.flags['iframe_view_loaded']]);
|
2012-02-10 19:33:31 -08:00
|
|
|
self.flags['iframe_view_loaded'] = true;
|
2010-06-14 13:17:38 -04:00
|
|
|
try {
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe_contents = $feed_iframe.contents();
|
2010-06-14 13:17:38 -04:00
|
|
|
$iframe_contents.find('a')
|
|
|
|
.unbind('click.NB-taskbar')
|
|
|
|
.bind('click.NB-taskbar', function(e) {
|
|
|
|
var href = $(this).attr('href');
|
|
|
|
if (href.indexOf('#') == 0) {
|
|
|
|
e.preventDefault();
|
|
|
|
var $footnote = $('a[name='+href.substr(1)+'], [id='+href.substr(1)+']',
|
|
|
|
$iframe_contents);
|
|
|
|
// NEWSBLUR.log(['Footnote', $footnote, href, href.substr(1)]);
|
2011-07-13 09:50:02 -07:00
|
|
|
$iframe_contents.scrollTo($footnote, {
|
|
|
|
duration: 600,
|
2010-06-14 13:17:38 -04:00
|
|
|
axis: 'y',
|
|
|
|
easing: 'easeInOutQuint',
|
|
|
|
offset: 0,
|
|
|
|
queue: false
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
self.taskbar_show_return_to_page();
|
|
|
|
});
|
|
|
|
$iframe_contents
|
|
|
|
.unbind('scroll')
|
2010-12-06 10:41:24 -05:00
|
|
|
.scroll($.rescope(self.handle_scroll_feed_iframe, self));
|
2010-06-14 13:17:38 -04:00
|
|
|
$iframe_contents
|
2010-06-15 18:29:13 -04:00
|
|
|
.unbind('mousemove.reader')
|
|
|
|
.bind('mousemove.reader', $.rescope(self.handle_mousemove_iframe_view, self));
|
2010-06-14 13:17:38 -04:00
|
|
|
if (self.flags['story_titles_loaded']) {
|
|
|
|
// NEWSBLUR.log(['iframe loaded, titles loaded']);
|
|
|
|
self.fetch_story_locations_in_story_frame(0, true, $iframe_contents);
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
// Not on local domain. Ignore.
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
2012-02-10 19:33:31 -08:00
|
|
|
|
|
|
|
var $iframe_contents = $feed_iframe.contents();
|
|
|
|
$iframe_contents
|
|
|
|
.unbind('scroll')
|
|
|
|
.scroll($.rescope(self.handle_scroll_feed_iframe, self));
|
|
|
|
$iframe_contents
|
|
|
|
.unbind('mousemove.reader')
|
|
|
|
.bind('mousemove.reader', $.rescope(self.handle_mousemove_iframe_view, self));
|
|
|
|
if (self.flags['story_titles_loaded']) {
|
|
|
|
NEWSBLUR.log(['iframe loaded, titles loaded']);
|
|
|
|
self.fetch_story_locations_in_story_frame(0, true, $iframe_contents);
|
|
|
|
}
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
taskbar_show_return_to_page: function() {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_iframe = $('.NB-feed-frame');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-02-13 14:49:13 -05:00
|
|
|
_.delay(function() {
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_iframe = $('.NB-feed-frame');
|
2010-06-14 13:17:38 -04:00
|
|
|
var $taskbar_view_page = $('.NB-taskbar .task_view_page');
|
|
|
|
|
|
|
|
try {
|
2011-02-02 14:10:24 -05:00
|
|
|
NEWSBLUR.log(['return', $feed_iframe.contents().find('body')]);
|
2010-12-06 10:41:24 -05:00
|
|
|
var length = $feed_iframe.contents().find('body').length;
|
2010-06-14 13:17:38 -04:00
|
|
|
if (length) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch(e) {
|
2011-02-02 14:10:24 -05:00
|
|
|
$taskbar_view_page.addClass('NB-task-return');
|
2010-06-14 13:17:38 -04:00
|
|
|
} finally {
|
2011-02-02 14:10:24 -05:00
|
|
|
$taskbar_view_page.addClass('NB-task-return');
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2011-02-02 14:10:24 -05:00
|
|
|
}, 1000);
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2012-01-23 21:56:42 -08:00
|
|
|
load_page_of_feed_stories: function(options) {
|
2012-05-25 16:42:41 -07:00
|
|
|
options = _.extend({}, {'show_loading': true}, options);
|
2010-06-14 13:17:38 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
2012-05-25 16:42:41 -07:00
|
|
|
var feed_id = this.active_feed;
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-12-12 22:52:15 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!this.flags['opening_feed']) {
|
2012-02-17 18:36:33 -08:00
|
|
|
this.flags['opening_feed'] = true;
|
|
|
|
this.counts['page'] += 1;
|
2012-05-29 11:48:40 -07:00
|
|
|
NEWSBLUR.app.story_titles.show_loading(options);
|
2012-05-25 16:42:41 -07:00
|
|
|
|
2010-12-04 13:32:13 -05:00
|
|
|
if (this.active_feed == 'starred') {
|
2012-02-17 18:36:33 -08:00
|
|
|
this.model.fetch_starred_stories(this.counts['page'], _.bind(this.post_open_starred_stories, this),
|
2012-01-08 14:15:22 -08:00
|
|
|
this.show_stories_error, false);
|
2012-01-31 10:15:11 -08:00
|
|
|
} else if (this.flags['social_view']) {
|
2012-05-25 16:42:41 -07:00
|
|
|
this.model.fetch_social_stories(this.active_feed,
|
2012-02-21 10:06:12 -08:00
|
|
|
this.counts['page'], _.bind(this.post_open_social_stories, this),
|
2012-01-26 08:43:46 -08:00
|
|
|
this.show_stories_error, false);
|
2011-02-04 09:56:15 -05:00
|
|
|
} else if (this.flags['river_view']) {
|
|
|
|
this.model.fetch_river_stories(this.active_feed, this.cache['river_feeds_with_unreads'],
|
2012-02-17 18:36:33 -08:00
|
|
|
this.counts['page'], _.bind(this.post_open_river_stories, this),
|
2012-01-08 14:15:22 -08:00
|
|
|
this.show_stories_error, false);
|
2010-12-03 09:49:38 -05:00
|
|
|
} else {
|
2012-02-17 18:36:33 -08:00
|
|
|
this.model.load_feed(feed_id, this.counts['page'], false,
|
2012-01-08 14:15:22 -08:00
|
|
|
$.rescope(this.post_open_feed, this), this.show_stories_error);
|
2010-12-03 09:49:38 -05:00
|
|
|
}
|
2010-06-11 20:55:38 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2012-01-26 08:43:46 -08:00
|
|
|
make_feed_title_in_stories: function(feed_id, options) {
|
2010-11-01 18:20:26 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-06-14 13:17:38 -04:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2011-01-11 19:33:55 -05:00
|
|
|
if (!feed) return;
|
2012-05-22 13:25:21 -07:00
|
|
|
|
2012-05-24 17:32:01 -07:00
|
|
|
var feed_title_view = new NEWSBLUR.Views.Feed({model: feed, type: 'story', el: '.NB-feedbar'}).render();
|
|
|
|
|
2011-05-01 20:22:54 -04:00
|
|
|
if (this.model.preference('show_tooltips')) {
|
2012-05-24 17:32:01 -07:00
|
|
|
$('.NB-feedbar-train-feed, .NB-feedbar-statistics', feed_title_view.$el).tipsy({
|
2011-05-01 20:22:54 -04:00
|
|
|
gravity: 's',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
}
|
2012-05-23 15:41:02 -07:00
|
|
|
|
2012-05-24 17:32:01 -07:00
|
|
|
$('.NB-feedbar-last-updated-date', feed_title_view.$el).text(feed.get('updated') ? feed.get('updated') + ' ago' : 'Loading...');
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-01-04 19:27:00 -05:00
|
|
|
show_feed_hidden_story_title_indicator: function(is_feed_load) {
|
|
|
|
if (is_feed_load && this.flags['unread_threshold_temporarily']) return;
|
2011-01-04 19:39:57 -05:00
|
|
|
else this.flags['unread_threshold_temporarily'] = null;
|
2011-01-04 19:27:00 -05:00
|
|
|
|
2010-11-01 18:20:26 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var feed_id = this.active_feed;
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var unread_view_name = this.get_unread_view_name();
|
2011-01-04 08:40:15 -05:00
|
|
|
var $indicator = $('.NB-story-title-indicator', $story_titles);
|
2011-01-04 08:21:47 -05:00
|
|
|
var hidden_stories = _.any(this.model.stories, _.bind(function(story) {
|
2011-11-28 12:13:09 -05:00
|
|
|
var score = this.compute_story_score(story);
|
2011-01-04 08:21:47 -05:00
|
|
|
|
|
|
|
if (unread_view_name == 'positive') return score <= 0;
|
|
|
|
else if (unread_view_name == 'neutral') return score < 0;
|
|
|
|
}, this));
|
2012-05-23 15:41:02 -07:00
|
|
|
if (!hidden_stories) return;
|
2010-11-01 18:20:26 -04:00
|
|
|
|
2012-05-23 15:41:02 -07:00
|
|
|
$indicator.css({'display': 'block', 'opacity': 0});
|
|
|
|
if (is_feed_load) {
|
|
|
|
_.delay(function() {
|
|
|
|
$indicator.animate({'opacity': 1}, {'duration': 1000, 'easing': 'easeOutCubic'});
|
|
|
|
}, 500);
|
2010-11-01 18:20:26 -04:00
|
|
|
}
|
2012-05-23 15:41:02 -07:00
|
|
|
$indicator.removeClass('unread_threshold_positive')
|
|
|
|
.removeClass('unread_threshold_neutral')
|
|
|
|
.removeClass('unread_threshold_negative')
|
|
|
|
.addClass('unread_threshold_'+unread_view_name);
|
2010-11-01 18:20:26 -04:00
|
|
|
},
|
|
|
|
|
2011-09-27 22:16:09 -07:00
|
|
|
check_story_titles_last_story: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
2012-05-29 11:48:40 -07:00
|
|
|
|
2012-05-25 16:42:41 -07:00
|
|
|
if (!this.model.flags['no_more_stories']) {
|
2012-05-29 11:48:40 -07:00
|
|
|
console.log(["check_story_titles_last_story"]);
|
2011-09-27 22:16:09 -07:00
|
|
|
var $last_story = $('#story_titles .story').last();
|
|
|
|
var container_offset = $story_titles.position().top;
|
|
|
|
var full_height = ($last_story.offset() && $last_story.offset().top) + $last_story.height() - container_offset;
|
|
|
|
var visible_height = $('#story_titles').height();
|
|
|
|
var scroll_y = $('#story_titles').scrollTop();
|
|
|
|
// NEWSBLUR.log(['Story_titles Scroll', full_height, container_offset, visible_height, scroll_y]);
|
|
|
|
|
|
|
|
// Fudge factor is simply because it looks better at 13 pixels off.
|
|
|
|
if ((visible_height + 13) >= full_height) {
|
|
|
|
this.load_page_of_feed_stories();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-01-18 18:07:43 -08:00
|
|
|
check_feed_view_scrolled_to_bottom: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var $feed_view = this.$s.$feed_view;
|
|
|
|
|
2012-05-25 16:42:41 -07:00
|
|
|
if (!this.model.flags['no_more_stories']) {
|
2012-05-29 11:48:40 -07:00
|
|
|
console.log(["check_feed_view_scrolled_to_bottom"]);
|
2012-01-18 18:07:43 -08:00
|
|
|
var $last_story = $('.NB-feed-story', $feed_view).last();
|
|
|
|
var container_offset = $feed_view.position().top;
|
|
|
|
var full_height = ($last_story.offset() && $last_story.offset().top) + $last_story.height() - container_offset;
|
|
|
|
var visible_height = $feed_view.height();
|
|
|
|
var scroll_y = $feed_view.scrollTop();
|
|
|
|
|
|
|
|
// Fudge factor is simply because it looks better at 13 pixels off.
|
|
|
|
if ((visible_height + 26) >= full_height) {
|
|
|
|
// NEWSBLUR.log(['Feed view scroll', full_height, container_offset, visible_height, scroll_y]);
|
|
|
|
this.load_page_of_feed_stories();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-11-01 18:20:26 -04:00
|
|
|
show_hidden_story_titles: function() {
|
|
|
|
var feed_id = this.active_feed;
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var $indicator = $('.NB-story-title-indicator', this.$s.$story_titles);
|
2011-01-04 08:21:47 -05:00
|
|
|
var unread_view_name = $indicator.hasClass('unread_threshold_positive') ?
|
|
|
|
'positive' :
|
|
|
|
'neutral';
|
|
|
|
var hidden_stories_at_threshold = _.any(this.model.stories, _.bind(function(story) {
|
2011-11-28 12:13:09 -05:00
|
|
|
var score = this.compute_story_score(story);
|
2011-01-04 08:21:47 -05:00
|
|
|
|
|
|
|
if (unread_view_name == 'positive') return score == 0;
|
|
|
|
else if (unread_view_name == 'neutral') return score < 0;
|
|
|
|
}, this));
|
|
|
|
var hidden_stories_below_threshold = unread_view_name == 'positive' &&
|
|
|
|
_.any(this.model.stories, _.bind(function(story) {
|
2011-11-28 12:13:09 -05:00
|
|
|
var score = this.compute_story_score(story);
|
2011-01-04 08:21:47 -05:00
|
|
|
return score < 0;
|
|
|
|
}, this));
|
2010-11-01 18:20:26 -04:00
|
|
|
|
2011-01-04 19:44:00 -05:00
|
|
|
// NEWSBLUR.log(['show_hidden_story_titles', hidden_stories_at_threshold, hidden_stories_below_threshold, unread_view_name]);
|
2011-01-04 19:39:57 -05:00
|
|
|
|
2010-11-01 18:20:26 -04:00
|
|
|
// First click, open neutral. Second click, open negative.
|
2011-01-04 08:21:47 -05:00
|
|
|
if (unread_view_name == 'positive' && hidden_stories_at_threshold && hidden_stories_below_threshold) {
|
2011-01-04 19:39:57 -05:00
|
|
|
this.flags['unread_threshold_temporarily'] = 'neutral';
|
2011-01-03 19:18:27 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({
|
2010-11-01 18:20:26 -04:00
|
|
|
'unread_view_name': 'neutral',
|
|
|
|
'animate': true,
|
2011-02-01 18:29:22 -05:00
|
|
|
'follow': true,
|
|
|
|
'temporary': true
|
2010-11-01 18:20:26 -04:00
|
|
|
});
|
|
|
|
$indicator.removeClass('unread_threshold_positive').addClass('unread_threshold_neutral');
|
2011-01-04 08:21:47 -05:00
|
|
|
} else {
|
2011-01-04 19:39:57 -05:00
|
|
|
this.flags['unread_threshold_temporarily'] = 'negative';
|
2011-01-03 19:18:27 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({
|
2011-01-04 08:21:47 -05:00
|
|
|
'unread_view_name': 'negative',
|
2010-11-01 18:20:26 -04:00
|
|
|
'animate': true,
|
2011-02-01 18:29:22 -05:00
|
|
|
'follow': true,
|
|
|
|
'temporary': true
|
2010-11-01 18:20:26 -04:00
|
|
|
});
|
|
|
|
$indicator.removeClass('unread_threshold_positive')
|
|
|
|
.removeClass('unread_threshold_neutral')
|
|
|
|
.addClass('unread_threshold_negative');
|
2012-05-23 16:02:32 -07:00
|
|
|
$indicator.animate({'opacity': 0}, {'duration': 500}).css('display', 'none');
|
2010-11-01 18:20:26 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
open_feed_link: function(feed_id, $fd) {
|
2010-10-12 20:13:33 -04:00
|
|
|
if (!feed_id) feed_id = this.active_feed;
|
2010-06-14 13:17:38 -04:00
|
|
|
this.mark_feed_as_read(feed_id);
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2012-05-21 20:08:27 -07:00
|
|
|
window.open(feed.get('feed_link'), '_blank');
|
2011-10-31 18:04:25 -07:00
|
|
|
// window.focus();
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2010-09-17 12:40:42 -04:00
|
|
|
open_feed_intelligence_modal: function(score, feed_id, feed_loaded) {
|
2010-09-12 13:50:27 -04:00
|
|
|
feed_id = feed_id || this.active_feed;
|
2011-10-30 22:17:16 -07:00
|
|
|
|
|
|
|
if (feed_id) {
|
|
|
|
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierFeed(feed_id, {
|
|
|
|
'score': score,
|
|
|
|
'feed_loaded': feed_loaded
|
|
|
|
});
|
|
|
|
}
|
2010-08-01 23:47:40 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
open_trainer_modal: function(score) {
|
|
|
|
var feed_id = this.active_feed;
|
|
|
|
|
2010-08-01 19:12:42 -04:00
|
|
|
// NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierFeed(feed_id, {'score': score});
|
|
|
|
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierTrainer({'score': score});
|
2011-12-21 18:23:53 -08:00
|
|
|
},
|
|
|
|
|
2012-04-04 16:09:01 -07:00
|
|
|
open_friends_modal: function() {
|
2011-12-23 18:28:16 -08:00
|
|
|
NEWSBLUR.reader_friends = new NEWSBLUR.ReaderFriends();
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2012-04-04 16:09:01 -07:00
|
|
|
open_profile_editor_modal: function() {
|
|
|
|
NEWSBLUR.reader_profile_editor = new NEWSBLUR.ReaderProfileEditor();
|
|
|
|
},
|
|
|
|
|
2011-03-28 10:08:10 -04:00
|
|
|
open_recommend_modal: function(feed_id) {
|
2011-04-07 10:30:05 -04:00
|
|
|
NEWSBLUR.recommend_feed = new NEWSBLUR.ReaderRecommendFeed(feed_id);
|
2011-03-28 10:08:10 -04:00
|
|
|
},
|
|
|
|
|
2011-05-10 18:30:35 -04:00
|
|
|
open_tutorial_modal: function() {
|
|
|
|
NEWSBLUR.tutorial = new NEWSBLUR.ReaderTutorial();
|
|
|
|
},
|
|
|
|
|
2012-03-05 19:18:40 -08:00
|
|
|
open_intro_modal: function(options) {
|
|
|
|
NEWSBLUR.intro = new NEWSBLUR.ReaderIntro(options);
|
2012-03-02 17:51:28 -08:00
|
|
|
},
|
|
|
|
|
2011-12-24 00:30:37 -08:00
|
|
|
hide_intelligence_trainer: function() {
|
|
|
|
var $trainer = $('.NB-module-account-trainer');
|
|
|
|
|
2012-03-19 14:15:38 -07:00
|
|
|
$trainer.addClass('NB-done');
|
2011-12-24 00:30:37 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
hide_find_friends: function() {
|
|
|
|
var $findfriends = $('.NB-module-find-friends');
|
|
|
|
|
2012-03-19 14:15:38 -07:00
|
|
|
$findfriends.addClass('NB-done');
|
2011-12-24 00:30:37 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
check_hide_getting_started: function(force) {
|
2012-03-19 14:15:38 -07:00
|
|
|
var friends = this.model.preference('has_found_friends');
|
|
|
|
var trained = this.model.preference('has_trained_intelligence');
|
|
|
|
var feeds = this.model.preference('has_setup_feeds');
|
|
|
|
|
|
|
|
if (force ||
|
|
|
|
friends && trained && feeds) {
|
2011-12-24 00:30:37 -08:00
|
|
|
var $gettingstarted = $('.NB-module-gettingstarted');
|
|
|
|
$gettingstarted.animate({
|
|
|
|
'opacity': 0
|
|
|
|
}, {
|
|
|
|
'duration': 500,
|
|
|
|
'complete': function() {
|
|
|
|
$gettingstarted.slideUp(350);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.model.preference('hide_getting_started', true);
|
2012-03-19 14:15:38 -07:00
|
|
|
} else {
|
|
|
|
var $intro = $('.NB-module-item-intro');
|
|
|
|
var $findfriends = $('.NB-module-find-friends');
|
|
|
|
var $trainer = $('.NB-module-account-trainer');
|
|
|
|
|
|
|
|
$intro.toggleClass('NB-done', feeds);
|
|
|
|
$findfriends.toggleClass('NB-done', friends);
|
|
|
|
$findfriends.toggleClass('NB-hidden', !feeds);
|
|
|
|
$trainer.toggleClass('NB-done', trained);
|
|
|
|
$trainer.toggleClass('NB-hidden', !feeds);
|
2011-12-24 00:30:37 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-07 21:38:09 -07:00
|
|
|
hide_mobile: function() {
|
|
|
|
var $mobile = $('.NB-module-mobile');
|
|
|
|
|
|
|
|
this.model.preference('hide_mobile', true);
|
|
|
|
$mobile.animate({
|
|
|
|
'opacity': 0
|
|
|
|
}, {
|
|
|
|
'duration': 500,
|
|
|
|
'complete': function() {
|
|
|
|
$mobile.slideUp(350);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ==========================
|
|
|
|
// = Story Pane - Feed View =
|
|
|
|
// ==========================
|
|
|
|
|
2010-12-04 13:32:13 -05:00
|
|
|
make_story_feed_entries: function(stories, first_load, options) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_view = this.$s.$feed_view;
|
2011-01-24 23:50:38 -05:00
|
|
|
var $stories = this.$s.$feed_stories;
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
var unread_view = this.model.preference('unread_view');
|
2011-01-25 22:59:38 -05:00
|
|
|
var river_same_feed;
|
2011-01-29 19:16:40 -05:00
|
|
|
var feed = this.model.get_feed(this.active_feed);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-04 13:32:13 -05:00
|
|
|
options = options || {};
|
|
|
|
|
2011-01-26 20:51:29 -05:00
|
|
|
if (first_load && !options.refresh_load) {
|
|
|
|
$('.NB-feed-story-endbar', $feed_view).remove();
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
for (var s in stories) {
|
2012-05-25 16:42:41 -07:00
|
|
|
// REMOVED
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
var image_count = $('img', $story).length;
|
|
|
|
if (!image_count) {
|
|
|
|
this.flags.feed_view_images_loaded[story.id] = true;
|
|
|
|
} else {
|
|
|
|
// Progressively load the images in each story, so that when one story
|
|
|
|
// loads, the position is calculated and the next story can calculate
|
|
|
|
// its position (atfer its own images are loaded).
|
2010-11-04 21:49:13 -04:00
|
|
|
this.flags.feed_view_images_loaded[story.id] = false;
|
2010-06-14 13:17:38 -04:00
|
|
|
(function($story, story, image_count) {
|
|
|
|
$('img', $story).load(function() {
|
|
|
|
// NEWSBLUR.log(['Loaded image', $story, story, image_count]);
|
|
|
|
if (image_count == 1) {
|
|
|
|
self.flags.feed_view_images_loaded[story.id] = true;
|
|
|
|
} else {
|
|
|
|
image_count--;
|
|
|
|
}
|
2010-11-15 22:43:01 -05:00
|
|
|
return true;
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
2012-05-25 16:42:41 -07:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
})($story, story, image_count);
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-12-08 20:53:45 -05:00
|
|
|
|
2011-01-10 09:49:26 -05:00
|
|
|
if (!stories || !stories.length) {
|
2012-06-02 16:33:44 -07:00
|
|
|
// this.fetch_story_locations_in_feed_view({'reset_timer': true});
|
2010-12-15 16:10:54 -05:00
|
|
|
}
|
|
|
|
|
2011-05-03 12:19:53 -04:00
|
|
|
if (first_load) this.show_stories_preference_in_feed_view(true);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-11-06 14:25:49 -08:00
|
|
|
make_story_content: function(story_content) {
|
2012-03-08 09:56:52 -08:00
|
|
|
var $story_content = $('<div>').html(story_content);
|
2011-11-06 14:25:49 -08:00
|
|
|
return $story_content;
|
|
|
|
},
|
|
|
|
|
2011-03-17 18:33:59 -04:00
|
|
|
save_classifier: function(type, value, score, feed_id, callback) {
|
2011-03-09 09:48:24 -05:00
|
|
|
var data = {
|
|
|
|
'feed_id': feed_id
|
|
|
|
};
|
|
|
|
if (score == 0) {
|
|
|
|
data['remove_like_'+type] = value;
|
|
|
|
} else if (score == 1) {
|
|
|
|
data['like_'+type] = value;
|
|
|
|
} else if (score == -1) {
|
|
|
|
data['dislike_'+type] = value;
|
|
|
|
}
|
|
|
|
|
2011-10-24 08:55:28 -07:00
|
|
|
this.model.classifiers[feed_id][type+'s'][value] = score;
|
2011-04-24 01:52:44 -04:00
|
|
|
this.model.save_classifier(data, _.bind(function(resp) {
|
2012-05-25 22:13:50 -07:00
|
|
|
this.model.recalculate_story_scores(feed_id);
|
2011-03-17 20:06:38 -04:00
|
|
|
this.force_feeds_refresh(callback, true, feed_id);
|
2011-03-09 09:48:24 -05:00
|
|
|
}, this));
|
2011-03-02 19:59:31 -05:00
|
|
|
},
|
|
|
|
|
2011-01-19 08:54:59 -05:00
|
|
|
show_correct_feed_in_feed_title_floater: function(story) {
|
2011-01-25 22:59:38 -05:00
|
|
|
var $story, $header;
|
2011-01-30 23:00:22 -05:00
|
|
|
|
2012-05-25 18:54:04 -07:00
|
|
|
if (story && this.cache.feed_title_floater_feed_id != story.get('story_feed_id')) {
|
2011-01-25 22:59:38 -05:00
|
|
|
var $feed_floater = this.$s.$feed_floater;
|
2011-11-15 18:37:42 -08:00
|
|
|
$story = this.find_story_in_feed_view(story.id);
|
2011-01-25 22:59:38 -05:00
|
|
|
$header = $('.NB-feed-story-header-feed', $story);
|
|
|
|
var $new_header = $header.clone();
|
2012-04-19 22:38:00 -07:00
|
|
|
var $original_image = $('.NB-feed-story-header-feed .feed_favicon', $story);
|
|
|
|
var $new_image = $original_image.clone();
|
|
|
|
$new_image.after($original_image);
|
2011-01-25 22:59:38 -05:00
|
|
|
|
|
|
|
if (!$new_header.find('.NB-feed-story-feed').length) {
|
2012-05-25 18:54:04 -07:00
|
|
|
var feed = this.model.get_feed(story.get('story_feed_id'));
|
2011-01-25 22:59:38 -05:00
|
|
|
feed && $new_header.append($.make('div', { className: 'NB-feed-story-feed' }, [
|
2012-05-25 18:54:04 -07:00
|
|
|
($original_image.length && $original_image) || $.make('img', { className: 'feed_favicon', src: $.favicon(feed || story.get('story_feed_id')) }),
|
2012-05-21 14:36:54 -07:00
|
|
|
$.make('span', { className: 'feed_title' }, feed.get('feed_title'))
|
2011-01-25 22:59:38 -05:00
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
|
|
|
$feed_floater.empty().append($new_header);
|
2012-05-25 18:54:04 -07:00
|
|
|
this.cache.feed_title_floater_feed_id = story.get('story_feed_id');
|
2011-01-26 20:51:29 -05:00
|
|
|
$feed_floater.width($header.outerWidth());
|
2011-01-30 23:00:22 -05:00
|
|
|
} else if (!story) {
|
|
|
|
this.$s.$feed_floater.empty();
|
|
|
|
this.cache.feed_title_floater_feed_id = null;
|
2011-01-25 22:59:38 -05:00
|
|
|
}
|
|
|
|
|
2011-01-30 23:00:22 -05:00
|
|
|
if (story && this.cache.feed_title_floater_story_id != story.id) {
|
2011-11-15 18:37:42 -08:00
|
|
|
$story = $story || this.find_story_in_feed_view(story.id);
|
2011-01-25 22:59:38 -05:00
|
|
|
$header = $header || $('.NB-feed-story-header-feed', $story);
|
|
|
|
$('.NB-floater').removeClass('NB-floater');
|
|
|
|
$header.addClass('NB-floater');
|
|
|
|
this.cache.feed_title_floater_story_id = story.id;
|
2011-01-30 23:00:22 -05:00
|
|
|
} else if (!story) {
|
|
|
|
this.cache.feed_title_floater_story_id = null;
|
2011-01-25 22:59:38 -05:00
|
|
|
}
|
2011-01-19 08:54:59 -05:00
|
|
|
},
|
|
|
|
|
2010-11-25 15:34:06 -05:00
|
|
|
apply_story_styling: function(reset_stories) {
|
|
|
|
var $body = this.$s.$body;
|
|
|
|
$body.removeClass('NB-theme-sans-serif');
|
|
|
|
$body.removeClass('NB-theme-serif');
|
|
|
|
|
|
|
|
if (NEWSBLUR.Preferences['story_styling'] == 'sans-serif') {
|
|
|
|
$body.addClass('NB-theme-sans-serif');
|
|
|
|
} else if (NEWSBLUR.Preferences['story_styling'] == 'serif') {
|
|
|
|
$body.addClass('NB-theme-serif');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reset_stories) {
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({'animate': true, 'follow': true});
|
2010-11-25 15:34:06 -05:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-11-04 21:49:13 -04:00
|
|
|
prefetch_story_locations_in_feed_view: function() {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
var stories = this.model.stories;
|
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
// NEWSBLUR.log(['Prefetching', this.flags['feed_view_positions_calculated'], this.flags.feed_view_images_loaded, (_.keys(this.flags.feed_view_images_loaded).length > 0 || this.cache.feed_view_story_positions_keys.length > 0)]);
|
2010-11-04 21:49:13 -04:00
|
|
|
if (!this.flags['feed_view_positions_calculated']) {
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
$.extend(this.cache, {
|
2010-06-14 13:17:38 -04:00
|
|
|
'feed_view_story_positions': {},
|
|
|
|
'feed_view_story_positions_keys': []
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
|
|
|
|
2010-11-04 21:49:13 -04:00
|
|
|
for (var s in stories) {
|
|
|
|
var story = stories[s];
|
2012-05-29 11:48:40 -07:00
|
|
|
// var $story = self.cache.feed_view_stories[story.id];
|
|
|
|
// this.determine_feed_view_story_position($story, story);
|
2012-05-25 18:54:04 -07:00
|
|
|
// NEWSBLUR.log(['Pre-fetching', $story, story.get('story_title'), this.flags.feed_view_images_loaded[story.id]]);
|
2012-05-29 11:48:40 -07:00
|
|
|
// if (!$story || !$story.length || this.flags['feed_view_positions_calculated']) break;
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2012-02-22 09:11:35 -08:00
|
|
|
if ((_.keys(this.flags.feed_view_images_loaded).length > 0 ||
|
|
|
|
this.cache.feed_view_story_positions_keys.length > 0) &&
|
|
|
|
(this.flags.feed_view_images_loaded.length &&
|
|
|
|
_.all(_.values(this.flags.feed_view_images_loaded)))) {
|
2012-02-17 17:41:20 -08:00
|
|
|
this.fetch_story_locations_in_feed_view({'reset_timer': true});
|
2010-12-12 23:22:53 -05:00
|
|
|
} else {
|
|
|
|
// NEWSBLUR.log(['Still loading feed view...', _.keys(this.flags.feed_view_images_loaded).length, this.cache.feed_view_story_positions_keys.length, this.flags.feed_view_images_loaded]);
|
2010-11-04 21:49:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.flags['feed_view_positions_calculated']) {
|
|
|
|
setTimeout(function() {
|
|
|
|
if (!self.flags['feed_view_positions_calculated']) {
|
|
|
|
self.prefetch_story_locations_in_feed_view();
|
|
|
|
}
|
|
|
|
}, 2000);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-02-17 17:41:20 -08:00
|
|
|
fetch_story_locations_in_feed_view: function(options) {
|
|
|
|
options = options || {};
|
2011-01-29 19:16:40 -05:00
|
|
|
var stories = this.model.stories;
|
|
|
|
if (!stories || !stories.length) return;
|
2012-02-17 17:41:20 -08:00
|
|
|
if (options.reset_timer) this.counts['feed_view_positions_timer'] = 0;
|
2011-01-29 19:16:40 -05:00
|
|
|
|
2011-07-24 23:00:05 -07:00
|
|
|
$.extend(this.cache, {
|
|
|
|
'feed_view_story_positions': {},
|
|
|
|
'feed_view_story_positions_keys': []
|
|
|
|
});
|
|
|
|
|
2011-01-29 19:16:40 -05:00
|
|
|
for (var s in stories) {
|
|
|
|
var story = stories[s];
|
|
|
|
var $story = this.cache.feed_view_stories[story.id];
|
|
|
|
this.determine_feed_view_story_position($story, story);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.flags['feed_view_positions_calculated'] = true;
|
2012-03-01 10:15:26 -08:00
|
|
|
// NEWSBLUR.log(['Feed view entirely loaded', this.model.stories.length + " stories", this.counts['feed_view_positions_timer']/1000 + " sec delay"]);
|
2012-02-17 17:41:20 -08:00
|
|
|
|
2012-02-24 16:14:24 -08:00
|
|
|
this.counts['feed_view_positions_timer'] = Math.max(this.counts['feed_view_positions_timer']*2, 1000);
|
2012-02-17 17:41:20 -08:00
|
|
|
clearTimeout(this.flags['next_fetch']);
|
|
|
|
this.flags['next_fetch'] = _.delay(_.bind(this.fetch_story_locations_in_feed_view, this),
|
|
|
|
this.counts['feed_view_positions_timer']);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
determine_feed_view_story_position: function($story, story) {
|
2010-08-30 22:42:44 -04:00
|
|
|
if ($story && $story.is(':visible')) {
|
2011-10-19 23:04:45 -07:00
|
|
|
var position_original = parseInt($story.position().top, 10);
|
2010-06-14 13:17:38 -04:00
|
|
|
var position_offset = parseInt($story.offsetParent().scrollTop(), 10);
|
|
|
|
var position = position_original + position_offset;
|
|
|
|
this.cache.feed_view_story_positions[position] = story;
|
|
|
|
this.cache.feed_view_story_positions_keys.push(position);
|
2010-11-04 21:49:13 -04:00
|
|
|
this.cache.feed_view_story_positions_keys.sort(function(a, b) { return a-b; });
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['Positioning story', position, $story, story, this.cache.feed_view_story_positions_keys]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// ===================
|
|
|
|
// = Taskbar - Story =
|
|
|
|
// ===================
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
switch_taskbar_view: function(view, skip_save_type) {
|
2011-02-04 00:22:58 -05:00
|
|
|
// NEWSBLUR.log(['switch_taskbar_view', view]);
|
2010-06-14 13:17:38 -04:00
|
|
|
var self = this;
|
|
|
|
var $story_pane = this.$s.$story_pane;
|
2010-10-28 18:17:14 -04:00
|
|
|
var feed = this.model.get_feed(this.active_feed);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2012-05-21 14:36:54 -07:00
|
|
|
if (view == 'page' && feed && feed.get('has_exception') && feed.get('exception_type') == 'page') {
|
2012-01-16 17:55:13 -08:00
|
|
|
this.open_feed_exception_modal();
|
2010-10-28 18:17:14 -04:00
|
|
|
return;
|
2012-05-21 14:36:54 -07:00
|
|
|
} else if (_.contains(['page', 'story'], view) && feed && feed.get('disabled_page')) {
|
2012-05-07 16:26:31 -07:00
|
|
|
view = 'feed';
|
2011-04-30 23:33:36 -04:00
|
|
|
} else if ($('.task_button_view.task_view_'+view).hasClass('NB-disabled')) {
|
2010-12-04 21:53:39 -05:00
|
|
|
return;
|
|
|
|
}
|
2010-12-06 10:41:24 -05:00
|
|
|
// NEWSBLUR.log(['$button', $button, this.flags['page_view_showing_feed_view'], $button.hasClass('NB-active'), skip_save_type]);
|
2010-06-14 13:17:38 -04:00
|
|
|
var $taskbar_buttons = $('.NB-taskbar .task_button_view');
|
|
|
|
var $feed_view = this.$s.$feed_view;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_iframe = this.$s.$feed_iframe;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $page_to_feed_arrow = $('.NB-taskbar .NB-task-view-page-to-feed-arrow');
|
2010-12-06 10:41:24 -05:00
|
|
|
var $feed_to_story_arrow = $('.NB-taskbar .NB-task-view-feed-to-story-arrow');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
if (!skip_save_type && this.story_view != view) {
|
2010-07-06 14:57:32 -04:00
|
|
|
this.model.view_setting(this.active_feed, view);
|
|
|
|
}
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
$page_to_feed_arrow.hide();
|
|
|
|
$feed_to_story_arrow.hide();
|
|
|
|
this.flags['page_view_showing_feed_view'] = false;
|
|
|
|
if (skip_save_type == 'page') {
|
2010-06-14 13:17:38 -04:00
|
|
|
$page_to_feed_arrow.show();
|
|
|
|
this.flags['page_view_showing_feed_view'] = true;
|
2010-12-06 10:41:24 -05:00
|
|
|
} else if (skip_save_type == 'story') {
|
|
|
|
$feed_to_story_arrow.show();
|
2010-12-07 09:52:14 -05:00
|
|
|
this.flags['feed_view_showing_story_view'] = true;
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
|
|
|
$taskbar_buttons.removeClass('NB-active');
|
|
|
|
$('.task_button_view.task_view_'+view).addClass('NB-active');
|
|
|
|
this.story_view = view;
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
2010-12-14 18:48:52 -05:00
|
|
|
// this.flags.scrolling_by_selecting_story_title = true;
|
|
|
|
// clearInterval(this.locks.scrolling);
|
2010-12-13 21:53:22 -05:00
|
|
|
// this.locks.scrolling = setTimeout(function() {
|
2010-12-14 18:48:52 -05:00
|
|
|
// self.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
// }, 1000);
|
2010-06-14 13:17:38 -04:00
|
|
|
if (view == 'page') {
|
2010-07-06 18:30:16 -04:00
|
|
|
if (this.flags['iframe_prevented_from_loading']) {
|
2012-01-31 10:15:11 -08:00
|
|
|
this.load_feed_iframe();
|
2010-07-06 18:30:16 -04:00
|
|
|
}
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe_story = this.find_story_in_feed_iframe(this.active_story);
|
2010-06-14 13:17:38 -04:00
|
|
|
this.scroll_to_story_in_iframe(this.active_story, $iframe_story, true);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$story_pane.animate({
|
|
|
|
'left': 0
|
|
|
|
}, {
|
|
|
|
'easing': 'easeInOutQuint',
|
2011-06-07 12:57:34 -04:00
|
|
|
'duration': this.model.preference('animations') ? 550 : 0,
|
2010-06-14 13:17:38 -04:00
|
|
|
'queue': false
|
|
|
|
});
|
|
|
|
} else if (view == 'feed') {
|
|
|
|
if (this.active_story) {
|
2012-05-26 13:16:59 -07:00
|
|
|
NEWSBLUR.app.story_list.scroll_to_selected_story(this.active_story.story_view, {immediate: true});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
$story_pane.animate({
|
2010-12-06 10:41:24 -05:00
|
|
|
'left': -1 * $feed_iframe.width()
|
2010-06-14 13:17:38 -04:00
|
|
|
}, {
|
|
|
|
'easing': 'easeInOutQuint',
|
2011-06-07 12:57:34 -04:00
|
|
|
'duration': this.model.preference('animations') ? 550 : 0,
|
2010-06-14 13:17:38 -04:00
|
|
|
'queue': false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.flags['switching_to_feed_view'] = true;
|
|
|
|
setTimeout(function() {
|
|
|
|
self.flags['switching_to_feed_view'] = false;
|
|
|
|
}, 100);
|
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_stories_preference_in_feed_view();
|
|
|
|
if (!this.flags['feed_view_positions_calculated']) {
|
2012-06-02 16:33:44 -07:00
|
|
|
// this.prefetch_story_locations_in_feed_view();
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
} else if (view == 'story') {
|
|
|
|
$story_pane.animate({
|
2010-12-07 09:52:14 -05:00
|
|
|
'left': -2 * $feed_iframe.width()
|
2010-06-14 13:17:38 -04:00
|
|
|
}, {
|
|
|
|
'easing': 'easeInOutQuint',
|
2011-06-07 12:57:34 -04:00
|
|
|
'duration': this.model.preference('animations') ? 550 : 0,
|
2010-06-14 13:17:38 -04:00
|
|
|
'queue': false
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
2010-12-08 20:53:45 -05:00
|
|
|
this.load_story_iframe();
|
2011-02-09 19:24:35 -05:00
|
|
|
if (!this.active_story) {
|
|
|
|
this.show_next_story(1);
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-07-06 14:57:32 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
switch_taskbar_view_direction: function(direction) {
|
|
|
|
var $active = $('.taskbar_nav_view .NB-active');
|
|
|
|
var view;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (direction == -1) {
|
|
|
|
if ($active.hasClass('task_view_page')) {
|
|
|
|
// view = 'page';
|
|
|
|
} else if ($active.hasClass('task_view_feed')) {
|
|
|
|
view = 'page';
|
|
|
|
} else if ($active.hasClass('task_view_story')) {
|
|
|
|
view = 'feed';
|
|
|
|
}
|
|
|
|
} else if (direction == 1) {
|
|
|
|
if ($active.hasClass('task_view_page')) {
|
|
|
|
view = 'feed';
|
|
|
|
} else if ($active.hasClass('task_view_feed')) {
|
|
|
|
view = 'story';
|
|
|
|
} else if ($active.hasClass('task_view_story')) {
|
|
|
|
// view = 'story';
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (view) {
|
|
|
|
this.switch_taskbar_view(view);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
show_stories_preference_in_feed_view: function(is_creating) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_view = this.$s.$feed_view;
|
|
|
|
var $feed_view_stories = $(".NB-feed-story", $feed_view);
|
2011-01-24 23:50:38 -05:00
|
|
|
var $stories = this.$s.$feed_stories;
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = this.active_story;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
if (story && this.model.preference('feed_view_single_story')) {
|
2010-12-09 09:59:45 -05:00
|
|
|
// NEWSBLUR.log(['show_stories_preference_in_feed_view', is_creating, this.model.preference('feed_view_single_story'), $feed_view_stories.length + " stories"]);
|
2010-06-14 13:17:38 -04:00
|
|
|
$stories.removeClass('NB-feed-view-feed').addClass('NB-feed-view-story');
|
|
|
|
$feed_view_stories.css({'display': 'none'});
|
2011-05-03 12:19:53 -04:00
|
|
|
if (is_creating) this.$s.$feed_stories.scrollTop('0px');
|
2010-12-08 20:53:45 -05:00
|
|
|
var $current_story = this.get_current_story_from_story_titles($feed_view_stories);
|
2010-06-14 13:17:38 -04:00
|
|
|
if ($current_story && $current_story.length) {
|
|
|
|
$current_story.css({'display': 'block'});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-12-08 20:53:45 -05:00
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
|
|
|
} else {
|
|
|
|
$stories.removeClass('NB-feed-view-story').addClass('NB-feed-view-feed');
|
|
|
|
if (!is_creating) {
|
|
|
|
this.show_story_titles_above_intelligence_level({'animate': false});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
}
|
2011-10-19 18:42:49 -07:00
|
|
|
this.cache.story_pane_position = null;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
// ==============
|
|
|
|
// = Story View =
|
|
|
|
// ==============
|
|
|
|
|
2010-12-07 09:52:14 -05:00
|
|
|
open_story_in_story_view: function(story, is_temporary) {
|
2010-12-07 20:04:37 -05:00
|
|
|
if (!story) story = this.active_story;
|
2012-05-25 18:54:04 -07:00
|
|
|
var feed = this.model.get_feed(story.get('story_feed_id'));
|
2012-05-21 14:36:54 -07:00
|
|
|
if ((feed && feed.get('disabled_page')) ||
|
2012-05-25 18:54:04 -07:00
|
|
|
NEWSBLUR.utils.is_url_iframe_buster(story.get('story_permalink'))) {
|
2012-05-09 12:09:23 -07:00
|
|
|
if (!is_temporary) {
|
|
|
|
this.switch_taskbar_view('feed', 'story');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.switch_taskbar_view('story', is_temporary ? 'story' : false);
|
2012-05-25 18:54:04 -07:00
|
|
|
this.load_story_iframe(story, story.get('story_feed_id'));
|
2012-05-09 12:09:23 -07:00
|
|
|
}
|
2010-12-06 10:41:24 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
load_story_iframe: function(story, feed_id) {
|
2010-12-08 20:53:45 -05:00
|
|
|
story = story || this.active_story;
|
|
|
|
if (!story) return;
|
2010-12-06 10:41:24 -05:00
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
var self = this;
|
|
|
|
var $story_iframe = this.$s.$story_iframe;
|
|
|
|
|
2012-05-25 18:54:04 -07:00
|
|
|
if ($story_iframe.attr('src') != story.get('story_permalink')) {
|
|
|
|
// NEWSBLUR.log(['load_story_iframe', story.get('story_permalink'), $story_iframe.attr('src')]);
|
2010-12-08 20:53:45 -05:00
|
|
|
this.unload_story_iframe();
|
2010-12-06 10:41:24 -05:00
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
if (!feed_id) {
|
|
|
|
feed_id = $story_iframe.data('feed_id');
|
|
|
|
} else {
|
|
|
|
$story_iframe.data('feed_id', feed_id);
|
|
|
|
}
|
2010-12-06 10:41:24 -05:00
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
this.flags.iframe_scroll_snap_back_prepared = true;
|
|
|
|
this.iframe_link_attacher_num_links = 0;
|
2012-05-25 18:54:04 -07:00
|
|
|
$story_iframe.removeAttr('src').attr({src: story.get('story_permalink')});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-12-07 09:52:14 -05:00
|
|
|
unload_story_iframe: function() {
|
|
|
|
var $story_iframe = this.$s.$story_iframe;
|
|
|
|
|
2011-09-30 18:02:48 -07:00
|
|
|
$story_iframe.empty();
|
2010-12-08 20:53:45 -05:00
|
|
|
$story_iframe.removeAttr('src').attr({src: 'about:blank'});
|
2010-12-07 09:52:14 -05:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ===================
|
|
|
|
// = Taskbar - Feeds =
|
|
|
|
// ===================
|
|
|
|
|
2011-02-01 03:35:11 +01:00
|
|
|
open_add_feed_modal: function(options) {
|
2010-06-14 13:17:38 -04:00
|
|
|
clearInterval(this.flags['bouncing_callout']);
|
2010-08-30 19:57:27 -04:00
|
|
|
$.modal.close();
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-02-01 03:35:11 +01:00
|
|
|
NEWSBLUR.add_feed = new NEWSBLUR.ReaderAddFeed(options);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
open_manage_feed_modal: function(feed_id) {
|
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-07-25 23:13:27 -04:00
|
|
|
NEWSBLUR.manage_feed = new NEWSBLUR.ReaderManageFeed(feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
2010-10-10 23:36:09 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
open_mark_read_modal: function() {
|
|
|
|
NEWSBLUR.mark_read = new NEWSBLUR.ReaderMarkRead();
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
2010-10-10 23:36:09 -04:00
|
|
|
|
|
|
|
open_keyboard_shortcuts_modal: function() {
|
|
|
|
NEWSBLUR.keyboard = new NEWSBLUR.ReaderKeyboard();
|
|
|
|
},
|
2010-08-18 20:35:45 -04:00
|
|
|
|
2011-01-20 09:57:23 -05:00
|
|
|
open_goodies_modal: function() {
|
|
|
|
NEWSBLUR.goodies = new NEWSBLUR.ReaderGoodies();
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
open_preferences_modal: function() {
|
2010-07-25 23:13:27 -04:00
|
|
|
NEWSBLUR.preferences = new NEWSBLUR.ReaderPreferences();
|
|
|
|
},
|
2011-07-27 09:33:34 -07:00
|
|
|
|
2011-09-21 17:49:26 -07:00
|
|
|
open_account_modal: function(options) {
|
|
|
|
NEWSBLUR.account = new NEWSBLUR.ReaderAccount(options);
|
2011-07-27 09:33:34 -07:00
|
|
|
},
|
2010-07-25 23:13:27 -04:00
|
|
|
|
2010-09-24 01:08:03 -04:00
|
|
|
open_feedchooser_modal: function() {
|
|
|
|
NEWSBLUR.feedchooser = new NEWSBLUR.ReaderFeedchooser();
|
|
|
|
},
|
|
|
|
|
2010-08-18 20:35:45 -04:00
|
|
|
open_feed_exception_modal: function(feed_id) {
|
2012-01-16 17:55:13 -08:00
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
|
2010-08-18 20:35:45 -04:00
|
|
|
NEWSBLUR.feed_exception = new NEWSBLUR.ReaderFeedException(feed_id);
|
|
|
|
},
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
open_feed_statistics_modal: function(feed_id) {
|
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-07-25 23:13:27 -04:00
|
|
|
NEWSBLUR.statistics = new NEWSBLUR.ReaderStatistics(feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2012-02-22 09:11:35 -08:00
|
|
|
open_social_profile_modal: function(user_id) {
|
2012-04-17 15:37:01 -07:00
|
|
|
if (_.string.contains(user_id, 'social:')) {
|
|
|
|
user_id = parseInt(user_id.replace('social:', ''), 10);
|
|
|
|
}
|
2012-02-22 09:11:35 -08:00
|
|
|
NEWSBLUR.social_profile = new NEWSBLUR.ReaderSocialProfile(user_id);
|
|
|
|
},
|
|
|
|
|
2012-04-19 19:09:31 -07:00
|
|
|
close_social_profile: function() {
|
|
|
|
if (NEWSBLUR.social_profile) {
|
|
|
|
NEWSBLUR.social_profile.close();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-02-22 19:11:29 -05:00
|
|
|
close_sidebar: function() {
|
|
|
|
this.$s.$body.layout().close('west');
|
|
|
|
this.resize_window();
|
2011-02-23 18:09:09 -05:00
|
|
|
this.flags['sidebar_closed'] = true;
|
2011-02-22 19:11:29 -05:00
|
|
|
$('.NB-taskbar-sidebar-toggle-open').stop().animate({
|
|
|
|
'left': -1
|
|
|
|
}, {
|
|
|
|
'duration': 1000,
|
|
|
|
'easing': 'easeOutQuint',
|
|
|
|
'queue': false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
open_sidebar: function() {
|
|
|
|
this.$s.$body.layout().open('west');
|
|
|
|
this.resize_window();
|
2011-02-23 18:09:09 -05:00
|
|
|
this.flags['sidebar_closed'] = false;
|
2011-02-22 19:11:29 -05:00
|
|
|
$('.NB-taskbar-sidebar-toggle-open').stop().css({
|
|
|
|
'left': -24
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-12-11 17:16:12 -05:00
|
|
|
// =======================
|
|
|
|
// = Sidebar Manage Menu =
|
|
|
|
// =======================
|
2010-10-10 20:14:31 -04:00
|
|
|
|
2010-12-30 18:37:29 -05:00
|
|
|
make_manage_menu: function(type, feed_id, story_id, inverse, $item) {
|
2010-09-12 13:50:27 -04:00
|
|
|
var $manage_menu;
|
2012-05-22 13:25:21 -07:00
|
|
|
// console.log(["make_manage_menu", type, feed_id, story_id, inverse, $item]);
|
2012-03-30 14:56:16 -07:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
if (type == 'site') {
|
2010-10-05 19:05:01 -04:00
|
|
|
var show_chooser = !NEWSBLUR.Globals.is_premium && NEWSBLUR.Globals.is_authenticated;
|
2010-09-12 13:50:27 -04:00
|
|
|
$manage_menu = $.make('ul', { className: 'NB-menu-manage' }, [
|
|
|
|
$.make('li', { className: 'NB-menu-manage-site-info' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2010-09-22 10:12:38 -04:00
|
|
|
$.make('span', { className: 'NB-menu-manage-title' }, "Manage NewsBlur")
|
2010-09-12 13:50:27 -04:00
|
|
|
]).corner('tl tr 8px'),
|
2010-10-10 23:36:09 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-mark-read NB-menu-manage-site-mark-read' }, [
|
2011-07-27 09:33:34 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Mark everything as read'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Choose how many days back.')
|
2012-04-04 16:09:01 -07:00
|
|
|
]),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-trainer' }, [
|
2012-04-04 16:09:01 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence Trainer'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Accurate filters are happy filters.')
|
2012-04-04 16:09:01 -07:00
|
|
|
]),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-goodies' }, [
|
2012-04-04 16:09:01 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Goodies'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Extensions and extras.')
|
2011-07-27 09:33:34 -07:00
|
|
|
]),
|
2012-05-11 10:06:05 -07:00
|
|
|
(show_chooser && $.make('li', { className: 'NB-menu-manage-feedchooser' }, [
|
2011-07-27 22:17:34 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Choose Your 64 sites'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Enable the sites you want.')
|
|
|
|
])),
|
2011-07-27 22:17:34 -07:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2010-10-10 23:36:09 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-keyboard' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Keyboard shortcuts')
|
|
|
|
]),
|
2011-05-09 20:59:52 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-tutorial' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-03-02 17:51:28 -08:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Tips & Tricks')
|
2011-05-09 20:59:52 -04:00
|
|
|
]),
|
2010-10-10 23:36:09 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-account' }, [
|
2010-07-30 23:50:49 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Account')
|
2010-09-12 13:50:27 -04:00
|
|
|
]),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-profile-editor' }, [
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Profile')
|
2010-09-12 13:50:27 -04:00
|
|
|
]),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-friends' }, [
|
2011-01-20 09:57:23 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Friends')
|
2011-01-20 09:57:23 -05:00
|
|
|
]),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-preferences' }, [
|
2010-09-24 01:08:03 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-11 10:06:05 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Preferences')
|
|
|
|
])
|
2010-09-12 13:50:27 -04:00
|
|
|
]);
|
|
|
|
$manage_menu.addClass('NB-menu-manage-notop');
|
|
|
|
} else if (type == 'feed') {
|
2010-09-13 00:38:25 -04:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-12-31 14:35:00 -05:00
|
|
|
if (!feed) return;
|
2011-01-31 20:08:07 -05:00
|
|
|
var unread_count = this.get_unread_count(true, feed_id);
|
|
|
|
var tab_unread_count = Math.min(25, unread_count);
|
2010-09-12 13:50:27 -04:00
|
|
|
$manage_menu = $.make('ul', { className: 'NB-menu-manage' }, [
|
2010-09-13 00:38:25 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator-inverse' }),
|
2012-05-21 14:36:54 -07:00
|
|
|
(feed.get('has_exception') && $.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-exception' }, [
|
2010-09-13 00:38:25 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Fix this misbehaving site')
|
|
|
|
])),
|
2012-05-21 14:36:54 -07:00
|
|
|
(feed.get('has_exception') && $.make('li', { className: 'NB-menu-separator-inverse' })),
|
|
|
|
(feed.get('exception_type') != 'feed' && $.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-mark-read NB-menu-manage-feed-mark-read' }, [
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Mark as read')
|
2010-09-13 00:38:25 -04:00
|
|
|
])),
|
2010-10-10 20:14:31 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-reload' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Insta-fetch stories')
|
|
|
|
]),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-stats' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Statistics')
|
2010-07-30 23:50:49 -04:00
|
|
|
]),
|
2011-09-26 09:22:46 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-settings' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2011-11-12 18:19:57 -08:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Site settings')
|
2011-09-26 09:22:46 -07:00
|
|
|
]),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2010-07-24 00:04:14 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-train' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2010-12-30 18:37:29 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence trainer'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'What you like and dislike.')
|
2010-07-24 00:04:14 -04:00
|
|
|
]),
|
2011-03-28 10:08:10 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-recommend' }, [
|
2010-12-31 10:34:31 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2011-03-28 10:08:10 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Recommend this site')
|
|
|
|
]),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2011-09-04 15:42:13 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-move NB-menu-manage-feed-move' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Move to folder')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-confirm NB-menu-manage-feed-move-confirm NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-confirm-position'}, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-move-save NB-menu-manage-feed-move-save NB-modal-submit-green NB-modal-submit-button' }, 'Save'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-add-folders' }, NEWSBLUR.utils.make_folders(this.model))
|
|
|
|
])
|
|
|
|
]),
|
2010-12-11 11:26:21 -05:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-rename NB-menu-manage-feed-rename' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Rename this site')
|
|
|
|
]),
|
2011-09-04 15:42:13 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-confirm NB-menu-manage-feed-rename-confirm NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-confirm-position'}, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-rename-save NB-menu-manage-feed-rename-save NB-modal-submit-green NB-modal-submit-button' }, 'Save'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-21 14:36:54 -07:00
|
|
|
$.make('input', { name: 'new_title', className: 'NB-menu-manage-title', value: feed.get('feed_title') })
|
2011-09-04 15:42:13 -07:00
|
|
|
])
|
2010-12-11 11:26:21 -05:00
|
|
|
]),
|
2010-09-14 20:49:28 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete NB-menu-manage-feed-delete' }, [
|
2010-07-21 23:22:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Delete this site')
|
2010-07-21 23:22:27 -04:00
|
|
|
]),
|
2010-09-14 20:49:28 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete-confirm NB-menu-manage-feed-delete-confirm' }, [
|
2010-07-24 00:04:14 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Really delete?')
|
2010-07-21 23:22:27 -04:00
|
|
|
])
|
2010-09-12 13:50:27 -04:00
|
|
|
]);
|
|
|
|
$manage_menu.data('feed_id', feed_id);
|
2010-09-14 20:49:28 -04:00
|
|
|
$manage_menu.data('$feed', $item);
|
2011-01-31 20:08:07 -05:00
|
|
|
if (feed_id && unread_count == 0) {
|
2010-09-12 13:50:27 -04:00
|
|
|
$('.NB-menu-manage-feed-mark-read', $manage_menu).addClass('NB-disabled');
|
2010-12-14 17:08:52 -05:00
|
|
|
$('.NB-menu-manage-feed-unreadtabs', $manage_menu).addClass('NB-disabled');
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if (type == 'socialfeed') {
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
if (!feed) return;
|
|
|
|
var unread_count = this.get_unread_count(true, feed_id);
|
|
|
|
var tab_unread_count = Math.min(25, unread_count);
|
|
|
|
$manage_menu = $.make('ul', { className: 'NB-menu-manage' }, [
|
|
|
|
$.make('li', { className: 'NB-menu-separator-inverse' }),
|
2012-05-21 14:36:54 -07:00
|
|
|
(feed.get('has_exception') && $.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-exception' }, [
|
2012-03-30 14:56:16 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Fix this misbehaving site')
|
|
|
|
])),
|
2012-05-21 14:36:54 -07:00
|
|
|
(feed.get('has_exception') && $.make('li', { className: 'NB-menu-separator-inverse' })),
|
2012-04-17 15:37:01 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-social-profile' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'View profile')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2012-05-21 14:36:54 -07:00
|
|
|
(feed.get('exception_type') != 'feed' && $.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-mark-read NB-menu-manage-feed-mark-read' }, [
|
2012-03-30 14:56:16 -07:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Mark as read')
|
|
|
|
])),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-stats' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Statistics')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-settings' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Site settings')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-train' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence trainer'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'What you like and dislike.')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete NB-menu-manage-socialfeed-delete' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Unfollow')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete-confirm NB-menu-manage-socialfeed-delete-confirm' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Really unfollow?')
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
$manage_menu.data('feed_id', feed_id);
|
|
|
|
$manage_menu.data('$feed', $item);
|
|
|
|
if (feed_id && unread_count == 0) {
|
|
|
|
$('.NB-menu-manage-feed-mark-read', $manage_menu).addClass('NB-disabled');
|
|
|
|
$('.NB-menu-manage-feed-unreadtabs', $manage_menu).addClass('NB-disabled');
|
|
|
|
}
|
2010-09-12 13:50:27 -04:00
|
|
|
} else if (type == 'folder') {
|
|
|
|
$manage_menu = $.make('ul', { className: 'NB-menu-manage' }, [
|
2010-09-13 17:32:41 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator-inverse' }),
|
2010-09-14 20:49:28 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-mark-read NB-menu-manage-folder-mark-read' }, [
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Mark folder as read')
|
|
|
|
]),
|
2012-05-24 11:54:10 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-folder-subscribe' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Add a site to this folder')
|
|
|
|
]),
|
2010-09-22 10:12:38 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2011-09-04 15:42:13 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-move NB-menu-manage-folder-move' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Move to folder')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-confirm NB-menu-manage-folder-move-confirm NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-confirm-position'}, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-move-save NB-menu-manage-folder-move-save NB-modal-submit-green NB-modal-submit-button' }, 'Save'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-add-folders' }, NEWSBLUR.utils.make_folders(this.model))
|
|
|
|
])
|
|
|
|
]),
|
2010-12-11 12:41:24 -05:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-rename NB-menu-manage-folder-rename' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Rename this folder')
|
|
|
|
]),
|
2011-09-04 15:42:13 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-confirm NB-menu-manage-folder-rename-confirm NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-confirm-position'}, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-rename-save NB-menu-manage-folder-rename-save NB-modal-submit-green NB-modal-submit-button' }, 'Save'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('input', { name: 'new_title', className: 'NB-menu-manage-title', value: feed_id })
|
|
|
|
])
|
2010-12-11 12:41:24 -05:00
|
|
|
]),
|
2010-09-22 10:12:38 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete NB-menu-manage-folder-delete' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Delete this folder')
|
|
|
|
]),
|
2010-09-14 20:49:28 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-delete-confirm NB-menu-manage-folder-delete-confirm' }, [
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Really delete?')
|
2010-09-13 17:32:41 -04:00
|
|
|
])
|
2010-09-12 13:50:27 -04:00
|
|
|
]);
|
2010-09-14 20:49:28 -04:00
|
|
|
$manage_menu.data('folder_name', feed_id);
|
|
|
|
$manage_menu.data('$folder', $item);
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'story') {
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var story = this.model.get_story(story_id);
|
2012-05-25 18:54:04 -07:00
|
|
|
var starred_class = story.get('starred') ? ' NB-story-starred ' : '';
|
|
|
|
var starred_title = story.get('starred') ? 'Remove bookmark' : 'Save This Story';
|
|
|
|
var shared_class = story.get('shared') ? ' NB-story-shared ' : '';
|
|
|
|
var shared_title = story.get('shared') ? 'Shared' : 'Share story';
|
2010-12-30 18:37:29 -05:00
|
|
|
|
2012-04-24 10:38:23 -07:00
|
|
|
$manage_menu = $.make('ul', { className: 'NB-menu-manage NB-menu-manage-story ' + starred_class + shared_class }, [
|
2011-02-23 11:40:25 -05:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-story-open' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2012-05-25 18:54:04 -07:00
|
|
|
$.make('input', { name: 'story_permalink', className: 'NB-menu-manage-open-input', value: story.get('story_permalink') }),
|
2011-02-23 11:40:25 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Open')
|
|
|
|
]),
|
2010-12-31 10:34:31 -05:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2010-12-30 18:37:29 -05:00
|
|
|
$.make('li', { className: 'NB-menu-manage-story-star' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, starred_title)
|
|
|
|
]),
|
2012-05-25 18:54:04 -07:00
|
|
|
(story.get('read_status') && $.make('li', { className: 'NB-menu-manage-story-unread' }, [
|
2011-11-08 13:48:54 -08:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Mark as unread')
|
|
|
|
])),
|
2011-02-04 00:22:58 -05:00
|
|
|
$.make('li', { className: 'NB-menu-manage-story-thirdparty' }, [
|
2011-02-16 20:45:37 -05:00
|
|
|
(NEWSBLUR.Preferences['story_share_facebook'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-facebook'}).bind('mouseenter', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Facebook').parent().addClass('NB-menu-manage-highlight-facebook');
|
2011-02-04 00:22:58 -05:00
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-facebook');
|
2011-02-16 20:45:37 -05:00
|
|
|
}, this))),
|
|
|
|
(NEWSBLUR.Preferences['story_share_twitter'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-twitter'}).bind('mouseenter', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Twitter').parent().addClass('NB-menu-manage-highlight-twitter');
|
2011-02-04 00:22:58 -05:00
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-twitter');
|
2011-02-16 20:45:37 -05:00
|
|
|
}, this))),
|
|
|
|
(NEWSBLUR.Preferences['story_share_readitlater'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-readitlater'}).bind('mouseenter', _.bind(function(e) {
|
2012-04-17 10:58:32 -07:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Pocket (RIL)').parent().addClass('NB-menu-manage-highlight-readitlater');
|
2011-02-15 21:31:33 -05:00
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-readitlater');
|
2011-02-16 20:45:37 -05:00
|
|
|
}, this))),
|
2012-01-13 10:46:56 -08:00
|
|
|
(NEWSBLUR.Preferences['story_share_tumblr'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-tumblr'}).bind('mouseenter', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Tumblr').parent().addClass('NB-menu-manage-highlight-tumblr');
|
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-tumblr');
|
|
|
|
}, this))),
|
2012-05-06 16:26:54 -07:00
|
|
|
(NEWSBLUR.Preferences['story_share_delicious'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-delicious'}).bind('mouseenter', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Delicious').parent().addClass('NB-menu-manage-highlight-delicious');
|
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-delicious');
|
|
|
|
}, this))),
|
2011-11-07 18:21:38 -08:00
|
|
|
(NEWSBLUR.Preferences['story_share_pinboard'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-pinboard'}).bind('mouseenter', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Pinboard').parent().addClass('NB-menu-manage-highlight-pinboard');
|
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-pinboard');
|
2011-11-07 18:21:38 -08:00
|
|
|
}, this))),
|
|
|
|
(NEWSBLUR.Preferences['story_share_googleplus'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-googleplus'}).bind('mouseenter', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Google+').parent().addClass('NB-menu-manage-highlight-googleplus');
|
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-googleplus');
|
2011-11-07 18:21:38 -08:00
|
|
|
}, this))),
|
2011-11-09 18:38:00 -08:00
|
|
|
(NEWSBLUR.Preferences['story_share_instapaper'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-instapaper'}).bind('mouseenter', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Instapaper').parent().addClass('NB-menu-manage-highlight-instapaper');
|
2011-05-03 11:40:38 -04:00
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
2011-11-09 18:38:00 -08:00
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-instapaper');
|
2011-05-03 11:40:38 -04:00
|
|
|
}, this))),
|
2012-03-19 20:12:57 -07:00
|
|
|
(NEWSBLUR.Preferences['story_share_readability'] && $.make('div', { className: 'NB-menu-manage-thirdparty-icon NB-menu-manage-thirdparty-readability'}).bind('mouseenter', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Readability').parent().addClass('NB-menu-manage-highlight-readability');
|
|
|
|
}, this)).bind('mouseleave', _.bind(function(e) {
|
|
|
|
$(e.target).siblings('.NB-menu-manage-title').text('Email story').parent().removeClass('NB-menu-manage-highlight-readability');
|
|
|
|
}, this))),
|
2011-01-07 16:36:46 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2011-11-09 18:38:00 -08:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Email story')
|
2011-01-07 16:36:46 -05:00
|
|
|
]).bind('click', _.bind(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2011-02-04 00:22:58 -05:00
|
|
|
var $target = $(e.target);
|
|
|
|
if ($target.hasClass('NB-menu-manage-thirdparty-facebook')) {
|
|
|
|
this.send_story_to_facebook(story.id);
|
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-twitter')) {
|
|
|
|
this.send_story_to_twitter(story.id);
|
2011-02-15 21:31:33 -05:00
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-readitlater')) {
|
|
|
|
this.send_story_to_readitlater(story.id);
|
2012-01-13 10:46:56 -08:00
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-tumblr')) {
|
|
|
|
this.send_story_to_tumblr(story.id);
|
2012-05-06 16:26:54 -07:00
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-delicious')) {
|
|
|
|
this.send_story_to_delicious(story.id);
|
2011-02-16 20:45:37 -05:00
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-readability')) {
|
|
|
|
this.send_story_to_readability(story.id);
|
2011-11-07 18:21:38 -08:00
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-pinboard')) {
|
|
|
|
this.send_story_to_pinboard(story.id);
|
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-googleplus')) {
|
|
|
|
this.send_story_to_googleplus(story.id);
|
2011-11-09 18:38:00 -08:00
|
|
|
} else if ($target.hasClass('NB-menu-manage-thirdparty-instapaper')) {
|
2011-02-04 00:22:58 -05:00
|
|
|
this.send_story_to_instapaper(story.id);
|
2011-11-09 18:38:00 -08:00
|
|
|
} else {
|
|
|
|
this.send_story_to_email(story.id);
|
2011-02-04 00:22:58 -05:00
|
|
|
}
|
2011-01-07 16:36:46 -05:00
|
|
|
}, this)),
|
2012-04-24 10:38:23 -07:00
|
|
|
$.make('li', { className: 'NB-menu-manage-story NB-menu-manage-story-share' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, shared_title)
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-story NB-menu-manage-confirm NB-menu-manage-story-share-confirm NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-confirm-position' }, [
|
2012-06-06 20:37:20 -07:00
|
|
|
new NEWSBLUR.Views.StoryShareView({
|
|
|
|
model: this.model
|
|
|
|
}).render().el
|
2012-04-24 10:38:23 -07:00
|
|
|
])
|
|
|
|
]),
|
2010-12-31 10:34:31 -05:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-story-train' }, [
|
2010-12-30 18:37:29 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2010-12-31 10:34:31 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence trainer'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'What you like and dislike.')
|
2010-12-31 14:35:00 -05:00
|
|
|
])
|
2010-12-30 18:37:29 -05:00
|
|
|
]);
|
|
|
|
$manage_menu.data('feed_id', feed_id);
|
|
|
|
$manage_menu.data('story_id', story_id);
|
|
|
|
$manage_menu.data('$story', $item);
|
2012-04-24 10:38:23 -07:00
|
|
|
|
2012-06-05 16:18:30 -07:00
|
|
|
// this.update_share_button_label($('.NB-sideoption-share-comments', $manage_menu));
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
|
2010-09-13 00:38:25 -04:00
|
|
|
if (inverse) $manage_menu.addClass('NB-inverse');
|
2010-06-14 13:17:38 -04:00
|
|
|
return $manage_menu;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-04-03 10:52:34 -04:00
|
|
|
show_manage_menu: function(type, $item, options) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2011-04-03 10:52:34 -04:00
|
|
|
var options = _.extend({
|
|
|
|
'toplevel': false,
|
|
|
|
'inverse': false
|
|
|
|
}, options);
|
2010-06-14 13:17:38 -04:00
|
|
|
var $manage_menu_container = $('.NB-menu-manage-container');
|
2012-03-30 14:56:16 -07:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
clearTimeout(this.flags.closed_manage_menu);
|
2012-05-17 13:22:00 -07:00
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = false;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// If another menu is open, hide it first.
|
|
|
|
// If this menu is already open, then hide it instead.
|
|
|
|
if (($item && $item[0] == $manage_menu_container.data('item')) &&
|
|
|
|
parseInt($manage_menu_container.css('opacity'), 10) == 1) {
|
2012-05-11 10:06:05 -07:00
|
|
|
this.hide_manage_menu(type, $item);
|
2010-09-12 13:50:27 -04:00
|
|
|
return;
|
2012-05-11 10:06:05 -07:00
|
|
|
} else {
|
|
|
|
this.hide_manage_menu(type, $item);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
|
2011-02-02 08:05:31 -05:00
|
|
|
if ($item.hasClass('NB-empty')) return;
|
2011-02-01 22:58:00 -05:00
|
|
|
|
2011-02-08 22:07:59 -05:00
|
|
|
$item.addClass('NB-showing-menu');
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// Create menu, size and position it, then attach to the right place.
|
2010-12-30 18:37:29 -05:00
|
|
|
var feed_id, inverse, story_id;
|
2010-09-14 20:49:28 -04:00
|
|
|
if (type == 'folder') {
|
2012-05-25 18:54:04 -07:00
|
|
|
feed_id = options.folder_title;
|
2011-04-03 10:52:34 -04:00
|
|
|
inverse = options.inverse || $('.folder_title', $item).hasClass("NB-hover-inverse");
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'feed') {
|
2012-05-21 20:08:27 -07:00
|
|
|
feed_id = options.feed_id;
|
2011-04-03 10:52:34 -04:00
|
|
|
inverse = options.inverse || $item.hasClass("NB-hover-inverse");
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if (type == 'socialfeed') {
|
2012-05-25 18:54:04 -07:00
|
|
|
feed_id = options.feed_id;
|
2012-03-30 14:56:16 -07:00
|
|
|
inverse = options.inverse || $item.hasClass("NB-hover-inverse");
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'story') {
|
2012-05-25 18:54:04 -07:00
|
|
|
story_id = options.story_id;
|
2011-09-27 22:16:09 -07:00
|
|
|
if ($item.hasClass('NB-hover-inverse')) inverse = true;
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'site') {
|
2011-02-22 19:11:29 -05:00
|
|
|
$('.NB-task-manage').tipsy('hide');
|
2011-02-22 19:45:29 -05:00
|
|
|
$('.NB-task-manage').tipsy('disable');
|
2010-09-14 20:49:28 -04:00
|
|
|
}
|
2011-04-03 10:52:34 -04:00
|
|
|
var toplevel = options.toplevel || $item.hasClass("NB-toplevel") ||
|
2010-12-30 18:37:29 -05:00
|
|
|
$item.children('.folder_title').hasClass("NB-toplevel");
|
|
|
|
var $manage_menu = this.make_manage_menu(type, feed_id, story_id, inverse, $item);
|
2010-06-14 13:17:38 -04:00
|
|
|
$manage_menu_container.empty().append($manage_menu);
|
2010-09-12 13:50:27 -04:00
|
|
|
$manage_menu_container.data('item', $item && $item[0]);
|
2010-06-14 13:17:38 -04:00
|
|
|
$('.NB-task-manage').parents('.NB-taskbar').css('z-index', 2);
|
2010-09-12 13:50:27 -04:00
|
|
|
if (type == 'site') {
|
|
|
|
$manage_menu_container.align($('.NB-task-manage'), '-bottom -left', {
|
|
|
|
'top': -32,
|
|
|
|
'left': -2
|
|
|
|
});
|
|
|
|
$('.NB-task-manage').addClass('NB-hover');
|
|
|
|
$manage_menu_container.corner('tl tr 8px');
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if (type == 'feed' || type == 'folder' || type == 'story' || type == 'socialfeed') {
|
2010-12-12 20:06:32 -05:00
|
|
|
var left, top;
|
|
|
|
// NEWSBLUR.log(['menu open', $item, inverse, toplevel, type]);
|
2010-09-13 00:38:25 -04:00
|
|
|
if (inverse) {
|
2011-09-27 23:06:49 -07:00
|
|
|
var $align = $item;
|
2010-12-12 20:06:32 -05:00
|
|
|
if (type == 'feed') {
|
|
|
|
left = toplevel ? 0 : -20;
|
2010-12-31 10:34:31 -05:00
|
|
|
top = toplevel ? 21 : 21;
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if (type == 'socialfeed') {
|
|
|
|
left = toplevel ? 0 : -20;
|
|
|
|
top = toplevel ? 21 : 21;
|
2010-12-12 20:06:32 -05:00
|
|
|
} else if (type == 'folder') {
|
|
|
|
left = toplevel ? 0 : -20;
|
2010-12-31 10:34:31 -05:00
|
|
|
top = toplevel ? 24 : 24;
|
2011-09-27 23:06:49 -07:00
|
|
|
$align = $('.folder_title', $item);
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'story') {
|
|
|
|
left = 4;
|
2011-09-27 22:16:09 -07:00
|
|
|
top = 24 ;
|
2011-09-27 23:06:49 -07:00
|
|
|
$align = $('.NB-story-manage-icon,.NB-feed-story-manage-icon', $item);
|
2012-04-27 17:44:00 -07:00
|
|
|
if (!$align.is(':visible')) {
|
|
|
|
$align = $('.NB-storytitles-sentiment', $item);
|
|
|
|
}
|
2010-12-12 20:06:32 -05:00
|
|
|
}
|
2012-04-27 17:44:00 -07:00
|
|
|
|
2010-09-13 00:38:25 -04:00
|
|
|
$manage_menu_container.align($align, '-bottom -left', {
|
|
|
|
'top': -1 * top,
|
|
|
|
'left': left
|
|
|
|
});
|
2012-04-27 17:44:00 -07:00
|
|
|
|
2010-09-13 00:38:25 -04:00
|
|
|
$manage_menu_container.corner('br 8px');
|
|
|
|
$('li', $manage_menu_container).each(function() {
|
|
|
|
$(this).prependTo($(this).parent());
|
|
|
|
});
|
|
|
|
} else {
|
2011-09-27 23:06:49 -07:00
|
|
|
var $align = $item;
|
2010-12-12 20:06:32 -05:00
|
|
|
if (type == 'feed') {
|
2011-09-27 23:06:49 -07:00
|
|
|
left = toplevel ? 2 : -18;
|
2010-12-12 20:06:32 -05:00
|
|
|
top = toplevel ? 21 : 21;
|
2011-09-27 23:06:49 -07:00
|
|
|
$align = $('.NB-feedlist-manage-icon', $item);
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if (type == 'socialfeed') {
|
|
|
|
left = toplevel ? 2 : -18;
|
|
|
|
top = toplevel ? 21 : 21;
|
|
|
|
$align = $('.NB-feedlist-manage-icon', $item);
|
2010-12-12 20:06:32 -05:00
|
|
|
} else if (type == 'folder') {
|
|
|
|
left = toplevel ? 2 : -20;
|
|
|
|
top = toplevel ? 22 : 21;
|
2011-01-12 22:45:52 -05:00
|
|
|
} else if (type == 'story') {
|
|
|
|
left = 4;
|
2011-01-14 00:59:51 -05:00
|
|
|
top = 18;
|
2011-09-27 23:06:49 -07:00
|
|
|
$align = $('.NB-story-manage-icon,.NB-feed-story-manage-icon', $item);
|
2012-04-27 17:44:00 -07:00
|
|
|
if (!$align.is(':visible')) {
|
|
|
|
$align = $('.NB-storytitles-sentiment', $item);
|
|
|
|
}
|
2010-12-12 20:06:32 -05:00
|
|
|
}
|
2011-09-27 23:06:49 -07:00
|
|
|
$manage_menu_container.align($align, '-top -left', {
|
2010-09-13 00:38:25 -04:00
|
|
|
'top': top,
|
|
|
|
'left': left
|
|
|
|
});
|
|
|
|
$manage_menu_container.corner('tr 8px');
|
|
|
|
}
|
2010-09-12 13:50:27 -04:00
|
|
|
}
|
|
|
|
$manage_menu_container.stop().css({'display': 'block', 'opacity': 1});
|
|
|
|
|
|
|
|
// Create and position the arrow tab
|
2012-03-30 14:56:16 -07:00
|
|
|
if (type == 'feed' || type == 'folder' || type == 'story' || type == 'socialfeed') {
|
2010-09-13 00:38:25 -04:00
|
|
|
var $arrow = $.make('div', { className: 'NB-menu-manage-arrow' });
|
|
|
|
if (inverse) {
|
|
|
|
$arrow.corner('bl br 5px');
|
|
|
|
$manage_menu_container.append($arrow);
|
|
|
|
$arrow.addClass('NB-inverse');
|
|
|
|
} else {
|
|
|
|
$arrow.corner('tl tr 5px');
|
|
|
|
$manage_menu_container.prepend($arrow);
|
|
|
|
}
|
2010-09-12 13:50:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hide menu on click outside menu.
|
|
|
|
_.defer(function() {
|
|
|
|
$(document).bind('click.menu', function(e) {
|
2010-12-31 14:35:00 -05:00
|
|
|
if (e.button == 2) return; // Ignore right-clicks
|
2010-09-12 13:50:27 -04:00
|
|
|
self.hide_manage_menu(type, $item, false);
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// Hide menu on mouseout (on a delay).
|
2010-06-14 13:17:38 -04:00
|
|
|
$manage_menu_container.hover(function() {
|
|
|
|
clearTimeout(self.flags.closed_manage_menu);
|
|
|
|
}, function() {
|
|
|
|
clearTimeout(self.flags.closed_manage_menu);
|
|
|
|
self.flags.closed_manage_menu = setTimeout(function() {
|
2010-07-24 00:04:14 -04:00
|
|
|
if (self.flags.closed_manage_menu) {
|
2010-09-12 13:50:27 -04:00
|
|
|
self.hide_manage_menu(type, $item, true);
|
2010-07-24 00:04:14 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}, 1000);
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
2010-09-12 13:50:27 -04:00
|
|
|
|
2012-04-27 17:44:00 -07:00
|
|
|
// Hide menu on esc.
|
|
|
|
$('input,textarea', $manage_menu_container).bind('keydown', 'esc', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.flags['showing_confirm_input_on_manage_menu'] = false;
|
|
|
|
self.hide_manage_menu(type, $item, true);
|
|
|
|
});
|
|
|
|
if (type == 'story') {
|
|
|
|
var share = _.bind(function(e) {
|
|
|
|
e.preventDefault();
|
2012-06-02 16:33:44 -07:00
|
|
|
this.active_story.story_share_view.mark_story_as_shared({'source': 'menu'});
|
2012-04-27 17:44:00 -07:00
|
|
|
}, this);
|
|
|
|
$('.NB-sideoption-share-comments', $manage_menu_container).bind('keydown', 'ctrl+return', share);
|
|
|
|
$('.NB-sideoption-share-comments', $manage_menu_container).bind('keydown', 'meta+return', share);
|
|
|
|
}
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// Hide menu on scroll.
|
2010-12-30 18:37:29 -05:00
|
|
|
var $scroll;
|
2010-09-12 13:50:27 -04:00
|
|
|
this.flags['feed_list_showing_manage_menu'] = true;
|
2012-03-30 14:56:16 -07:00
|
|
|
if (type == 'feed' || type == 'socialfeed') {
|
2010-12-30 18:37:29 -05:00
|
|
|
$scroll = this.$s.$feed_list.parent();
|
|
|
|
} else if (type == 'story') {
|
2011-05-16 11:34:05 -04:00
|
|
|
$scroll = this.$s.$story_titles.add(this.$s.$feed_stories);
|
2010-12-30 18:37:29 -05:00
|
|
|
}
|
|
|
|
$scroll && $scroll.unbind('scroll.manage_menu').bind('scroll.manage_menu', function(e) {
|
2010-09-12 13:50:27 -04:00
|
|
|
if (self.flags['feed_list_showing_manage_menu']) {
|
|
|
|
self.hide_manage_menu(type, $item, true);
|
|
|
|
} else {
|
2011-01-12 22:45:52 -05:00
|
|
|
$scroll.unbind('scroll.manage_menu');
|
2010-09-12 13:50:27 -04:00
|
|
|
}
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
hide_manage_menu: function(type, $item, animate) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $manage_menu_container = $('.NB-menu-manage-container');
|
|
|
|
var height = $manage_menu_container.outerHeight();
|
2011-09-04 15:42:13 -07:00
|
|
|
if (this.flags['showing_confirm_input_on_manage_menu'] && animate) return;
|
2010-09-12 13:50:27 -04:00
|
|
|
// NEWSBLUR.log(['hide_manage_menu', type, $item, animate, $manage_menu_container.css('opacity')]);
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
clearTimeout(this.flags.closed_manage_menu);
|
2010-09-12 13:50:27 -04:00
|
|
|
this.flags['feed_list_showing_manage_menu'] = false;
|
2010-06-14 13:17:38 -04:00
|
|
|
$(document).unbind('click.menu');
|
2010-09-13 00:38:25 -04:00
|
|
|
$manage_menu_container.uncorner();
|
2011-05-01 20:22:54 -04:00
|
|
|
if (this.model.preference('show_tooltips')) {
|
|
|
|
$('.NB-task-manage').tipsy('enable');
|
|
|
|
}
|
2011-02-08 22:07:59 -05:00
|
|
|
|
2011-11-07 20:50:46 -08:00
|
|
|
if ($item) $item.removeClass('NB-showing-menu');
|
2011-02-08 22:07:59 -05:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
if (animate) {
|
|
|
|
$manage_menu_container.stop().animate({
|
|
|
|
'opacity': 0
|
|
|
|
}, {
|
|
|
|
'duration': 250,
|
|
|
|
'queue': false,
|
|
|
|
'complete': function() {
|
|
|
|
$manage_menu_container.css({'display': 'none', 'opacity': 0});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$manage_menu_container.css({'display': 'none', 'opacity': 0});
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
$('.NB-task-manage').removeClass('NB-hover');
|
2012-04-27 17:44:00 -07:00
|
|
|
|
|
|
|
this.blur_to_page();
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2010-12-11 17:16:12 -05:00
|
|
|
// ========================
|
|
|
|
// = Manage menu - Delete =
|
|
|
|
// ========================
|
|
|
|
|
2010-07-01 00:29:26 -04:00
|
|
|
show_confirm_delete_menu_item: function() {
|
2010-09-14 20:49:28 -04:00
|
|
|
var $delete = $('.NB-menu-manage-feed-delete,.NB-menu-manage-folder-delete');
|
|
|
|
var $confirm = $('.NB-menu-manage-feed-delete-confirm,.NB-menu-manage-folder-delete-confirm');
|
2010-07-01 00:29:26 -04:00
|
|
|
|
|
|
|
$delete.addClass('NB-menu-manage-feed-delete-cancel');
|
2010-07-21 23:22:27 -04:00
|
|
|
$('.NB-menu-manage-title', $delete).text('Cancel delete');
|
2010-07-01 00:29:26 -04:00
|
|
|
$confirm.slideDown(500);
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_confirm_delete_menu_item: function() {
|
2010-09-14 20:49:28 -04:00
|
|
|
var $delete = $('.NB-menu-manage-feed-delete,.NB-menu-manage-folder-delete');
|
|
|
|
var $confirm = $('.NB-menu-manage-feed-delete-confirm,.NB-menu-manage-folder-delete-confirm');
|
2010-07-01 00:29:26 -04:00
|
|
|
|
|
|
|
$delete.removeClass('NB-menu-manage-feed-delete-cancel');
|
2010-12-11 11:26:21 -05:00
|
|
|
|
|
|
|
var text = $delete.hasClass('NB-menu-manage-folder-delete') ?
|
|
|
|
'Delete this folder' :
|
|
|
|
'Delete this site';
|
2010-09-14 20:49:28 -04:00
|
|
|
$('.NB-menu-manage-title', $delete).text(text);
|
2010-07-01 00:29:26 -04:00
|
|
|
$confirm.slideUp(500);
|
|
|
|
},
|
|
|
|
|
2012-05-23 12:10:35 -07:00
|
|
|
manage_menu_delete_feed: function(feed_id, $feed) {
|
2010-07-01 00:29:26 -04:00
|
|
|
var self = this;
|
2012-05-23 12:10:35 -07:00
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var feed_view = feed.get_view($feed);
|
|
|
|
feed.delete_feed({view: feed_view});
|
2010-09-14 20:49:28 -04:00
|
|
|
},
|
|
|
|
|
2012-03-30 14:56:16 -07:00
|
|
|
show_confirm_unfollow_menu_item: function() {
|
|
|
|
var $unfollow = $('.NB-menu-manage-socialfeed-delete');
|
|
|
|
var $confirm = $('.NB-menu-manage-socialfeed-delete-confirm');
|
|
|
|
|
|
|
|
$unfollow.addClass('NB-menu-manage-socialfeed-delete-cancel');
|
|
|
|
$('.NB-menu-manage-title', $unfollow).text('Cancel unfollow');
|
|
|
|
$confirm.slideDown(500);
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_confirm_unfollow_menu_item: function() {
|
|
|
|
var $unfollow = $('.NB-menu-manage-socialfeed-delete,.NB-menu-manage-folder-delete');
|
|
|
|
var $confirm = $('.NB-menu-manage-socialfeed-delete-confirm,.NB-menu-manage-folder-delete-confirm');
|
|
|
|
|
|
|
|
$unfollow.removeClass('NB-menu-manage-socialfeed-delete-cancel');
|
|
|
|
|
|
|
|
$('.NB-menu-manage-title', $unfollow).text('Unfollow');
|
|
|
|
$confirm.slideUp(500);
|
|
|
|
},
|
|
|
|
|
|
|
|
manage_menu_unfollow_feed: function(feed, $feed) {
|
|
|
|
var self = this;
|
|
|
|
var feed_id = feed || this.active_feed;
|
|
|
|
|
|
|
|
this.model.unfollow_user(feed_id, function() {
|
2012-05-17 18:40:46 -07:00
|
|
|
NEWSBLUR.app.feed_list.make_social_feeds();
|
2012-03-30 14:56:16 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2012-05-23 21:07:01 -07:00
|
|
|
manage_menu_delete_folder: function(folder_title, $folder) {
|
2010-09-14 20:49:28 -04:00
|
|
|
var self = this;
|
2012-05-23 21:07:01 -07:00
|
|
|
var folder_view = NEWSBLUR.assets.folders.get_view($folder);
|
2010-07-01 00:29:26 -04:00
|
|
|
|
2012-05-23 21:07:01 -07:00
|
|
|
folder_view.model.delete_folder();
|
2010-12-11 14:02:37 -05:00
|
|
|
},
|
|
|
|
|
2011-09-04 15:42:13 -07:00
|
|
|
// ========================
|
|
|
|
// = Manage menu - Move =
|
|
|
|
// ========================
|
|
|
|
|
|
|
|
show_confirm_move_menu_item: function(feed_id, $feed) {
|
|
|
|
var self = this;
|
|
|
|
var $move = $('.NB-menu-manage-feed-move,.NB-menu-manage-folder-move');
|
|
|
|
var $confirm = $('.NB-menu-manage-feed-move-confirm,.NB-menu-manage-folder-move-confirm');
|
|
|
|
var $position = $('.NB-menu-manage-confirm-position', $confirm);
|
|
|
|
var $select = $('select', $confirm);
|
2012-05-23 20:10:28 -07:00
|
|
|
if (_.isNumber(feed_id)) {
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var feed_view = feed.get_view($feed);
|
|
|
|
var in_folder = feed_view.options.folder_title;
|
|
|
|
} else {
|
|
|
|
folder_view = NEWSBLUR.assets.folders.get_view($feed);
|
|
|
|
var in_folder = folder_view.collection.options.title;
|
|
|
|
}
|
2011-09-04 15:42:13 -07:00
|
|
|
|
|
|
|
$move.addClass('NB-menu-manage-feed-move-cancel');
|
|
|
|
$('.NB-menu-manage-title', $move).text('Cancel move');
|
|
|
|
$position.css('position', 'relative');
|
|
|
|
var height = $confirm.height();
|
|
|
|
$position.css('position', 'absolute');
|
|
|
|
$confirm.css({'height': 0, 'display': 'block'}).animate({'height': height}, {
|
|
|
|
'duration': 500,
|
|
|
|
'easing': 'easeOutQuart'
|
|
|
|
});
|
|
|
|
$('select', $confirm).focus().select();
|
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = true;
|
2012-04-25 12:18:26 -07:00
|
|
|
|
2011-09-04 15:42:13 -07:00
|
|
|
$('option', $select).each(function() {
|
|
|
|
if ($(this).attr('value') == in_folder) {
|
|
|
|
$(this).attr('selected', 'selected');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_confirm_move_menu_item: function(moved) {
|
|
|
|
var $move = $('.NB-menu-manage-feed-move,.NB-menu-manage-folder-move');
|
|
|
|
var $confirm = $('.NB-menu-manage-feed-move-confirm,.NB-menu-manage-folder-move-confirm');
|
|
|
|
|
|
|
|
$move.removeClass('NB-menu-manage-feed-move-cancel');
|
|
|
|
var text = 'Move to folder';
|
|
|
|
if (moved) {
|
|
|
|
text = 'Moved';
|
|
|
|
$move.addClass('NB-active');
|
|
|
|
} else {
|
|
|
|
$move.removeClass('NB-active');
|
|
|
|
}
|
|
|
|
$('.NB-menu-manage-title', $move).text(text);
|
|
|
|
$confirm.slideUp(500);
|
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = false;
|
|
|
|
},
|
|
|
|
|
2012-05-23 17:21:06 -07:00
|
|
|
manage_menu_move_feed: function(feed_id, $feed) {
|
|
|
|
var self = this;
|
|
|
|
var feed_id = feed_id || this.active_feed;
|
|
|
|
var to_folder = $('.NB-menu-manage-feed-move-confirm select').val();
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var feed_view = feed.get_view($feed);
|
2011-11-07 20:50:46 -08:00
|
|
|
|
2012-05-23 17:21:06 -07:00
|
|
|
var moved = feed.move_to_folder(to_folder, {view: feed_view});
|
|
|
|
this.hide_confirm_move_menu_item(moved);
|
|
|
|
if (moved) {
|
2011-11-07 20:50:46 -08:00
|
|
|
_.delay(_.bind(function() {
|
2012-05-23 17:21:06 -07:00
|
|
|
this.hide_manage_menu('feed', $feed, true);
|
|
|
|
}, this), 500);
|
|
|
|
}
|
2011-09-04 15:42:13 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
manage_menu_move_folder: function(folder, $folder) {
|
2012-05-23 20:10:28 -07:00
|
|
|
var self = this;
|
|
|
|
var to_folder = $('.NB-menu-manage-folder-move-confirm select').val();
|
|
|
|
var folder_view = NEWSBLUR.assets.folders.get_view($folder);
|
|
|
|
var in_folder = folder_view.collection.options.title;
|
|
|
|
var folder_name = folder_view.options.title;
|
|
|
|
var child_folders = folder_view.collection.child_folder_names();
|
2011-09-04 15:42:13 -07:00
|
|
|
|
2011-11-08 09:20:10 -08:00
|
|
|
if (to_folder == in_folder ||
|
|
|
|
to_folder == folder_name ||
|
|
|
|
_.contains(child_folders, to_folder)) {
|
|
|
|
return this.hide_confirm_move_menu_item();
|
|
|
|
}
|
2011-11-07 20:50:46 -08:00
|
|
|
|
2012-05-23 20:10:28 -07:00
|
|
|
var moved = folder_view.model.move_to_folder(to_folder, {view: folder_view});
|
|
|
|
this.hide_confirm_move_menu_item(moved);
|
|
|
|
if (moved) {
|
2011-11-07 20:50:46 -08:00
|
|
|
_.delay(_.bind(function() {
|
2012-05-23 20:10:28 -07:00
|
|
|
this.hide_manage_menu('folder', $folder, true);
|
|
|
|
}, this), 500);
|
|
|
|
}
|
2011-09-04 15:42:13 -07:00
|
|
|
},
|
|
|
|
|
2010-12-11 17:16:12 -05:00
|
|
|
// ========================
|
|
|
|
// = Manage menu - Rename =
|
|
|
|
// ========================
|
2010-12-11 11:26:21 -05:00
|
|
|
|
|
|
|
show_confirm_rename_menu_item: function() {
|
2010-12-11 14:02:37 -05:00
|
|
|
var self = this;
|
2010-12-11 11:26:21 -05:00
|
|
|
var $rename = $('.NB-menu-manage-feed-rename,.NB-menu-manage-folder-rename');
|
|
|
|
var $confirm = $('.NB-menu-manage-feed-rename-confirm,.NB-menu-manage-folder-rename-confirm');
|
2011-09-04 15:42:13 -07:00
|
|
|
var $position = $('.NB-menu-manage-confirm-position', $confirm);
|
2010-12-11 11:26:21 -05:00
|
|
|
|
|
|
|
$rename.addClass('NB-menu-manage-feed-rename-cancel');
|
|
|
|
$('.NB-menu-manage-title', $rename).text('Cancel rename');
|
2011-09-04 15:42:13 -07:00
|
|
|
$position.css('position', 'relative');
|
2010-12-11 11:26:21 -05:00
|
|
|
var height = $confirm.height();
|
2011-09-04 15:42:13 -07:00
|
|
|
$position.css('position', 'absolute');
|
|
|
|
$confirm.css({'height': 0, 'display': 'block'}).animate({'height': height}, {
|
|
|
|
'duration': 500,
|
|
|
|
'easing': 'easeOutQuart'
|
|
|
|
});
|
2010-12-11 12:41:24 -05:00
|
|
|
$('input', $confirm).focus().select();
|
2011-09-04 15:42:13 -07:00
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = true;
|
2010-12-11 14:02:37 -05:00
|
|
|
$('.NB-menu-manage-feed-rename-confirm input.NB-menu-manage-title').bind('keyup', 'return', function(e) {
|
|
|
|
var $t = $(e.target);
|
|
|
|
var feed_id = $t.closest('.NB-menu-manage').data('feed_id');
|
|
|
|
var $feed = $t.closest('.NB-menu-manage').data('$feed');
|
|
|
|
self.manage_menu_rename_feed(feed_id, $feed);
|
|
|
|
});
|
|
|
|
$('.NB-menu-manage-folder-rename-confirm input.NB-menu-manage-title').bind('keyup', 'return', function(e) {
|
|
|
|
var $t = $(e.target);
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
|
|
|
self.manage_menu_rename_folder(folder_name, $folder);
|
|
|
|
});
|
2010-12-11 11:26:21 -05:00
|
|
|
},
|
|
|
|
|
2010-12-11 14:02:37 -05:00
|
|
|
hide_confirm_rename_menu_item: function(renamed) {
|
2010-12-11 11:26:21 -05:00
|
|
|
var $rename = $('.NB-menu-manage-feed-rename,.NB-menu-manage-folder-rename');
|
|
|
|
var $confirm = $('.NB-menu-manage-feed-rename-confirm,.NB-menu-manage-folder-rename-confirm');
|
|
|
|
|
|
|
|
$rename.removeClass('NB-menu-manage-feed-rename-cancel');
|
|
|
|
var text = $rename.hasClass('NB-menu-manage-folder-rename') ?
|
|
|
|
'Rename this folder' :
|
|
|
|
'Rename this site';
|
2010-12-11 14:02:37 -05:00
|
|
|
if (renamed) {
|
|
|
|
text = 'Renamed';
|
|
|
|
$rename.addClass('NB-active');
|
|
|
|
} else {
|
|
|
|
$rename.removeClass('NB-active');
|
|
|
|
}
|
2010-12-11 11:26:21 -05:00
|
|
|
$('.NB-menu-manage-title', $rename).text(text);
|
|
|
|
$confirm.slideUp(500);
|
2011-09-04 15:42:13 -07:00
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = false;
|
2010-12-11 11:26:21 -05:00
|
|
|
},
|
|
|
|
|
2012-05-23 12:27:59 -07:00
|
|
|
manage_menu_rename_feed: function(feed_id) {
|
|
|
|
var feed_id = feed_id || this.active_feed;
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-12-11 14:02:37 -05:00
|
|
|
var new_title = $('.NB-menu-manage-feed-rename-confirm .NB-menu-manage-title').val();
|
2010-12-11 11:26:21 -05:00
|
|
|
|
2012-05-23 12:27:59 -07:00
|
|
|
if (new_title.length > 0) feed.rename(new_title);
|
2010-12-11 14:02:37 -05:00
|
|
|
this.hide_confirm_rename_menu_item(true);
|
2010-12-11 11:26:21 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
manage_menu_rename_folder: function(folder, $folder) {
|
2010-12-11 14:02:37 -05:00
|
|
|
var self = this;
|
|
|
|
var new_folder_name = $('.NB-menu-manage-folder-rename-confirm .NB-menu-manage-title').val();
|
2012-05-23 20:20:11 -07:00
|
|
|
var folder_view = NEWSBLUR.assets.folders.get_view($folder);
|
2010-12-11 17:16:12 -05:00
|
|
|
|
2012-05-23 20:20:11 -07:00
|
|
|
if (new_folder_name.length > 0) folder_view.model.rename(new_folder_name);
|
2010-12-11 14:02:37 -05:00
|
|
|
this.hide_confirm_rename_menu_item(true);
|
2010-12-11 11:26:21 -05:00
|
|
|
},
|
|
|
|
|
2012-04-24 10:38:23 -07:00
|
|
|
// =============================
|
|
|
|
// = Manage Menu - Share Story =
|
|
|
|
// =============================
|
|
|
|
|
|
|
|
show_confirm_story_share_menu_item: function() {
|
|
|
|
var self = this;
|
|
|
|
var $share = $('.NB-menu-manage-story-share');
|
|
|
|
var $confirm = $('.NB-menu-manage-story-share-confirm');
|
|
|
|
var $position = $('.NB-menu-manage-confirm-position', $confirm);
|
|
|
|
|
|
|
|
$share.addClass('NB-menu-manage-story-share-cancel');
|
|
|
|
$('.NB-menu-manage-title', $share).text('Cancel share');
|
|
|
|
$position.css('position', 'relative');
|
|
|
|
var height = $confirm.height();
|
|
|
|
$position.css('position', 'absolute');
|
|
|
|
$confirm.css({'height': 0, 'display': 'block'}).animate({'height': height}, {
|
|
|
|
'duration': 500,
|
|
|
|
'easing': 'easeOutQuart'
|
|
|
|
});
|
|
|
|
$('textarea', $confirm).focus().select();
|
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_confirm_story_share_menu_item: function(shared) {
|
|
|
|
var $share = $('.NB-menu-manage-story-share');
|
|
|
|
var $confirm = $('.NB-menu-manage-story-share-confirm');
|
|
|
|
|
|
|
|
$share.removeClass('NB-menu-manage-story-share-cancel');
|
|
|
|
var text = 'Share story';
|
|
|
|
if (shared) {
|
|
|
|
text = 'Shared';
|
|
|
|
$share.addClass('NB-active');
|
|
|
|
} else {
|
|
|
|
$share.removeClass('NB-active');
|
|
|
|
}
|
|
|
|
$('.NB-menu-manage-title', $share).text(text);
|
2012-05-02 13:29:17 -07:00
|
|
|
$confirm.slideUp(500, _.bind(function() {
|
|
|
|
if (shared) {
|
|
|
|
var story_id = this.active_story.id;
|
|
|
|
var $story_title = this.find_story_in_story_titles(story_id);
|
|
|
|
this.hide_manage_menu('story', $story_title, true);
|
|
|
|
}
|
|
|
|
}, this));
|
2012-04-24 10:38:23 -07:00
|
|
|
this.flags['showing_confirm_input_on_manage_menu'] = false;
|
2012-05-02 13:29:17 -07:00
|
|
|
|
2012-04-24 10:38:23 -07:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ==========================
|
|
|
|
// = Taskbar - Intelligence =
|
|
|
|
// ==========================
|
|
|
|
|
|
|
|
load_intelligence_slider: function() {
|
|
|
|
var self = this;
|
|
|
|
var $slider = this.$s.$intelligence_slider;
|
|
|
|
var unread_view = this.model.preference('unread_view');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
this.switch_feed_view_unread_view(unread_view);
|
2012-02-08 18:11:08 -08:00
|
|
|
this.slide_intelligence_slider(unread_view);
|
|
|
|
|
|
|
|
// $slider.slider({
|
|
|
|
// range: 'max',
|
|
|
|
// min: -1,
|
|
|
|
// max: 1,
|
|
|
|
// step: 1,
|
|
|
|
// value: unread_view,
|
|
|
|
// slide: function(e, ui) {
|
|
|
|
// self.switch_feed_view_unread_view(ui.value);
|
|
|
|
// },
|
|
|
|
// stop: function(e, ui) {
|
|
|
|
// self.slide_intelligence_slider(ui.value);
|
|
|
|
// }
|
|
|
|
// });
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
2011-07-29 09:41:49 -07:00
|
|
|
slide_intelligence_slider: function(value) {
|
2012-02-08 18:11:08 -08:00
|
|
|
var $slider = this.$s.$intelligence_slider;
|
2011-07-29 09:41:49 -07:00
|
|
|
if (this.model.preference('unread_view') != value) {
|
|
|
|
this.model.preference('unread_view', value);
|
|
|
|
}
|
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
|
|
|
this.switch_feed_view_unread_view(value);
|
|
|
|
this.show_feed_hidden_story_title_indicator();
|
|
|
|
this.show_story_titles_above_intelligence_level({'animate': true, 'follow': true});
|
2012-02-08 18:11:08 -08:00
|
|
|
|
|
|
|
$('.NB-active', $slider).removeClass('NB-active');
|
|
|
|
if (value < 0) {
|
|
|
|
$('.NB-intelligence-slider-red', $slider).addClass('NB-active');
|
|
|
|
} else if (value > 0) {
|
|
|
|
$('.NB-intelligence-slider-green', $slider).addClass('NB-active');
|
|
|
|
} else {
|
|
|
|
$('.NB-intelligence-slider-yellow', $slider).addClass('NB-active');
|
|
|
|
}
|
2011-07-29 09:41:49 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
move_intelligence_slider: function(direction) {
|
|
|
|
var $slider = this.$s.$intelligence_slider;
|
|
|
|
var value = this.model.preference('unread_view') + direction;
|
|
|
|
$slider.slider({value: value});
|
|
|
|
this.slide_intelligence_slider(value);
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
switch_feed_view_unread_view: function(unread_view) {
|
2011-01-04 10:10:23 -05:00
|
|
|
if (!_.isNumber(unread_view)) unread_view = this.model.preference('unread_view');
|
2011-01-04 19:39:57 -05:00
|
|
|
var $feed_list = this.$s.$feed_list;
|
2012-01-21 16:12:54 -08:00
|
|
|
var $social_feeds = this.$s.$social_feeds;
|
2011-01-04 19:39:57 -05:00
|
|
|
var unread_view_name = this.get_unread_view_name(unread_view);
|
|
|
|
var $next_story_button = $('.task_story_next_unread');
|
2010-11-01 18:20:26 -04:00
|
|
|
var $story_title_indicator = $('.NB-story-title-indicator', this.$story_titles);
|
2011-01-04 08:21:47 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$feed_list.removeClass('unread_view_positive')
|
|
|
|
.removeClass('unread_view_neutral')
|
|
|
|
.removeClass('unread_view_negative')
|
|
|
|
.addClass('unread_view_'+unread_view_name);
|
2012-01-21 16:12:54 -08:00
|
|
|
$social_feeds.removeClass('unread_view_positive')
|
|
|
|
.removeClass('unread_view_neutral')
|
|
|
|
.removeClass('unread_view_negative')
|
|
|
|
.addClass('unread_view_'+unread_view_name);
|
2010-12-04 23:06:35 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$next_story_button.removeClass('task_story_next_positive')
|
|
|
|
.removeClass('task_story_next_neutral')
|
|
|
|
.removeClass('task_story_next_negative')
|
|
|
|
.addClass('task_story_next_'+unread_view_name);
|
2010-11-01 18:20:26 -04:00
|
|
|
|
|
|
|
$story_title_indicator.removeClass('unread_threshold_positive')
|
|
|
|
.removeClass('unread_threshold_neutral')
|
|
|
|
.removeClass('unread_threshold_negative')
|
|
|
|
.addClass('unread_threshold_'+unread_view_name);
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
get_unread_view_name: function(unread_view) {
|
2010-07-21 00:47:55 -04:00
|
|
|
if (typeof unread_view == 'undefined') {
|
|
|
|
unread_view = this.model.preference('unread_view');
|
|
|
|
}
|
2011-01-11 22:12:33 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
return (unread_view > 0
|
|
|
|
? 'positive'
|
|
|
|
: unread_view < 0
|
|
|
|
? 'negative'
|
|
|
|
: 'neutral');
|
|
|
|
},
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
get_unread_count: function(visible_only, feed_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var total = 0;
|
2011-01-10 09:49:26 -05:00
|
|
|
var $folder;
|
2010-09-12 13:50:27 -04:00
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-02-04 09:56:15 -05:00
|
|
|
if (feed_id == 'starred') {
|
|
|
|
// Umm, no. Not yet.
|
|
|
|
} else if (this.flags['river_view']) {
|
2011-01-10 09:49:26 -05:00
|
|
|
if (feed_id == 'river:') {
|
|
|
|
$folder = this.$s.$feed_list;
|
|
|
|
} else {
|
|
|
|
$folder = $('li.folder.NB-selected');
|
|
|
|
}
|
2011-01-31 20:08:07 -05:00
|
|
|
var counts = this.list_feeds_with_unreads_in_folder($folder, true, visible_only);
|
2011-01-10 09:49:26 -05:00
|
|
|
return _.reduce(counts, function(m, c) { return m + c; }, 0);
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
2011-01-10 09:49:26 -05:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
if (!visible_only) {
|
2012-05-21 14:36:54 -07:00
|
|
|
total = feed.get('ng') + feed.get('nt') + feed.get('ps');
|
2011-01-10 09:49:26 -05:00
|
|
|
} else {
|
|
|
|
var unread_view_name = this.get_unread_view_name();
|
|
|
|
if (unread_view_name == 'positive') {
|
2012-05-21 14:36:54 -07:00
|
|
|
total = feed.get('ps');
|
2011-01-10 09:49:26 -05:00
|
|
|
} else if (unread_view_name == 'neutral') {
|
2012-05-21 14:36:54 -07:00
|
|
|
total = feed.get('ps') + feed.get('nt');
|
2011-01-10 09:49:26 -05:00
|
|
|
} else if (unread_view_name == 'negative') {
|
2012-05-21 14:36:54 -07:00
|
|
|
total = feed.get('ps') + feed.get('nt') + feed.get('ng');
|
2011-01-10 09:49:26 -05:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2011-01-10 09:49:26 -05:00
|
|
|
return total;
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-01-03 19:18:27 -05:00
|
|
|
show_story_titles_above_intelligence_level: function(opts) {
|
2010-11-01 18:20:26 -04:00
|
|
|
var defaults = {
|
|
|
|
'unread_view_name': null,
|
|
|
|
'animate': true,
|
2011-02-01 18:29:22 -05:00
|
|
|
'follow': true,
|
|
|
|
'temporary': false
|
2010-11-01 18:20:26 -04:00
|
|
|
};
|
|
|
|
var options = $.extend({}, defaults, opts);
|
2010-06-14 13:17:38 -04:00
|
|
|
var self = this;
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-11-01 18:20:26 -04:00
|
|
|
var unread_view_name = options['unread_view_name'] || this.get_unread_view_name();
|
2010-06-14 13:17:38 -04:00
|
|
|
var $stories_show, $stories_hide;
|
2011-01-04 19:27:00 -05:00
|
|
|
|
2012-04-19 22:38:00 -07:00
|
|
|
if (this.model.stories.length > 18) {
|
2011-12-20 11:55:48 -08:00
|
|
|
options['animate'] = false;
|
|
|
|
}
|
|
|
|
|
2011-01-04 19:27:00 -05:00
|
|
|
if (this.flags['unread_threshold_temporarily']) {
|
|
|
|
unread_view_name = this.flags['unread_threshold_temporarily'];
|
2011-02-28 09:44:06 -05:00
|
|
|
options['temporary'] = true;
|
2011-01-04 19:27:00 -05:00
|
|
|
}
|
2010-12-02 20:18:33 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (unread_view_name == 'positive') {
|
|
|
|
$stories_show = $('.story,.NB-feed-story').filter('.NB-story-positive');
|
|
|
|
$stories_hide = $('.story,.NB-feed-story')
|
|
|
|
.filter('.NB-story-neutral,.NB-story-negative');
|
|
|
|
} else if (unread_view_name == 'neutral') {
|
|
|
|
$stories_show = $('.story,.NB-feed-story')
|
|
|
|
.filter('.NB-story-positive,.NB-story-neutral');
|
|
|
|
$stories_hide = $('.story,.NB-feed-story').filter('.NB-story-negative');
|
2011-02-01 18:29:22 -05:00
|
|
|
if (options['temporary']) {
|
|
|
|
$stories_show.filter('.NB-story-neutral').addClass('NB-story-hidden-visible');
|
|
|
|
} else {
|
|
|
|
$stories_show.filter('.NB-story-hidden-visible').removeClass('NB-story-hidden-visible');
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
} else if (unread_view_name == 'negative') {
|
|
|
|
$stories_show = $('.story,.NB-feed-story')
|
|
|
|
.filter('.NB-story-positive,.NB-story-neutral,.NB-story-negative');
|
|
|
|
$stories_hide = $();
|
2011-02-01 18:29:22 -05:00
|
|
|
if (options['temporary']) {
|
|
|
|
$stories_show.filter('.NB-story-negative,.NB-story-neutral:not(:visible)')
|
|
|
|
.addClass('NB-story-hidden-visible');
|
|
|
|
} else {
|
|
|
|
$stories_show.filter('.NB-story-hidden-visible').removeClass('NB-story-hidden-visible');
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-11-04 18:12:28 -07:00
|
|
|
if ((this.story_view == 'feed' || this.flags.page_view_showing_feed_view) &&
|
|
|
|
this.model.preference('feed_view_single_story')) {
|
2010-12-09 09:59:45 -05:00
|
|
|
// No need to show/hide feed view stories under single_story preference.
|
|
|
|
// If the user switches to feed/page, then no animation is happening
|
|
|
|
// and this will work anyway.
|
2011-05-03 12:19:53 -04:00
|
|
|
var active_story = this.active_story;
|
|
|
|
var $active_story = active_story && $('.NB-feed-story').filter(function() {
|
|
|
|
return $(this).data('story_id') == active_story.id;
|
|
|
|
});
|
|
|
|
if ($active_story && $active_story.length) {
|
|
|
|
$stories_show = $stories_show.not('.NB-feed-story').add($active_story);
|
|
|
|
$stories_hide = $stories_hide.add('.NB-feed-story').not($stories_show);
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!options['animate']) {
|
|
|
|
$stories_hide.css({'display': 'none'});
|
|
|
|
$stories_show.css({'display': 'block'});
|
2012-05-29 11:48:40 -07:00
|
|
|
// this.check_story_titles_last_story();
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
if (this.story_view == 'feed' && !this.model.preference('feed_view_single_story')) {
|
|
|
|
if ($stories_show.filter(':visible').length != $stories_show.length
|
2010-06-14 13:17:38 -04:00
|
|
|
|| $stories_hide.filter(':visible').length != 0) {
|
2011-01-04 19:27:00 -05:00
|
|
|
// NEWSBLUR.log(['Show/Hide stories', $stories_show.filter(':visible').length, $stories_show.length, $stories_hide.filter(':visible').length, $stories_hide.length]);
|
2010-06-14 13:17:38 -04:00
|
|
|
setTimeout(function() {
|
2010-12-08 20:53:45 -05:00
|
|
|
self.flags['feed_view_positions_calculated'] = false;
|
2012-06-02 16:33:44 -07:00
|
|
|
// self.prefetch_story_locations_in_feed_view();
|
2010-11-04 21:49:13 -04:00
|
|
|
}, 500);
|
2010-06-13 18:57:20 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['Showing correct stories', this.story_view, this.flags['feed_view_positions_calculated'], unread_view_name, $stories_show.length, $stories_hide.length]);
|
|
|
|
if (options['animate'] && options['follow']) {
|
2011-06-07 12:57:34 -04:00
|
|
|
if (this.model.preference('animations')) {
|
2011-09-28 09:31:30 -07:00
|
|
|
$stories_hide.slideUp(500, function() {
|
2012-05-29 11:48:40 -07:00
|
|
|
// self.check_story_titles_last_story();
|
2011-09-28 09:31:30 -07:00
|
|
|
});
|
2011-06-07 12:57:34 -04:00
|
|
|
$stories_show.slideDown(500);
|
|
|
|
} else {
|
|
|
|
$stories_hide.css({'display': 'none'});
|
|
|
|
$stories_show.css({'display': 'block'});
|
2012-05-29 11:48:40 -07:00
|
|
|
// this.check_story_titles_last_story();
|
2011-06-07 12:57:34 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
setTimeout(function() {
|
2011-01-03 19:18:27 -05:00
|
|
|
if (!self.active_story) return;
|
2010-12-30 18:37:29 -05:00
|
|
|
var $story = self.find_story_in_story_titles(self.active_story.id);
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['$story', $story]);
|
|
|
|
if ($story && $story.length && $story.is(':visible')) {
|
|
|
|
var story = self.active_story;
|
|
|
|
self.active_story = null; // Set is in open_story(), which allows it to scroll.
|
|
|
|
self.open_story(story, $story);
|
|
|
|
self.scroll_story_titles_to_show_selected_story_title($story);
|
|
|
|
}
|
2011-06-07 12:57:34 -04:00
|
|
|
}, this.model.preference('animations') ? 550 : 0);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ===================
|
|
|
|
// = Feed Refreshing =
|
|
|
|
// ===================
|
|
|
|
|
2010-12-24 11:00:30 -05:00
|
|
|
force_instafetch_stories: function(feed_id) {
|
|
|
|
var self = this;
|
|
|
|
feed_id = feed_id || this.active_feed;
|
2012-05-22 17:39:21 -07:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
feed.set({
|
|
|
|
fetched_once: false,
|
|
|
|
has_exception: false
|
|
|
|
});
|
2011-04-23 18:22:52 -04:00
|
|
|
|
2012-05-22 17:39:21 -07:00
|
|
|
this.model.save_exception_retry(feed_id, _.bind(this.force_feed_refresh, this, feed_id),
|
|
|
|
this.show_stories_error);
|
2010-12-24 11:00:30 -05:00
|
|
|
},
|
|
|
|
|
2011-11-07 08:27:59 -08:00
|
|
|
setup_socket_realtime_unread_counts: function(force) {
|
2012-03-30 16:03:07 -07:00
|
|
|
if (!force && NEWSBLUR.Globals.is_anonymous) return;
|
2012-04-02 18:48:41 -07:00
|
|
|
// if (!force && !NEWSBLUR.Globals.is_premium) return;
|
|
|
|
if (this.socket && !this.socket.socket.connected) {
|
|
|
|
this.socket.socket.connect();
|
|
|
|
} else if (force || !this.socket || !this.socket.socket.connected) {
|
|
|
|
var server = window.location.protocol + '//' + window.location.hostname + ':8888';
|
|
|
|
this.socket = this.socket || io.connect(server);
|
2011-11-06 12:21:27 -08:00
|
|
|
|
|
|
|
// this.socket.refresh_feeds = _.debounce(_.bind(this.force_feeds_refresh, this), 1000*10);
|
|
|
|
this.socket.on('connect', _.bind(function() {
|
2012-03-28 19:13:30 -07:00
|
|
|
var active_feeds = this.send_socket_active_feeds();
|
|
|
|
console.log(["Connected to real-time pubsub with " + active_feeds.length + " feeds."]);
|
2011-11-06 12:21:27 -08:00
|
|
|
this.socket.on('feed:update', _.bind(function(feed_id, message) {
|
2012-03-28 16:24:24 -07:00
|
|
|
console.log(['Real-time feed update', feed_id, message]);
|
2012-04-03 19:24:02 -07:00
|
|
|
this.force_feeds_refresh(false, false, feed_id);
|
2011-11-06 12:21:27 -08:00
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.flags.feed_refreshing_in_realtime = true;
|
|
|
|
this.setup_feed_refresh();
|
2012-05-09 11:45:52 -07:00
|
|
|
|
2012-05-09 12:26:34 -07:00
|
|
|
$('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating in real-time'));
|
2012-05-09 11:45:52 -07:00
|
|
|
$('.NB-module-content-account-realtime').attr('title', 'Reticulating splines').removeClass('NB-error');
|
2011-11-06 12:21:27 -08:00
|
|
|
}, this));
|
2012-03-28 19:13:30 -07:00
|
|
|
this.socket.on('disconnect', _.bind(function() {
|
|
|
|
console.log(["Lost connection to real-time pubsub. Falling back to polling."]);
|
2012-04-02 18:48:41 -07:00
|
|
|
this.flags.feed_refreshing_in_realtime = false;
|
2012-03-28 19:13:30 -07:00
|
|
|
this.setup_feed_refresh();
|
2012-05-09 12:26:34 -07:00
|
|
|
$('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating every 60 sec'));
|
2012-04-02 18:48:41 -07:00
|
|
|
$('.NB-module-content-account-realtime').attr('title', 'Polling for updates...').addClass('NB-error');
|
|
|
|
}, this));
|
|
|
|
this.socket.on('error', _.bind(function() {
|
|
|
|
console.log(["Can't connect to real-time pubsub."]);
|
|
|
|
this.flags.feed_refreshing_in_realtime = false;
|
2012-05-09 12:26:34 -07:00
|
|
|
$('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating every 60 sec'));
|
2012-04-02 18:48:41 -07:00
|
|
|
$('.NB-module-content-account-realtime').attr('title', 'Polling for updates...').addClass('NB-error');
|
|
|
|
_.delay(_.bind(this.setup_socket_realtime_unread_counts, this), 60*1000);
|
2012-03-28 19:13:30 -07:00
|
|
|
}, this));
|
2011-11-06 12:21:27 -08:00
|
|
|
}
|
2012-04-02 18:48:41 -07:00
|
|
|
|
2011-11-06 12:21:27 -08:00
|
|
|
},
|
|
|
|
|
2012-03-28 16:13:17 -07:00
|
|
|
send_socket_active_feeds: function() {
|
|
|
|
if (!this.socket) return;
|
|
|
|
|
2012-05-21 14:36:54 -07:00
|
|
|
var active_feeds = _.compact(this.model.feeds.map(function(feed) {
|
|
|
|
return feed.get('active') && feed.id;
|
2012-03-28 16:13:17 -07:00
|
|
|
}));
|
2012-04-03 19:24:02 -07:00
|
|
|
active_feeds = active_feeds.concat(this.model.social_feeds.pluck('id'));
|
2012-03-28 16:13:17 -07:00
|
|
|
|
2012-03-30 16:03:07 -07:00
|
|
|
if (active_feeds.length) {
|
|
|
|
this.socket.emit('subscribe:feeds', active_feeds, NEWSBLUR.Globals.username);
|
|
|
|
}
|
2012-03-28 19:13:30 -07:00
|
|
|
|
|
|
|
return active_feeds;
|
2012-03-28 16:13:17 -07:00
|
|
|
},
|
|
|
|
|
2011-01-30 21:48:17 -05:00
|
|
|
setup_feed_refresh: function(new_feeds) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2011-04-12 11:02:02 -04:00
|
|
|
var refresh_interval = this.constants.FEED_REFRESH_INTERVAL;
|
2012-05-22 17:39:21 -07:00
|
|
|
var feed_count = this.model.feeds.size();
|
2011-01-30 21:48:17 -05:00
|
|
|
|
2011-02-08 22:07:59 -05:00
|
|
|
if (!NEWSBLUR.Globals.is_premium) {
|
2011-04-12 18:23:04 -04:00
|
|
|
refresh_interval *= 2;
|
|
|
|
}
|
2011-11-01 15:31:25 -07:00
|
|
|
if (feed_count > 250) {
|
2011-04-12 18:23:04 -04:00
|
|
|
refresh_interval *= 4;
|
2011-02-08 22:07:59 -05:00
|
|
|
}
|
2011-11-01 15:31:25 -07:00
|
|
|
if (feed_count > 500) {
|
|
|
|
refresh_interval *= 1.5;
|
|
|
|
}
|
2012-04-02 18:48:41 -07:00
|
|
|
if (this.flags['feed_refreshing_in_realtime'] && !this.flags['has_unfetched_feeds'] &&
|
|
|
|
this.socket && this.socket.socket.connected) {
|
|
|
|
refresh_interval *= 20;
|
2011-11-06 12:21:27 -08:00
|
|
|
}
|
2011-11-01 00:20:06 -07:00
|
|
|
|
2011-11-01 15:31:25 -07:00
|
|
|
if (new_feeds && feed_count < 250) {
|
2012-04-23 17:02:50 -07:00
|
|
|
refresh_interval = (1000 * 60) * 1/6;
|
2011-11-01 15:31:25 -07:00
|
|
|
} else if (new_feeds && feed_count < 500) {
|
|
|
|
refresh_interval = (1000 * 60) * 1/4;
|
2011-01-30 21:48:17 -05:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2012-04-23 17:02:50 -07:00
|
|
|
// 10 second minimum
|
|
|
|
refresh_interval = Math.max(10*1000, refresh_interval);
|
|
|
|
|
2010-08-17 20:59:47 -04:00
|
|
|
clearInterval(this.flags.feed_refresh);
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
this.flags.feed_refresh = setInterval(function() {
|
2010-08-30 22:42:44 -04:00
|
|
|
if (!self.flags['pause_feed_refreshing']) {
|
|
|
|
self.model.refresh_feeds(_.bind(function(updated_feeds) {
|
|
|
|
self.post_feed_refresh(updated_feeds);
|
2012-03-30 16:03:07 -07:00
|
|
|
}, self), self.flags['has_unfetched_feeds'], null, function(e) {
|
|
|
|
console.log(["Feed refresh error", e]);
|
|
|
|
});
|
2010-08-30 22:42:44 -04:00
|
|
|
}
|
2011-02-06 15:04:21 -05:00
|
|
|
}, refresh_interval);
|
2012-03-28 19:13:30 -07:00
|
|
|
console.log(["Setting refresh interval to every " + refresh_interval/1000 + " seconds."]);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2012-02-23 14:03:11 -08:00
|
|
|
force_feed_refresh: function(feed_id, new_feed_id) {
|
2011-03-17 18:33:59 -04:00
|
|
|
var self = this;
|
|
|
|
feed_id = feed_id || this.active_feed;
|
2011-11-29 09:43:16 -08:00
|
|
|
new_feed_id = new_feed_id || feed_id;
|
2011-04-23 18:22:52 -04:00
|
|
|
|
2012-05-22 17:39:21 -07:00
|
|
|
this.force_feeds_refresh(function() {
|
|
|
|
// Open the feed back up if it is being refreshed and is still open.
|
2011-11-29 09:43:16 -08:00
|
|
|
if (self.active_feed == feed_id || self.active_feed == new_feed_id) {
|
2012-05-22 17:39:21 -07:00
|
|
|
self.open_feed(new_feed_id, {force: true});
|
2011-03-17 18:33:59 -04:00
|
|
|
}
|
2012-01-08 14:15:22 -08:00
|
|
|
}, true, new_feed_id, this.show_stories_error);
|
2011-03-17 18:33:59 -04:00
|
|
|
},
|
|
|
|
|
2012-01-08 14:15:22 -08:00
|
|
|
force_feeds_refresh: function(callback, replace_active_feed, feed_id, error_callback) {
|
2010-06-14 13:17:38 -04:00
|
|
|
if (callback) {
|
|
|
|
this.cache.refresh_callback = callback;
|
|
|
|
} else {
|
|
|
|
delete this.cache.refresh_callback;
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-08-30 22:42:44 -04:00
|
|
|
|
|
|
|
this.flags['pause_feed_refreshing'] = true;
|
|
|
|
this.model.refresh_feeds(_.bind(function(updated_feeds) {
|
2011-03-17 22:08:21 -04:00
|
|
|
this.post_feed_refresh(updated_feeds, replace_active_feed, feed_id);
|
2012-01-08 14:15:22 -08:00
|
|
|
}, this), this.flags['has_unfetched_feeds'], feed_id, error_callback);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2011-03-17 22:08:21 -04:00
|
|
|
post_feed_refresh: function(updated_feeds, replace_active_feed, single_feed_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var feeds = this.model.feeds;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (this.cache.refresh_callback && $.isFunction(this.cache.refresh_callback)) {
|
2010-10-10 23:36:09 -04:00
|
|
|
this.cache.refresh_callback(feeds);
|
2010-06-14 13:17:38 -04:00
|
|
|
delete this.cache.refresh_callback;
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2012-04-03 18:17:54 -07:00
|
|
|
|
|
|
|
this.flags['refresh_inline_feed_delay'] = false;
|
2012-05-22 17:39:21 -07:00
|
|
|
this.flags['pause_feed_refreshing'] = false;
|
2010-08-11 22:02:47 -04:00
|
|
|
this.check_feed_fetch_progress();
|
2011-11-01 00:20:06 -07:00
|
|
|
this.count_collapsed_unread_stories();
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ===================
|
|
|
|
// = Mouse Indicator =
|
|
|
|
// ===================
|
|
|
|
|
2010-12-09 09:59:45 -05:00
|
|
|
hide_mouse_indicator: function() {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-06-11 20:55:38 -04:00
|
|
|
|
2010-12-09 09:59:45 -05:00
|
|
|
if (!this.flags['mouse_indicator_hidden']) {
|
|
|
|
this.flags['mouse_indicator_hidden'] = true;
|
|
|
|
this.$s.$mouse_indicator.animate({'opacity': 0, 'left': -10}, {
|
|
|
|
'duration': 200,
|
|
|
|
'queue': false,
|
|
|
|
'complete': function() {
|
|
|
|
self.flags['mouse_indicator_hidden'] = true;
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-12-09 09:59:45 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
show_mouse_indicator: function() {
|
|
|
|
var self = this;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-09 09:59:45 -05:00
|
|
|
if (this.flags['mouse_indicator_hidden']) {
|
|
|
|
this.flags['mouse_indicator_hidden'] = false;
|
|
|
|
this.$s.$mouse_indicator.animate({'opacity': 1, 'left': 0}, {
|
|
|
|
'duration': 200,
|
|
|
|
'queue': false,
|
|
|
|
'complete': function() {
|
|
|
|
self.flags['mouse_indicator_hidden'] = false;
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-11 16:55:07 -04:00
|
|
|
handle_mouse_indicator_hover: function() {
|
|
|
|
var self = this;
|
|
|
|
var $callout = $('.NB-callout-mouse-indicator');
|
|
|
|
$('.NB-callout-text', $callout).text('Lock');
|
|
|
|
$callout.corner('5px');
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
this.$s.$mouse_indicator.hover(function() {
|
2010-06-11 20:55:38 -04:00
|
|
|
if (parseInt(self.model.preference('lock_mouse_indicator'), 10)) {
|
|
|
|
$('.NB-callout-text', $callout).text('Unlock');
|
|
|
|
} else {
|
|
|
|
$('.NB-callout-text', $callout).text('Lock');
|
|
|
|
}
|
2010-06-11 16:55:07 -04:00
|
|
|
self.flags['still_hovering_on_mouse_indicator'] = true;
|
|
|
|
setTimeout(function() {
|
|
|
|
if (self.flags['still_hovering_on_mouse_indicator']) {
|
|
|
|
$callout.css({
|
|
|
|
'display': 'block'
|
|
|
|
}).animate({
|
|
|
|
'opacity': 1,
|
|
|
|
'left': '20px'
|
|
|
|
}, {'duration': 200, 'queue': false});
|
|
|
|
}
|
|
|
|
}, 50);
|
|
|
|
}, function() {
|
|
|
|
self.flags['still_hovering_on_mouse_indicator'] = false;
|
|
|
|
$callout.animate({'opacity': 0, 'left': '-100px'}, {'duration': 200, 'queue': false});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-06-11 20:55:38 -04:00
|
|
|
lock_mouse_indicator: function() {
|
|
|
|
var self = this;
|
|
|
|
var $callout = $('.NB-callout-mouse-indicator');
|
|
|
|
|
|
|
|
if (parseInt(self.model.preference('lock_mouse_indicator'), 10)) {
|
|
|
|
self.model.preference('lock_mouse_indicator', 0);
|
|
|
|
$('.NB-callout-text', $callout).text('Unlocked');
|
|
|
|
} else {
|
|
|
|
self.model.preference('lock_mouse_indicator', this.cache.mouse_position_y);
|
|
|
|
$('.NB-callout-text', $callout).text('Locked');
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
self.flags['still_hovering_on_mouse_indicator'] = true;
|
|
|
|
$callout.fadeOut(200);
|
|
|
|
}, 500);
|
|
|
|
},
|
|
|
|
|
|
|
|
position_mouse_indicator: function() {
|
|
|
|
var position = parseInt(this.model.preference('lock_mouse_indicator'), 10);
|
|
|
|
if (position == 0) {
|
|
|
|
position = 50; // Start with a 50 offset
|
|
|
|
} else {
|
|
|
|
position = position - 8; // Compensate for mouse indicator height.
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
this.$s.$mouse_indicator.css('top', position);
|
2010-06-11 20:55:38 -04:00
|
|
|
},
|
|
|
|
|
2010-07-05 16:05:54 -04:00
|
|
|
// ==========================
|
|
|
|
// = Login and Signup Forms =
|
|
|
|
// ==========================
|
|
|
|
|
|
|
|
handle_login_and_signup_forms: function() {
|
|
|
|
var self = this;
|
|
|
|
var $hidden_inputs = $('.NB-signup-hidden');
|
2011-09-14 20:08:40 -07:00
|
|
|
var $signup_username = $('input[name=signup-username]');
|
2010-07-05 16:05:54 -04:00
|
|
|
|
|
|
|
$signup_username.bind('focus', function() {
|
|
|
|
$hidden_inputs.slideDown(300);
|
|
|
|
}).bind('blur', function() {
|
2011-04-02 19:41:22 -04:00
|
|
|
if ($signup_username.val().length < 1) {
|
2010-07-05 16:05:54 -04:00
|
|
|
$hidden_inputs.slideUp(300);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-06-30 12:17:22 -04:00
|
|
|
// ==================
|
|
|
|
// = Features Board =
|
|
|
|
// ==================
|
|
|
|
|
|
|
|
load_feature_page: function(direction) {
|
|
|
|
var self = this;
|
2011-03-04 12:45:31 -05:00
|
|
|
var $module = $('.NB-module-features');
|
2010-07-07 16:22:26 -04:00
|
|
|
var $next = $('.NB-module-features .NB-module-next-page');
|
|
|
|
var $previous = $('.NB-module-features .NB-module-previous-page');
|
2011-03-04 12:45:31 -05:00
|
|
|
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.addClass('NB-loading');
|
2010-06-30 12:17:22 -04:00
|
|
|
|
2012-01-23 10:16:50 -08:00
|
|
|
if (direction == -1 && this.counts['feature_page'] <= 0) {
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.removeClass('NB-loading');
|
2012-01-23 10:16:50 -08:00
|
|
|
this.counts['feature_page'] = 0;
|
2010-06-30 12:17:22 -04:00
|
|
|
return;
|
|
|
|
}
|
2010-06-30 21:57:24 -04:00
|
|
|
if (direction == 1 && this.flags['features_last_page']) {
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.removeClass('NB-loading');
|
2010-06-30 16:18:55 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-11 11:43:48 -04:00
|
|
|
this.model.get_features_page(this.counts['feature_page']+direction, function(features) {
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.removeClass('NB-loading');
|
2010-08-11 11:43:48 -04:00
|
|
|
self.counts['feature_page'] += direction;
|
2010-06-30 16:18:55 -04:00
|
|
|
|
2011-05-07 12:06:51 -04:00
|
|
|
var $table = $.make('table', { className: 'NB-features', cellSpacing: 0, cellPadding: 0 });
|
2010-06-30 16:18:55 -04:00
|
|
|
for (var f in features) {
|
2010-06-30 22:13:24 -04:00
|
|
|
if (f == 3) break;
|
2010-06-30 16:18:55 -04:00
|
|
|
var feature = features[f];
|
|
|
|
var $tr = $.make('tr', { className: 'NB-module-feature' }, [
|
2010-07-31 00:13:27 -04:00
|
|
|
$.make('td', { className: 'NB-module-feature-date' }, feature.date),
|
2010-06-30 16:18:55 -04:00
|
|
|
$.make('td', { className: 'NB-module-feature-description' }, feature.description)
|
|
|
|
]);
|
|
|
|
$table.append($tr);
|
|
|
|
}
|
2010-06-30 12:17:22 -04:00
|
|
|
|
2011-05-07 12:06:51 -04:00
|
|
|
$('.NB-module-features .NB-features').replaceWith($table);
|
2010-06-30 21:57:24 -04:00
|
|
|
|
|
|
|
var features_count = features.length;
|
|
|
|
if (features_count < 4) {
|
|
|
|
$next.addClass('NB-disabled');
|
|
|
|
self.flags['features_last_page'] = true;
|
|
|
|
} else {
|
|
|
|
$next.removeClass('NB-disabled');
|
|
|
|
self.flags['features_last_page'] = false;
|
|
|
|
}
|
2010-08-11 11:43:48 -04:00
|
|
|
if (self.counts['feature_page'] > 0) {
|
2010-06-30 21:57:24 -04:00
|
|
|
$previous.removeClass('NB-disabled');
|
|
|
|
} else {
|
|
|
|
$previous.addClass('NB-disabled');
|
|
|
|
}
|
|
|
|
|
2010-06-30 12:17:22 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2011-03-29 21:56:15 -04:00
|
|
|
setup_howitworks_hovers: function() {
|
|
|
|
var $page_indicators = $('.NB-module-howitworks .NB-module-page-indicator');
|
|
|
|
$page_indicators.bind('mouseenter', _.bind(function(e) {
|
|
|
|
var page = $(e.target).prevAll('.NB-module-page-indicator').length;
|
|
|
|
this.load_howitworks_page(page);
|
|
|
|
}, this));
|
|
|
|
},
|
|
|
|
|
2010-07-07 16:22:26 -04:00
|
|
|
load_howitworks_page: function(page) {
|
|
|
|
var self = this;
|
|
|
|
var $next = $('.NB-module-howitworks .NB-module-next-page');
|
|
|
|
var $previous = $('.NB-module-howitworks .NB-module-previous-page');
|
|
|
|
var $pages = $('.NB-howitworks-page');
|
|
|
|
var $page_indicators = $('.NB-module-howitworks .NB-module-page-indicator');
|
|
|
|
var pages_count = $pages.length;
|
|
|
|
|
|
|
|
if (page == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (page >= pages_count) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$pages.removeClass("NB-active");
|
|
|
|
$page_indicators.removeClass("NB-active");
|
|
|
|
$pages.eq(page).addClass("NB-active");
|
|
|
|
$page_indicators.eq(page).addClass("NB-active");
|
|
|
|
|
|
|
|
if (page >= pages_count - 1) {
|
|
|
|
$next.addClass('NB-disabled');
|
|
|
|
} else {
|
|
|
|
$next.removeClass('NB-disabled');
|
|
|
|
}
|
|
|
|
if (page <= 0) {
|
|
|
|
$previous.addClass('NB-disabled');
|
|
|
|
} else {
|
|
|
|
$previous.removeClass('NB-disabled');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-12 11:18:56 -07:00
|
|
|
// ===============================
|
|
|
|
// = Interactions and Activities =
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
load_interactions_page: function(direction) {
|
|
|
|
var self = this;
|
|
|
|
var $module = $('.NB-module-interactions');
|
|
|
|
|
|
|
|
$module.addClass('NB-loading');
|
|
|
|
direction = direction || 0;
|
2012-04-12 17:41:33 -07:00
|
|
|
|
2012-04-12 11:18:56 -07:00
|
|
|
this.model.load_interactions_page(this.counts['interactions_page']+direction,
|
|
|
|
function(resp) {
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
if (!resp) return;
|
|
|
|
$module.replaceWith(resp);
|
|
|
|
$module = $('.NB-module-interactions');
|
|
|
|
var page = $module[0].className.match(/NB-page-(\d+)/)[1];
|
|
|
|
self.counts['interactions_page'] = parseInt(page, 10);
|
|
|
|
self.load_javascript_elements_on_page();
|
|
|
|
}, function() {
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
load_activities_page: function(direction) {
|
|
|
|
var self = this;
|
|
|
|
var $module = $('.NB-module-activities');
|
2012-04-12 15:19:26 -07:00
|
|
|
|
2012-04-12 11:18:56 -07:00
|
|
|
$module.addClass('NB-loading');
|
|
|
|
direction = direction || 0;
|
|
|
|
|
|
|
|
this.model.load_activities_page(this.counts['activities_page']+direction,
|
|
|
|
function(resp) {
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
if (!resp) return;
|
|
|
|
$module.replaceWith(resp);
|
|
|
|
$module = $('.NB-module-activities');
|
|
|
|
var page = $module[0].className.match(/NB-page-(\d+)/)[1];
|
|
|
|
self.counts['activities_page'] = parseInt(page, 10);
|
|
|
|
self.load_javascript_elements_on_page();
|
|
|
|
}, function() {
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-04-12 15:19:26 -07:00
|
|
|
setup_interactions_module: function() {
|
|
|
|
clearInterval(this.locks.load_interactions_module);
|
|
|
|
if (!NEWSBLUR.Globals.debug) {
|
|
|
|
this.locks.load_interactions_module = setInterval(_.bind(function() {
|
|
|
|
this.load_interactions_page();
|
2012-04-12 17:41:33 -07:00
|
|
|
}, this), 5*60*1000);
|
2012-04-12 15:19:26 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setup_activities_module: function() {
|
|
|
|
clearInterval(this.locks.load_activities_module);
|
|
|
|
if (!NEWSBLUR.Globals.debug) {
|
|
|
|
this.locks.load_activities_module = setInterval(_.bind(function() {
|
|
|
|
this.load_activities_page();
|
2012-04-12 17:41:33 -07:00
|
|
|
}, this), 5*60*1000);
|
2012-04-12 15:19:26 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ========
|
|
|
|
// = FTUX =
|
|
|
|
// ========
|
2010-06-13 00:54:32 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
setup_ftux_add_feed_callout: function() {
|
2010-06-13 00:54:32 -04:00
|
|
|
var self = this;
|
2012-03-19 14:15:38 -07:00
|
|
|
if (this.flags['bouncing_callout']) return;
|
2010-06-13 00:54:32 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$('.NB-callout-ftux .NB-callout-text').text('First things first...');
|
|
|
|
$('.NB-callout-ftux').corner('5px');
|
|
|
|
$('.NB-callout-ftux').css({
|
|
|
|
'opacity': 0,
|
|
|
|
'display': 'block'
|
|
|
|
}).animate({
|
|
|
|
'opacity': 1,
|
2010-10-02 17:05:55 -04:00
|
|
|
'bottom': 6
|
2010-06-13 00:54:32 -04:00
|
|
|
}, {
|
2010-06-14 13:17:38 -04:00
|
|
|
'duration': 750,
|
|
|
|
'easing': 'easeInOutQuint'
|
|
|
|
}).each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
self.flags['bouncing_callout'] = setInterval(function() {
|
|
|
|
$this.animate({'bottom': '+=2px'}, {'duration': 200, 'easing': 'easeInOutQuint'})
|
|
|
|
.animate({'bottom': '+=0px'}, {'duration': 50})
|
|
|
|
.animate({'bottom': '-=2px'}, {'duration': 200, 'easing': 'easeInOutQuint'});
|
2010-06-13 18:57:20 -04:00
|
|
|
}, 1000);
|
|
|
|
});
|
2010-06-13 00:54:32 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
setup_ftux_signup_callout: function() {
|
|
|
|
var self = this;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!self.flags['bouncing_callout']) {
|
|
|
|
$('.NB-callout-ftux-signup .NB-callout-text').text('Signup');
|
|
|
|
$('.NB-callout-ftux-signup').corner('5px');
|
|
|
|
$('.NB-callout-ftux-signup').css({
|
|
|
|
'opacity': 0,
|
|
|
|
'display': 'block'
|
|
|
|
}).animate({
|
|
|
|
'opacity': 1,
|
|
|
|
'bottom': 36
|
|
|
|
}, {
|
|
|
|
'duration': 750,
|
|
|
|
'easing': 'easeInOutQuint'
|
|
|
|
}).each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
self.flags['bouncing_callout'] = setInterval(function() {
|
|
|
|
$this.animate({'bottom': '+=2px'}, {'duration': 200, 'easing': 'easeInOutQuint'})
|
|
|
|
.animate({'bottom': '+=0px'}, {'duration': 50})
|
|
|
|
.animate({'bottom': '-=2px'}, {'duration': 200, 'easing': 'easeInOutQuint'});
|
|
|
|
}, 10000);
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-08-17 20:59:47 -04:00
|
|
|
// =============================
|
|
|
|
// = Import from Google Reader =
|
|
|
|
// =============================
|
2012-03-05 19:18:40 -08:00
|
|
|
|
|
|
|
post_google_reader_connect: function(data) {
|
|
|
|
if (NEWSBLUR.intro) {
|
|
|
|
NEWSBLUR.intro.start_import_from_google_reader(data);
|
|
|
|
} else {
|
|
|
|
this.start_import_from_google_reader();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-08-17 20:59:47 -04:00
|
|
|
start_import_from_google_reader: function() {
|
2010-08-17 23:40:03 -04:00
|
|
|
var self = this;
|
|
|
|
var $progress = this.$s.$feeds_progress;
|
|
|
|
var $bar = $('.NB-progress-bar', $progress);
|
|
|
|
var percentage = 0;
|
2011-02-01 00:23:44 -05:00
|
|
|
this.flags['import_from_google_reader_working'] = true;
|
2010-08-17 23:40:03 -04:00
|
|
|
|
|
|
|
$('.NB-progress-title', $progress).text('Importing from Google Reader');
|
|
|
|
$('.NB-progress-counts', $progress).hide();
|
|
|
|
$('.NB-progress-percentage', $progress).hide();
|
|
|
|
$bar.progressbar({
|
|
|
|
value: percentage
|
|
|
|
});
|
|
|
|
|
2011-01-31 19:51:39 -05:00
|
|
|
this.animate_progress_bar($bar, 4);
|
2010-08-17 23:40:03 -04:00
|
|
|
|
|
|
|
this.model.start_import_from_google_reader($.rescope(this.finish_import_from_google_reader, this));
|
2010-11-24 15:01:35 -05:00
|
|
|
this.show_progress_bar();
|
2010-08-17 20:59:47 -04:00
|
|
|
},
|
2010-08-17 23:40:03 -04:00
|
|
|
|
2010-08-17 20:59:47 -04:00
|
|
|
finish_import_from_google_reader: function(e, data) {
|
2010-08-17 23:40:03 -04:00
|
|
|
var $progress = this.$s.$feeds_progress;
|
|
|
|
var $bar = $('.NB-progress-bar', $progress);
|
2011-02-01 00:23:44 -05:00
|
|
|
this.flags['import_from_google_reader_working'] = false;
|
|
|
|
clearTimeout(this.locks['animate_progress_bar']);
|
2010-08-17 23:40:03 -04:00
|
|
|
|
|
|
|
if (data.code >= 1) {
|
|
|
|
$bar.progressbar({value: 100});
|
2012-05-23 10:02:30 -07:00
|
|
|
NEWSBLUR.assets.load_feeds();
|
2010-08-17 23:40:03 -04:00
|
|
|
} else {
|
|
|
|
NEWSBLUR.log(['Import Error!', data]);
|
|
|
|
this.$s.$feed_link_loader.fadeOut(250);
|
|
|
|
$progress.addClass('NB-progress-error');
|
|
|
|
$('.NB-progress-title', $progress).text('Error importing Google Reader');
|
|
|
|
$('.NB-progress-link', $progress).html($.make('a', { href: NEWSBLUR.URLs['google-reader-authorize'], className: 'NB-splash-link' }, 'Try importing again'));
|
2011-11-01 09:25:59 -07:00
|
|
|
$('.left-center-footer').css('height', 'auto');
|
2010-08-17 23:40:03 -04:00
|
|
|
}
|
2010-08-17 20:59:47 -04:00
|
|
|
},
|
2010-08-17 23:40:03 -04:00
|
|
|
|
2010-08-17 20:59:47 -04:00
|
|
|
start_count_unreads_after_import: function() {
|
2010-08-17 23:40:03 -04:00
|
|
|
var self = this;
|
|
|
|
var $progress = this.$s.$feeds_progress;
|
|
|
|
var $bar = $('.NB-progress-bar', $progress);
|
|
|
|
var percentage = 0;
|
2011-01-31 19:51:39 -05:00
|
|
|
var feeds_count = _.keys(this.model.feeds).length;
|
2010-08-17 23:40:03 -04:00
|
|
|
|
2012-03-12 12:33:54 -07:00
|
|
|
if (!this.flags['pause_feed_refreshing'] || this.flags['has_unfetched_feeds']) return;
|
2010-12-31 14:35:00 -05:00
|
|
|
|
2011-02-01 00:23:44 -05:00
|
|
|
this.flags['count_unreads_after_import_working'] = true;
|
2010-08-18 08:10:24 -04:00
|
|
|
|
2010-08-17 23:40:03 -04:00
|
|
|
$('.NB-progress-title', $progress).text('Counting is difficult');
|
|
|
|
$('.NB-progress-counts', $progress).hide();
|
|
|
|
$('.NB-progress-percentage', $progress).hide();
|
|
|
|
$bar.progressbar({
|
|
|
|
value: percentage
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function() {
|
2011-02-01 00:23:44 -05:00
|
|
|
if (self.flags['count_unreads_after_import_working']) {
|
2011-02-06 15:04:21 -05:00
|
|
|
self.animate_progress_bar($bar, feeds_count / 10);
|
2010-08-17 23:40:03 -04:00
|
|
|
self.show_progress_bar();
|
|
|
|
}
|
|
|
|
}, 500);
|
2010-08-17 20:59:47 -04:00
|
|
|
},
|
2010-08-17 23:40:03 -04:00
|
|
|
|
2010-08-17 20:59:47 -04:00
|
|
|
finish_count_unreads_after_import: function(e, data) {
|
2010-08-17 23:40:03 -04:00
|
|
|
$('.NB-progress-bar', this.$s.$feeds_progress).progressbar({
|
|
|
|
value: 100
|
|
|
|
});
|
2011-02-01 00:23:44 -05:00
|
|
|
this.flags['count_unreads_after_import_working'] = false;
|
|
|
|
clearTimeout(this.locks['animate_progress_bar']);
|
2010-08-17 23:40:03 -04:00
|
|
|
this.$s.$feed_link_loader.fadeOut(250);
|
|
|
|
this.setup_feed_refresh();
|
|
|
|
if (!this.flags['has_unfetched_feeds']) {
|
|
|
|
this.hide_progress_bar();
|
|
|
|
}
|
2010-08-17 20:59:47 -04:00
|
|
|
},
|
2010-09-04 17:02:26 -04:00
|
|
|
|
2011-03-02 12:05:58 -05:00
|
|
|
// =====================
|
|
|
|
// = Recommended Feeds =
|
|
|
|
// =====================
|
|
|
|
|
|
|
|
load_recommended_feeds: function() {
|
2011-03-14 21:44:04 -04:00
|
|
|
// Reload recommended feeds every 10 minutes.
|
2011-04-12 11:02:02 -04:00
|
|
|
clearInterval(this.locks.load_recommended_feed);
|
|
|
|
this.locks.load_recommended_feed = setInterval(_.bind(function() {
|
2011-04-09 11:13:02 -04:00
|
|
|
this.load_recommended_feed(0, true);
|
2011-03-14 21:44:04 -04:00
|
|
|
}, this), 10*60*1000);
|
2011-03-02 12:05:58 -05:00
|
|
|
},
|
|
|
|
|
2012-04-19 22:38:00 -07:00
|
|
|
load_feed_in_tryfeed_view: function(feed_id, options) {
|
|
|
|
options = options || {};
|
|
|
|
feed = _.extend({
|
|
|
|
id : feed_id,
|
2012-04-19 22:43:07 -07:00
|
|
|
feed_id : feed_id,
|
2012-05-04 15:27:53 -07:00
|
|
|
feed_title : options.feed && options.feed.feed_title,
|
|
|
|
temp : true
|
2012-04-19 22:38:00 -07:00
|
|
|
}, options.feed);
|
2011-03-15 23:42:27 -04:00
|
|
|
var $tryfeed_container = this.$s.$tryfeed_header.closest('.NB-feeds-header-container');
|
2011-03-15 10:21:47 -04:00
|
|
|
|
2011-03-15 23:42:27 -04:00
|
|
|
this.reset_feed();
|
|
|
|
this.model.set_feed(feed_id, feed);
|
|
|
|
|
|
|
|
$('.NB-feeds-header-title', this.$s.$tryfeed_header).text(feed.feed_title);
|
2012-04-19 22:38:00 -07:00
|
|
|
$('.NB-feeds-header-icon', this.$s.$tryfeed_header).attr('src', $.favicon(feed));
|
2011-03-15 23:42:27 -04:00
|
|
|
|
|
|
|
$tryfeed_container.slideDown(350, _.bind(function() {
|
2012-04-19 22:38:00 -07:00
|
|
|
options.force = true;
|
|
|
|
options.try_feed = true;
|
|
|
|
this.open_feed(feed_id, options);
|
2011-03-15 23:42:27 -04:00
|
|
|
this.flags['showing_feed_in_tryfeed_view'] = true;
|
|
|
|
this.$s.$tryfeed_header.addClass('NB-selected');
|
|
|
|
}, this));
|
|
|
|
},
|
|
|
|
|
2012-04-11 15:20:57 -07:00
|
|
|
load_social_feed_in_tryfeed_view: function(social_feed, options) {
|
|
|
|
options = options || {};
|
|
|
|
if (_.isNumber(social_feed)) {
|
|
|
|
social_feed = this.model.get_feed('social:' + social_feed);
|
2012-04-30 12:20:04 -07:00
|
|
|
} else if (_.isString(social_feed)) {
|
|
|
|
social_feed = this.model.get_feed(social_feed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!social_feed) {
|
|
|
|
social_feed = this.model.add_social_feed(options.feed);
|
2012-04-11 15:20:57 -07:00
|
|
|
}
|
|
|
|
|
2012-03-14 12:38:59 -07:00
|
|
|
var $tryfeed_container = this.$s.$tryfeed_header.closest('.NB-feeds-header-container');
|
|
|
|
|
|
|
|
this.reset_feed();
|
2012-04-11 15:20:57 -07:00
|
|
|
|
2012-03-14 12:38:59 -07:00
|
|
|
$('.NB-feeds-header-title', this.$s.$tryfeed_header).text(social_feed.get('username'));
|
2012-05-21 14:36:54 -07:00
|
|
|
$('.NB-feeds-header-icon', this.$s.$tryfeed_header).attr('src', $.favicon(social_feed));
|
2012-03-14 12:38:59 -07:00
|
|
|
|
|
|
|
$tryfeed_container.slideDown(350, _.bind(function() {
|
2012-04-16 11:21:52 -07:00
|
|
|
this.open_social_stories(social_feed.get('id'), options);
|
2012-03-14 12:38:59 -07:00
|
|
|
this.switch_taskbar_view('feed');
|
2012-03-15 11:33:00 -07:00
|
|
|
this.flags['showing_social_feed_in_tryfeed_view'] = true;
|
2012-03-14 12:38:59 -07:00
|
|
|
this.$s.$tryfeed_header.addClass('NB-selected');
|
|
|
|
}, this));
|
|
|
|
},
|
|
|
|
|
2011-03-15 23:42:27 -04:00
|
|
|
hide_tryfeed_view: function() {
|
|
|
|
var $tryfeed_container = this.$s.$tryfeed_header.closest('.NB-feeds-header-container');
|
|
|
|
$tryfeed_container.slideUp(350);
|
|
|
|
this.$s.$story_taskbar.find('.NB-tryfeed-add').remove();
|
2012-03-15 11:33:00 -07:00
|
|
|
this.$s.$story_taskbar.find('.NB-tryfeed-follow').remove();
|
2011-03-15 23:42:27 -04:00
|
|
|
this.flags['showing_feed_in_tryfeed_view'] = false;
|
2012-03-15 11:33:00 -07:00
|
|
|
this.flags['showing_social_feed_in_tryfeed_view'] = false;
|
2011-03-15 23:42:27 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
show_tryfeed_add_button: function() {
|
2011-03-16 19:20:38 -04:00
|
|
|
if (this.$s.$story_taskbar.find('.NB-tryfeed-add:visible').length) return;
|
|
|
|
|
2011-03-15 23:42:27 -04:00
|
|
|
var $add = $.make('div', { className: 'NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-tryfeed-add NB-modal-submit-green NB-modal-submit-button' }, 'Add')
|
|
|
|
]).css({'opacity': 0});
|
|
|
|
this.$s.$story_taskbar.find('.NB-taskbar').append($add);
|
|
|
|
$add.animate({'opacity': 1}, {'duration': 600});
|
2011-03-11 20:05:41 -05:00
|
|
|
},
|
|
|
|
|
2012-04-19 22:38:00 -07:00
|
|
|
correct_tryfeed_title: function() {
|
|
|
|
var feed = this.model.get_feed(this.active_feed);
|
2012-05-21 14:36:54 -07:00
|
|
|
$('.NB-feeds-header-title', this.$s.$tryfeed_header).text(feed.get('feed_title'));
|
2012-04-19 22:38:00 -07:00
|
|
|
this.make_feed_title_in_stories(this.active_feed);
|
|
|
|
},
|
|
|
|
|
2012-03-15 11:33:00 -07:00
|
|
|
show_tryfeed_follow_button: function() {
|
|
|
|
if (this.$s.$story_taskbar.find('.NB-tryfeed-follow:visible').length) return;
|
|
|
|
|
|
|
|
var $add = $.make('div', { className: 'NB-modal-submit' }, [
|
|
|
|
$.make('div', { className: 'NB-tryfeed-follow NB-modal-submit-green NB-modal-submit-button' }, 'Follow')
|
|
|
|
]).css({'opacity': 0});
|
|
|
|
this.$s.$story_taskbar.find('.NB-taskbar').append($add);
|
|
|
|
$add.animate({'opacity': 1}, {'duration': 600});
|
|
|
|
},
|
|
|
|
|
2011-03-11 20:05:41 -05:00
|
|
|
add_recommended_feed: function(feed_id) {
|
2011-03-15 23:42:27 -04:00
|
|
|
var feed_address = this.model.get_feed(feed_id ? feed_id : this.active_feed).feed_address;
|
|
|
|
|
|
|
|
this.open_add_feed_modal({url: feed_address});
|
2011-03-11 20:05:41 -05:00
|
|
|
},
|
|
|
|
|
2012-03-15 11:33:00 -07:00
|
|
|
follow_user_in_tryfeed: function(feed_id) {
|
2012-03-15 14:00:44 -07:00
|
|
|
var self = this;
|
2012-03-15 11:33:00 -07:00
|
|
|
var socialsub = this.model.get_feed(feed_id);
|
2012-03-15 14:00:44 -07:00
|
|
|
this.model.follow_user(socialsub.user_id, function(data) {
|
2012-05-17 18:40:46 -07:00
|
|
|
NEWSBLUR.app.feed_list.make_social_feeds();
|
|
|
|
self.open_social_stories(feed_id);
|
2012-03-15 11:33:00 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2011-07-11 18:22:28 -07:00
|
|
|
approve_feed_in_moderation_queue: function(feed_id) {
|
2011-03-13 16:24:49 -04:00
|
|
|
var self = this;
|
2011-07-11 18:22:28 -07:00
|
|
|
var $module = $('.NB-module-recommended.NB-recommended-unmoderated');
|
|
|
|
$module.addClass('NB-loading');
|
2011-07-11 18:44:47 -07:00
|
|
|
var date = $('.NB-recommended-moderation-date').val();
|
2011-07-11 18:22:28 -07:00
|
|
|
|
2011-07-11 18:44:47 -07:00
|
|
|
this.model.approve_feed_in_moderation_queue(feed_id, date, function(resp) {
|
2011-07-11 18:22:28 -07:00
|
|
|
if (!resp) return;
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
$module.replaceWith(resp);
|
|
|
|
self.load_javascript_elements_on_page();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
decline_feed_in_moderation_queue: function(feed_id) {
|
|
|
|
var self = this;
|
|
|
|
var $module = $('.NB-module-recommended.NB-recommended-unmoderated');
|
|
|
|
$module.addClass('NB-loading');
|
|
|
|
|
|
|
|
this.model.decline_feed_in_moderation_queue(feed_id, function(resp) {
|
|
|
|
if (!resp) return;
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
$module.replaceWith(resp);
|
|
|
|
self.load_javascript_elements_on_page();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
load_recommended_feed: function(direction, refresh, unmoderated) {
|
2011-03-13 16:24:49 -04:00
|
|
|
var self = this;
|
2011-07-11 18:22:28 -07:00
|
|
|
var $module = unmoderated ?
|
|
|
|
$('.NB-module-recommended.NB-recommended-unmoderated') :
|
|
|
|
$('.NB-module-recommended:not(.NB-recommended-unmoderated)');
|
|
|
|
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.addClass('NB-loading');
|
|
|
|
direction = direction || 0;
|
2011-03-11 20:05:41 -05:00
|
|
|
|
2011-07-11 18:22:28 -07:00
|
|
|
this.model.load_recommended_feed(this.counts['recommended_feed_page']+direction,
|
|
|
|
!!refresh, unmoderated, function(resp) {
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.removeClass('NB-loading');
|
2012-04-12 11:18:56 -07:00
|
|
|
if (!resp) return;
|
2011-03-13 16:24:49 -04:00
|
|
|
$module.replaceWith(resp);
|
2012-04-12 11:18:56 -07:00
|
|
|
self.counts['recommended_feed_page'] += direction;
|
2011-03-13 16:24:49 -04:00
|
|
|
self.load_javascript_elements_on_page();
|
2012-04-12 11:18:56 -07:00
|
|
|
}, function() {
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
});
|
2011-03-11 20:05:41 -05:00
|
|
|
},
|
|
|
|
|
2011-04-24 22:47:20 -04:00
|
|
|
// ====================
|
|
|
|
// = Dashboard Graphs =
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
setup_dashboard_graphs: function() {
|
2012-04-06 18:28:26 -07:00
|
|
|
if (NEWSBLUR.Globals.debug) return;
|
|
|
|
|
2011-04-24 22:47:20 -04:00
|
|
|
// Reload dashboard graphs every 10 minutes.
|
|
|
|
clearInterval(this.locks.load_dashboard_graphs);
|
2012-02-14 10:34:10 -08:00
|
|
|
if (!NEWSBLUR.Globals.debug) {
|
|
|
|
this.locks.load_dashboard_graphs = setInterval(_.bind(function() {
|
|
|
|
this.load_dashboard_graphs();
|
|
|
|
}, this), NEWSBLUR.Globals.is_staff ? 60*1000 : 10*60*1000);
|
|
|
|
}
|
2011-04-24 22:47:20 -04:00
|
|
|
},
|
|
|
|
|
2011-12-18 18:03:40 -08:00
|
|
|
load_dashboard_graphs: function() {
|
2011-04-24 22:47:20 -04:00
|
|
|
var self = this;
|
2011-12-20 08:55:55 -08:00
|
|
|
var $module = $('.NB-module-site-stats');
|
2011-04-24 22:47:20 -04:00
|
|
|
$module.addClass('NB-loading');
|
|
|
|
|
|
|
|
this.model.load_dashboard_graphs(function(resp) {
|
|
|
|
$module.removeClass('NB-loading');
|
2012-04-12 11:18:56 -07:00
|
|
|
if (!resp) return;
|
2011-04-24 22:47:20 -04:00
|
|
|
$module.replaceWith(resp);
|
|
|
|
self.load_javascript_elements_on_page();
|
2012-04-12 11:18:56 -07:00
|
|
|
}, function() {
|
|
|
|
$module.removeClass('NB-loading');
|
|
|
|
});
|
2011-04-24 22:47:20 -04:00
|
|
|
},
|
|
|
|
|
2011-12-18 18:03:40 -08:00
|
|
|
|
|
|
|
setup_feedback_table: function() {
|
2012-04-06 18:28:26 -07:00
|
|
|
if (NEWSBLUR.Globals.debug) return;
|
|
|
|
|
2011-12-18 18:03:40 -08:00
|
|
|
// Reload feedback module every 10 minutes.
|
|
|
|
clearInterval(this.locks.load_feedback_table);
|
2012-02-14 10:34:10 -08:00
|
|
|
if (!NEWSBLUR.Globals.debug) {
|
|
|
|
this.locks.load_feedback_table = setInterval(_.bind(function() {
|
|
|
|
this.load_feedback_table();
|
|
|
|
}, this), NEWSBLUR.Globals.is_staff ? 60*1000 : 10*60*1000);
|
|
|
|
}
|
2011-12-18 18:03:40 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
load_feedback_table: function() {
|
|
|
|
var self = this;
|
|
|
|
var $module = $('.NB-feedback-table');
|
|
|
|
$module.addClass('NB-loading');
|
|
|
|
|
|
|
|
this.model.load_feedback_table(function(resp) {
|
|
|
|
if (!resp) return;
|
|
|
|
$module.removeClass('NB-loading');
|
2011-04-24 22:47:20 -04:00
|
|
|
$module.replaceWith(resp);
|
|
|
|
self.load_javascript_elements_on_page();
|
|
|
|
}, $.noop);
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ==========
|
|
|
|
// = Events =
|
|
|
|
// ==========
|
2010-08-17 23:40:03 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
handle_clicks: function(elem, e) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-09-12 13:50:27 -04:00
|
|
|
var stopPropagation = false;
|
2012-03-14 12:38:59 -07:00
|
|
|
var start = new Date;
|
2010-07-07 16:22:26 -04:00
|
|
|
|
2011-01-12 22:45:52 -05:00
|
|
|
// NEWSBLUR.log(['click', e, e.button]);
|
2010-09-12 13:50:27 -04:00
|
|
|
// Feeds ==========================================================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-10-31 18:04:25 -07:00
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .folder_title .NB-feedlist-collapse-icon' }, function($t, $p){
|
2010-12-12 20:06:32 -05:00
|
|
|
e.preventDefault();
|
|
|
|
stopPropagation = true;
|
2011-10-31 18:04:25 -07:00
|
|
|
var $folder = $t.closest('.folder_title');
|
2010-09-05 18:08:08 -07:00
|
|
|
if (!self.flags['sorting_feed']) {
|
|
|
|
self.collapse_folder($folder);
|
|
|
|
}
|
|
|
|
});
|
2011-10-31 18:04:25 -07:00
|
|
|
if (stopPropagation) return;
|
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .folder_title' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var $folder = $t.closest('li.folder');
|
|
|
|
var folder_title = $t.find('.folder_title_text').text();
|
|
|
|
self.open_river_stories($folder, folder_title);
|
|
|
|
});
|
2011-04-03 10:52:34 -04:00
|
|
|
|
|
|
|
// ============
|
|
|
|
// = Feed Bar =
|
|
|
|
// ============
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feedbar-mark-feed-read' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = parseInt($t.closest('.feed').data('id'), 10);
|
2010-06-14 13:17:38 -04:00
|
|
|
self.mark_feed_as_read(feed_id, $t);
|
|
|
|
$t.fadeOut(400);
|
|
|
|
});
|
2010-08-13 18:18:46 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feedbar-statistics' }, function($t, $p){
|
|
|
|
self.open_feed_statistics_modal();
|
|
|
|
});
|
2010-10-21 23:32:07 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feedbar-train-feed' }, function($t, $p){
|
2010-06-14 13:17:38 -04:00
|
|
|
e.preventDefault();
|
|
|
|
if (!$('.NB-task-manage').hasClass('NB-disabled')) {
|
2012-02-13 11:07:32 -08:00
|
|
|
self.open_feed_intelligence_modal(1, self.active_feed, !self.flags.social_view);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
});
|
2010-11-01 18:20:26 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-story-title-indicator' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_hidden_story_titles();
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
// = Feed Header ==================================================
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-feeds-header-starred' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_starred_stories();
|
|
|
|
});
|
2010-12-10 15:26:50 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feeds-header-river' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2010-12-12 22:52:15 -05:00
|
|
|
self.open_river_stories();
|
2010-12-10 15:26:50 -05:00
|
|
|
});
|
2010-12-02 11:09:09 -05:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// = Stories ======================================================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// = Taskbar ======================================================
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-task-add' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_add_feed_modal();
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-task-manage' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
2010-09-12 13:50:27 -04:00
|
|
|
self.show_manage_menu('site', $t);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
});
|
2011-02-22 19:11:29 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-taskbar-sidebar-toggle-close' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.close_sidebar();
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-taskbar-sidebar-toggle-open' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_sidebar();
|
|
|
|
});
|
2012-05-17 13:22:00 -07:00
|
|
|
|
|
|
|
// = Context Menu ================================================
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-open-input' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
self.flags['showing_confirm_input_on_manage_menu'] = true;
|
|
|
|
$t.select().blur(function() {
|
|
|
|
self.flags['showing_confirm_input_on_manage_menu'] = false;
|
|
|
|
});
|
|
|
|
});
|
2010-07-24 00:04:14 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-train' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
2010-09-12 13:50:27 -04:00
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
2010-09-17 12:40:42 -04:00
|
|
|
self.open_feed_intelligence_modal(1, feed_id, false);
|
2010-07-24 00:04:14 -04:00
|
|
|
}
|
|
|
|
});
|
2011-03-28 10:08:10 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-recommend' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
self.open_recommend_modal(feed_id);
|
|
|
|
});
|
2010-12-30 19:24:52 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-train' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
var feed_id = $t.closest('.NB-menu-manage').data('feed_id');
|
|
|
|
var story_id = $t.closest('.NB-menu-manage').data('story_id');
|
2011-03-06 21:33:06 -05:00
|
|
|
self.open_story_trainer(story_id, feed_id);
|
2010-12-30 19:24:52 -05:00
|
|
|
}
|
|
|
|
});
|
2010-08-01 23:47:40 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-trainer' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_trainer_modal();
|
|
|
|
}
|
|
|
|
});
|
2011-05-10 18:30:35 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-tutorial' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_tutorial_modal();
|
|
|
|
}
|
|
|
|
});
|
2012-03-02 17:51:28 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-intro' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_intro_modal();
|
|
|
|
}
|
|
|
|
});
|
2010-07-24 00:04:14 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-stats' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
2010-09-12 13:50:27 -04:00
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
NEWSBLUR.log(['statistics feed_id', feed_id]);
|
|
|
|
self.open_feed_statistics_modal(feed_id);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
});
|
2011-09-26 09:22:46 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-settings' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
2012-01-16 17:55:13 -08:00
|
|
|
self.open_feed_exception_modal(feed_id);
|
2011-09-26 09:22:46 -07:00
|
|
|
}
|
|
|
|
});
|
2010-10-10 20:14:31 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-reload' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
2010-12-24 11:00:30 -05:00
|
|
|
self.force_instafetch_stories(feed_id);
|
2010-10-10 20:14:31 -04:00
|
|
|
}
|
|
|
|
});
|
2010-09-14 20:49:28 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-delete' }, function($t, $p){
|
2010-07-01 00:29:26 -04:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2010-09-14 20:49:28 -04:00
|
|
|
if ($t.hasClass('NB-menu-manage-feed-delete-cancel') ||
|
|
|
|
$t.hasClass('NB-menu-manage-folder-delete-cancel')) {
|
2010-07-01 00:29:26 -04:00
|
|
|
self.hide_confirm_delete_menu_item();
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if ($t.hasClass('NB-menu-manage-feed-delete') ||
|
|
|
|
$t.hasClass('NB-menu-manage-folder-delete')) {
|
2010-07-01 00:29:26 -04:00
|
|
|
self.show_confirm_delete_menu_item();
|
2012-03-30 14:56:16 -07:00
|
|
|
} else if ($t.hasClass('NB-menu-manage-socialfeed-delete-cancel')) {
|
|
|
|
self.hide_confirm_unfollow_menu_item();
|
|
|
|
} else if ($t.hasClass('NB-menu-manage-socialfeed-delete')) {
|
|
|
|
self.show_confirm_unfollow_menu_item();
|
2010-07-01 00:29:26 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-delete-confirm' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2010-09-12 13:50:27 -04:00
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
2010-09-14 20:49:28 -04:00
|
|
|
var $feed = $t.parents('.NB-menu-manage').data('$feed');
|
|
|
|
self.manage_menu_delete_feed(feed_id, $feed);
|
|
|
|
});
|
2012-03-30 14:56:16 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-socialfeed-delete-confirm' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
var $feed = $t.parents('.NB-menu-manage').data('$feed');
|
|
|
|
self.manage_menu_unfollow_feed(feed_id, $feed);
|
|
|
|
});
|
2010-09-14 20:49:28 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-delete-confirm' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
|
|
|
self.manage_menu_delete_folder(folder_name, $folder);
|
2010-07-01 00:29:26 -04:00
|
|
|
});
|
2011-09-04 15:42:13 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-move' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
var $feed = $t.parents('.NB-menu-manage').data('$feed');
|
|
|
|
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
|
|
|
|
|
|
|
if ($t.hasClass('NB-menu-manage-feed-move-cancel') ||
|
|
|
|
$t.hasClass('NB-menu-manage-folder-move-cancel')) {
|
|
|
|
self.hide_confirm_move_menu_item();
|
|
|
|
} else {
|
|
|
|
self.show_confirm_move_menu_item(feed_id || folder_name, $feed || $folder);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-move-save' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
2011-11-07 20:50:46 -08:00
|
|
|
self.manage_menu_move_folder(folder_name, $folder);
|
2011-09-04 15:42:13 -07:00
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-move-save' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
var $feed = $t.parents('.NB-menu-manage').data('$feed');
|
|
|
|
self.manage_menu_move_feed(feed_id, $feed);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-move-confirm' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-move-confirm' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2010-12-11 11:26:21 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-rename' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
if ($t.hasClass('NB-menu-manage-feed-rename-cancel') ||
|
|
|
|
$t.hasClass('NB-menu-manage-folder-rename-cancel')) {
|
|
|
|
self.hide_confirm_rename_menu_item();
|
|
|
|
} else {
|
|
|
|
self.show_confirm_rename_menu_item();
|
|
|
|
}
|
|
|
|
});
|
2010-12-11 12:41:24 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-rename-save' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
|
|
|
self.manage_menu_rename_folder(folder_name, $folder);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-rename-save' }, function($t, $p){
|
2010-12-11 11:26:21 -05:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
var $feed = $t.parents('.NB-menu-manage').data('$feed');
|
|
|
|
self.manage_menu_rename_feed(feed_id, $feed);
|
|
|
|
});
|
2010-12-11 12:41:24 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-rename-confirm' }, function($t, $p){
|
2010-12-11 11:26:21 -05:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2010-12-11 12:41:24 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-rename-confirm' }, function($t, $p){
|
2010-12-11 11:26:21 -05:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2012-04-24 10:38:23 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-share' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
if ($t.hasClass('NB-menu-manage-story-share-cancel')) {
|
|
|
|
self.hide_confirm_story_share_menu_item();
|
|
|
|
} else {
|
|
|
|
self.show_confirm_story_share_menu_item();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-share-confirm' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2010-07-24 00:04:14 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-mark-read' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2010-09-12 13:50:27 -04:00
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
self.mark_feed_as_read(feed_id);
|
2010-07-24 00:04:14 -04:00
|
|
|
});
|
2010-09-16 10:35:36 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-mark-read' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
|
|
|
self.mark_folder_as_read(folder_name, $folder);
|
|
|
|
});
|
2012-05-24 11:54:10 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-folder-subscribe' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var folder_name = $t.parents('.NB-menu-manage').data('folder_name');
|
|
|
|
var $folder = $t.parents('.NB-menu-manage').data('$folder');
|
|
|
|
self.open_add_feed_modal({folder_title: folder_name});
|
|
|
|
});
|
2012-05-17 13:22:00 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-open' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!self.flags['showing_confirm_input_on_manage_menu']) {
|
|
|
|
var story_id = $t.closest('.NB-menu-manage-story').data('story_id');
|
2012-05-25 20:52:30 -07:00
|
|
|
var story = self.model.get_story(story_id);
|
|
|
|
story.story_view.open_story_in_new_tab();
|
2012-05-17 13:22:00 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-star' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var story_id = $t.closest('.NB-menu-manage-story').data('story_id');
|
2012-05-25 20:52:30 -07:00
|
|
|
var story_view = NEWSBLUR.assets.get_story(story_id).story_view;
|
|
|
|
story_view.star_story();
|
2012-05-17 13:22:00 -07:00
|
|
|
});
|
2010-09-14 20:49:28 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-site-mark-read' }, function($t, $p){
|
2010-06-14 13:17:38 -04:00
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_mark_read_modal();
|
|
|
|
}
|
|
|
|
});
|
2012-04-17 15:37:01 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-social-profile' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
self.open_social_profile_modal(feed_id);
|
|
|
|
});
|
2010-10-10 23:36:09 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-keyboard' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_keyboard_shortcuts_modal();
|
|
|
|
}
|
|
|
|
});
|
2010-09-13 00:38:25 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-exception' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
2012-01-16 17:55:13 -08:00
|
|
|
self.open_feed_exception_modal(feed_id);
|
2010-09-13 00:38:25 -04:00
|
|
|
});
|
2011-01-20 09:57:23 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-goodies' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_goodies_modal();
|
|
|
|
}
|
|
|
|
});
|
2011-12-22 13:36:03 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-friends' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_friends_modal();
|
|
|
|
}
|
|
|
|
});
|
2012-04-04 16:09:01 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-profile-editor' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_profile_editor_modal();
|
|
|
|
}
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-preferences' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_preferences_modal();
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
2011-07-27 09:33:34 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-account' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_account_modal();
|
|
|
|
}
|
|
|
|
});
|
2010-09-24 01:08:03 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feedchooser' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_feedchooser_modal();
|
|
|
|
}
|
|
|
|
});
|
2010-10-17 17:25:10 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-account-upgrade' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_feedchooser_modal();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-account-train' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_trainer_modal();
|
|
|
|
}
|
|
|
|
});
|
2011-12-21 18:23:53 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-friends-button' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_friends_modal();
|
|
|
|
}
|
|
|
|
});
|
2011-05-10 18:30:35 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-launch-tutorial' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_tutorial_modal();
|
|
|
|
}
|
|
|
|
});
|
2012-03-02 17:51:28 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-launch-intro' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.open_intro_modal();
|
|
|
|
}
|
|
|
|
});
|
2011-12-24 00:30:37 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-gettingstarted-hide' }, function($t, $p){
|
2011-05-13 10:15:56 -04:00
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
2011-12-24 00:30:37 -08:00
|
|
|
self.check_hide_getting_started(true);
|
2011-05-13 10:15:56 -04:00
|
|
|
}
|
|
|
|
});
|
2011-08-07 21:38:09 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-mobile-hide' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.hide_mobile();
|
|
|
|
}
|
|
|
|
});
|
2010-12-30 19:24:52 -05:00
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-unread' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-05-25 20:52:30 -07:00
|
|
|
var story_id = $t.closest('.NB-menu-manage').data('story_id');
|
|
|
|
var story = self.model.get_story(story_id);
|
|
|
|
NEWSBLUR.assets.stories.mark_unread(story);
|
2010-12-30 19:24:52 -05:00
|
|
|
});
|
|
|
|
|
2011-02-02 14:10:24 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.task_view_page:not(.NB-task-return)' }, function($t, $p){
|
2010-06-14 13:17:38 -04:00
|
|
|
e.preventDefault();
|
2011-02-02 14:10:24 -05:00
|
|
|
self.switch_taskbar_view('page');
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.task_view_feed' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.switch_taskbar_view('feed');
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.task_view_story' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.switch_taskbar_view('story');
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
2011-02-02 14:10:24 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-task-return' }, function($t, $p){
|
2010-06-14 13:17:38 -04:00
|
|
|
e.preventDefault();
|
2010-12-06 10:41:24 -05:00
|
|
|
self.load_feed_iframe();
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
2012-01-16 17:55:13 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-task-feed-settings' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_feed_exception_modal();
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.task_button_story.task_story_next_unread' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2011-04-30 22:09:43 -04:00
|
|
|
self.open_next_unread_story_across_feeds();
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.task_button_story.task_story_next' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_story(1);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.task_button_story.task_story_previous' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_previous_story();
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.task_button_signup' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_splash_page();
|
|
|
|
});
|
2012-02-08 18:11:08 -08:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-intelligence-slider-control' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var unread_value;
|
|
|
|
if ($t.hasClass('NB-intelligence-slider-red')) {
|
|
|
|
unread_value = -1;
|
|
|
|
} else if ($t.hasClass('NB-intelligence-slider-yellow')) {
|
|
|
|
unread_value = 0;
|
|
|
|
} else if ($t.hasClass('NB-intelligence-slider-green')) {
|
|
|
|
unread_value = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.switch_feed_view_unread_view(unread_value);
|
|
|
|
self.slide_intelligence_slider(unread_value);
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2011-03-04 12:27:31 -05:00
|
|
|
// =====================
|
|
|
|
// = Recommended Feeds =
|
|
|
|
// =====================
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-recommended-statistics' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = $t.closest('.NB-recommended').data('feed-id');
|
2011-03-04 12:45:31 -05:00
|
|
|
$('.NB-module-recommended').addClass('NB-loading');
|
2011-03-04 12:27:31 -05:00
|
|
|
self.model.load_canonical_feed(feed_id, function() {
|
2011-03-04 12:45:31 -05:00
|
|
|
$('.NB-module-recommended').removeClass('NB-loading');
|
2011-03-04 12:27:31 -05:00
|
|
|
self.open_feed_statistics_modal(feed_id);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-recommended-intelligence' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = $t.closest('.NB-recommended').data('feed-id');
|
2011-03-04 12:45:31 -05:00
|
|
|
$('.NB-module-recommended').addClass('NB-loading');
|
2011-03-04 12:27:31 -05:00
|
|
|
self.model.load_canonical_feed(feed_id, function() {
|
2011-03-04 12:45:31 -05:00
|
|
|
$('.NB-module-recommended').removeClass('NB-loading');
|
2011-03-04 12:27:31 -05:00
|
|
|
self.open_feed_intelligence_modal(1, feed_id);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-recommended-try' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-04-19 22:38:00 -07:00
|
|
|
var $recommended_feeds = $('.NB-module-recommended');
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = $t.closest('.NB-recommended').data('feed-id');
|
2012-05-04 15:27:53 -07:00
|
|
|
self.open_feed(feed_id, {'feed': {
|
2012-04-19 22:43:07 -07:00
|
|
|
'feed_title': $('.NB-recommended-title', $recommended_feeds).text(),
|
2012-05-04 15:27:53 -07:00
|
|
|
'favicon_url': $('.NB-recommended-favicon', $recommended_feeds).attr('src'),
|
|
|
|
'temp': true
|
2012-04-19 22:38:00 -07:00
|
|
|
}});
|
2011-03-04 12:27:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-recommended-add' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = $t.closest('.NB-recommended').data('feed-id');
|
2011-03-11 20:05:41 -05:00
|
|
|
$('.NB-module-recommended').addClass('NB-loading');
|
|
|
|
self.model.load_canonical_feed(feed_id, function() {
|
|
|
|
$('.NB-module-recommended').removeClass('NB-loading');
|
|
|
|
self.add_recommended_feed(feed_id);
|
|
|
|
});
|
2011-03-04 12:27:31 -05:00
|
|
|
});
|
|
|
|
|
2011-07-11 18:22:28 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-recommended-decline' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = $t.closest('.NB-recommended').data('feed-id');
|
2011-07-11 18:22:28 -07:00
|
|
|
self.decline_feed_in_moderation_queue(feed_id);
|
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-recommended-approve' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = $t.closest('.NB-recommended').data('feed-id');
|
2011-07-11 18:22:28 -07:00
|
|
|
self.approve_feed_in_moderation_queue(feed_id);
|
|
|
|
});
|
|
|
|
|
2011-03-04 12:27:31 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-recommended .NB-module-next-page' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2011-03-13 16:24:49 -04:00
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
2011-07-11 18:22:28 -07:00
|
|
|
var unmoderated = $t.closest('.NB-module-recommended').hasClass('NB-recommended-unmoderated');
|
|
|
|
self.load_recommended_feed(1, false, unmoderated);
|
2011-03-13 16:24:49 -04:00
|
|
|
}
|
2011-03-04 12:27:31 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-recommended .NB-module-previous-page' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
2011-07-11 18:22:28 -07:00
|
|
|
var unmoderated = $t.closest('.NB-module-recommended').hasClass('NB-recommended-unmoderated');
|
|
|
|
self.load_recommended_feed(-1, false, unmoderated);
|
2011-03-04 12:27:31 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-03-15 23:42:27 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-tryfeed-add' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = self.active_feed;
|
|
|
|
self.add_recommended_feed(feed_id);
|
|
|
|
});
|
2012-03-15 11:33:00 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-tryfeed-follow' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = self.active_feed;
|
|
|
|
self.follow_user_in_tryfeed(feed_id);
|
|
|
|
});
|
2011-03-15 23:42:27 -04:00
|
|
|
|
2012-04-10 17:28:00 -07:00
|
|
|
// = Interactions Module ==========================================
|
|
|
|
|
2012-04-16 11:21:52 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-interaction-username, .NB-interaction-follow .NB-interaction-photo' }, function($t, $p){
|
2012-04-10 17:28:00 -07:00
|
|
|
e.preventDefault();
|
|
|
|
var user_id = $t.data('userId');
|
|
|
|
var username = $t.closest('.NB-interaction').find('.NB-interaction-username').text();
|
|
|
|
self.model.add_user_profiles([{user_id: user_id, username: username}]);
|
|
|
|
self.open_social_profile_modal(user_id);
|
|
|
|
});
|
2012-04-16 11:21:52 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-interaction-comment_reply .NB-interaction-reply-content, .NB-interaction-reply_reply .NB-interaction-reply-content, .NB-interaction-comment_reply .NB-interaction-photo' }, function($t, $p){
|
2012-04-11 15:20:57 -07:00
|
|
|
e.preventDefault();
|
2012-04-19 22:38:00 -07:00
|
|
|
var $interaction = $t.closest('.NB-interaction');
|
2012-05-09 21:11:48 -07:00
|
|
|
var feed_id = 'social:' + $interaction.data('feedId');
|
2012-04-19 22:38:00 -07:00
|
|
|
var story_id = $interaction.data('contentId');
|
2012-05-10 22:11:06 -07:00
|
|
|
var user_id = $interaction.data('userId');
|
2012-04-19 22:38:00 -07:00
|
|
|
var username = $interaction.data('username');
|
2012-04-19 19:09:31 -07:00
|
|
|
|
|
|
|
self.close_social_profile();
|
2012-04-16 11:21:52 -07:00
|
|
|
if (self.model.get_feed(feed_id)) {
|
2012-04-11 15:20:57 -07:00
|
|
|
self.open_social_stories(feed_id, {'story_id': story_id});
|
|
|
|
} else {
|
2012-04-16 11:21:52 -07:00
|
|
|
var socialsub = self.model.add_social_feed({
|
|
|
|
id: feed_id,
|
|
|
|
user_id: user_id,
|
|
|
|
username: username
|
|
|
|
});
|
|
|
|
self.load_social_feed_in_tryfeed_view(socialsub, {'story_id': story_id});
|
2012-04-11 15:20:57 -07:00
|
|
|
}
|
|
|
|
});
|
2012-04-10 17:28:00 -07:00
|
|
|
|
2012-04-11 15:53:53 -07:00
|
|
|
// = Activities Module ==========================================
|
|
|
|
|
2012-05-10 22:29:23 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-interaction-starred-story-title,.NB-activity-star .NB-interaction-photo' }, function($t, $p){
|
2012-04-11 15:53:53 -07:00
|
|
|
e.preventDefault();
|
|
|
|
var story_id = $t.closest('.NB-interaction').data('contentId');
|
2012-04-19 19:09:31 -07:00
|
|
|
|
|
|
|
self.close_social_profile();
|
2012-04-11 15:53:53 -07:00
|
|
|
self.open_starred_stories({'story_id': story_id});
|
|
|
|
});
|
2012-05-10 22:29:23 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-interaction-feed-title,.NB-activity-feedsub .NB-interaction-photo' }, function($t, $p){
|
2012-04-11 15:53:53 -07:00
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.closest('.NB-interaction').data('feedId');
|
|
|
|
|
2012-04-19 19:09:31 -07:00
|
|
|
self.close_social_profile();
|
2012-05-04 15:27:53 -07:00
|
|
|
self.open_feed(feed_id);
|
2012-04-11 15:53:53 -07:00
|
|
|
});
|
2012-05-10 22:29:23 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-interaction-sharedstory .NB-interaction-sharedstory-title, .NB-interaction-sharedstory .NB-interaction-sharedstory-content, .NB-interaction-sharedstory .NB-interaction-photo, .NB-activity-sharedstory .NB-interaction-sharedstory-title, .NB-activity-sharedstory .NB-interaction-sharedstory-content, .NB-activity-sharedstory .NB-interaction-photo' }, function($t, $p){
|
2012-04-16 11:21:52 -07:00
|
|
|
e.preventDefault();
|
2012-04-19 22:38:00 -07:00
|
|
|
var $interaction = $t.closest('.NB-interaction');
|
|
|
|
var feed_id = $interaction.data('feedId');
|
|
|
|
var story_id = $interaction.data('contentId');
|
|
|
|
var user_id = $interaction.data('userId');
|
2012-04-19 19:09:31 -07:00
|
|
|
|
|
|
|
self.close_social_profile();
|
2012-04-16 11:21:52 -07:00
|
|
|
if ($t.hasClass('NB-interaction-sharedstory-content')) {
|
|
|
|
self.open_social_stories('social:'+user_id, {'story_id': story_id});
|
|
|
|
} else {
|
2012-05-04 15:27:53 -07:00
|
|
|
self.open_feed(feed_id, {'story_id': story_id, 'feed': {
|
2012-04-19 22:38:00 -07:00
|
|
|
'feed_title': $('.NB-interaction-sharedstory-title', $interaction).text(),
|
|
|
|
'favicon_url': $('.NB-interaction-photo', $interaction).attr('src')
|
|
|
|
}});
|
2012-04-16 11:21:52 -07:00
|
|
|
}
|
|
|
|
});
|
2012-05-10 22:29:23 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-activity-comment_reply .NB-interaction-reply-content, .NB-activity-comment_reply .NB-interaction-photo' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var $interaction = $t.closest('.NB-interaction');
|
|
|
|
var feed_id = 'social:' + $interaction.data('userId');
|
|
|
|
var story_id = $interaction.data('contentId');
|
|
|
|
var user_id = $interaction.data('userId');
|
|
|
|
var username = $interaction.data('username');
|
|
|
|
|
|
|
|
self.close_social_profile();
|
|
|
|
if (self.model.get_feed(feed_id)) {
|
|
|
|
self.open_social_stories(feed_id, {'story_id': story_id});
|
|
|
|
} else {
|
|
|
|
var socialsub = self.model.add_social_feed({
|
|
|
|
id: feed_id,
|
|
|
|
user_id: user_id,
|
|
|
|
username: username
|
|
|
|
});
|
|
|
|
self.load_social_feed_in_tryfeed_view(socialsub, {'story_id': story_id});
|
|
|
|
}
|
|
|
|
});
|
2012-04-16 11:21:52 -07:00
|
|
|
|
2012-04-11 15:53:53 -07:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// = One-offs =====================================================
|
|
|
|
|
2010-07-07 16:22:26 -04:00
|
|
|
var clicked = false;
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '#mouse-indicator' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.lock_mouse_indicator();
|
|
|
|
});
|
2010-08-17 23:40:03 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-progress-close' }, function($t, $p){
|
2010-08-11 22:02:47 -04:00
|
|
|
e.preventDefault();
|
|
|
|
self.hide_unfetched_feed_progress(true);
|
|
|
|
});
|
2010-07-07 16:22:26 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-next-page', childOf: '.NB-module-features' }, function($t, $p){
|
2010-06-30 12:17:22 -04:00
|
|
|
e.preventDefault();
|
|
|
|
self.load_feature_page(1);
|
|
|
|
});
|
2010-07-07 16:22:26 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-previous-page', childOf: '.NB-module-features' }, function($t, $p){
|
2010-06-30 12:17:22 -04:00
|
|
|
e.preventDefault();
|
|
|
|
self.load_feature_page(-1);
|
|
|
|
});
|
2010-07-07 16:22:26 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-next-page', childOf: '.NB-module-howitworks' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var page = $('.NB-howitworks-page.NB-active').prevAll('.NB-howitworks-page').length;
|
|
|
|
self.load_howitworks_page(page+1);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-previous-page', childOf: '.NB-module-howitworks' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var page = $('.NB-howitworks-page.NB-active').prevAll('.NB-howitworks-page').length;
|
|
|
|
self.load_howitworks_page(page-1);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-page-indicator', childOf: '.NB-module-howitworks' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var page = $t.prevAll('.NB-module-page-indicator').length;
|
|
|
|
self.load_howitworks_page(page);
|
|
|
|
});
|
2012-04-12 11:18:56 -07:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-next-page', childOf: '.NB-module-interactions' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.load_interactions_page(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-previous-page', childOf: '.NB-module-interactions' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.load_interactions_page(-1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-next-page', childOf: '.NB-module-activities' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.load_activities_page(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-module-previous-page', childOf: '.NB-module-activities' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$t.hasClass('NB-disabled')) {
|
|
|
|
self.load_activities_page(-1);
|
|
|
|
}
|
|
|
|
});
|
2010-09-02 20:41:53 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-splash-meta-about' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
NEWSBLUR.about = new NEWSBLUR.About();
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-splash-meta-faq' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
NEWSBLUR.faq = new NEWSBLUR.Faq();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-07-07 16:22:26 -04:00
|
|
|
|
2012-04-25 12:18:26 -07:00
|
|
|
// NEWSBLUR.log(['End', (new Date()) - start]);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
handle_dblclicks: function(elem, e) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
var stopPropagation = false;
|
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .NB-feedlist-manage-icon' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
stopPropagation = true;
|
|
|
|
});
|
|
|
|
if (stopPropagation) return;
|
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .feed.NB-feed-exception' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
exception = true;
|
|
|
|
});
|
|
|
|
if (stopPropagation) return;
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '#story_titles .story' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
// NEWSBLUR.log(['Story dblclick', $t]);
|
|
|
|
var story_id = $('.story_id', $t).text();
|
|
|
|
var story = self.model.get_story(story_id);
|
2010-12-07 09:52:14 -05:00
|
|
|
self.open_story_in_story_view(story, true);
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .feed' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
// NEWSBLUR.log(['Feed dblclick', $('.feed_id', $t), $t]);
|
2012-02-10 19:33:31 -08:00
|
|
|
var feed_id = parseInt($t.data('id'), 10);
|
2010-06-14 13:17:38 -04:00
|
|
|
self.open_feed_link(feed_id, $t);
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-31 14:35:00 -05:00
|
|
|
handle_rightclicks: function(elem, e) {
|
|
|
|
var self = this;
|
|
|
|
|
2011-02-01 00:51:19 -05:00
|
|
|
// NEWSBLUR.log(['right click', e.button, e, e.target, e.currentTarget]);
|
2010-12-31 14:35:00 -05:00
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-arrow' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
handle_scroll_feed_iframe: function(elem, e) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var self = this;
|
|
|
|
if (this.story_view == 'page'
|
|
|
|
&& !this.flags['page_view_showing_feed_view']
|
|
|
|
&& !this.flags['scrolling_by_selecting_story_title']) {
|
2010-12-06 10:41:24 -05:00
|
|
|
var from_top = this.cache.mouse_position_y + this.$s.$feed_iframe.contents().scrollTop();
|
2010-06-14 13:17:38 -04:00
|
|
|
var positions = this.cache.iframe_story_positions_keys;
|
|
|
|
var closest = $.closest(from_top, positions);
|
|
|
|
var story = this.cache.iframe_story_positions[positions[closest]];
|
|
|
|
// NEWSBLUR.log(['Scroll iframe', from_top, closest, positions[closest], this.cache.iframe_story_positions[positions[closest]]]);
|
|
|
|
this.navigate_story_titles_to_story(story);
|
2010-07-24 18:22:23 -04:00
|
|
|
if (!this.flags.iframe_scroll_snap_back_prepared) {
|
|
|
|
this.iframe_scroll = from_top - this.cache.mouse_position_y;
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
this.flags.iframe_scroll_snap_back_prepared = false;
|
|
|
|
// NEWSBLUR.log(['Setting snap back', this.iframe_scroll]);
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-15 18:29:13 -04:00
|
|
|
handle_mousemove_iframe_view: function(elem, e) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.show_mouse_indicator();
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
if (parseInt(this.model.preference('lock_mouse_indicator'), 10)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
var scroll_top = this.$s.$feed_iframe.contents().scrollTop();
|
2010-06-14 13:17:38 -04:00
|
|
|
this.cache.mouse_position_y = e.pageY - scroll_top;
|
|
|
|
this.$s.$mouse_indicator.css('top', this.cache.mouse_position_y - 8);
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
self.flags['mousemove_timeout'] = false;
|
|
|
|
}, 40);
|
|
|
|
if (!this.flags['mousemove_timeout']
|
|
|
|
&& !this.flags.scrolling_by_selecting_story_title) {
|
|
|
|
var from_top = this.cache.mouse_position_y + scroll_top;
|
|
|
|
var positions = this.cache.iframe_story_positions_keys;
|
|
|
|
var closest = $.closest(from_top, positions);
|
|
|
|
var story = this.cache.iframe_story_positions[positions[closest]];
|
|
|
|
this.flags['mousemove_timeout'] = true;
|
|
|
|
this.navigate_story_titles_to_story(story);
|
|
|
|
// NEWSBLUR.log(['Setting snap back', this.iframe_scroll]);
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-09 09:59:45 -05:00
|
|
|
handle_mousemove_feed_view: function(elem, e) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
|
2010-12-09 09:59:45 -05:00
|
|
|
if (this.model.preference('feed_view_single_story')) {
|
|
|
|
return this.hide_mouse_indicator();
|
|
|
|
} else {
|
|
|
|
this.show_mouse_indicator();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parseInt(this.model.preference('lock_mouse_indicator'), 10)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.cache.mouse_position_y = e.pageY ;
|
2011-10-19 18:42:49 -07:00
|
|
|
if (this.cache.story_pane_position == null) {
|
2011-10-19 23:04:45 -07:00
|
|
|
this.cache.story_pane_position = this.$s.$feed_stories.offsetParent().offset().top;
|
2011-10-19 18:42:49 -07:00
|
|
|
}
|
|
|
|
this.$s.$mouse_indicator.css('top', this.cache.mouse_position_y - this.cache.story_pane_position - 8);
|
2010-12-09 09:59:45 -05:00
|
|
|
|
|
|
|
if (this.flags['mousemove_timeout']) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
self.flags['mousemove_timeout'] = false;
|
|
|
|
}, 40);
|
|
|
|
|
|
|
|
if (!this.flags['mousemove_timeout']
|
2010-06-14 13:17:38 -04:00
|
|
|
&& !this.flags['switching_to_feed_view']
|
|
|
|
&& !this.flags.scrolling_by_selecting_story_title
|
|
|
|
&& this.story_view != 'story') {
|
2011-01-24 23:50:38 -05:00
|
|
|
var from_top = this.cache.mouse_position_y + this.$s.$feed_stories.scrollTop();
|
2011-10-19 23:04:45 -07:00
|
|
|
var offset = this.cache.story_pane_position;
|
|
|
|
var position = from_top - offset;
|
2010-06-14 13:17:38 -04:00
|
|
|
var positions = this.cache.feed_view_story_positions_keys;
|
2011-10-19 23:04:45 -07:00
|
|
|
var closest = $.closest(position, positions);
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = this.cache.feed_view_story_positions[positions[closest]];
|
2010-12-09 09:59:45 -05:00
|
|
|
this.flags['mousemove_timeout'] = true;
|
2011-01-11 21:37:38 -05:00
|
|
|
if (story == this.active_story) return;
|
2010-12-09 09:59:45 -05:00
|
|
|
// NEWSBLUR.log(['Mousemove feed view', from_top, closest, positions[closest]]);
|
|
|
|
this.navigate_story_titles_to_story(story);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
handle_scroll_feed_view: function(elem, e) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
|
2011-02-23 19:41:05 -05:00
|
|
|
// NEWSBLUR.log(['handle_scroll_feed_view', this.story_view, this.flags['switching_to_feed_view'], this.flags['scrolling_by_selecting_story_title']]);
|
2010-12-08 20:53:45 -05:00
|
|
|
if ((this.story_view == 'feed' ||
|
|
|
|
(this.story_view == 'page' && this.flags['page_view_showing_feed_view'])) &&
|
|
|
|
!this.flags['switching_to_feed_view'] &&
|
|
|
|
!this.flags['scrolling_by_selecting_story_title'] &&
|
|
|
|
!this.model.preference('feed_view_single_story')) {
|
2011-01-24 23:50:38 -05:00
|
|
|
var from_top = this.cache.mouse_position_y + this.$s.$feed_stories.scrollTop();
|
2011-10-19 23:04:45 -07:00
|
|
|
var offset = this.cache.story_pane_position;
|
|
|
|
var position = from_top - offset;
|
2010-06-14 13:17:38 -04:00
|
|
|
var positions = this.cache.feed_view_story_positions_keys;
|
2011-10-19 23:04:45 -07:00
|
|
|
var closest = $.closest(position, positions);
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = this.cache.feed_view_story_positions[positions[closest]];
|
|
|
|
// NEWSBLUR.log(['Scroll feed view', from_top, e, closest, positions[closest], this.cache.feed_view_story_positions_keys, positions, self.cache]);
|
|
|
|
this.navigate_story_titles_to_story(story);
|
2012-01-18 18:07:43 -08:00
|
|
|
this.check_feed_view_scrolled_to_bottom();
|
2010-06-13 20:10:48 -04:00
|
|
|
}
|
2011-01-24 23:50:38 -05:00
|
|
|
|
2012-02-03 11:41:01 -08:00
|
|
|
if ((this.flags.river_view || this.flags.social_view) &&
|
2011-01-24 23:50:38 -05:00
|
|
|
!this.model.preference('feed_view_single_story')) {
|
2011-01-26 19:36:28 -05:00
|
|
|
var story;
|
|
|
|
if (this.flags.scrolling_by_selecting_story_title) {
|
|
|
|
story = this.active_story;
|
|
|
|
} else {
|
|
|
|
var from_top = Math.max(1, this.$s.$feed_stories.scrollTop());
|
|
|
|
var positions = this.cache.feed_view_story_positions_keys;
|
|
|
|
var closest = $.closest(from_top, positions);
|
|
|
|
story = this.cache.feed_view_story_positions[positions[closest]];
|
|
|
|
}
|
2011-01-30 23:00:22 -05:00
|
|
|
|
2011-01-24 23:50:38 -05:00
|
|
|
this.show_correct_feed_in_feed_title_floater(story);
|
|
|
|
}
|
2010-06-14 14:00:46 -04:00
|
|
|
},
|
|
|
|
|
2012-04-24 10:38:23 -07:00
|
|
|
handle_keyup: function(elem, e) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2010-06-14 14:00:46 -04:00
|
|
|
handle_keystrokes: function() {
|
|
|
|
var self = this;
|
|
|
|
var $document = $(document);
|
|
|
|
|
2010-12-14 17:08:52 -05:00
|
|
|
NEWSBLUR.hotkeys.initialize();
|
|
|
|
|
2010-10-12 20:22:18 -04:00
|
|
|
$document.bind('keydown', '?', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_keyboard_shortcuts_modal();
|
|
|
|
});
|
2010-10-12 20:23:03 -04:00
|
|
|
$document.bind('keydown', 'shift+/', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_keyboard_shortcuts_modal();
|
|
|
|
});
|
2010-06-14 14:00:46 -04:00
|
|
|
$document.bind('keydown', 'down', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_story(1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'up', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_story(-1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'j', function(e) {
|
|
|
|
e.preventDefault();
|
2010-08-13 10:43:48 -04:00
|
|
|
self.show_next_story(1);
|
2010-06-14 14:00:46 -04:00
|
|
|
});
|
|
|
|
$document.bind('keydown', 'k', function(e) {
|
|
|
|
e.preventDefault();
|
2010-08-13 10:43:48 -04:00
|
|
|
self.show_next_story(-1);
|
2010-10-21 18:52:25 -04:00
|
|
|
});
|
|
|
|
$document.bind('keydown', 'shift+j', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_feed(1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'shift+k', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_feed(-1);
|
2010-10-21 19:36:03 -04:00
|
|
|
});
|
|
|
|
$document.bind('keydown', 'shift+down', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_feed(1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'shift+up', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_feed(-1);
|
2010-06-14 14:00:46 -04:00
|
|
|
});
|
|
|
|
$document.bind('keydown', 'left', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.switch_taskbar_view_direction(-1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'right', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.switch_taskbar_view_direction(1);
|
|
|
|
});
|
2010-10-25 20:20:59 -04:00
|
|
|
$document.bind('keydown', 'h', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.switch_taskbar_view_direction(-1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'l', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.switch_taskbar_view_direction(1);
|
|
|
|
});
|
2011-05-02 14:15:24 -07:00
|
|
|
$document.bind('keydown', 'r', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_river_stories();
|
|
|
|
});
|
2010-10-12 20:13:33 -04:00
|
|
|
$document.bind('keydown', 'enter', function(e) {
|
|
|
|
e.preventDefault();
|
2010-12-07 20:04:37 -05:00
|
|
|
self.open_story_in_story_view(null, true);
|
2010-10-12 20:13:33 -04:00
|
|
|
});
|
|
|
|
$document.bind('keydown', 'return', function(e) {
|
|
|
|
e.preventDefault();
|
2010-12-07 20:04:37 -05:00
|
|
|
self.open_story_in_story_view(null, true);
|
2010-10-12 20:13:33 -04:00
|
|
|
});
|
2010-06-14 14:00:46 -04:00
|
|
|
$document.bind('keydown', 'space', function(e) {
|
|
|
|
e.preventDefault();
|
2011-11-06 14:38:19 -08:00
|
|
|
self.page_in_story(0.4, 1);
|
2010-06-14 14:00:46 -04:00
|
|
|
});
|
|
|
|
$document.bind('keydown', 'shift+space', function(e) {
|
|
|
|
e.preventDefault();
|
2011-11-25 11:06:07 -05:00
|
|
|
self.page_in_story(0.65, -1);
|
2010-06-14 14:00:46 -04:00
|
|
|
});
|
2012-05-07 15:11:10 -07:00
|
|
|
$document.bind('keydown', 'shift+u', function(e) {
|
2011-02-23 18:09:09 -05:00
|
|
|
e.preventDefault();
|
|
|
|
if (self.flags['sidebar_closed']) {
|
|
|
|
self.open_sidebar();
|
|
|
|
} else {
|
|
|
|
self.close_sidebar();
|
|
|
|
}
|
|
|
|
});
|
2011-04-12 11:02:02 -04:00
|
|
|
$document.bind('keydown', 'n', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_next_unread_story_across_feeds();
|
|
|
|
});
|
2011-11-02 09:43:06 -07:00
|
|
|
$document.bind('keydown', 'm', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_last_unread_story();
|
|
|
|
});
|
2011-05-01 00:03:13 -04:00
|
|
|
$document.bind('keydown', 'b', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_previous_story();
|
|
|
|
});
|
2011-07-29 09:41:49 -07:00
|
|
|
$document.bind('keydown', 's', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (self.active_story) {
|
|
|
|
var story_id = self.active_story.id;
|
2012-05-25 20:52:30 -07:00
|
|
|
var story_view = NEWSBLUR.assets.get_story(story_id).story_view;
|
|
|
|
story_view.star_story();
|
2011-07-29 09:41:49 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$document.bind('keypress', '+', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.move_intelligence_slider(1);
|
|
|
|
});
|
|
|
|
$document.bind('keypress', '-', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.move_intelligence_slider(-1);
|
|
|
|
});
|
2011-07-29 09:58:25 -07:00
|
|
|
$document.bind('keypress', 'd', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_splash_page();
|
|
|
|
});
|
2011-10-30 22:15:04 -07:00
|
|
|
$document.bind('keypress', 't', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_story_trainer();
|
|
|
|
});
|
2012-01-11 10:33:31 -08:00
|
|
|
$document.bind('keypress', 'a', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_add_feed_modal();
|
|
|
|
});
|
2011-10-30 22:17:16 -07:00
|
|
|
$document.bind('keypress', 'f', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_feed_intelligence_modal(1);
|
|
|
|
});
|
2011-10-31 18:04:25 -07:00
|
|
|
$document.bind('keypress', 'o', function(e) {
|
|
|
|
e.preventDefault();
|
2012-05-25 20:52:30 -07:00
|
|
|
var story_id = self.active_story;
|
|
|
|
if (!story_id) return;
|
|
|
|
var story = self.model.get_story(story_id);
|
|
|
|
story.story_view.open_story_in_new_tab();
|
2011-10-31 18:04:25 -07:00
|
|
|
});
|
2011-10-31 18:40:07 -07:00
|
|
|
$document.bind('keydown', 'shift+a', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (self.flags.river_view) {
|
|
|
|
self.mark_folder_as_read();
|
|
|
|
} else {
|
|
|
|
self.mark_feed_as_read();
|
|
|
|
}
|
|
|
|
});
|
2011-11-06 14:44:20 -08:00
|
|
|
$document.bind('keydown', 'shift+e', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_river_stories();
|
|
|
|
});
|
2012-05-07 15:11:10 -07:00
|
|
|
$document.bind('keydown', 'u', function(e) {
|
2012-01-04 14:09:40 -08:00
|
|
|
e.preventDefault();
|
2012-01-09 20:06:38 -08:00
|
|
|
var story_id = self.active_story.id;
|
2012-05-25 20:52:30 -07:00
|
|
|
var story = self.model.get_story(story_id);
|
2012-05-25 18:54:04 -07:00
|
|
|
if (self.active_story && !self.active_story.get('read_status')) {
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_read(story, {skip_delay: true});
|
2012-05-25 18:54:04 -07:00
|
|
|
} else if (self.active_story && self.active_story.get('read_status')) {
|
2012-05-25 20:52:30 -07:00
|
|
|
NEWSBLUR.assets.stories.mark_unread(story);
|
2012-01-04 14:09:40 -08:00
|
|
|
}
|
|
|
|
});
|
2012-04-27 17:44:00 -07:00
|
|
|
$document.bind('keydown', 'shift+s', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (self.active_story) {
|
|
|
|
var story_id = self.active_story.id;
|
|
|
|
var $story_title = self.find_story_in_story_titles(story_id);
|
|
|
|
self.add_hover_inverse_to_feed($story_title);
|
|
|
|
self.show_manage_menu('story', $story_title);
|
|
|
|
self.show_confirm_story_share_menu_item();
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
2012-05-17 18:40:46 -07:00
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-10-19 19:09:08 -04:00
|
|
|
})(jQuery);
|