2010-06-08 11:19:41 -04:00
|
|
|
(function($) {
|
|
|
|
|
|
|
|
NEWSBLUR.Reader = function() {
|
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
// ===========
|
|
|
|
// = Globals =
|
|
|
|
// ===========
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
this.model = NEWSBLUR.AssetModel.reader();
|
|
|
|
this.story_view = 'page';
|
2010-06-14 13:17:38 -04:00
|
|
|
this.$s = {
|
2010-06-14 14:00:46 -04:00
|
|
|
$body: $('body'),
|
2010-06-14 13:17:38 -04:00
|
|
|
$feed_list: $('#feed_list'),
|
|
|
|
$story_titles: $('#story_titles'),
|
2010-06-15 18:29:13 -04:00
|
|
|
$content_pane: $('.content-pane'),
|
2010-06-14 13:17:38 -04:00
|
|
|
$story_pane: $('#story_pane .NB-story-pane-container'),
|
|
|
|
$feed_view: $('.NB-feed-story-view'),
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe: $('.NB-feed-iframe'),
|
|
|
|
$story_iframe: $('.NB-story-iframe'),
|
2010-06-14 13:17:38 -04:00
|
|
|
$intelligence_slider: $('.NB-intelligence-slider'),
|
2010-08-09 20:44:36 -04:00
|
|
|
$mouse_indicator: $('#mouse-indicator'),
|
2010-08-11 11:43:48 -04:00
|
|
|
$feed_link_loader: $('#NB-feeds-list-loader'),
|
2010-11-22 10:44:52 -05:00
|
|
|
$feeds_progress: $('#NB-progress'),
|
2010-12-01 14:11:42 -05:00
|
|
|
$header: $('.NB-feeds-header'),
|
2010-12-04 21:53:39 -05:00
|
|
|
$starred_header: $('.NB-feeds-header-starred'),
|
2010-12-10 15:26:50 -05:00
|
|
|
$river_header: $('.NB-feeds-header-river'),
|
2010-12-04 21:53:39 -05:00
|
|
|
$taskbar: $('.taskbar_nav')
|
2010-06-14 13:17:38 -04:00
|
|
|
};
|
2010-06-08 11:19:41 -04:00
|
|
|
this.flags = {
|
|
|
|
'feed_view_images_loaded': {},
|
2010-08-11 11:43:48 -04:00
|
|
|
'bouncing_callout': false,
|
|
|
|
'has_unfetched_feeds': false
|
2010-06-08 11:19:41 -04:00
|
|
|
};
|
|
|
|
this.locks = {};
|
2010-08-11 11:43:48 -04:00
|
|
|
this.counts = {
|
2010-06-30 12:17:22 -04:00
|
|
|
'feature_page': 0,
|
2010-08-11 11:43:48 -04:00
|
|
|
'unfetched_feeds': 0,
|
|
|
|
'fetched_feeds': 0
|
|
|
|
};
|
|
|
|
this.cache = {
|
2010-06-08 11:19:41 -04:00
|
|
|
'iframe_stories': {},
|
|
|
|
'feed_view_stories': {},
|
|
|
|
'iframe_story_positions': {},
|
|
|
|
'feed_view_story_positions': {},
|
|
|
|
'iframe_story_positions_keys': [],
|
|
|
|
'feed_view_story_positions_keys': [],
|
2010-12-12 22:52:15 -05:00
|
|
|
'river_feeds_with_unreads': [],
|
2010-06-11 20:55:38 -04:00
|
|
|
'mouse_position_y': parseInt(this.model.preference('lock_mouse_indicator'), 10)
|
2010-06-08 11:19:41 -04:00
|
|
|
};
|
2010-11-09 10:04:20 -05:00
|
|
|
this.FEED_REFRESH_INTERVAL = (1000 * 60) * 1; // 1 minute
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ==================
|
|
|
|
// = Event Handlers =
|
|
|
|
// ==================
|
|
|
|
|
2010-06-14 14:00:46 -04:00
|
|
|
this.$s.$body.bind('dblclick.reader', $.rescope(this.handle_dblclicks, this));
|
|
|
|
this.$s.$body.bind('click.reader', $.rescope(this.handle_clicks, this));
|
2010-12-31 14:35:00 -05:00
|
|
|
this.$s.$body.bind('contextmenu.reader', $.rescope(this.handle_rightclicks, this));
|
2010-06-14 14:00:46 -04:00
|
|
|
this.$s.$story_titles.scroll($.rescope(this.handle_scroll_story_titles, this));
|
2010-06-14 13:17:38 -04:00
|
|
|
this.$s.$feed_view.scroll($.rescope(this.handle_scroll_feed_view, this));
|
|
|
|
this.$s.$feed_view.bind('mousemove', $.rescope(this.handle_mousemove_feed_view, this));
|
2010-06-14 14:00:46 -04:00
|
|
|
this.handle_keystrokes();
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
// ==================
|
|
|
|
// = Initialization =
|
|
|
|
// ==================
|
|
|
|
|
2010-10-10 20:14:31 -04:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
this.unload_feed_iframe();
|
|
|
|
this.unload_story_iframe();
|
2010-11-24 15:01:35 -05:00
|
|
|
this.apply_resizable_layout();
|
2010-08-17 20:59:47 -04:00
|
|
|
if (NEWSBLUR.Flags['start_import_from_google_reader']) {
|
|
|
|
this.start_import_from_google_reader();
|
|
|
|
} else {
|
|
|
|
this.load_feeds();
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
this.cornerize_buttons();
|
|
|
|
this.setup_feed_page_iframe_load();
|
|
|
|
this.load_intelligence_slider();
|
2010-06-11 16:55:07 -04:00
|
|
|
this.handle_mouse_indicator_hover();
|
2010-06-11 20:55:38 -04:00
|
|
|
this.position_mouse_indicator();
|
2010-07-05 16:05:54 -04:00
|
|
|
this.handle_login_and_signup_forms();
|
2010-10-06 18:44:53 -04:00
|
|
|
this.iframe_buster_buster();
|
2010-11-25 15:34:06 -05:00
|
|
|
this.apply_story_styling();
|
2010-06-08 11:19:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
NEWSBLUR.Reader.prototype = {
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
// ========
|
|
|
|
// = Page =
|
|
|
|
// ========
|
|
|
|
|
|
|
|
apply_resizable_layout: function() {
|
2010-11-22 10:44:52 -05:00
|
|
|
var outerLayout, rightLayout, contentLayout, leftLayout, leftCenterLayout;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 14:00:46 -04:00
|
|
|
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'),
|
|
|
|
west__onresize_end: $.rescope(this.save_feed_pane_size, this),
|
2010-06-13 18:57:20 -04:00
|
|
|
spacing_open: 4,
|
2010-08-13 19:21:29 -04:00
|
|
|
resizerDragOpacity: 0.6
|
2010-06-13 18:57:20 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
leftLayout = $('.left-pane').layout({
|
|
|
|
closable: false,
|
2010-12-10 09:32:06 -05:00
|
|
|
fxName: "scale",
|
|
|
|
fxSettings: { duration: 500, easing: "easeInOutQuint" },
|
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,
|
|
|
|
south__spacing_open: 0
|
|
|
|
});
|
2010-11-22 10:44:52 -05:00
|
|
|
|
|
|
|
leftCenterLayout = $('.left-center').layout({
|
|
|
|
closable: false,
|
|
|
|
slidable: false,
|
|
|
|
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,
|
|
|
|
fxSettings: { duration: 1000, easing: "easeInOutQuint" }
|
2010-11-22 10:44:52 -05:00
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-13 18:57:20 -04:00
|
|
|
rightLayout = $('.right-pane').layout({
|
|
|
|
south__paneSelector: ".right-north",
|
|
|
|
center__paneSelector: ".content-pane",
|
2010-08-13 19:50:56 -04:00
|
|
|
south__size: this.model.preference('story_titles_pane_size'),
|
|
|
|
south__onresize_end: $.rescope(this.save_story_titles_pane_size, this),
|
2010-06-13 18:57:20 -04:00
|
|
|
spacing_open: 10,
|
|
|
|
resizerDragOpacity: 0.6
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-15 18:29:13 -04:00
|
|
|
contentLayout = this.$s.$content_pane.layout({
|
2010-06-13 18:57:20 -04:00
|
|
|
center__paneSelector: ".content-center",
|
|
|
|
south__paneSelector: ".content-north",
|
|
|
|
south__size: 30,
|
|
|
|
spacing_open: 0,
|
|
|
|
resizerDragOpacity: 0.6
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.right-pane').hide();
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-08-13 19:50:56 -04:00
|
|
|
save_feed_pane_size: function(w, pane, $pane, state, options, name) {
|
|
|
|
this.model.preference('feed_pane_size', state.size);
|
|
|
|
},
|
|
|
|
|
|
|
|
save_story_titles_pane_size: function(w, pane, $pane, state, options, name) {
|
|
|
|
this.model.preference('story_titles_pane_size', state.size);
|
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
cornerize_buttons: function() {
|
|
|
|
$('.button').corner();
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_splash_page: function() {
|
2010-08-13 19:21:29 -04:00
|
|
|
var self = this;
|
2010-06-08 11:19:41 -04:00
|
|
|
$('.right-pane').show();
|
|
|
|
$('#NB-splash').hide();
|
|
|
|
$('#NB-splash-overlay').hide();
|
2010-08-13 19:21:29 -04:00
|
|
|
this.$s.$body.layout().resizeAll();
|
2010-11-22 10:44:52 -05:00
|
|
|
this.$s.$header.addClass('NB-active');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
|
|
|
if (NEWSBLUR.Globals.is_anonymous) {
|
|
|
|
this.setup_ftux_signup_callout();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
show_splash_page: function() {
|
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-11-22 10:44:52 -05:00
|
|
|
this.mark_feed_as_selected(null, null);
|
2010-06-08 11:19:41 -04:00
|
|
|
$('.right-pane').hide();
|
|
|
|
$('#NB-splash').show();
|
|
|
|
$('#NB-splash-overlay').show();
|
2010-11-22 10:44:52 -05:00
|
|
|
this.$s.$header.removeClass('NB-active');
|
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
|
|
|
};
|
2010-08-13 19:21:29 -04:00
|
|
|
setInterval(function() {
|
|
|
|
if (prevent_bust > 0) {
|
|
|
|
prevent_bust -= 2;
|
2010-12-04 23:26:52 -05:00
|
|
|
if (!self.flags['iframe_view_loaded'] && !self.flags['iframe_view_not_busting'] && self.story_view == 'page' && 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);
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// =======================
|
|
|
|
// = Getters and Finders =
|
|
|
|
// =======================
|
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
get_current_story_from_story_titles: function($feed_view_stories) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_view = this.$s.$feed_view;
|
2010-12-08 20:53:45 -05:00
|
|
|
var $feed_view_stories = $feed_view_stories || $(".NB-feed-story", $feed_view);
|
2010-06-14 13:17:38 -04:00
|
|
|
var story = this.active_story;
|
|
|
|
var $current_story;
|
|
|
|
|
|
|
|
if (story) {
|
|
|
|
$feed_view_stories.each(function() {
|
|
|
|
if ($(this).data('story') == story.id) {
|
|
|
|
$current_story = $(this);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return $current_story;
|
|
|
|
},
|
|
|
|
|
|
|
|
find_feed_in_feed_list: function(feed_id) {
|
|
|
|
var $feed_list = this.$s.$feed_list;
|
|
|
|
var $feeds = $([]);
|
|
|
|
|
|
|
|
$('.feed', $feed_list).each(function() {
|
|
|
|
if ($(this).data('feed_id') == feed_id) {
|
|
|
|
$feeds.push($(this).get(0));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var story = this.model.get_story(story_id);
|
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;
|
|
|
|
// NEWSBLUR.log(['Finding story in story titles', $this, story]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return $story_title;
|
|
|
|
},
|
|
|
|
|
|
|
|
find_story_in_feed_view: function(story) {
|
|
|
|
if (!story) return;
|
|
|
|
|
|
|
|
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++) {
|
|
|
|
if ($stories.eq(s).data('story') == story.id) {
|
|
|
|
$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 = $([]);
|
|
|
|
|
|
|
|
if (this.flags.iframe_story_locations_fetched || story.id in this.cache.iframe_stories) {
|
|
|
|
return this.cache.iframe_stories[story.id];
|
|
|
|
}
|
|
|
|
|
|
|
|
var title = story.story_title.replace(/ |[^a-z0-9-,]/gi, '');
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-07-02 11:14:41 -04:00
|
|
|
// NEWSBLUR.log(['Found stories', $stories.length, $same_size_stories.length, $same_size_stories, story.story_title]);
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
var overlap = Math.abs(story_text.length - story.story_title.length);
|
|
|
|
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) {
|
2010-12-04 23:26:52 -05:00
|
|
|
var self = this;
|
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);
|
2010-12-04 23:26:52 -05:00
|
|
|
|
|
|
|
if (!this.flags['iframe_view_not_busting']) {
|
|
|
|
var feed_id = this.active_feed;
|
|
|
|
_.delay(function() {
|
|
|
|
if (feed_id == self.active_feed) {
|
|
|
|
self.flags['iframe_view_not_busting'] = true;
|
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NEWSBLUR.log(['Found story', $story]);
|
|
|
|
return $story;
|
|
|
|
},
|
|
|
|
|
2010-09-21 11:16:22 -04:00
|
|
|
get_feed_ids_in_folder: function($folder) {
|
|
|
|
$folder = $folder || this.$s.$feed_list;
|
|
|
|
|
2010-11-09 22:06:08 -05:00
|
|
|
var $feeds = $('.feed:not(.NB-empty)', $folder);
|
|
|
|
var feeds = _.map($('.feed:not(.NB-empty)', $folder), function(o) {
|
2010-11-01 23:00:20 -04:00
|
|
|
return o && $(o).data('feed_id');
|
2010-09-21 11:16:22 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
return feeds;
|
|
|
|
},
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
// ==============
|
|
|
|
// = Navigation =
|
|
|
|
// ==============
|
|
|
|
|
|
|
|
show_next_story: function(direction) {
|
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;
|
|
|
|
|
|
|
|
if (!$current_story.length) {
|
2010-06-14 13:17:38 -04:00
|
|
|
$current_story = $('.story:first', $story_titles);
|
2010-06-08 11:19:41 -04:00
|
|
|
$next_story = $current_story;
|
|
|
|
} else if (direction == 1) {
|
|
|
|
$next_story = $current_story.nextAll('.story:visible').eq(0);
|
|
|
|
} else if (direction == -1) {
|
|
|
|
$next_story = $current_story.prevAll('.story:visible').eq(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
show_next_unread_story: function(second_pass) {
|
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);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
} else if (!second_pass) {
|
|
|
|
// Nothing up, nothing down, but still unread. Load 1 page then find it.
|
|
|
|
this.flags['find_next_unread_on_page_of_feed_stories_load'] = true;
|
|
|
|
this.load_page_of_feed_stories();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {
|
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) {
|
2010-11-24 13:16:10 -05:00
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_list = this.$s.$feed_list;
|
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;
|
2010-11-09 18:30:18 -05:00
|
|
|
var $feeds = $('.feed:visible:not(.NB-empty)', $feed_list);
|
2010-06-08 11:19:41 -04:00
|
|
|
if (!$current_feed.length) {
|
2010-11-09 18:30:18 -05:00
|
|
|
$current_feed = $('.feed:first:visible:not(.NB-empty)', $feed_list);
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$next_feed = $feeds.eq(current_feed+direction);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var feed_id = $next_feed.data('feed_id');
|
2010-10-21 18:52:25 -04:00
|
|
|
if (feed_id && feed_id == this.active_feed) {
|
|
|
|
this.show_next_feed(direction, $next_feed);
|
|
|
|
} else if (feed_id) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var position = $feed_list.scrollTop() + $next_feed.offset().top - $next_feed.outerHeight();
|
2010-10-21 18:52:25 -04:00
|
|
|
var showing = $feed_list.height() - 100;
|
2010-06-08 11:19:41 -04:00
|
|
|
if (position > showing) {
|
|
|
|
scroll = position;
|
|
|
|
} else {
|
|
|
|
scroll = 0;
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
$feed_list.scrollTop(scroll);
|
2010-11-24 13:16:10 -05:00
|
|
|
NEWSBLUR.log(['feed_id', feed_id, this.next_feed]);
|
|
|
|
this.open_feed(feed_id, false, $next_feed, 350);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
navigate_story_titles_to_story: function(story) {
|
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') {
|
2010-12-06 10:41:24 -05:00
|
|
|
this.$s.$feed_iframe.scrollTo({top:dir+'='+scroll_height, left:'+=0'}, 150);
|
2010-12-08 20:53:45 -05:00
|
|
|
} else if (this.story_view == 'feed') {
|
2010-06-14 13:17:38 -04:00
|
|
|
this.$s.$feed_view.scrollTo({top:dir+'='+scroll_height, left:'+=0'}, 150);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
push_current_story_on_history: function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $current_story = $('.selected', this.$s.$story_titles);
|
2010-06-08 11:19:41 -04:00
|
|
|
if ($current_story.length) {
|
|
|
|
this.cache['previous_stories_stack'].push($current_story);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// =============
|
|
|
|
// = Feed Pane =
|
|
|
|
// =============
|
|
|
|
|
|
|
|
load_feeds: function() {
|
|
|
|
var self = this;
|
2010-10-15 09:21:46 -04:00
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
if ($('#feed_list').length) {
|
|
|
|
$('.NB-callout-ftux .NB-callout-text').text('Loading feeds...');
|
2010-08-09 20:44:36 -04:00
|
|
|
this.$s.$feed_link_loader.css({'display': 'block'});
|
2010-06-08 11:19:41 -04:00
|
|
|
this.model.load_feeds($.rescope(this.make_feeds, this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
make_feeds: function() {
|
2010-09-22 19:26:56 -04:00
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_list = this.$s.$feed_list.empty();
|
2010-06-08 11:19:41 -04:00
|
|
|
var folders = this.model.folders;
|
|
|
|
var feeds = this.model.feeds;
|
2010-08-09 20:44:36 -04:00
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
// NEWSBLUR.log(['Making feeds', {'folders': folders, 'feeds': feeds}]);
|
|
|
|
|
|
|
|
$('#story_taskbar').css({'display': 'block'});
|
2010-10-05 19:05:01 -04:00
|
|
|
|
|
|
|
this.flags['has_chosen_feeds'] = this.detect_all_inactive_feeds();
|
2010-08-11 23:52:17 -04:00
|
|
|
this.make_feeds_folder($feed_list, folders, 0);
|
2010-12-31 14:35:00 -05:00
|
|
|
this.$s.$feed_list.css({
|
|
|
|
'display': 'block',
|
|
|
|
'opacity': 0
|
|
|
|
}).animate({'opacity': 1}, {'duration': 500});
|
2010-12-07 23:40:29 -05:00
|
|
|
this.hover_over_feed_titles();
|
2010-11-01 23:00:20 -04:00
|
|
|
this.$s.$feed_list.prepend($.make('li', { className: 'feed NB-empty' }));
|
2010-08-11 23:02:17 -04:00
|
|
|
this.$s.$feed_link_loader.fadeOut(250);
|
2010-10-16 21:32:06 -04:00
|
|
|
|
2010-10-02 17:05:55 -04:00
|
|
|
if (folders.length) {
|
2010-06-08 11:19:41 -04:00
|
|
|
$('.NB-task-manage').removeClass('NB-disabled');
|
|
|
|
$('.NB-callout-ftux').fadeOut(500);
|
|
|
|
}
|
2010-10-16 21:32:06 -04:00
|
|
|
|
2010-09-28 18:53:57 -04:00
|
|
|
if (NEWSBLUR.Globals.is_authenticated && this.flags['has_chosen_feeds']) {
|
2010-12-31 14:35:00 -05:00
|
|
|
_.delay(_.bind(this.start_count_unreads_after_import, this), 1000);
|
2010-10-10 20:14:31 -04:00
|
|
|
this.force_feeds_refresh($.rescope(this.finish_count_unreads_after_import, this));
|
2010-10-02 17:05:55 -04:00
|
|
|
} else if (!this.flags['has_chosen_feeds'] && folders.length) {
|
2010-10-14 09:51:56 -04:00
|
|
|
_.defer(_.bind(this.open_feedchooser_modal, this), 100);
|
2010-10-16 21:32:06 -04:00
|
|
|
return;
|
2010-10-05 19:05:01 -04:00
|
|
|
} else if (NEWSBLUR.Globals.is_authenticated) {
|
2010-10-02 17:05:55 -04:00
|
|
|
this.setup_ftux_add_feed_callout();
|
|
|
|
}
|
2010-10-16 21:32:06 -04:00
|
|
|
|
|
|
|
if (folders.length) {
|
|
|
|
this.load_sortable_feeds();
|
|
|
|
$('.feed', $feed_list).tsort('.feed_title');
|
|
|
|
$('.folder', $feed_list).tsort('.folder_title_text');
|
2010-11-22 10:44:52 -05:00
|
|
|
this.update_header_counts();
|
2010-12-01 14:11:42 -05:00
|
|
|
_.delay(_.bind(this.update_starred_count, this), 250);
|
2010-10-16 21:32:06 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-10-05 19:05:01 -04:00
|
|
|
detect_all_inactive_feeds: function() {
|
|
|
|
var feeds = this.model.feeds;
|
|
|
|
var has_chosen_feeds = _.any(feeds, function(feed) {
|
|
|
|
return feed.active;
|
|
|
|
});
|
|
|
|
return has_chosen_feeds;
|
|
|
|
},
|
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
make_feeds_folder: function($feeds, items, depth, collapsed_parent) {
|
2010-08-11 23:52:17 -04:00
|
|
|
var self = this;
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
for (var i in items) {
|
|
|
|
var item = items[i];
|
|
|
|
|
|
|
|
if (typeof item == "number") {
|
2010-08-25 10:18:08 -04:00
|
|
|
var feed = this.model.get_feed(item);
|
2010-08-16 16:30:04 -04:00
|
|
|
if (!feed) continue;
|
2010-07-26 21:38:56 -04:00
|
|
|
var $feed = this.make_feed_title_line(feed, true, 'feed');
|
2010-06-08 11:19:41 -04:00
|
|
|
$feeds.append($feed);
|
2010-08-11 23:52:17 -04:00
|
|
|
if (depth == 0) {
|
2010-09-11 17:15:08 -04:00
|
|
|
$feed.addClass('NB-toplevel');
|
2010-08-11 23:52:17 -04:00
|
|
|
}
|
2010-08-11 11:43:48 -04:00
|
|
|
|
|
|
|
if (feed.not_yet_fetched) {
|
2010-10-02 17:05:55 -04:00
|
|
|
// NEWSBLUR.log(['Feed not fetched', feed]);
|
2010-08-11 22:02:47 -04:00
|
|
|
if (!this.model.preference('hide_fetch_progress')) {
|
|
|
|
this.flags['has_unfetched_feeds'] = true;
|
|
|
|
}
|
2010-08-11 11:43:48 -04:00
|
|
|
}
|
2010-11-01 23:00:20 -04:00
|
|
|
} else if (typeof item == "object" && item) {
|
2010-06-08 11:19:41 -04:00
|
|
|
for (var o in item) {
|
|
|
|
var folder = item[o];
|
|
|
|
var $folder = $.make('li', { className: 'folder' }, [
|
2010-09-11 17:15:08 -04:00
|
|
|
$.make('div', { className: 'folder_title ' + (depth==0 ? 'NB-toplevel':'') }, [
|
2010-12-12 20:06:32 -05:00
|
|
|
$.make('div', { className: 'NB-folder-icon' }),
|
|
|
|
$.make('div', { className: 'NB-feedlist-river-icon' }),
|
2010-12-10 15:26:50 -05:00
|
|
|
$.make('div', { className: 'NB-feedlist-manage-icon' }),
|
2010-12-12 20:06:32 -05:00
|
|
|
$.make('span', { className: 'folder_title_text' }, o)
|
2010-09-05 18:08:08 -07:00
|
|
|
]),
|
2010-11-01 23:00:20 -04:00
|
|
|
$.make('ul', { className: 'folder' }, [
|
|
|
|
$.make('li', { className: 'feed NB-empty' })
|
|
|
|
])
|
2010-12-31 14:35:00 -05:00
|
|
|
]);
|
2010-10-21 13:48:08 -04:00
|
|
|
var is_collapsed = _.contains(NEWSBLUR.Preferences.collapsed_folders, o);
|
2010-09-05 18:08:08 -07:00
|
|
|
|
|
|
|
(function($feeds, $folder, is_collapsed, collapsed_parent) {
|
2010-10-14 09:51:56 -04:00
|
|
|
var continue_loading_next_feed = function() {
|
2010-09-05 18:08:08 -07:00
|
|
|
if (is_collapsed) {
|
|
|
|
$('ul.folder', $folder).css({'display': 'none'});
|
2010-10-06 09:42:59 -04:00
|
|
|
$feeds.append($folder);
|
2010-09-05 18:08:08 -07:00
|
|
|
self.collapse_folder($('.folder_title', $folder).eq(0), true);
|
|
|
|
if (collapsed_parent) {
|
|
|
|
$folder.parents('li.folder').each(function() {
|
|
|
|
self.collapse_folder($('.folder_title', this).eq(0), true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
2010-10-06 09:42:59 -04:00
|
|
|
$feeds.append($folder);
|
|
|
|
}
|
2010-12-31 14:35:00 -05:00
|
|
|
// if (self.flags['has_chosen_feeds']) {
|
|
|
|
// $folder.css({
|
|
|
|
// 'display': 'block',
|
|
|
|
// 'opacity': 0
|
|
|
|
// }).animate({'opacity': 1}, {'duration': 500});
|
|
|
|
// }
|
2010-09-11 17:15:08 -04:00
|
|
|
self.hover_over_feed_titles($folder);
|
2010-10-14 09:51:56 -04:00
|
|
|
};
|
|
|
|
if (!self.flags['has_chosen_feeds']) {
|
|
|
|
continue_loading_next_feed();
|
|
|
|
} else {
|
2010-12-31 14:35:00 -05:00
|
|
|
setTimeout(continue_loading_next_feed, depth*50);
|
2010-10-14 09:51:56 -04:00
|
|
|
}
|
2010-09-05 18:08:08 -07:00
|
|
|
})($feeds, $folder, is_collapsed, collapsed_parent);
|
|
|
|
this.make_feeds_folder($('ul.folder', $folder), folder, depth+1, is_collapsed);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.feed', $feeds).tsort('.feed_title');
|
2010-09-05 18:08:08 -07:00
|
|
|
$('.folder', $feeds).tsort('.folder_title_text');
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-07-26 21:38:56 -04:00
|
|
|
make_feed_title_line: function(feed, list_item, type) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var unread_class = '';
|
2010-08-18 20:35:45 -04:00
|
|
|
var exception_class = '';
|
2010-06-08 11:19:41 -04:00
|
|
|
if (feed.ps) {
|
|
|
|
unread_class += ' unread_positive';
|
|
|
|
}
|
|
|
|
if (feed.nt) {
|
|
|
|
unread_class += ' unread_neutral';
|
|
|
|
}
|
|
|
|
if (feed.ng) {
|
|
|
|
unread_class += ' unread_negative';
|
|
|
|
}
|
2010-10-28 18:17:14 -04:00
|
|
|
if (feed.has_exception && feed.exception_type == 'feed') {
|
2010-09-28 18:53:57 -04:00
|
|
|
exception_class += ' NB-feed-exception';
|
2010-08-18 20:35:45 -04:00
|
|
|
}
|
|
|
|
if (feed.not_yet_fetched && !feed.has_exception) {
|
2010-09-28 18:53:57 -04:00
|
|
|
exception_class += ' NB-feed-unfetched';
|
2010-08-18 20:35:45 -04:00
|
|
|
}
|
2010-09-28 18:53:57 -04:00
|
|
|
if (!feed.active) {
|
|
|
|
exception_class += ' NB-feed-inactive';
|
|
|
|
}
|
|
|
|
|
2010-08-18 20:35:45 -04:00
|
|
|
var $feed = $.make((list_item?'li':'div'), { className: 'feed ' + unread_class + exception_class }, [
|
2010-06-08 11:19:41 -04:00
|
|
|
$.make('div', { className: 'feed_counts' }, [
|
2010-09-05 18:08:08 -07:00
|
|
|
this.make_feed_counts_floater(feed.ps, feed.nt, feed.ng)
|
2010-06-08 11:19:41 -04:00
|
|
|
]),
|
2010-10-05 19:05:01 -04:00
|
|
|
$.make('img', { className: 'feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + feed.feed_link }),
|
2010-08-30 18:41:53 -04:00
|
|
|
$.make('span', { className: 'feed_title' }, [
|
|
|
|
feed.feed_title,
|
2010-12-11 14:02:37 -05:00
|
|
|
(type == 'story' && $.make('span', { className: 'NB-feedbar-train-feed', title: 'Train Intelligence' })),
|
2010-08-30 18:41:53 -04:00
|
|
|
(type == 'story' && $.make('span', { className: 'NB-feedbar-statistics', title: 'Statistics' }))
|
|
|
|
]),
|
2010-07-26 21:38:56 -04:00
|
|
|
(type == 'story' && $.make('div', { className: 'NB-feedbar-last-updated' }, [
|
|
|
|
$.make('span', { className: 'NB-feedbar-last-updated-label' }, 'Updated: '),
|
2010-09-22 19:59:07 -04:00
|
|
|
$.make('span', { className: 'NB-feedbar-last-updated-date' }, feed.updated + ' ago')
|
2010-07-26 21:38:56 -04:00
|
|
|
])),
|
2010-08-18 20:35:45 -04:00
|
|
|
(type == 'story' && $.make('div', { className: 'NB-feedbar-mark-feed-read' }, 'Mark All as Read')),
|
2010-10-10 20:14:31 -04:00
|
|
|
$.make('div', { className: 'NB-feed-exception-icon' }),
|
|
|
|
$.make('div', { className: 'NB-feed-unfetched-icon' }),
|
2010-09-11 17:15:08 -04:00
|
|
|
(type == 'feed' && $.make('div', { className: 'NB-feedlist-manage-icon' }))
|
2010-06-08 11:19:41 -04:00
|
|
|
]).data('feed_id', feed.id);
|
|
|
|
|
2010-11-26 19:03:31 -05:00
|
|
|
$('.NB-feedbar-train-feed, .NB-feedbar-statistics', $feed).tipsy({
|
|
|
|
gravity: 's',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
return $feed;
|
|
|
|
},
|
|
|
|
|
2010-09-05 18:08:08 -07:00
|
|
|
make_feed_counts_floater: function(positive_count, neutral_count, negative_count) {
|
|
|
|
var unread_class = "";
|
|
|
|
if (positive_count) {
|
|
|
|
unread_class += ' unread_positive';
|
|
|
|
}
|
|
|
|
if (neutral_count) {
|
|
|
|
unread_class += ' unread_neutral';
|
|
|
|
}
|
|
|
|
if (negative_count) {
|
|
|
|
unread_class += ' unread_negative';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $.make('div', { className: 'feed_counts_floater ' + unread_class }, [
|
|
|
|
$.make('span', {
|
|
|
|
className: 'unread_count unread_count_positive '
|
|
|
|
+ (positive_count
|
|
|
|
? "unread_count_full"
|
|
|
|
: "unread_count_empty")
|
|
|
|
}, ''+positive_count),
|
|
|
|
$.make('span', {
|
|
|
|
className: 'unread_count unread_count_neutral '
|
|
|
|
+ (neutral_count
|
|
|
|
? "unread_count_full"
|
|
|
|
: "unread_count_empty")
|
|
|
|
}, ''+neutral_count),
|
|
|
|
$.make('span', {
|
|
|
|
className: 'unread_count unread_count_negative '
|
|
|
|
+ (negative_count
|
|
|
|
? "unread_count_full"
|
|
|
|
: "unread_count_empty")
|
|
|
|
}, ''+negative_count)
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
|
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({
|
2010-12-10 09:32:06 -05:00
|
|
|
items: '.feed:not(.NB-empty),li.folder',
|
2010-12-25 23:04:43 -05:00
|
|
|
connectWith: 'ul.folder',
|
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',
|
2010-12-16 23:57:05 -05:00
|
|
|
containment: '.NB-feedlist',
|
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');
|
|
|
|
ui.item.addClass('NB-feed-sorting');
|
2010-07-11 11:10:45 -04:00
|
|
|
self.$s.$feed_list.addClass('NB-feed-sorting');
|
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) {
|
2010-12-25 23:04:43 -05:00
|
|
|
$('.feed', ui.placeholder.closest('ul.folder')).tsort('.feed_title');
|
|
|
|
$('li.folder', ui.placeholder.closest('ul.folder')).tsort('.folder_title_text');
|
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');
|
2010-07-11 11:10:45 -04:00
|
|
|
self.$s.$feed_list.removeClass('NB-feed-sorting');
|
2010-07-10 17:59:17 -04:00
|
|
|
$('.feed', e.target).tsort('.feed_title');
|
2010-12-25 23:04:43 -05:00
|
|
|
$('li.folder', e.target).tsort('.folder_title_text');
|
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')) {
|
2010-12-10 09:32:06 -05:00
|
|
|
var feed_id = $item.data('feed_id');
|
|
|
|
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
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
$folder.data('collapsed', true);
|
|
|
|
$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);
|
|
|
|
$folder.data('collapsed', false);
|
|
|
|
this.hide_collapsed_folder_count($folder_title);
|
|
|
|
$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
|
|
|
},
|
|
|
|
|
|
|
|
show_collapsed_folder_count: function($folder_title, $children) {
|
|
|
|
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');
|
2010-12-12 20:06:32 -05:00
|
|
|
var $river = $('.NB-feedlist-river-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')) {
|
|
|
|
$river.animate({'opacity': 0}, {'duration': 100});
|
|
|
|
$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
|
|
|
|
}));
|
|
|
|
$counts.animate({'opacity': 1}, {'duration': 400});
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_collapsed_folder_count: function($folder_title) {
|
|
|
|
var $counts = $('.feed_counts_floater', $folder_title);
|
2010-12-12 20:06:32 -05:00
|
|
|
var $river = $('.NB-feedlist-river-icon', $folder_title);
|
|
|
|
|
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-11 17:15:08 -04:00
|
|
|
hover_over_feed_titles: function($folder) {
|
2010-10-06 22:22:32 -04:00
|
|
|
var self = this;
|
|
|
|
var $feeds;
|
|
|
|
$folder = $folder || this.$s.$feed_list;
|
2010-09-13 00:38:25 -04:00
|
|
|
|
2010-10-06 22:22:32 -04:00
|
|
|
if ($folder.is('.feed')) {
|
|
|
|
$feeds = $folder;
|
|
|
|
} else {
|
|
|
|
$feeds = $('.feed, .folder_title', $folder);
|
|
|
|
}
|
|
|
|
|
|
|
|
$feeds.rightClick(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
if ($this.is('.feed')) {
|
|
|
|
self.show_manage_menu('feed', $this);
|
|
|
|
} else if ($this.is('.folder_title')) {
|
2010-12-30 18:37:29 -05:00
|
|
|
self.show_manage_menu('folder', $this.closest('li.folder'));
|
2010-10-06 22:22:32 -04:00
|
|
|
}
|
2010-09-11 17:15:08 -04:00
|
|
|
});
|
|
|
|
|
2010-10-06 22:22:32 -04:00
|
|
|
// NEWSBLUR.log(['hover_over_feed_titles', $folder, $feeds]);
|
|
|
|
|
|
|
|
$feeds.unbind('mouseenter').unbind('mouseleave');
|
|
|
|
|
2010-09-11 17:15:08 -04:00
|
|
|
$feeds.hover(function() {
|
2010-11-01 19:28:57 -04:00
|
|
|
if (!self.$s.$feed_list.hasClass('NB-feed-sorting')) {
|
|
|
|
var $this = $(this);
|
2010-12-31 14:41:59 -05:00
|
|
|
// _.defer(function() { $('.NB-hover', $folder).not($this).removeClass('NB-hover'); });
|
2010-11-01 19:28:57 -04:00
|
|
|
// NEWSBLUR.log(['scroll', $this.scrollTop(), $this.offset(), $this.position()]);
|
2010-12-31 10:34:31 -05:00
|
|
|
if ($this.offset().top > $(window).height() - 270) {
|
2010-11-01 19:28:57 -04:00
|
|
|
$this.addClass('NB-hover-inverse');
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 17:15:08 -04:00
|
|
|
}, function() {
|
2010-09-13 00:38:25 -04:00
|
|
|
var $this = $(this);
|
|
|
|
$this.removeClass('NB-hover-inverse');
|
2010-09-11 17:15:08 -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');
|
2010-09-28 18:53:57 -04:00
|
|
|
$('.NB-progress-link', $progress).html($.make('a', { href: '#', className: 'NB-splash-link NB-menu-manage-feedchooser' }, 'Choose your 64'));
|
|
|
|
|
|
|
|
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();
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!$progress.is(':visible')) {
|
|
|
|
setTimeout(function() {
|
|
|
|
self.show_progress_bar();
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_unfetched_feed_progress: function(permanent) {
|
|
|
|
if (permanent) {
|
|
|
|
this.model.preference('hide_fetch_progress', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.hide_progress_bar();
|
|
|
|
},
|
|
|
|
|
2010-12-04 23:06:35 -05:00
|
|
|
switch_preferences_hide_read_feeds: function() {
|
|
|
|
var hide_read_feeds = parseInt(this.model.preference('hide_read_feeds'), 10);
|
2010-12-04 23:18:07 -05:00
|
|
|
var $button = $('.NB-feeds-header-sites');
|
2010-12-04 23:06:35 -05:00
|
|
|
|
|
|
|
if (hide_read_feeds) {
|
|
|
|
$button.tipsy('hide');
|
|
|
|
$button.attr('title', 'Show only unread stories');
|
|
|
|
$button.tipsy('show');
|
|
|
|
} else {
|
|
|
|
$button.tipsy('hide');
|
|
|
|
$button.attr('title', 'Show all sites');
|
|
|
|
$button.tipsy('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.model.preference('hide_read_feeds', hide_read_feeds ? 0 : 1);
|
|
|
|
this.switch_feed_view_unread_view();
|
|
|
|
},
|
|
|
|
|
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,
|
|
|
|
'find_next_unread_on_page_of_feed_stories_load': 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,
|
2010-10-05 19:05:01 -04:00
|
|
|
'feed_list_showing_manage_menu': false
|
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': {},
|
|
|
|
'feed_view_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,
|
|
|
|
'prefetch_iteration': 0
|
2010-07-02 12:02:10 -04:00
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
|
|
|
this.active_feed = null;
|
2010-12-08 20:53:45 -05:00
|
|
|
this.active_story = null;
|
2010-06-14 13:17:38 -04:00
|
|
|
this.$s.$story_titles.data('page', 0);
|
|
|
|
this.$s.$story_titles.data('feed_id', null);
|
2010-09-05 18:08:08 -07:00
|
|
|
this.$s.$feed_view.empty();
|
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');
|
2010-12-12 20:06:32 -05:00
|
|
|
$('.NB-selected', this.$s.$feed_list).removeClass('NB-selected');
|
2010-12-12 22:52:15 -05:00
|
|
|
this.$s.$body.removeClass('NB-view-river');
|
2010-12-04 21:53:39 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).removeClass('NB-disabled');
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-11-24 13:16:10 -05:00
|
|
|
open_feed: function(feed_id, force, $feed_link, delay) {
|
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;
|
2010-06-08 11:19:41 -04:00
|
|
|
this.flags['opening_feed'] = true;
|
|
|
|
|
2010-08-30 22:42:44 -04:00
|
|
|
if (feed_id != this.active_feed || force) {
|
2010-11-01 18:20:26 -04:00
|
|
|
$story_titles.empty().scrollTop(0);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.reset_feed();
|
|
|
|
this.hide_splash_page();
|
|
|
|
|
|
|
|
this.active_feed = feed_id;
|
2010-11-24 13:16:10 -05:00
|
|
|
this.next_feed = feed_id;
|
2010-06-14 13:17:38 -04:00
|
|
|
$story_titles.data('page', 0);
|
|
|
|
$story_titles.data('feed_id', feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.iframe_scroll = null;
|
2010-10-28 18:17:14 -04:00
|
|
|
this.set_correct_story_view_for_feed(feed_id);
|
2010-10-13 09:08:42 -04:00
|
|
|
$feed_link = $feed_link || $('.feed.selected', this.$s.$feed_list).eq(0);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.mark_feed_as_selected(feed_id, $feed_link);
|
2010-11-01 18:20:26 -04:00
|
|
|
this.show_feed_title_in_stories(feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
this.show_feedbar_loading();
|
|
|
|
this.make_content_pane_feed_counter(feed_id);
|
|
|
|
this.switch_taskbar_view(this.story_view);
|
|
|
|
// NEWSBLUR.log(['open_feed', this.flags, this.active_feed, feed_id]);
|
2010-11-24 13:16:10 -05:00
|
|
|
|
|
|
|
_.delay(_.bind(function() {
|
|
|
|
if (!delay || feed_id == self.next_feed) {
|
|
|
|
this.model.load_feed(feed_id, 0, true, $.rescope(this.post_open_feed, this));
|
|
|
|
}
|
|
|
|
}, this), delay || 0);
|
2010-07-06 18:30:16 -04:00
|
|
|
var feed_view_setting = this.model.view_setting(feed_id);
|
2010-07-06 18:43:06 -04:00
|
|
|
if (!feed_view_setting || feed_view_setting == 'page') {
|
2010-11-24 13:16:10 -05:00
|
|
|
_.delay(_.bind(function() {
|
|
|
|
if (!delay || feed_id == self.next_feed) {
|
2010-12-06 10:41:24 -05:00
|
|
|
this.load_feed_iframe(feed_id);
|
2010-11-24 13:16:10 -05:00
|
|
|
}
|
|
|
|
}, this), 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.flags['opening_feed'] = false; // don't trigger scroll, which fetches more stories
|
|
|
|
this.setup_mousemove_on_views();
|
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) {
|
2010-10-11 12:07:32 -04:00
|
|
|
return this.open_feed(this.active_feed, 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
|
|
|
|
|
|
|
if (this.active_feed == feed_id) {
|
|
|
|
// NEWSBLUR.log(['post_open_feed', data.stories, this.flags]);
|
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
|
|
|
this.story_titles_clear_loading_endbar();
|
|
|
|
this.create_story_titles(stories);
|
|
|
|
this.make_story_feed_entries(stories, first_load);
|
2010-11-01 18:20:26 -04:00
|
|
|
this.show_feed_hidden_story_title_indicator();
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({'animate': false});
|
2010-09-22 19:59:07 -04:00
|
|
|
$('.NB-feedbar-last-updated-date').text(data.last_update + ' ago');
|
2010-06-08 11:19:41 -04:00
|
|
|
if (this.flags['find_next_unread_on_page_of_feed_stories_load']) {
|
|
|
|
this.show_next_unread_story(true);
|
|
|
|
}
|
2010-12-25 23:25:09 -05:00
|
|
|
this.flags['story_titles_loaded'] = true;
|
2010-06-08 11:19:41 -04:00
|
|
|
if (!first_load) {
|
|
|
|
var stories_count = this.cache['iframe_story_positions_keys'].length;
|
|
|
|
this.flags.iframe_story_locations_fetched = false;
|
2010-12-06 10:41:24 -05:00
|
|
|
var $iframe = this.$s.$feed_iframe.contents();
|
2010-06-08 11:19:41 -04:00
|
|
|
this.fetch_story_locations_in_story_frame(stories_count, false, $iframe);
|
2010-12-25 23:25:09 -05:00
|
|
|
if (this.story_view == 'feed') {
|
|
|
|
this.prefetch_story_locations_in_feed_view();
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
} else {
|
2010-12-08 20:53:45 -05:00
|
|
|
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();
|
|
|
|
}, this), 500);
|
|
|
|
}
|
|
|
|
} else if (this.story_view == 'feed') {
|
|
|
|
this.prefetch_story_locations_in_feed_view();
|
2010-06-10 14:23:02 -04:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-12-14 17:08:52 -05:00
|
|
|
if (this.flags['open_unread_stories_in_tabs']) {
|
|
|
|
_.defer(_.bind(this.open_unread_stories_in_tabs, this));
|
|
|
|
}
|
2010-06-08 11:19:41 -04: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) {
|
2010-10-28 18:17:14 -04:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-12-02 11:09:09 -05:00
|
|
|
view = view || this.model.view_setting(feed_id);
|
2010-10-28 18:17:14 -04:00
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
if (feed && feed.has_exception && feed.exception_type == 'page') {
|
2010-10-28 18:17:14 -04:00
|
|
|
if (view == 'page') {
|
|
|
|
view = 'feed';
|
|
|
|
}
|
|
|
|
$('.task_view_page').addClass('NB-exception-page');
|
|
|
|
} else {
|
|
|
|
$('.task_view_page').removeClass('NB-exception-page');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.story_view = view;
|
|
|
|
},
|
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
// ===============
|
|
|
|
// = Feed Header =
|
|
|
|
// ===============
|
|
|
|
|
|
|
|
update_header_counts: function(skip_sites) {
|
|
|
|
if (!skip_sites) {
|
|
|
|
var feeds_count = _.select(this.model.feeds, function(f) {
|
|
|
|
return f.active;
|
|
|
|
}).length;
|
|
|
|
if (feeds_count) {
|
2010-12-04 23:06:35 -05:00
|
|
|
$('.NB-feeds-header-right .NB-feeds-header-sites').text(feeds_count + Inflector.pluralize(' site', feeds_count));
|
2010-12-02 11:09:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var unread_counts = _.reduce(this.model.feeds, function(m, v) {
|
|
|
|
if (v.active) {
|
|
|
|
m['positive'] += v.ps;
|
|
|
|
m['neutral'] += v.nt;
|
|
|
|
m['negative'] += v.ng;
|
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}, {'positive': 0, 'negative': 0, 'neutral': 0});
|
|
|
|
_(['positive', 'neutral', 'negative']).each(function(level) {
|
|
|
|
var $count = $('.NB-feeds-header-'+level);
|
|
|
|
$count.text(unread_counts[level]);
|
|
|
|
$count.toggleClass('NB-empty', unread_counts[level] == 0);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
update_starred_count: function() {
|
|
|
|
var starred_count = this.model.starred_count;
|
|
|
|
var $starred_count = $('.NB-feeds-header-starred-count', this.$s.$starred_header);
|
|
|
|
var $starred_container = this.$s.$starred_header.closest('.NB-feeds-header-starred-container');
|
2010-09-05 18:08:08 -07:00
|
|
|
|
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
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
open_starred_stories: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
|
|
|
|
$story_titles.empty().scrollTop('0px');
|
|
|
|
this.reset_feed();
|
|
|
|
this.hide_splash_page();
|
2010-12-04 13:32:13 -05:00
|
|
|
this.active_feed = 'starred';
|
|
|
|
|
2010-12-02 11:09:09 -05:00
|
|
|
$story_titles.data('page', 0);
|
|
|
|
$story_titles.data('feed_id', null);
|
|
|
|
this.iframe_scroll = null;
|
|
|
|
this.mark_feed_as_selected(null, null);
|
|
|
|
this.$s.$starred_header.addClass('NB-selected');
|
2010-12-12 22:52:15 -05:00
|
|
|
this.$s.$body.addClass('NB-view-river');
|
2010-12-04 21:53:39 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).addClass('NB-disabled');
|
2010-12-04 13:32:13 -05:00
|
|
|
var explicit_view_setting = NEWSBLUR.Preferences.view_settings[this.active_feed];
|
|
|
|
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.show_feed_title_in_stories(feed_id);
|
|
|
|
this.show_feedbar_loading();
|
|
|
|
// this.make_content_pane_feed_counter(feed_id);
|
|
|
|
this.switch_taskbar_view(this.story_view);
|
|
|
|
this.setup_mousemove_on_views();
|
|
|
|
|
2010-12-03 09:49:38 -05:00
|
|
|
this.model.fetch_starred_stories(0, _.bind(this.post_open_starred_stories, this), 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]);
|
2010-12-02 20:18:33 -05:00
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
|
|
|
this.story_titles_clear_loading_endbar();
|
2010-12-10 15:26:50 -05:00
|
|
|
this.create_story_titles(data.stories, {'river_stories': true});
|
|
|
|
this.make_story_feed_entries(data.stories, first_load, {'river_stories': true});
|
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
|
|
|
// $('.NB-feedbar-last-updated-date').text(data.last_update + ' ago');
|
|
|
|
this.flags['story_titles_loaded'] = true;
|
2010-12-12 23:22:53 -05:00
|
|
|
this.prefetch_story_locations_in_feed_view();
|
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;
|
2010-09-14 20:49:28 -04:00
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
$story_titles.empty().scrollTop('0px');
|
|
|
|
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;
|
|
|
|
}
|
2010-11-24 13:16:10 -05:00
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
$story_titles.data('page', 0);
|
|
|
|
$story_titles.data('feed_id', null);
|
|
|
|
this.iframe_scroll = null;
|
|
|
|
this.mark_feed_as_selected(null, null);
|
|
|
|
this.$s.$body.addClass('NB-view-river');
|
2010-12-12 22:52:15 -05:00
|
|
|
$folder.addClass('NB-selected');
|
2010-12-10 15:26:50 -05:00
|
|
|
$('.task_view_page', this.$s.$taskbar).addClass('NB-disabled');
|
|
|
|
var explicit_view_setting = NEWSBLUR.Preferences.view_settings[this.active_feed];
|
|
|
|
if (!explicit_view_setting) {
|
|
|
|
explicit_view_setting = 'feed';
|
|
|
|
}
|
|
|
|
this.set_correct_story_view_for_feed(this.active_feed, explicit_view_setting);
|
|
|
|
// this.show_feed_title_in_stories(feed_id);
|
|
|
|
this.show_feedbar_loading();
|
|
|
|
// this.make_content_pane_feed_counter(feed_id);
|
|
|
|
this.switch_taskbar_view(this.story_view);
|
|
|
|
this.setup_mousemove_on_views();
|
|
|
|
|
2010-12-12 22:52:15 -05:00
|
|
|
var feeds = this.list_feeds_with_unreads_in_folder($folder);
|
2010-12-10 15:26:50 -05:00
|
|
|
this.model.fetch_river_stories(feeds, 0, _.bind(this.post_open_river_stories, this), true);
|
|
|
|
},
|
|
|
|
|
|
|
|
post_open_river_stories: function(data, first_load) {
|
2010-12-12 23:22:53 -05:00
|
|
|
if (this.active_feed.indexOf('river:') != -1) {
|
|
|
|
// NEWSBLUR.log(['post_open_river_stories', data.stories.length, first_load, this.flags['feed_view_positions_calculated']]);
|
2010-12-10 15:26:50 -05:00
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
|
|
|
this.story_titles_clear_loading_endbar();
|
|
|
|
this.create_story_titles(data.stories, {'river_stories': true});
|
|
|
|
this.make_story_feed_entries(data.stories, first_load, {'river_stories': true});
|
|
|
|
this.show_story_titles_above_intelligence_level({'animate': false});
|
|
|
|
// $('.NB-feedbar-last-updated-date').text(data.last_update + ' ago');
|
|
|
|
this.flags['story_titles_loaded'] = true;
|
2010-12-12 23:22:53 -05:00
|
|
|
this.prefetch_story_locations_in_feed_view();
|
2010-12-10 15:26:50 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
list_feeds_with_unreads_in_folder: function($folder) {
|
2010-12-12 22:52:15 -05:00
|
|
|
var model = this.model;
|
|
|
|
$folder = $folder || this.$s.$feed_list;
|
|
|
|
|
|
|
|
var $feeds = $('.feed:not(.NB-empty)', $folder);
|
|
|
|
var feeds = _.compact(_.map($('.feed:not(.NB-empty)', $folder), function(o) {
|
|
|
|
var feed_id = $(o).data('feed_id');
|
|
|
|
var feed = model.get_feed(feed_id);
|
|
|
|
return (feed.ps || feed.nt || feed.ng) && feed_id;
|
|
|
|
}));
|
2010-12-10 15:26:50 -05:00
|
|
|
|
2010-12-12 22:52:15 -05:00
|
|
|
this.cache['river_feeds_with_unreads'] = feeds;
|
|
|
|
|
|
|
|
return feeds;
|
2010-09-14 20:49:28 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// ==========================
|
|
|
|
// = Story Pane - All Views =
|
|
|
|
// ==========================
|
|
|
|
|
2010-12-14 18:48:52 -05:00
|
|
|
open_story: function(story, $story_title) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var self = this;
|
|
|
|
var feed_position;
|
|
|
|
var iframe_position;
|
2010-12-08 20:53:45 -05:00
|
|
|
// NEWSBLUR.log(['Story', this.story_view, story]);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (this.active_story != story) {
|
|
|
|
this.active_story = story;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-14 18:48:52 -05:00
|
|
|
this.mark_story_title_as_selected($story_title);
|
2010-12-30 19:24:52 -05:00
|
|
|
this.mark_story_as_read(story.id);
|
2010-06-08 11:19:41 -04: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);
|
|
|
|
this.flags['scrolling_by_selecting_story_title'] = true;
|
|
|
|
|
|
|
|
// User clicks on story, scroll them to it.
|
|
|
|
var $feed_story = this.find_story_in_feed_view(story);
|
|
|
|
|
|
|
|
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);
|
|
|
|
feed_position = this.scroll_to_story_in_story_feed(story, $feed_story);
|
|
|
|
} 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();
|
|
|
|
feed_position = this.scroll_to_story_in_story_feed(story, $feed_story);
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
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) {
|
2010-12-07 20:04:37 -05: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_story_feed: function(story, $story, skip_scroll) {
|
|
|
|
var self = this;
|
|
|
|
var $feed_view = this.$s.$feed_view;
|
|
|
|
|
|
|
|
if (!story || !$story || !$story.length) {
|
|
|
|
$story = $('.story:first', $feed_view);
|
|
|
|
story = this.model.get_story($story.data('story'));
|
|
|
|
}
|
2010-06-28 13:25:02 -04:00
|
|
|
if (!story || !$story || !$story.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// NEWSBLUR.log(['scroll_to_story_in_story_feed', story, $story]);
|
|
|
|
|
|
|
|
if ($story && $story.length) {
|
2010-12-07 09:52:14 -05:00
|
|
|
if (skip_scroll ||
|
2010-12-08 20:53:45 -05:00
|
|
|
(this.story_view == 'feed' &&
|
|
|
|
this.model.preference('feed_view_single_story')) ||
|
2010-12-07 09:52:14 -05:00
|
|
|
(this.story_view == 'page' &&
|
|
|
|
!this.flags['page_view_showing_feed_view'])) {
|
2010-06-14 13:17:38 -04:00
|
|
|
$feed_view.scrollTo($story, 0, { axis: 'y', offset: 0 }); // Do this at view switch instead.
|
|
|
|
|
|
|
|
} else if (this.story_view == 'feed' || this.flags['page_view_showing_feed_view']) {
|
|
|
|
$feed_view.scrollable().stop();
|
2010-12-09 18:47:06 -05:00
|
|
|
$feed_view.scrollTo($story, 420, { axis: 'y', easing: 'easeInOutQuint', offset: 0, queue: false, onAfter: function() {
|
2010-12-14 18:48:52 -05:00
|
|
|
self.locks.scrolling = setTimeout(function() {
|
|
|
|
self.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
}, 100);
|
2010-12-09 18:47:06 -05: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
|
|
|
var parent_scroll = $story.parents('.NB-feed-story-view').scrollTop();
|
|
|
|
var story_offset = $story.offset().top;
|
|
|
|
return story_offset + parent_scroll;
|
|
|
|
},
|
|
|
|
|
|
|
|
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;
|
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']) {
|
|
|
|
$iframe.scrollTo($story, 0, { axis: 'y', offset: -24 }); // Do this at story_view switch
|
|
|
|
} else if (this.story_view == 'page') {
|
|
|
|
$iframe.scrollable().stop();
|
2010-12-09 18:47:06 -05:00
|
|
|
$iframe.scrollTo($story, 580, { axis: 'y', easing: 'easeInOutQuint', offset: -24, queue: false, onAfter: function() {
|
2010-12-14 18:48:52 -05:00
|
|
|
self.locks.scrolling = setTimeout(function() {
|
|
|
|
self.flags.scrolling_by_selecting_story_title = false;
|
|
|
|
}, 100);
|
2010-12-09 18:47:06 -05:00
|
|
|
} });
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
var parent_scroll = $story.parents('.NB-feed-story-view').scrollTop();
|
|
|
|
var story_offset = $story.offset().top;
|
|
|
|
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);
|
2010-11-06 12:53:42 -04:00
|
|
|
// NEWSBLUR.log(['Pre-fetching', parseInt(s, 10), last_story_index, last_story_same_position, $story, story.story_title]);
|
|
|
|
if (!$story ||
|
|
|
|
!$story.length ||
|
|
|
|
this.flags['iframe_fetching_story_locations'] ||
|
2010-11-08 19:39:27 -05:00
|
|
|
this.flags['iframe_story_locations_fetched'] ||
|
|
|
|
parseInt($story.offset().top, 10) > this.cache['prefetch_iteration']*4000) {
|
2010-11-06 12:53:42 -04:00
|
|
|
if ($story && $story.length) {
|
2010-11-08 19:39:27 -05:00
|
|
|
NEWSBLUR.log(['Prefetch break on position too far', parseInt($story.offset().top, 10), this.cache['prefetch_iteration']*4000]);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}, 2000);
|
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;
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (story && story['story_feed_id'] == this.active_feed) {
|
2010-12-06 10:41:24 -05:00
|
|
|
var $story = this.find_story_in_feed_iframe(story, $iframe);
|
2010-11-08 19:27:57 -05:00
|
|
|
// NEWSBLUR.log(['Fetching story', s, {'title': story.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);
|
|
|
|
self.flags.iframe_story_locations_fetched = false;
|
|
|
|
} else {
|
|
|
|
NEWSBLUR.log(['iFrame view entirely loaded', (s-2) + ' stories', self.cache.iframe_stories]);
|
|
|
|
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);
|
2010-06-14 13:17:38 -04:00
|
|
|
} else if (story && story['story_feed_id'] != this.active_feed) {
|
|
|
|
NEWSBLUR.log(['Switched off iframe early']);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
open_story_link: function(story, $st) {
|
2010-11-15 22:43:01 -05:00
|
|
|
window.open(story['story_permalink'], '_blank');
|
2010-06-14 13:17:38 -04:00
|
|
|
window.focus();
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
mark_story_title_as_selected: function($story_title) {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
$('.selected', $story_titles).removeClass('selected');
|
|
|
|
$('.after_selected', $story_titles).removeClass('after_selected');
|
|
|
|
$story_title.addClass('selected');
|
|
|
|
$story_title.parent('.story').next('.story').children('a').addClass('after_selected');
|
|
|
|
},
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-30 19:24:52 -05:00
|
|
|
mark_story_as_read: function(story_id) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-12-30 19:24:52 -05:00
|
|
|
var $story_title = this.find_story_in_story_titles(story_id);
|
2010-12-14 19:23:16 -05:00
|
|
|
var feed_id = parseInt($story_title.data('feed_id'), 10) || this.active_feed;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-30 19:24:52 -05:00
|
|
|
this.model.mark_story_as_read(story_id, feed_id, function(read) {
|
|
|
|
self.update_read_count(story_id, feed_id, false, read);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
mark_story_as_unread: function(story_id, feed_id) {
|
|
|
|
var self = this;
|
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-09-05 18:08:08 -07:00
|
|
|
|
2010-12-30 19:24:52 -05:00
|
|
|
this.model.mark_story_as_unread(story_id, feed_id, function() {
|
|
|
|
self.update_read_count(story_id, feed_id, true);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
update_read_count: function(story_id, feed_id, unread, previously_read) {
|
|
|
|
if (previously_read) return;
|
|
|
|
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var $feed_list = this.$s.$feed_list;
|
|
|
|
var $feed = this.find_feed_in_feed_list(feed_id);
|
|
|
|
var $feed_counts = $('.feed_counts_floater', $feed);
|
|
|
|
var $story_title = this.find_story_in_story_titles(story_id);
|
|
|
|
var $content_pane = this.$s.$content_pane;
|
|
|
|
var unread_count_positive = feed.ps;
|
|
|
|
var unread_count_neutral = feed.nt;
|
|
|
|
var unread_count_negative = feed.ng;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-30 19:24:52 -05:00
|
|
|
$story_title.toggleClass('read', !unread);
|
|
|
|
// NEWSBLUR.log(['marked read', unread_count_positive, unread_count_neutral, unread_count_negative, $story_title.is('.NB-story-positive'), $story_title.is('.NB-story-neutral'), $story_title.is('.NB-story-negative')]);
|
|
|
|
|
|
|
|
if ($story_title.is('.NB-story-positive')) {
|
|
|
|
var count = Math.max(unread_count_positive + (unread?1:-1), 0);
|
|
|
|
feed.ps = count;
|
|
|
|
$('.unread_count_positive', $feed).text(count);
|
|
|
|
$('.unread_count_positive', $content_pane).text(count);
|
|
|
|
if (count == 0) {
|
|
|
|
$feed.removeClass('unread_positive');
|
|
|
|
$feed_counts.removeClass('unread_positive');
|
|
|
|
} else {
|
|
|
|
$feed.addClass('unread_positive');
|
|
|
|
$feed_counts.addClass('unread_positive');
|
2010-09-05 18:08:08 -07:00
|
|
|
}
|
2010-12-30 19:24:52 -05:00
|
|
|
} else if ($story_title.is('.NB-story-neutral')) {
|
|
|
|
var count = Math.max(unread_count_neutral + (unread?1:-1), 0);
|
|
|
|
feed.nt = count;
|
|
|
|
$('.unread_count_neutral', $feed).text(count);
|
|
|
|
$('.unread_count_neutral', $content_pane).text(count);
|
|
|
|
if (count == 0) {
|
|
|
|
$feed.removeClass('unread_neutral');
|
|
|
|
$feed_counts.removeClass('unread_neutral');
|
|
|
|
} else {
|
|
|
|
$feed.addClass('unread_neutral');
|
|
|
|
$feed_counts.addClass('unread_neutral');
|
|
|
|
}
|
|
|
|
} else if ($story_title.is('.NB-story-negative')) {
|
|
|
|
var count = Math.max(unread_count_negative + (unread?1:-1), 0);
|
|
|
|
feed.ng = count;
|
|
|
|
$('.unread_count_negative', $feed).text(count);
|
|
|
|
$('.unread_count_negative', $content_pane).text(count);
|
|
|
|
if (count == 0) {
|
|
|
|
$feed.removeClass('unread_negative');
|
|
|
|
$feed_counts.removeClass('unread_negative');
|
|
|
|
} else {
|
|
|
|
$feed.addClass('unread_negative');
|
|
|
|
$feed_counts.addClass('unread_negative');
|
2010-09-05 18:08:08 -07:00
|
|
|
}
|
2010-12-30 19:24:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$('.feed', $content_pane).animate({'opacity': 1}, {'duration': 250, 'queue': false});
|
2010-09-05 18:08:08 -07:00
|
|
|
|
2010-12-30 19:24:52 -05:00
|
|
|
setTimeout(function() {
|
|
|
|
$('.feed', $content_pane).animate({'opacity': .1}, {'duration': 250, 'queue': false});
|
|
|
|
}, 400);
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-30 19:24:52 -05:00
|
|
|
if (!$feed.is(':visible')) {
|
|
|
|
// NEWSBLUR.log(['Under collapsed folder', $feed, $feed.parents(':visible'),
|
|
|
|
// $feed.parents(':visible').eq(0).children('.folder_title')]);
|
|
|
|
var $folder_title = $feed.parents(':visible').eq(0).children('.folder_title');
|
|
|
|
var $children = $folder_title.parent('.folder').children('.folder, .feed');
|
|
|
|
this.show_collapsed_folder_count($folder_title, $children);
|
|
|
|
}
|
|
|
|
|
2010-11-22 10:44:52 -05:00
|
|
|
this.update_header_counts(true);
|
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]);
|
2010-11-25 09:26:21 -05:00
|
|
|
this.update_header_counts(true);
|
2010-09-16 10:35:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
mark_folder_as_read: function(folder_name, $folder) {
|
2010-09-21 11:16:22 -04:00
|
|
|
var feeds = this.get_feed_ids_in_folder($folder);
|
2010-06-14 13:17:38 -04: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.mark_feed_as_read_update_counts(null, $folder);
|
|
|
|
this.model.mark_feed_as_read(feeds);
|
2010-11-25 09:26:21 -05:00
|
|
|
this.update_header_counts(true);
|
2010-09-16 10:35:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
mark_feed_as_read_update_counts: function(feed_id, $folder) {
|
|
|
|
if (feed_id) {
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
var $feed = this.find_feed_in_feed_list(feed_id);
|
|
|
|
var $feed_counts = $('.feed_counts_floater', $feed);
|
|
|
|
var $content_pane = this.$s.$content_pane;
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-09-16 10:35:36 -04:00
|
|
|
feed.ps = 0;
|
|
|
|
feed.nt = 0;
|
|
|
|
feed.ng = 0;
|
|
|
|
$('.unread_count_neutral', $feed).text(0);
|
|
|
|
$('.unread_count_positive', $feed).text(0);
|
|
|
|
$('.unread_count_negative', $feed).text(0);
|
|
|
|
if (feed_id == this.active_feed) {
|
|
|
|
$('.unread_count_neutral', $content_pane).text(0);
|
|
|
|
$('.unread_count_positive', $content_pane).text(0);
|
|
|
|
$('.unread_count_negative', $content_pane).text(0);
|
|
|
|
$('.story:not(.read)', $story_titles).addClass('read');
|
|
|
|
}
|
|
|
|
$feed.removeClass('unread_neutral');
|
|
|
|
$feed.removeClass('unread_positive');
|
|
|
|
$feed.removeClass('unread_negative');
|
|
|
|
$feed_counts.removeClass('unread_neutral');
|
|
|
|
$feed_counts.removeClass('unread_positive');
|
|
|
|
$feed_counts.removeClass('unread_negative');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($folder) {
|
|
|
|
$('.unread_count_neutral', $folder).text(0);
|
|
|
|
$('.unread_count_positive', $folder).text(0);
|
|
|
|
$('.unread_count_negative', $folder).text(0);
|
|
|
|
$feed_counts = $('.feed_counts_floater', $folder);
|
|
|
|
$feed_counts.removeClass('unread_neutral');
|
|
|
|
$feed_counts.removeClass('unread_positive');
|
|
|
|
$feed_counts.removeClass('unread_negative');
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
mark_story_as_like: function(story_id, feed_id) {
|
2010-12-31 14:35:00 -05:00
|
|
|
feed_id = feed_id || this.model.get_story(story_id).story_feed_id;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
var is_starred_view = this.active_feed == 'starred';
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierStory(story_id, feed_id, {
|
|
|
|
'score': 1,
|
|
|
|
'feed_loaded': !is_starred_view
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
mark_story_as_dislike: function(story_id, feed_id) {
|
|
|
|
feed_id = feed_id || this.active_feed;
|
2010-06-14 13:17:38 -04:00
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
var is_starred_view = this.active_feed == 'starred';
|
|
|
|
|
|
|
|
NEWSBLUR.classifier = new NEWSBLUR.ReaderClassifierStory(story_id, feed_id, {
|
|
|
|
'score': -1,
|
|
|
|
'feed_loaded': !is_starred_view
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-30 18:37:29 -05:00
|
|
|
mark_story_as_starred: function(story_id, $story) {
|
2010-12-04 13:32:13 -05:00
|
|
|
var story = this.model.get_story(story_id);
|
2010-12-31 10:34:31 -05:00
|
|
|
var $star = $('.NB-storytitles-star', $story);
|
2010-12-30 18:37:29 -05:00
|
|
|
$story.addClass('NB-story-starred');
|
|
|
|
$star.attr({'title': 'Saved!'});
|
|
|
|
$star.tipsy({
|
|
|
|
gravity: 'sw',
|
|
|
|
fade: true,
|
|
|
|
trigger: 'manual',
|
2010-12-31 10:34:31 -05:00
|
|
|
offsetOpposite: -1
|
2010-11-30 10:30:18 -05:00
|
|
|
});
|
2010-12-30 18:37:29 -05:00
|
|
|
$star.tipsy('enable');
|
|
|
|
$star.tipsy('show');
|
|
|
|
_.delay(function() {
|
|
|
|
$star.tipsy('hide');
|
|
|
|
$star.tipsy('disable');
|
|
|
|
}, 850);
|
|
|
|
this.model.mark_story_as_starred(story_id, story.story_feed_id, function() {});
|
2010-12-02 11:09:09 -05:00
|
|
|
this.update_starred_count();
|
2010-11-30 10:30:18 -05:00
|
|
|
},
|
|
|
|
|
2010-12-30 18:37:29 -05:00
|
|
|
mark_story_as_unstarred: function(story_id, $story) {
|
2010-12-31 10:34:31 -05:00
|
|
|
var $star = $('.NB-storytitles-star', $story);
|
2010-12-30 18:37:29 -05:00
|
|
|
$story.one('mouseout', function() {
|
|
|
|
$story.removeClass('NB-unstarred');
|
2010-12-01 09:30:56 -05:00
|
|
|
});
|
2010-12-30 18:37:29 -05:00
|
|
|
$star.attr({'title': 'Removed'});
|
|
|
|
$star.tipsy({
|
|
|
|
gravity: 'sw',
|
|
|
|
fade: true,
|
|
|
|
trigger: 'manual',
|
2010-12-31 10:34:31 -05:00
|
|
|
offsetOpposite: -1
|
2010-12-01 09:30:56 -05:00
|
|
|
});
|
2010-12-30 18:37:29 -05:00
|
|
|
$star.tipsy('enable');
|
|
|
|
$star.tipsy('show');
|
|
|
|
_.delay(function() {
|
|
|
|
$star.tipsy('hide');
|
|
|
|
$star.tipsy('disable');
|
|
|
|
}, 850);
|
2010-12-31 10:34:31 -05:00
|
|
|
$story.removeClass('NB-story-starred');
|
2010-12-30 18:37:29 -05:00
|
|
|
this.model.mark_story_as_unstarred(story_id, function() {});
|
2010-12-02 11:09:09 -05:00
|
|
|
this.update_starred_count();
|
2010-12-01 09:30:56 -05:00
|
|
|
},
|
|
|
|
|
2010-12-31 10:34:31 -05:00
|
|
|
send_story_to_instapaper: function(story_id) {
|
|
|
|
var story = this.model.get_story(story_id);
|
|
|
|
var url = 'https://www.instapaper.com/api/add';
|
|
|
|
window.open(url + '?url=' + story.story_permalink + '&title=' + story.story_title, '_blank');
|
2010-06-08 11:19:41 -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;
|
2010-06-14 13:17:38 -04:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-07-26 21:38:56 -04:00
|
|
|
var $counter = this.make_feed_title_line(feed, false, 'counter');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$('.feed', $content_pane).remove();
|
|
|
|
$('#story_taskbar', $content_pane).append($counter);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$('.unread_count', $content_pane).corner('4px');
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
// Center the counter
|
|
|
|
var i_width = $('.feed', $content_pane).width();
|
|
|
|
var o_width = $content_pane.width();
|
|
|
|
var left = (o_width / 2.0) - (i_width / 2.0);
|
|
|
|
$('.feed', $content_pane).css({'left': left});
|
|
|
|
},
|
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
create_story_titles: function(stories, options) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-12-04 16:42:51 -05:00
|
|
|
options = options || {};
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
for (s in stories) {
|
|
|
|
var story = stories[s];
|
2010-12-04 16:42:51 -05:00
|
|
|
var $story_title = this.make_story_title(story, options);
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!stories[s].read_status) {
|
|
|
|
var $mark_read = $.make('a', { className: 'mark_story_as_read', href: '#'+stories[s].id }, '[Mark Read]');
|
|
|
|
$story_title.find('.title').append($mark_read);
|
2010-06-11 20:55:38 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
$story_titles.append($story_title);
|
|
|
|
}
|
|
|
|
// NEWSBLUR.log(['create_story_titles', stories]);
|
|
|
|
if (!stories || stories.length == 0) {
|
|
|
|
var $end_stories_line = $.make('div', {
|
|
|
|
className: 'NB-story-titles-end-stories-line'
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!($('.NB-story-titles-end-stories-line', $story_titles).length)) {
|
|
|
|
$story_titles.append($end_stories_line);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-11-26 19:03:31 -05:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-12-04 16:42:51 -05:00
|
|
|
make_story_title: function(story, options) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var unread_view = this.model.preference('unread_view');
|
|
|
|
var read = story.read_status
|
2010-11-30 10:30:18 -05:00
|
|
|
? ' read '
|
2010-06-14 13:17:38 -04:00
|
|
|
: '';
|
|
|
|
var score = this.compute_story_score(story);
|
|
|
|
var score_color = 'neutral';
|
2010-11-30 10:30:18 -05:00
|
|
|
var starred = story.starred ? ' NB-story-starred ' : '';
|
2010-12-12 22:52:15 -05:00
|
|
|
if (options.river_stories) {
|
2010-12-04 16:42:51 -05:00
|
|
|
var feed = this.model.get_feed(story.story_feed_id);
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
if (score > 0) score_color = 'positive';
|
|
|
|
if (score < 0) score_color = 'negative';
|
|
|
|
var $story_tags = $.make('span', { className: 'NB-storytitles-tags'});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
for (var t in story.story_tags) {
|
|
|
|
var tag = story.story_tags[t];
|
|
|
|
var $tag = $.make('span', { className: 'NB-storytitles-tag'}, tag).corner('4px');
|
|
|
|
$story_tags.append($tag);
|
|
|
|
break;
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-12-02 20:18:33 -05:00
|
|
|
var $story_title = $.make('div', { className: 'story ' + read + starred + 'NB-story-' + score_color }, [
|
2010-12-30 18:37:29 -05:00
|
|
|
$.make('div', { className: 'NB-storytitles-sentiment'}),
|
2010-12-31 10:34:31 -05:00
|
|
|
$.make('div', { className: 'NB-storytitles-star'}),
|
2010-11-15 22:43:01 -05:00
|
|
|
$.make('a', { href: story.story_permalink, className: 'story_title' }, [
|
2010-06-14 13:17:38 -04:00
|
|
|
$.make('span', { className: 'NB-storytitles-title' }, story.story_title),
|
|
|
|
$.make('span', { className: 'NB-storytitles-author' }, story.story_authors),
|
|
|
|
$story_tags
|
|
|
|
]),
|
2010-12-12 22:52:15 -05:00
|
|
|
(options['river_stories'] && feed &&
|
2010-12-04 16:42:51 -05:00
|
|
|
$.make('div', { className: 'NB-story-feed' }, [
|
|
|
|
$.make('img', { className: 'feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + feed.feed_link }),
|
|
|
|
$.make('span', { className: 'feed_title' }, feed.feed_title)
|
|
|
|
])),
|
2010-06-14 13:17:38 -04:00
|
|
|
$.make('span', { className: 'story_date' }, story.short_parsed_date),
|
|
|
|
$.make('span', { className: 'story_id' }, ''+story.id),
|
2010-12-30 18:37:29 -05:00
|
|
|
$.make('div', { className: 'NB-story-manage-icon' })
|
|
|
|
// $.make('div', { className: 'NB-story-sentiment NB-story-like', title: 'What I like about this story...' }),
|
|
|
|
// $.make('div', {
|
|
|
|
// className: 'NB-story-sentiment NB-story-star',
|
|
|
|
// title: (story.starred
|
|
|
|
// ? 'Remove bookmark'
|
|
|
|
// : 'Save this story for later')
|
|
|
|
// })
|
2010-12-04 16:42:51 -05:00
|
|
|
]).data('story_id', story.id).data('feed_id', story.story_feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (unread_view > score) {
|
|
|
|
$story_title.css({'display': 'none'});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-11-26 19:03:31 -05:00
|
|
|
|
|
|
|
$('.NB-story-sentiment', $story_title).tipsy({
|
|
|
|
delayIn: 375,
|
|
|
|
gravity: 's'
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
return $story_title;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
story_titles_clear_loading_endbar: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
|
|
|
|
var $endbar = $('.NB-story-titles-end-stories-line', $story_titles);
|
|
|
|
if ($endbar.length) {
|
|
|
|
$endbar.remove();
|
|
|
|
clearInterval(this.feed_stories_loading);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
compute_story_score: function(story) {
|
|
|
|
var score = 0;
|
|
|
|
var score_max = Math.max(story.intelligence['title'],
|
|
|
|
story.intelligence['author'],
|
|
|
|
story.intelligence['tags']);
|
|
|
|
var score_min = Math.min(story.intelligence['title'],
|
|
|
|
story.intelligence['author'],
|
|
|
|
story.intelligence['tags']);
|
|
|
|
if (score_max > 0) score = score_max;
|
|
|
|
else if (score_min < 0) score = score_min;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (score == 0) score = story.intelligence['feed'];
|
|
|
|
|
|
|
|
return score;
|
2010-06-08 11:19:41 -04: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_return = $('.NB-taskbar .task_return');
|
|
|
|
var $taskbar_view_page = $('.NB-taskbar .task_view_page');
|
|
|
|
$taskbar_view_page.removeClass('NB-disabled');
|
|
|
|
$taskbar_return.css({'display': 'none'});
|
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');
|
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;
|
2010-07-06 18:43:06 -04:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
this.unload_feed_iframe();
|
2010-07-06 18:43:06 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!feed_id) {
|
2010-12-06 10:41:24 -05:00
|
|
|
feed_id = $feed_iframe.data('feed_id');
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.data('feed_id', feed_id);
|
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;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.removeAttr('src').attr({src: '/reader/load_feed_page?feed_id='+feed_id});
|
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
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
// NEWSBLUR.log(['iFrame domain', $feed_iframe.attr('src').indexOf('/reader/load_feed_page?feed_id='+feed_id), $feed_iframe.attr('src')]);
|
|
|
|
if ($feed_iframe.attr('src').indexOf('/reader/load_feed_page?feed_id='+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
|
|
|
|
2010-12-06 10:41:24 -05:00
|
|
|
$feed_iframe.removeAttr('src').load(function() {
|
2010-06-14 13:17:38 -04:00
|
|
|
self.flags.iframe_view_loaded = true;
|
|
|
|
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)]);
|
|
|
|
$iframe_contents.scrollTo($footnote, 600, {
|
|
|
|
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
|
|
|
});
|
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
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
setTimeout(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_return = $('.NB-taskbar .task_return');
|
|
|
|
var $taskbar_view_page = $('.NB-taskbar .task_view_page');
|
|
|
|
|
|
|
|
try {
|
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) {
|
|
|
|
$taskbar_return.css({'display': 'block'});
|
|
|
|
$taskbar_view_page.addClass('NB-disabled');
|
|
|
|
} finally {
|
|
|
|
$taskbar_return.css({'display': 'block'});
|
2010-07-24 18:22:23 -04:00
|
|
|
$taskbar_view_page.addClass('NB-disabled');
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
}, 500);
|
|
|
|
},
|
|
|
|
|
|
|
|
load_page_of_feed_stories: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var feed_id = $story_titles.data('feed_id');
|
|
|
|
var page = $story_titles.data('page');
|
2010-12-12 22:52:15 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!this.flags['opening_feed']) {
|
|
|
|
this.show_feedbar_loading();
|
|
|
|
$story_titles.data('page', page+1);
|
2010-12-04 13:32:13 -05:00
|
|
|
if (this.active_feed == 'starred') {
|
2010-12-03 09:49:38 -05:00
|
|
|
this.model.fetch_starred_stories(page+1,
|
|
|
|
_.bind(this.post_open_starred_stories, this), false);
|
2010-12-15 17:45:51 -05:00
|
|
|
} else if (typeof this.active_feed == "string" && this.active_feed.indexOf('river:') != -1) {
|
2010-12-12 22:52:15 -05:00
|
|
|
this.model.fetch_river_stories(this.cache['river_feeds_with_unreads'], page+1,
|
2010-12-10 15:26:50 -05:00
|
|
|
_.bind(this.post_open_river_stories, this), false);
|
2010-12-03 09:49:38 -05:00
|
|
|
} else {
|
|
|
|
this.model.load_feed(feed_id, page+1, false,
|
|
|
|
$.rescope(this.post_open_feed, this));
|
|
|
|
}
|
2010-06-11 20:55:38 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
show_feedbar_loading: function() {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
|
|
|
var $feedbar = $('.NB-story-titles-end-stories-line');
|
|
|
|
|
|
|
|
if (!$feedbar.length) {
|
|
|
|
$feedbar = $.make('div', { className: 'NB-story-titles-end-stories-line' });
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
$feedbar.css({'background': '#E1EBFF'});
|
|
|
|
$story_titles.append($feedbar);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$feedbar.animate({'backgroundColor': '#5C89C9'}, {'duration': 750})
|
|
|
|
.animate({'backgroundColor': '#E1EBFF'}, 750);
|
|
|
|
this.feed_stories_loading = setInterval(function() {
|
|
|
|
$feedbar.animate({'backgroundColor': '#5C89C9'}, {'duration': 750})
|
|
|
|
.animate({'backgroundColor': '#E1EBFF'}, 750);
|
|
|
|
}, 1500);
|
|
|
|
},
|
|
|
|
|
2010-11-01 18:20:26 -04:00
|
|
|
show_feed_title_in_stories: function(feed_id) {
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-06-14 13:17:38 -04:00
|
|
|
var feed = this.model.get_feed(feed_id);
|
|
|
|
|
|
|
|
var $feedbar = $.make('div', { className: 'NB-feedbar' }, [
|
2010-07-26 21:38:56 -04:00
|
|
|
this.make_feed_title_line(feed, false, 'story'),
|
2010-11-26 19:03:31 -05:00
|
|
|
// $.make('div', { className: 'NB-feedbar-intelligence' }, [
|
|
|
|
// $.make('div', { className: 'NB-feed-sentiment NB-feed-like', title: 'What I like about this site...' }),
|
|
|
|
// $.make('div', { className: 'NB-feed-sentiment NB-feed-dislike', title: 'What I dislike about this site...' })
|
|
|
|
// ]),
|
2010-06-14 13:17:38 -04:00
|
|
|
$.make('span', { className: 'feed_id' }, ''+feed.id)
|
|
|
|
]).hover(function() {
|
|
|
|
$(this).addClass('NB-feedbar-hover');
|
|
|
|
},function() {
|
|
|
|
$(this).removeClass('NB-feedbar-hover');
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$story_titles.prepend($feedbar);
|
|
|
|
$('.unread_count', $feedbar).corner('4px');
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-11-01 18:20:26 -04:00
|
|
|
show_feed_hidden_story_title_indicator: function() {
|
|
|
|
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) {
|
|
|
|
var score = this.compute_story_score(story);
|
|
|
|
|
|
|
|
if (unread_view_name == 'positive') return score <= 0;
|
|
|
|
else if (unread_view_name == 'neutral') return score < 0;
|
|
|
|
}, this));
|
2010-11-01 18:20:26 -04:00
|
|
|
|
2011-01-04 08:21:47 -05:00
|
|
|
if (hidden_stories) {
|
2011-01-04 08:40:15 -05:00
|
|
|
if ($indicator.length) {
|
|
|
|
var $counts = this.make_feed_counts_floater(feed.ps, feed.nt, feed.ng);
|
|
|
|
$('.feed_counts_floater', $indicator).replaceWith($counts);
|
2011-01-04 10:10:23 -05:00
|
|
|
$indicator.css({'opacity': 1});
|
2011-01-04 08:40:15 -05:00
|
|
|
} else {
|
|
|
|
$indicator = $.make('div', { className: 'NB-story-title-indicator' }, [
|
|
|
|
this.make_feed_counts_floater(feed.ps, feed.nt, feed.ng),
|
|
|
|
$.make('span', { className: 'NB-story-title-indicator-text' }, 'show hidden stories')
|
|
|
|
]).css({
|
|
|
|
'opacity': 0
|
|
|
|
});
|
2011-01-04 10:10:23 -05:00
|
|
|
$('.NB-feedbar .feed .feed_title', this.$story_titles).prepend($indicator);
|
2011-01-04 08:40:15 -05:00
|
|
|
_.delay(function() {
|
|
|
|
$indicator.animate({'opacity': 1}, {'duration': 1000, 'easing': 'easeOutCubic'});
|
|
|
|
}, 500);
|
|
|
|
}
|
2010-11-01 18:20:26 -04:00
|
|
|
|
|
|
|
$indicator.removeClass('unread_threshold_positive')
|
|
|
|
.removeClass('unread_threshold_neutral')
|
|
|
|
.removeClass('unread_threshold_negative')
|
2011-01-04 08:40:15 -05:00
|
|
|
.addClass('unread_threshold_'+unread_view_name);
|
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) {
|
|
|
|
var score = this.compute_story_score(story);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var score = this.compute_story_score(story);
|
|
|
|
return score < 0;
|
|
|
|
}, this));
|
2010-11-01 18:20:26 -04:00
|
|
|
|
2011-01-04 08:21:47 -05:00
|
|
|
// NEWSBLUR.log(['show_hidden_story_titles', hidden_stories_at_threshold, hidden_stories_below_threshold, unread_view_name]);
|
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-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,
|
|
|
|
'follow': true
|
|
|
|
});
|
|
|
|
$indicator.removeClass('unread_threshold_positive').addClass('unread_threshold_neutral');
|
2011-01-04 08:21:47 -05:00
|
|
|
} else {
|
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,
|
|
|
|
'follow': true
|
|
|
|
});
|
|
|
|
$indicator.removeClass('unread_threshold_positive')
|
|
|
|
.removeClass('unread_threshold_neutral')
|
|
|
|
.addClass('unread_threshold_negative');
|
2011-01-04 08:21:47 -05:00
|
|
|
$indicator.animate({'opacity': 0}, {'duration': 500});
|
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);
|
|
|
|
window.open(feed['feed_link'], '_blank');
|
|
|
|
window.focus();
|
|
|
|
},
|
|
|
|
|
2010-12-14 17:08:52 -05:00
|
|
|
open_story_in_new_tab: function(story, $t) {
|
|
|
|
window.open(story['story_permalink'], '_blank');
|
|
|
|
window.focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
open_unread_stories_in_tabs: function(feed_id) {
|
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
if (this.active_feed == feed_id) {
|
|
|
|
this.flags['open_unread_stories_in_tabs'] = false;
|
|
|
|
_.each(this.model.stories, function(story) {
|
2010-12-14 23:10:13 -05:00
|
|
|
NEWSBLUR.log(['story', story, !story.read_status]);
|
2010-12-14 17:08:52 -05:00
|
|
|
if (!story.read_status) {
|
2010-12-14 23:10:13 -05:00
|
|
|
window.open(story['story_permalink'], '_blank');
|
|
|
|
window.focus();
|
2010-12-14 17:08:52 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
this.mark_feed_as_read(feed_id);
|
|
|
|
} else {
|
|
|
|
this.flags['open_unread_stories_in_tabs'] = true;
|
|
|
|
var $feed = this.find_feed_in_feed_list(feed_id);
|
|
|
|
this.open_feed(feed_id, false, $feed);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
mark_feed_as_selected: function(feed_id, $feed_link) {
|
2010-11-22 10:44:52 -05:00
|
|
|
if ($feed_link === undefined) {
|
2010-10-11 12:07:32 -04:00
|
|
|
$feed_link = $('.feed.selected', this.$feed_list).eq(0);
|
|
|
|
}
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$('#feed_list .selected').removeClass('selected');
|
|
|
|
$('#feed_list .after_selected').removeClass('after_selected');
|
2010-09-05 18:08:08 -07:00
|
|
|
if ($feed_link) {
|
|
|
|
$feed_link.addClass('selected');
|
|
|
|
$feed_link.parent('.feed').next('.feed').children('a').addClass('after_selected');
|
|
|
|
}
|
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;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-09-17 12:40:42 -04:00
|
|
|
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});
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
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;
|
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');
|
|
|
|
var $stories;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-12-04 13:32:13 -05:00
|
|
|
options = options || {};
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (first_load) {
|
|
|
|
$stories = $.make('ul', { className: 'NB-feed-stories' });
|
|
|
|
$feed_view.empty();
|
|
|
|
$feed_view.scrollTop('0px');
|
|
|
|
$feed_view.append($stories);
|
|
|
|
} else {
|
|
|
|
$stories = $('.NB-feed-stories', $feed_view);
|
2010-12-04 13:32:13 -05:00
|
|
|
if (!options.refresh_load) {
|
2010-06-14 13:17:38 -04:00
|
|
|
$('.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) {
|
|
|
|
var story = stories[s];
|
2010-12-15 16:10:54 -05:00
|
|
|
if (options.river_stories) var feed = this.model.get_feed(story.story_feed_id);
|
2010-06-14 13:17:38 -04:00
|
|
|
var read = story.read_status
|
2010-12-04 13:32:13 -05:00
|
|
|
? ' read '
|
2010-06-14 13:17:38 -04:00
|
|
|
: '';
|
|
|
|
var score = this.compute_story_score(story);
|
|
|
|
var score_color = 'neutral';
|
2010-12-10 15:26:50 -05:00
|
|
|
var river_stories = options['river_stories']
|
|
|
|
? ' NB-river-story '
|
2010-12-04 13:32:13 -05:00
|
|
|
: '';
|
2010-06-14 13:17:38 -04:00
|
|
|
if (score > 0) score_color = 'positive';
|
|
|
|
if (score < 0) score_color = 'negative';
|
|
|
|
|
2010-12-10 15:26:50 -05:00
|
|
|
var $story = $.make('li', { className: 'NB-feed-story ' + read + river_stories + ' NB-story-' + score_color }, [
|
2010-12-15 16:10:54 -05:00
|
|
|
$.make('div', { className: 'NB-feed-story-header-feed' }, [
|
|
|
|
(options.river_stories &&
|
|
|
|
$.make('div', { className: 'NB-feed-story-feed' }, [
|
|
|
|
$.make('img', { className: 'feed_favicon', src: NEWSBLUR.Globals.google_favicon_url + feed.feed_link }),
|
|
|
|
$.make('span', { className: 'feed_title' }, feed.feed_title)
|
|
|
|
])
|
|
|
|
)
|
|
|
|
]),
|
2010-06-14 13:17:38 -04:00
|
|
|
$.make('div', { className: 'NB-feed-story-header' }, [
|
|
|
|
$.make('div', { className: 'NB-feed-story-sentiment' }),
|
2010-12-15 16:10:54 -05:00
|
|
|
(story.story_authors &&
|
2010-06-14 13:17:38 -04:00
|
|
|
$.make('div', { className: 'NB-feed-story-author' }, story.story_authors)),
|
|
|
|
$.make('div', { className: 'NB-feed-story-title-container' }, [
|
|
|
|
$.make('div', { className: 'NB-feed-story-sentiment' }),
|
2010-11-15 22:43:01 -05:00
|
|
|
$.make('a', { className: 'NB-feed-story-title', href: story.story_permalink }, story.story_title)
|
2010-06-14 13:17:38 -04:00
|
|
|
]),
|
2010-12-10 09:32:06 -05:00
|
|
|
(story.long_parsed_date &&
|
2010-12-04 13:32:13 -05:00
|
|
|
$.make('span', { className: 'NB-feed-story-date' }, story.long_parsed_date)),
|
2010-12-10 09:32:06 -05:00
|
|
|
(story.starred_date &&
|
2010-12-04 13:32:13 -05:00
|
|
|
$.make('span', { className: 'NB-feed-story-starred-date' }, story.starred_date))
|
2010-06-14 13:17:38 -04:00
|
|
|
]),
|
|
|
|
$.make('div', { className: 'NB-feed-story-content' }, story.story_content)
|
|
|
|
]).data('story', story.id);
|
2010-10-31 16:03:50 -04:00
|
|
|
|
|
|
|
if (NEWSBLUR.Preferences.new_window == 1) {
|
|
|
|
$('a', $story).attr('target', '_blank');
|
|
|
|
}
|
|
|
|
|
2010-12-04 13:32:13 -05:00
|
|
|
if (options.refresh_load) {
|
2010-06-14 13:17:38 -04:00
|
|
|
$stories.prepend($story);
|
|
|
|
} else {
|
|
|
|
$stories.append($story);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.cache.feed_view_stories[story.id] = $story;
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
})($story, story, image_count);
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-12-08 20:53:45 -05:00
|
|
|
|
2010-12-15 16:10:54 -05:00
|
|
|
if (!stories.length) {
|
|
|
|
this.fetch_story_locations_in_feed_view();
|
|
|
|
}
|
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_stories_preference_in_feed_view(true);
|
2010-06-08 11:19:41 -04: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];
|
|
|
|
var $story = self.cache.feed_view_stories[story.id];
|
|
|
|
this.determine_feed_view_story_position($story, story);
|
|
|
|
// NEWSBLUR.log(['Pre-fetching', $story, story.story_title, this.flags.feed_view_images_loaded[story.id]]);
|
|
|
|
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
|
|
|
}
|
2010-11-04 21:49:13 -04:00
|
|
|
|
2010-11-15 22:43:01 -05:00
|
|
|
if (_.all(this.flags.feed_view_images_loaded) &&
|
2010-12-08 20:53:45 -05:00
|
|
|
(_.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
|
|
|
this.fetch_story_locations_in_feed_view();
|
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
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-11-04 21:49:13 -04:00
|
|
|
fetch_story_locations_in_feed_view: function() {
|
|
|
|
this.flags['feed_view_positions_calculated'] = true;
|
|
|
|
NEWSBLUR.log(['Feed view entirely loaded', this.model.stories.length + " stories"]);
|
|
|
|
var $feed_view = this.$s.$feed_view;
|
|
|
|
var $stories = $('.NB-feed-stories', $feed_view);
|
|
|
|
var $endbar = $.make('div', { className: 'NB-feed-story-endbar' });
|
2010-12-02 20:18:33 -05:00
|
|
|
$stories.find('.NB-feed-story-endbar').remove();
|
2010-11-04 21:49:13 -04:00
|
|
|
$stories.append($endbar);
|
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')) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var position_original = parseInt($story.offset().top, 10);
|
|
|
|
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) {
|
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
|
|
|
|
2010-12-04 21:53:39 -05:00
|
|
|
if (view == 'page' && feed && feed.has_exception && feed.exception_type == 'page') {
|
2010-10-28 18:17:14 -04:00
|
|
|
this.open_feed_exception_modal(this.active_feed);
|
|
|
|
return;
|
|
|
|
}
|
2010-12-04 21:53:39 -05:00
|
|
|
if ($('.task_button_view.task_view_'+view).hasClass('NB-disabled')) {
|
|
|
|
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;
|
2010-12-07 09:52:14 -05:00
|
|
|
this.flags['page_view_showing_feed_view'] = false;
|
2010-12-06 10:41:24 -05:00
|
|
|
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']) {
|
2010-12-06 10:41:24 -05:00
|
|
|
this.load_feed_iframe(this.active_feed);
|
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',
|
2010-12-07 09:52:14 -05:00
|
|
|
'duration': 550,
|
2010-06-14 13:17:38 -04:00
|
|
|
'queue': false
|
|
|
|
});
|
|
|
|
} else if (view == 'feed') {
|
|
|
|
if (this.active_story) {
|
2010-11-04 11:36:46 -04:00
|
|
|
var $feed_story = this.find_story_in_feed_view(this.active_story);
|
2010-06-14 13:17:38 -04:00
|
|
|
this.scroll_to_story_in_story_feed(this.active_story, $feed_story, 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',
|
2010-12-07 09:52:14 -05:00
|
|
|
'duration': 550,
|
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']) {
|
|
|
|
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',
|
2010-12-07 09:52:14 -05:00
|
|
|
'duration': 550,
|
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();
|
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);
|
|
|
|
var $stories = $('.NB-feed-stories', $feed_view);
|
|
|
|
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'});
|
|
|
|
$feed_view.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
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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;
|
2010-12-07 09:52:14 -05:00
|
|
|
this.switch_taskbar_view('story', is_temporary ? 'story' : false);
|
|
|
|
this.load_story_iframe(story, story.story_feed_id);
|
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;
|
|
|
|
|
2010-12-08 20:53:45 -05:00
|
|
|
if ($story_iframe.attr('src') != story.story_permalink) {
|
|
|
|
// NEWSBLUR.log(['load_story_iframe', story.story_permalink, $story_iframe.attr('src')]);
|
|
|
|
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;
|
|
|
|
$story_iframe.removeAttr('src').attr({src: story.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;
|
|
|
|
|
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 =
|
|
|
|
// ===================
|
|
|
|
|
|
|
|
open_add_feed_modal: function() {
|
|
|
|
clearInterval(this.flags['bouncing_callout']);
|
2010-08-30 19:57:27 -04:00
|
|
|
$.modal.close();
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
NEWSBLUR.add_feed = new NEWSBLUR.ReaderAddFeed();
|
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
|
|
|
|
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();
|
|
|
|
},
|
|
|
|
|
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) {
|
|
|
|
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
|
|
|
},
|
|
|
|
|
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;
|
2010-07-24 00:04:14 -04: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' }),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-keyboard' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Keyboard shortcuts')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
2010-09-14 20:49:28 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-mark-read NB-menu-manage-site-mark-read' }, [
|
2010-07-30 23:50:49 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
2010-09-13 00:38:25 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Mark everything as read'),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Choose how many days back.')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-trainer' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Intelligence Trainer'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Accurate filters are happy filters.')
|
|
|
|
]),
|
2010-10-31 16:03:50 -04:00
|
|
|
$.make('li', { className: 'NB-menu-manage-preferences' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Preferences'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Defaults and options.')
|
|
|
|
]),
|
2010-09-24 01:08:03 -04:00
|
|
|
(show_chooser && $.make('li', { className: 'NB-menu-manage-feedchooser' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Choose Your 64'),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-subtitle' }, 'Enable the sites you want.')
|
|
|
|
]))
|
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;
|
2010-12-14 23:02:24 -05:00
|
|
|
var tab_unread_count = Math.min(25, this.get_unread_count(true, feed_id));
|
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' }),
|
|
|
|
(feed.has_exception && $.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-exception' }, [
|
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Fix this misbehaving site')
|
|
|
|
])),
|
|
|
|
(feed.has_exception && $.make('li', { className: 'NB-menu-separator-inverse' })),
|
2010-10-28 18:17:14 -04:00
|
|
|
(feed.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
|
|
|
]),
|
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-01-03 10:09:01 -05:00
|
|
|
(tab_unread_count && $.make('li', { className: 'NB-menu-separator' })),
|
|
|
|
(tab_unread_count && $.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-feed-unreadtabs' }, [
|
2010-12-31 10:34:31 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('div', { className: 'NB-menu-manage-title' }, 'Open unreads in '+tab_unread_count+Inflector.pluralize(' tab', tab_unread_count))
|
2011-01-03 10:09:01 -05:00
|
|
|
])),
|
2010-09-12 13:50:27 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
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')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-rename-confirm NB-menu-manage-feed-rename-confirm NB-modal-submit' }, [
|
2010-12-11 12:41:24 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-rename-save NB-menu-manage-feed-rename-save NB-modal-submit-green NB-modal-submit-button' }, 'Save'),
|
2010-12-11 11:26:21 -05:00
|
|
|
$.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
$.make('input', { name: 'new_title', className: 'NB-menu-manage-title', value: feed.feed_title })
|
|
|
|
]),
|
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);
|
2010-09-12 13:50:27 -04:00
|
|
|
if (feed_id && this.get_unread_count(true, feed_id) == 0) {
|
|
|
|
$('.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
|
|
|
}
|
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')
|
|
|
|
]),
|
2010-09-22 10:12:38 -04:00
|
|
|
$.make('li', { className: 'NB-menu-separator' }),
|
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')
|
|
|
|
]),
|
|
|
|
$.make('li', { className: 'NB-menu-manage-feed NB-menu-manage-rename-confirm NB-menu-manage-folder-rename-confirm NB-modal-submit' }, [
|
|
|
|
$.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-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);
|
|
|
|
var starred_class = story.starred ? 'NB-story-starred' : '';
|
|
|
|
var starred_title = story.starred ? 'Remove bookmark' : 'Save This Story';
|
|
|
|
inverse = true;
|
|
|
|
|
|
|
|
$manage_menu = $.make('ul', { className: 'NB-menu-manage NB-menu-manage-story ' + starred_class }, [
|
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)
|
|
|
|
]),
|
2010-12-31 10:34:31 -05:00
|
|
|
// $.make('li', { className: 'NB-menu-manage-story-instapaper' }, [
|
|
|
|
// $.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
// $.make('div', { className: 'NB-menu-manage-title' }, 'Send to Instapaper')
|
|
|
|
// ]),
|
|
|
|
$.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
|
|
|
])
|
|
|
|
// (story.read_status && $.make('li', { className: 'NB-menu-separator' })),
|
|
|
|
// (story.read_status && $.make('li', { className: 'NB-menu-manage-story-unread' }, [
|
|
|
|
// $.make('div', { className: 'NB-menu-manage-image' }),
|
|
|
|
// $.make('div', { className: 'NB-menu-manage-title' }, 'Mark as unread')
|
|
|
|
// ]))
|
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);
|
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
|
|
|
},
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
show_manage_menu: function(type, $item) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
2010-06-14 13:17:38 -04:00
|
|
|
var $manage_menu_container = $('.NB-menu-manage-container');
|
2010-09-12 13:50:27 -04:00
|
|
|
// NEWSBLUR.log(['show_manage_menu', type, $item, $manage_menu_container.data('item'), $item && $item[0] == $manage_menu_container.data('item')]);
|
2010-06-14 13:17:38 -04:00
|
|
|
clearTimeout(this.flags.closed_manage_menu);
|
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) {
|
|
|
|
this.hide_manage_menu(type);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
this.hide_manage_menu(type);
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
|
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') {
|
|
|
|
feed_id = $('.folder_title_text', $item).eq(0).text();
|
2010-12-30 18:37:29 -05:00
|
|
|
inverse = $('.folder_title', $item).hasClass("NB-hover-inverse");
|
|
|
|
} else if (type == 'feed') {
|
|
|
|
feed_id = $item && $item.data('feed_id');
|
|
|
|
inverse = $item.hasClass("NB-hover-inverse");
|
|
|
|
} else if (type == 'story') {
|
|
|
|
story_id = $item.data('story_id');
|
|
|
|
inverse = true;
|
|
|
|
} else if (type == 'site') {
|
|
|
|
|
2010-09-14 20:49:28 -04:00
|
|
|
}
|
2010-12-30 18:37:29 -05:00
|
|
|
var toplevel = $item.hasClass("NB-toplevel") ||
|
|
|
|
$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');
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'feed' || type == 'folder' || type == 'story') {
|
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) {
|
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;
|
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;
|
2010-12-30 18:37:29 -05:00
|
|
|
} else if (type == 'story') {
|
|
|
|
left = 4;
|
|
|
|
top = 21;
|
2010-12-12 20:06:32 -05:00
|
|
|
}
|
2010-09-13 00:38:25 -04:00
|
|
|
var $align;
|
2010-12-30 18:37:29 -05:00
|
|
|
if (type == 'feed' || type == 'story') $align = $item;
|
2010-09-13 00:38:25 -04:00
|
|
|
else $align = $('.folder_title', $item);
|
|
|
|
$manage_menu_container.align($align, '-bottom -left', {
|
|
|
|
'top': -1 * top,
|
|
|
|
'left': left
|
|
|
|
});
|
|
|
|
$manage_menu_container.corner('br 8px');
|
|
|
|
$('li', $manage_menu_container).each(function() {
|
|
|
|
$(this).prependTo($(this).parent());
|
|
|
|
});
|
|
|
|
} else {
|
2010-12-12 20:06:32 -05:00
|
|
|
if (type == 'feed') {
|
|
|
|
left = toplevel ? 2 : -20;
|
|
|
|
top = toplevel ? 21 : 21;
|
|
|
|
} else if (type == 'folder') {
|
|
|
|
left = toplevel ? 2 : -20;
|
|
|
|
top = toplevel ? 22 : 21;
|
|
|
|
}
|
2010-09-13 00:38:25 -04:00
|
|
|
$manage_menu_container.align($item, '-top -left', {
|
|
|
|
'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
|
2010-12-30 18:37:29 -05:00
|
|
|
if (type == 'feed' || type == 'folder' || type == 'story') {
|
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
|
|
|
|
|
|
|
// 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;
|
2010-12-30 18:37:29 -05:00
|
|
|
if (type == 'feed') {
|
|
|
|
$scroll = this.$s.$feed_list.parent();
|
|
|
|
} else if (type == 'story') {
|
|
|
|
$scroll = this.$s.$story_titles;
|
|
|
|
}
|
|
|
|
$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 {
|
|
|
|
self.$s.$feed_list.unbind('scroll.manage_menu');
|
|
|
|
}
|
|
|
|
});
|
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();
|
2010-12-11 11:26:21 -05:00
|
|
|
if (this.flags['showing_rename_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();
|
|
|
|
|
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');
|
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
2010-09-14 20:49:28 -04:00
|
|
|
manage_menu_delete_feed: function(feed, $feed) {
|
2010-07-01 00:29:26 -04:00
|
|
|
var self = this;
|
|
|
|
var feed_id = feed || this.active_feed;
|
2010-10-23 10:29:35 -04:00
|
|
|
$feed = $feed || this.find_feed_in_feed_list(feed_id);
|
|
|
|
|
2010-09-14 20:49:28 -04:00
|
|
|
var in_folder = $feed.parents('li.folder').eq(0).find('.folder_title_text').eq(0).text();
|
|
|
|
|
|
|
|
this.model.delete_feed(feed_id, in_folder, function() {
|
|
|
|
self.delete_feed(feed_id, $feed);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
manage_menu_delete_folder: function(folder, $folder) {
|
|
|
|
var self = this;
|
2010-09-16 10:35:36 -04:00
|
|
|
var in_folder = '';
|
|
|
|
var $parent = $folder.parents('li.folder');
|
2010-09-22 10:12:38 -04:00
|
|
|
var feeds = this.get_feed_ids_in_folder($folder);
|
2010-09-16 10:35:36 -04:00
|
|
|
if ($parent.length) {
|
|
|
|
in_folder = $parent.eq(0).find('.folder_title_text').eq(0).text();
|
|
|
|
}
|
2010-07-01 00:29:26 -04:00
|
|
|
|
2010-09-22 10:12:38 -04:00
|
|
|
this.model.delete_folder(folder, in_folder, feeds, function() {
|
2010-09-14 20:49:28 -04:00
|
|
|
self.delete_folder(folder, $folder);
|
2010-07-01 00:29:26 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-12-11 14:02:37 -05:00
|
|
|
delete_feed: function(feed_id, $feed) {
|
|
|
|
var self = this;
|
|
|
|
$feed = $feed || this.find_feed_in_feed_list(feed_id);
|
|
|
|
$feed.slideUp(500);
|
|
|
|
|
|
|
|
if (this.active_feed == $feed.data('feed_id')) {
|
|
|
|
this.reset_feed();
|
|
|
|
this.show_splash_page();
|
|
|
|
}
|
|
|
|
this.update_header_counts();
|
|
|
|
},
|
|
|
|
|
|
|
|
delete_folder: function(folder_name, $folder) {
|
|
|
|
var self = this;
|
|
|
|
var feeds = this.get_feed_ids_in_folder($folder);
|
|
|
|
|
|
|
|
if ($folder.length) {
|
|
|
|
$folder.slideUp(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the active feed is under this folder, deselect it.
|
|
|
|
var feed_active = false;
|
|
|
|
_.each(feeds, _.bind(function(feed_id) {
|
|
|
|
if (self.active_feed == feed_id) {
|
|
|
|
this.reset_feed();
|
|
|
|
this.show_splash_page();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.update_header_counts();
|
|
|
|
},
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
$rename.addClass('NB-menu-manage-feed-rename-cancel');
|
|
|
|
$('.NB-menu-manage-title', $rename).text('Cancel rename');
|
|
|
|
var height = $confirm.height();
|
|
|
|
$confirm.css({'height': 0, 'display': 'block'}).animate({'height': height}, {'duration': 500});
|
2010-12-11 12:41:24 -05:00
|
|
|
$('input', $confirm).focus().select();
|
2010-12-11 11:26:21 -05:00
|
|
|
this.flags['showing_rename_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);
|
|
|
|
this.flags['showing_rename_input_on_manage_menu'] = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
manage_menu_rename_feed: function(feed, $feed) {
|
2010-12-11 14:02:37 -05:00
|
|
|
var self = this;
|
|
|
|
var feed_id = feed || this.active_feed;
|
|
|
|
$feed = $feed || this.find_feed_in_feed_list(feed_id);
|
|
|
|
var new_title = $('.NB-menu-manage-feed-rename-confirm .NB-menu-manage-title').val();
|
2010-12-11 11:26:21 -05:00
|
|
|
|
2010-12-11 17:16:12 -05:00
|
|
|
if (new_title.length <= 0) return this.hide_confirm_rename_menu_item();
|
|
|
|
|
2010-12-11 15:26:45 -05:00
|
|
|
this.model.rename_feed(feed_id, new_title, function() {
|
2010-12-11 11:26:21 -05:00
|
|
|
});
|
2010-12-11 15:26:45 -05:00
|
|
|
|
2010-12-11 14:02:37 -05:00
|
|
|
$('.feed_title', $feed).text(new_title);
|
|
|
|
if (feed_id == this.active_feed) {
|
|
|
|
$('.feed_title', this.$s.$story_titles).text(new_title);
|
|
|
|
}
|
|
|
|
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;
|
2010-12-11 11:26:21 -05:00
|
|
|
var in_folder = '';
|
2010-12-11 14:02:37 -05:00
|
|
|
var $parent = $folder.parents('li.folder');
|
|
|
|
var new_folder_name = $('.NB-menu-manage-folder-rename-confirm .NB-menu-manage-title').val();
|
2010-12-11 17:16:12 -05:00
|
|
|
|
|
|
|
if (new_folder_name.length <= 0) return this.hide_confirm_rename_menu_item();
|
|
|
|
|
2010-12-11 11:26:21 -05:00
|
|
|
if ($parent.length) {
|
|
|
|
in_folder = $parent.eq(0).find('.folder_title_text').eq(0).text();
|
|
|
|
}
|
|
|
|
|
2010-12-11 14:02:37 -05:00
|
|
|
this.model.rename_folder(folder, new_folder_name, in_folder, function() {
|
2010-12-11 11:26:21 -05:00
|
|
|
});
|
2010-12-11 14:02:37 -05:00
|
|
|
NEWSBLUR.log(['rename', $folder, new_folder_name]);
|
|
|
|
$('.folder_title_text', $folder).text(new_folder_name);
|
|
|
|
this.hide_confirm_rename_menu_item(true);
|
2010-12-11 17:16:12 -05:00
|
|
|
|
|
|
|
$('.NB-menu-manage-folder-rename').parents('.NB-menu-manage').data('folder_name', new_folder_name);
|
2010-12-11 11:26:21 -05: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);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$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) {
|
2010-07-21 00:47:55 -04:00
|
|
|
if (self.model.preference('unread_view') != ui.value) {
|
|
|
|
self.model.preference('unread_view', ui.value);
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
self.flags['feed_view_positions_calculated'] = false;
|
2010-11-05 10:35:52 -04:00
|
|
|
self.switch_feed_view_unread_view(ui.value);
|
2010-12-08 20:53:45 -05:00
|
|
|
self.show_story_titles_above_intelligence_level({'animate': true, 'follow': true});
|
2011-01-04 08:40:15 -05:00
|
|
|
self.show_feed_hidden_story_title_indicator();
|
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_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');
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_list = this.$s.$feed_list;
|
|
|
|
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);
|
2010-12-04 23:18:07 -05:00
|
|
|
var $hidereadfeeds_button = $('.NB-feeds-header-sites');
|
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);
|
2010-11-05 10:35:52 -04:00
|
|
|
|
|
|
|
if (NEWSBLUR.Preferences['hide_read_feeds'] == 1) {
|
2010-12-04 23:06:35 -05:00
|
|
|
$hidereadfeeds_button.attr('title', 'Show all sites');
|
|
|
|
$feed_list.parent().addClass('NB-feedlist-hide-read-feeds');
|
2010-11-05 10:35:52 -04:00
|
|
|
} else {
|
2010-12-04 23:06:35 -05:00
|
|
|
$hidereadfeeds_button.attr('title', 'Show only unread stories');
|
|
|
|
$feed_list.parent().removeClass('NB-feedlist-hide-read-feeds');
|
2010-11-05 10:35:52 -04:00
|
|
|
}
|
2010-12-04 23:06:35 -05:00
|
|
|
$hidereadfeeds_button.tipsy({
|
|
|
|
gravity: 'n',
|
|
|
|
delayIn: 375
|
|
|
|
});
|
|
|
|
|
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');
|
|
|
|
}
|
2010-07-06 16:37:49 -04: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;
|
2010-09-12 13:50:27 -04:00
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!visible_only) {
|
|
|
|
total = feed.ng + feed.nt + feed.ps;
|
|
|
|
} else {
|
2010-09-12 13:50:27 -04:00
|
|
|
var unread_view_name = this.get_unread_view_name();
|
2010-06-14 13:17:38 -04:00
|
|
|
if (unread_view_name == 'positive') {
|
|
|
|
total = feed.ps;
|
|
|
|
} else if (unread_view_name == 'neutral') {
|
|
|
|
total = feed.ps + feed.nt;
|
|
|
|
} else if (unread_view_name == 'negative') {
|
|
|
|
total = feed.ps + feed.nt + feed.ng;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
},
|
|
|
|
|
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,
|
|
|
|
'follow': true
|
|
|
|
};
|
|
|
|
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;
|
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');
|
|
|
|
} else if (unread_view_name == 'negative') {
|
|
|
|
$stories_show = $('.story,.NB-feed-story')
|
|
|
|
.filter('.NB-story-positive,.NB-story-neutral,.NB-story-negative');
|
|
|
|
$stories_hide = $();
|
|
|
|
}
|
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')) {
|
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.
|
2010-06-14 13:17:38 -04:00
|
|
|
$stories_show = $stories_show.not('.NB-feed-story');
|
|
|
|
$stories_hide = $stories_hide.not('.NB-feed-story');
|
2010-12-09 09:59:45 -05:00
|
|
|
// NEWSBLUR.log(['show_story_titles_above_intelligence_level', $stories_show.length, $stories_hide.length]);
|
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'});
|
|
|
|
}
|
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) {
|
2010-12-08 20:53:45 -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;
|
|
|
|
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']) {
|
|
|
|
$stories_hide.slideUp(500);
|
|
|
|
$stories_show.slideDown(500);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}, 550);
|
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
2010-06-14 13:17:38 -04:00
|
|
|
|
|
|
|
update_opinions: function($modal, feed_id) {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (feed_id != this.model.feed_id) return;
|
|
|
|
|
|
|
|
$('input[type=checkbox]', $modal).each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
var name = $this.attr('name').replace(/^(dis)?like_/, '');
|
|
|
|
var score = /^dislike/.test($this.attr('name')) ? -1 : 1;
|
|
|
|
var value = $this.val();
|
|
|
|
var checked = $this.attr('checked');
|
|
|
|
|
|
|
|
if (checked) {
|
|
|
|
if (name == 'tag') {
|
|
|
|
self.model.classifiers.tags[value] = score;
|
|
|
|
} else if (name == 'title') {
|
|
|
|
self.model.classifiers.titles[value] = score;
|
|
|
|
} else if (name == 'author') {
|
|
|
|
self.model.classifiers.authors[value] = score;
|
2010-10-21 13:37:36 -04:00
|
|
|
} else if (name == 'feed') {
|
2010-08-22 18:34:40 -04:00
|
|
|
self.model.classifiers.feeds[feed_id] = score;
|
2010-06-14 13:17:38 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (name == 'tag' && self.model.classifiers.tags[value] == score) {
|
|
|
|
delete self.model.classifiers.tags[value];
|
|
|
|
} else if (name == 'title' && self.model.classifiers.titles[value] == score) {
|
|
|
|
delete self.model.classifiers.titles[value];
|
|
|
|
} else if (name == 'author' && self.model.classifiers.authors[value] == score) {
|
|
|
|
delete self.model.classifiers.authors[value];
|
2010-10-21 13:37:36 -04:00
|
|
|
} else if (name == 'feed' && self.model.classifiers.feeds[feed_id] == score) {
|
2010-08-22 18:34:40 -04:00
|
|
|
delete self.model.classifiers.feeds[feed_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
|
|
|
|
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;
|
|
|
|
var $feed = this.find_feed_in_feed_list(feed_id);
|
|
|
|
$feed.addClass('NB-feed-unfetched').removeClass('NB-feed-exception');
|
|
|
|
|
|
|
|
this.model.save_exception_retry(feed_id, _.bind(this.force_feed_refresh, this, feed_id, $feed));
|
|
|
|
},
|
|
|
|
|
|
|
|
force_feed_refresh: function(feed_id, $feed) {
|
|
|
|
var self = this;
|
|
|
|
feed_id = feed_id || this.active_feed;
|
|
|
|
$feed = $feed || this.find_feed_in_feed_list(feed_id);
|
|
|
|
|
|
|
|
this.force_feeds_refresh(function(feeds) {
|
|
|
|
var $new_feed = self.make_feed_title_line(feeds[feed_id], true, 'feed');
|
|
|
|
$feed.replaceWith($new_feed);
|
|
|
|
self.hover_over_feed_titles($new_feed);
|
|
|
|
if (self.active_feed == feed_id) {
|
|
|
|
self.open_feed(feed_id, true, $new_feed);
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
setup_feed_refresh: function() {
|
2010-06-08 11:19:41 -04:00
|
|
|
var self = this;
|
|
|
|
|
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);
|
|
|
|
}, self), self.flags['has_unfetched_feeds']);
|
|
|
|
}
|
2010-10-06 22:22:32 -04:00
|
|
|
}, this.FEED_REFRESH_INTERVAL);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-10-10 20:14:31 -04:00
|
|
|
force_feeds_refresh: function(callback, update_all) {
|
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;
|
2010-12-31 14:35:00 -05:00
|
|
|
|
2010-08-30 22:42:44 -04:00
|
|
|
this.model.refresh_feeds(_.bind(function(updated_feeds) {
|
|
|
|
this.post_feed_refresh(updated_feeds, update_all);
|
|
|
|
}, this), this.flags['has_unfetched_feeds']);
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-08-30 22:42:44 -04:00
|
|
|
post_feed_refresh: function(updated_feeds, update_all) {
|
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
|
|
|
}
|
2010-08-11 11:43:48 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
for (var f in updated_feeds) {
|
|
|
|
var feed_id = updated_feeds[f];
|
|
|
|
var feed = this.model.get_feed(feed_id);
|
2010-08-16 16:30:04 -04:00
|
|
|
if (!feed) continue;
|
2010-07-26 21:38:56 -04:00
|
|
|
var $feed = this.make_feed_title_line(feed, true, 'feed');
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_on_page = this.find_feed_in_feed_list(feed_id);
|
2010-08-11 11:43:48 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (feed_id == this.active_feed) {
|
|
|
|
NEWSBLUR.log(['UPDATING INLINE', feed.feed_title, $feed, $feed_on_page]);
|
2010-11-25 10:32:00 -05:00
|
|
|
// var limit = $('.story', this.$s.$story_titles).length;
|
2010-08-30 22:42:44 -04:00
|
|
|
// this.model.refresh_feed(feed_id, $.rescope(this.post_refresh_active_feed, this), limit);
|
2010-11-25 10:32:00 -05:00
|
|
|
// $feed_on_page.replaceWith($feed);
|
|
|
|
// this.mark_feed_as_selected(this.active_feed, $feed);
|
2010-06-14 13:17:38 -04:00
|
|
|
} else {
|
2010-08-11 22:02:47 -04:00
|
|
|
if (!this.flags['has_unfetched_feeds']) {
|
|
|
|
NEWSBLUR.log(['UPDATING', feed.feed_title, $feed, $feed_on_page]);
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
$feed_on_page.replaceWith($feed);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-10-06 22:22:32 -04:00
|
|
|
this.hover_over_feed_titles($feed);
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-08-11 11:43:48 -04:00
|
|
|
|
2010-08-11 22:02:47 -04:00
|
|
|
this.check_feed_fetch_progress();
|
2010-11-22 10:44:52 -05:00
|
|
|
this.update_header_counts();
|
2010-08-30 22:42:44 -04:00
|
|
|
|
|
|
|
this.flags['pause_feed_refreshing'] = false;
|
2010-06-08 11:19:41 -04:00
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
post_refresh_active_feed: function(e, data, first_load) {
|
|
|
|
var stories = data.stories;
|
|
|
|
var tags = data.tags;
|
|
|
|
var feed_id = this.active_feed;
|
|
|
|
var new_stories = [];
|
|
|
|
var $first_story = $('.story:first', this.$s.$story_titles);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
for (var s in stories) {
|
|
|
|
feed_id = stories[s].story_feed_id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.active_feed == feed_id) {
|
|
|
|
for (var s in this.model.stories) {
|
|
|
|
var story = this.model.stories[s];
|
2010-12-30 18:37:29 -05:00
|
|
|
var $story = this.find_story_in_story_titles(story.id);
|
2010-06-14 13:17:38 -04:00
|
|
|
var $feed_story = this.find_story_in_feed_view(story);
|
|
|
|
|
|
|
|
if ($story && $story.length) {
|
|
|
|
// Just update intelligence
|
|
|
|
var score = this.compute_story_score(story);
|
|
|
|
$story.removeClass('NB-story-neutral')
|
|
|
|
.removeClass('NB-story-negative')
|
|
|
|
.removeClass('NB-story-positive');
|
|
|
|
$feed_story.removeClass('NB-story-neutral')
|
|
|
|
.removeClass('NB-story-negative')
|
|
|
|
.removeClass('NB-story-positive');
|
|
|
|
if (score < 0) {
|
|
|
|
$story.addClass('NB-story-negative');
|
|
|
|
$feed_story.addClass('NB-story-negative');
|
|
|
|
} else if (score > 0) {
|
|
|
|
$story.addClass('NB-story-positive');
|
|
|
|
$feed_story.addClass('NB-story-positive');
|
|
|
|
} else if (score == 0) {
|
|
|
|
$story.addClass('NB-story-neutral');
|
|
|
|
$feed_story.addClass('NB-story-neutral');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// New story! Prepend.
|
|
|
|
new_stories.unshift(story);
|
|
|
|
$new_story = this.make_story_title(story);
|
|
|
|
$new_story.css({'display': 'none'});
|
|
|
|
$first_story.before($new_story);
|
|
|
|
NEWSBLUR.log(['New story', $new_story, $first_story]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new_stories.length) {
|
2010-12-04 13:32:13 -05:00
|
|
|
this.make_story_feed_entries(new_stories, false, {'refresh_load': true});
|
2010-06-14 13:17:38 -04:00
|
|
|
this.flags['feed_view_positions_calculated'] = false;
|
|
|
|
}
|
2010-12-08 20:53:45 -05:00
|
|
|
this.show_story_titles_above_intelligence_level({'animate': true, 'follow': false});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
2010-11-22 10:44:52 -05:00
|
|
|
this.update_header_counts();
|
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');
|
|
|
|
var $signup_username = $('input[name=signup-signup_username]');
|
|
|
|
|
|
|
|
$signup_username.bind('focus', function() {
|
|
|
|
$hidden_inputs.slideDown(300);
|
|
|
|
}).bind('blur', function() {
|
|
|
|
if ($signup_username.val().length < 2) {
|
|
|
|
$hidden_inputs.slideUp(300);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-06-30 12:17:22 -04:00
|
|
|
// ==================
|
|
|
|
// = Features Board =
|
|
|
|
// ==================
|
|
|
|
|
|
|
|
load_feature_page: function(direction) {
|
|
|
|
var self = this;
|
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');
|
2010-06-30 12:17:22 -04:00
|
|
|
|
2010-08-11 11:43:48 -04:00
|
|
|
if (direction == -1 && !this.counts['feature_page']) {
|
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']) {
|
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) {
|
|
|
|
self.counts['feature_page'] += direction;
|
2010-06-30 16:18:55 -04:00
|
|
|
|
|
|
|
var $table = $.make('table', { cellSpacing: 0, cellPadding: 0 });
|
|
|
|
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
|
|
|
|
2010-06-30 16:18:55 -04:00
|
|
|
$('.NB-module-features table').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
|
|
|
});
|
|
|
|
},
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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;
|
|
|
|
|
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 =
|
|
|
|
// =============================
|
2010-08-17 23:40:03 -04:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
$('.NB-progress-title', $progress).text('Importing from Google Reader');
|
|
|
|
$('.NB-progress-counts', $progress).hide();
|
|
|
|
$('.NB-progress-percentage', $progress).hide();
|
|
|
|
$bar.progressbar({
|
|
|
|
value: percentage
|
|
|
|
});
|
|
|
|
|
|
|
|
var animate = function() {
|
|
|
|
var time = 50;
|
|
|
|
if (percentage > 90) {
|
|
|
|
time = 500;
|
|
|
|
} else if (percentage > 80) {
|
|
|
|
time = 400;
|
|
|
|
} else if (percentage > 70) {
|
|
|
|
time = 300;
|
|
|
|
} else if (percentage > 60) {
|
|
|
|
time = 200;
|
|
|
|
} else if (percentage > 50) {
|
|
|
|
time = 100;
|
|
|
|
}
|
|
|
|
setTimeout(function() {
|
|
|
|
if (!self.flags['import_from_google_reader_finished']) {
|
|
|
|
percentage += 1;
|
|
|
|
$bar.progressbar({value: percentage});
|
|
|
|
animate();
|
|
|
|
}
|
|
|
|
}, time);
|
|
|
|
};
|
|
|
|
animate();
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
this.flags['import_from_google_reader_finished'] = true;
|
|
|
|
|
|
|
|
if (data.code >= 1) {
|
|
|
|
$bar.progressbar({value: 100});
|
|
|
|
this.load_feeds();
|
|
|
|
} 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'));
|
|
|
|
}
|
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;
|
|
|
|
var factor = 17500 * _.keys(this.model.feeds).length / 40000;
|
|
|
|
|
2010-12-31 14:35:00 -05:00
|
|
|
if (!this.flags['pause_feed_refreshing']) return;
|
|
|
|
|
2010-08-18 08:10:24 -04:00
|
|
|
this.flags['count_unreads_after_import_finished'] = false;
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
|
|
|
var animate = function() {
|
|
|
|
// 17,500 ticks
|
|
|
|
var time = factor;
|
|
|
|
if (percentage > 90) {
|
|
|
|
time = factor * 100;
|
|
|
|
} else if (percentage > 80) {
|
|
|
|
time = factor * 50;
|
|
|
|
} else if (percentage > 70) {
|
|
|
|
time = factor * 20;
|
|
|
|
} else if (percentage > 60) {
|
|
|
|
time = factor * 8;
|
|
|
|
} else if (percentage > 50) {
|
|
|
|
time = factor * 2;
|
|
|
|
}
|
|
|
|
setTimeout(function() {
|
|
|
|
if (!self.flags['count_unreads_after_import_finished']) {
|
|
|
|
percentage += 1;
|
|
|
|
$bar.progressbar({value: percentage});
|
|
|
|
animate();
|
|
|
|
}
|
|
|
|
}, time);
|
|
|
|
};
|
|
|
|
animate();
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
if (!self.flags['count_unreads_after_import_finished']) {
|
|
|
|
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
|
|
|
|
});
|
|
|
|
this.flags['count_unreads_after_import_finished'] = true;
|
|
|
|
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
|
|
|
|
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;
|
2010-07-07 16:22:26 -04:00
|
|
|
// var start = (new Date().getMilliseconds());
|
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// Feeds ==========================================================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-09-11 17:15:08 -04:00
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .NB-feedlist-manage-icon' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (!self.flags['sorting_feed']) {
|
|
|
|
stopPropagation = true;
|
|
|
|
if ($t.parent().hasClass('feed')) {
|
2010-09-12 13:50:27 -04:00
|
|
|
self.show_manage_menu('feed', $t.parents('.feed').eq(0));
|
2010-09-11 17:15:08 -04:00
|
|
|
} else {
|
2010-09-12 13:50:27 -04:00
|
|
|
self.show_manage_menu('folder', $t.parents('.folder').eq(0));
|
2010-09-11 17:15:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (stopPropagation) return;
|
2010-08-18 20:35:45 -04:00
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .feed.NB-feed-exception' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!self.flags['sorting_feed']) {
|
|
|
|
var feed_id = $t.data('feed_id');
|
2010-09-12 13:50:27 -04:00
|
|
|
stopPropagation = true;
|
2010-08-18 20:35:45 -04:00
|
|
|
self.open_feed_exception_modal(feed_id, $t);
|
|
|
|
}
|
|
|
|
});
|
2010-09-11 17:15:08 -04:00
|
|
|
if (stopPropagation) return;
|
2010-08-18 20:35:45 -04:00
|
|
|
|
2010-11-25 15:46:54 -05:00
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .feed:not(.NB-empty)' }, function($t, $p){
|
2010-06-14 13:17:38 -04:00
|
|
|
e.preventDefault();
|
2010-07-10 17:59:17 -04:00
|
|
|
if (!self.flags['sorting_feed']) {
|
|
|
|
var feed_id = $t.data('feed_id');
|
2010-10-11 12:07:32 -04:00
|
|
|
self.open_feed(feed_id, false, $t);
|
2010-07-10 17:59:17 -04:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
2010-12-12 20:06:32 -05:00
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .folder_title .NB-feedlist-river-icon' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
stopPropagation = true;
|
|
|
|
var $folder = $t.closest('li.folder');
|
|
|
|
var folder_title = $t.siblings('.folder_title_text').text();
|
2010-12-12 22:52:15 -05:00
|
|
|
self.open_river_stories($folder, folder_title);
|
2010-12-12 20:06:32 -05:00
|
|
|
});
|
|
|
|
if (stopPropagation) return;
|
2010-09-05 18:08:08 -07:00
|
|
|
$.targetIs(e, { tagSelector: '#feed_list .folder_title' }, function($folder, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
if (!self.flags['sorting_feed']) {
|
|
|
|
self.collapse_folder($folder);
|
|
|
|
}
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feedbar-mark-feed-read' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.parents('.feed').data('feed_id');
|
|
|
|
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')) {
|
2010-10-21 23:32:07 -04:00
|
|
|
self.open_feed_intelligence_modal(1, this.active_feed, true);
|
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
|
|
|
// = Feed Bar =====================================================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feed-like' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_feed_intelligence_modal(1);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-feed-dislike' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.open_feed_intelligence_modal(-1);
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-09-12 13:50:27 -04:00
|
|
|
// = Stories ======================================================
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
var story_prevent_bubbling = false;
|
2010-12-30 18:37:29 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-story-manage-icon' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
story_prevent_bubbling = true;
|
|
|
|
self.show_manage_menu('story', $t.closest('.story'));
|
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-story-like' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2010-12-04 16:42:51 -05:00
|
|
|
var story_id = $t.closest('.story').data('story_id');
|
|
|
|
var feed_id = $t.closest('.story').data('feed_id');
|
|
|
|
self.mark_story_as_like(story_id, feed_id);
|
2010-06-14 13:17:38 -04:00
|
|
|
story_prevent_bubbling = true;
|
|
|
|
});
|
2010-12-30 18:37:29 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-star' }, function($t, $p){
|
2010-06-14 13:17:38 -04:00
|
|
|
e.preventDefault();
|
2010-12-30 18:37:29 -05:00
|
|
|
var story_id = $t.closest('.NB-menu-manage-story').data('story_id');
|
|
|
|
var $story = self.find_story_in_story_titles(story_id);
|
|
|
|
if ($story.hasClass('NB-story-starred')) {
|
|
|
|
self.mark_story_as_unstarred(story_id, $story);
|
2010-12-01 09:30:56 -05:00
|
|
|
} else {
|
2010-12-30 18:37:29 -05:00
|
|
|
self.mark_story_as_starred(story_id, $story);
|
2010-12-01 09:30:56 -05:00
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
story_prevent_bubbling = true;
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: 'a.button.like' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var story_id = self.$s.$story_pane.data('story_id');
|
2010-12-04 16:42:51 -05:00
|
|
|
var feed_id = $t.closest('.story').data('feed_id');
|
|
|
|
self.mark_story_as_like(story_id, feed_id);
|
2010-06-14 13:17:38 -04:00
|
|
|
story_prevent_bubbling = true;
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: 'a.button.dislike' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var story_id = self.$s.$story_pane.data('story_id');
|
2010-12-04 16:42:51 -05:00
|
|
|
var feed_id = $t.closest('.story').data('feed_id');
|
|
|
|
self.mark_story_as_dislike(story_id, feed_id);
|
2010-06-14 13:17:38 -04:00
|
|
|
story_prevent_bubbling = true;
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (story_prevent_bubbling) return false;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.story' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var story_id = $('.story_id', $t).text();
|
|
|
|
var story = self.model.get_story(story_id);
|
|
|
|
self.push_current_story_on_history();
|
2010-12-14 17:08:52 -05:00
|
|
|
if (NEWSBLUR.hotkeys.command) {
|
|
|
|
self.open_story_in_new_tab(story, $t);
|
|
|
|
} else {
|
|
|
|
self.open_story(story, $t);
|
|
|
|
}
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: 'a.mark_story_as_read' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var story_id = $t.attr('href').slice(1).split('/');
|
2010-12-30 19:24:52 -05:00
|
|
|
self.mark_story_as_read(story_id);
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
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
|
|
|
}
|
|
|
|
});
|
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
|
|
|
}
|
|
|
|
});
|
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');
|
|
|
|
self.mark_story_as_like(story_id, feed_id);
|
|
|
|
}
|
|
|
|
});
|
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();
|
|
|
|
}
|
|
|
|
});
|
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
|
|
|
}
|
|
|
|
});
|
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();
|
|
|
|
} else {
|
|
|
|
self.show_confirm_delete_menu_item();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.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);
|
|
|
|
});
|
|
|
|
$.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
|
|
|
});
|
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();
|
|
|
|
});
|
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-12-14 17:08:52 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-unreadtabs' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
|
|
|
self.open_unread_stories_in_tabs(feed_id);
|
|
|
|
});
|
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);
|
|
|
|
});
|
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();
|
|
|
|
}
|
|
|
|
});
|
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');
|
|
|
|
self.open_feed_exception_modal(feed_id, $t);
|
|
|
|
});
|
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
|
|
|
});
|
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();
|
|
|
|
}
|
|
|
|
});
|
2010-12-30 19:24:52 -05:00
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-unread' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var feed_id = $t.closest('.NB-menu-manage').data('feed_id');
|
|
|
|
var story_id = $t.closest('.NB-menu-manage').data('story_id');
|
|
|
|
self.mark_story_as_unread(story_id, feed_id);
|
|
|
|
});
|
|
|
|
|
2010-12-31 10:34:31 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-instapaper' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var story_id = $t.closest('.NB-menu-manage').data('story_id');
|
|
|
|
self.send_story_to_instapaper(story_id);
|
|
|
|
});
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.task_button_view' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
var view;
|
|
|
|
|
|
|
|
if ($t.hasClass('task_view_page')) {
|
|
|
|
view = 'page';
|
|
|
|
} else if ($t.hasClass('task_view_feed')) {
|
|
|
|
view = 'feed';
|
|
|
|
} else if ($t.hasClass('task_view_story')) {
|
|
|
|
view = 'story';
|
|
|
|
}
|
2010-12-04 21:53:39 -05:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
self.switch_taskbar_view(view);
|
2010-06-08 11:19:41 -04:00
|
|
|
});
|
2010-06-14 13:17:38 -04:00
|
|
|
$.targetIs(e, { tagSelector: '.task_return', childOf: '.taskbar_nav_return' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
2010-12-06 10:41:24 -05:00
|
|
|
self.load_feed_iframe();
|
2010-06-14 13:17:38 -04:00
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.task_button_story.task_story_next_unread' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_next_unread_story();
|
|
|
|
});
|
|
|
|
$.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();
|
|
|
|
});
|
2010-12-04 23:18:07 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feeds-header-sites' }, function($t, $p){
|
2010-12-04 23:06:35 -05:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
stopPropagation = true;
|
|
|
|
self.switch_preferences_hide_read_feeds();
|
|
|
|
});
|
|
|
|
if (stopPropagation) return;
|
2010-11-22 10:44:52 -05:00
|
|
|
$.targetIs(e, { tagSelector: '.NB-feeds-header' }, function($t, $p){
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_splash_page();
|
|
|
|
});
|
2010-06-08 11:19:41 -04: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);
|
|
|
|
});
|
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
|
|
|
|
|
|
|
// NEWSBLUR.log(['End', (new Date().getMilliseconds()) - 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]);
|
|
|
|
var feed_id = $t.data('feed_id');
|
|
|
|
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;
|
|
|
|
|
|
|
|
// NEWSBLUR.log(['right click', elem, e]);
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.story', childOf: '#story_titles' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.show_manage_menu('story', $t);
|
|
|
|
});
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-arrow' }, function($t, $p) {
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
handle_scroll_story_titles: function(elem, e) {
|
|
|
|
var self = this;
|
|
|
|
var $story_titles = this.$s.$story_titles;
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (!($('.NB-story-titles-end-stories-line', $story_titles).length)) {
|
|
|
|
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]);
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2010-06-14 13:17:38 -04:00
|
|
|
if (full_height <= visible_height) {
|
|
|
|
this.load_page_of_feed_stories();
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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 ;
|
|
|
|
this.$s.$mouse_indicator.css('top', this.cache.mouse_position_y - 8);
|
|
|
|
|
|
|
|
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') {
|
|
|
|
var from_top = this.cache.mouse_position_y + this.$s.$feed_view.scrollTop();
|
|
|
|
var positions = this.cache.feed_view_story_positions_keys;
|
|
|
|
var closest = $.closest(from_top, positions);
|
|
|
|
var story = this.cache.feed_view_story_positions[positions[closest]];
|
2010-12-09 09:59:45 -05:00
|
|
|
this.flags['mousemove_timeout'] = true;
|
|
|
|
// 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;
|
|
|
|
|
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')) {
|
2010-06-14 13:17:38 -04:00
|
|
|
var from_top = this.cache.mouse_position_y + this.$s.$feed_view.scrollTop();
|
|
|
|
var positions = this.cache.feed_view_story_positions_keys;
|
|
|
|
var closest = $.closest(from_top, positions);
|
|
|
|
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);
|
2010-06-13 20:10:48 -04:00
|
|
|
}
|
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);
|
|
|
|
});
|
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();
|
|
|
|
self.page_in_story(0.4, 1);
|
|
|
|
});
|
|
|
|
$document.bind('keydown', 'shift+space', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.page_in_story(0.4, -1);
|
|
|
|
});
|
2010-06-08 11:19:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2010-10-19 19:09:08 -04:00
|
|
|
})(jQuery);
|