Fixing issues around the feed floater.

This commit is contained in:
Samuel Clay 2012-06-14 17:21:51 -07:00
parent df50ccf101
commit a086cd83d4
5 changed files with 39 additions and 26 deletions

View file

@ -1629,7 +1629,6 @@ background: transparent;
z-index: 2; z-index: 2;
width: 100%; width: 100%;
display: none; display: none;
opacity: .9;
} }
.NB-view-river .NB-feed-story-view-floater { .NB-view-river .NB-feed-story-view-floater {
@ -1729,6 +1728,7 @@ background: transparent;
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
border-top: 1px solid #707070; border-top: 1px solid #707070;
z-index: 2; z-index: 2;
opacity: .9;
} }
#story_pane .NB-feed-story-header-feed.NB-feed-story-river-same-feed { #story_pane .NB-feed-story-header-feed.NB-feed-story-river-same-feed {
z-index: 0; z-index: 0;

View file

@ -949,7 +949,7 @@
if (!feed || (temp && !options.try_feed)) { if (!feed || (temp && !options.try_feed)) {
// Setup tryfeed views first, then come back here. // Setup tryfeed views first, then come back here.
options.feed = options.feed.attributes; options.feed = options.feed && options.feed.attributes;
return this.load_feed_in_tryfeed_view(feed_id, options); return this.load_feed_in_tryfeed_view(feed_id, options);
} }
@ -998,7 +998,8 @@
this.setup_mousemove_on_views(); this.setup_mousemove_on_views();
if (!options.silent) { if (!options.silent) {
var slug = _.string.words(_.string.clean(feed.get('feed_title').replace(/[^a-z0-9\. ]/ig, ''))).join('-').toLowerCase(); var feed_title = feed.get('feed_title') || '';
var slug = _.string.words(_.string.clean(feed_title.replace(/[^a-z0-9\. ]/ig, ''))).join('-').toLowerCase();
var url = "site/" + feed.id + "/" + slug; var url = "site/" + feed.id + "/" + slug;
if (!_.string.include(window.location.pathname, url)) { if (!_.string.include(window.location.pathname, url)) {
// console.log(["Navigating to url", url]); // console.log(["Navigating to url", url]);
@ -3965,7 +3966,7 @@
feed_id : feed_id, feed_id : feed_id,
feed_title : options.feed && options.feed.feed_title, feed_title : options.feed && options.feed.feed_title,
temp : true temp : true
}, options.feed.attributes); }, options.feed && options.feed.attributes);
var $tryfeed_container = this.$s.$tryfeed_header.closest('.NB-feeds-header-container'); var $tryfeed_container = this.$s.$tryfeed_header.closest('.NB-feeds-header-container');
this.reset_feed(); this.reset_feed();

View file

@ -1,9 +1,8 @@
NEWSBLUR.ReaderIntro = function(options) { NEWSBLUR.ReaderIntro = function(options) {
var defaults = {}; var defaults = {};
var intro_page = this.model.preference('intro_page'); var intro_page = NEWSBLUR.assets.preference('intro_page');
_.bindAll(this, 'close', 'start_import_from_google_reader', 'post_connect'); _.bindAll(this, 'close', 'start_import_from_google_reader', 'post_connect');
this.model = NEWSBLUR.assets;
this.options = $.extend({ this.options = $.extend({
'page_number': intro_page && _.isNumber(intro_page) && intro_page <= 4 ? intro_page : 1 'page_number': intro_page && _.isNumber(intro_page) && intro_page <= 4 ? intro_page : 1
}, defaults, options); }, defaults, options);
@ -168,8 +167,8 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
fetch_friends: function(callback) { fetch_friends: function(callback) {
$('.NB-modal-loading', this.$modal).addClass('NB-active'); $('.NB-modal-loading', this.$modal).addClass('NB-active');
this.model.fetch_friends(_.bind(function(data) { NEWSBLUR.assets.fetch_friends(_.bind(function(data) {
this.profile = this.model.user_profile; this.profile = NEWSBLUR.assets.user_profile;
this.services = data.services; this.services = data.services;
this.autofollow = data.autofollow; this.autofollow = data.autofollow;
this.make_find_friends_and_services(); this.make_find_friends_and_services();
@ -240,7 +239,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
disconnect: function(service) { disconnect: function(service) {
var $service = $('.NB-friends-service-'+service, this.$modal); var $service = $('.NB-friends-service-'+service, this.$modal);
$('.NB-friends-service-connect', $service).text('Disconnecting...'); $('.NB-friends-service-connect', $service).text('Disconnecting...');
this.model.disconnect_social_service(service, _.bind(function(data) { NEWSBLUR.assets.disconnect_social_service(service, _.bind(function(data) {
this.services = data.services; this.services = data.services;
this.make_find_friends_and_services(); this.make_find_friends_and_services();
this.make_profile_section(); this.make_profile_section();
@ -261,7 +260,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
} else { } else {
this.fetch_friends(); this.fetch_friends();
} }
this.model.preference('has_found_friends', true); NEWSBLUR.assets.preference('has_found_friends', true);
NEWSBLUR.reader.check_hide_getting_started(); NEWSBLUR.reader.check_hide_getting_started();
}, },
@ -283,12 +282,12 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
} }
var page_count = $('.NB-page', this.$modal).length; var page_count = $('.NB-page', this.$modal).length;
this.page_number = page_number; this.page_number = page_number;
this.model.preference('intro_page', page_number); NEWSBLUR.assets.preference('intro_page', page_number);
if (page_number == page_count) { if (page_number == page_count) {
$('.NB-tutorial-next-page-text', this.$modal).text('All Done '); $('.NB-tutorial-next-page-text', this.$modal).text('All Done ');
} else if (page_number > page_count) { } else if (page_number > page_count) {
this.model.preference('has_setup_feeds', true); NEWSBLUR.assets.preference('has_setup_feeds', true);
NEWSBLUR.reader.check_hide_getting_started(); NEWSBLUR.reader.check_hide_getting_started();
this.close(function() { this.close(function() {
NEWSBLUR.reader.open_dialog_after_feeds_loaded(); NEWSBLUR.reader.open_dialog_after_feeds_loaded();
@ -327,7 +326,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
var $carousel = $('.carousel', this.$modal); var $carousel = $('.carousel', this.$modal);
$carousel.carousel('pause'); $carousel.carousel('pause');
if (!_.isNumber(page)) { if (!_.isNumber(page)) {
if (_.size(this.model.feeds) && !this.options.force_import) { if (NEWSBLUR.assets.feeds.size() && !this.options.force_import) {
page = 2; page = 2;
$('.NB-intro-imports-sites', this.$modal).addClass('active'); $('.NB-intro-imports-sites', this.$modal).addClass('active');
} else { } else {
@ -346,7 +345,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
}, },
count_feeds: function() { count_feeds: function() {
var feed_count = _.size(this.model.feeds); var feed_count = NEWSBLUR.assets.feeds.size();
$(".NB-intro-imports-sites h4", this.$modal).text([ $(".NB-intro-imports-sites h4", this.$modal).text([
'You are subscribed to ', 'You are subscribed to ',
@ -355,7 +354,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
].join("")); ].join(""));
if (feed_count) { if (feed_count) {
this.model.preference('has_setup_feeds', true); NEWSBLUR.assets.preference('has_setup_feeds', true);
NEWSBLUR.reader.check_hide_getting_started(); NEWSBLUR.reader.check_hide_getting_started();
} }
}, },
@ -415,7 +414,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
NEWSBLUR.reader.flags.importing_from_google_reader = false; NEWSBLUR.reader.flags.importing_from_google_reader = false;
this.advance_import_carousel(1); this.advance_import_carousel(1);
$loading.addClass('NB-active'); $loading.addClass('NB-active');
this.model.start_import_from_google_reader($.rescope(this.finish_import_from_google_reader, this)); NEWSBLUR.assets.start_import_from_google_reader($.rescope(this.finish_import_from_google_reader, this));
} }
}, },
@ -491,14 +490,14 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
if ($input.is(':checked')) { if ($input.is(':checked')) {
$button.addClass('NB-active'); $button.addClass('NB-active');
if (this.services.twitter.twitter_uid) { if (this.services.twitter.twitter_uid) {
this.model.follow_twitter_account(username); NEWSBLUR.assets.follow_twitter_account(username);
} else { } else {
window.open('http://twitter.com/'+username, '_blank'); window.open('http://twitter.com/'+username, '_blank');
} }
} else { } else {
$button.removeClass('NB-active'); $button.removeClass('NB-active');
if (this.services.twitter.twitter_uid) { if (this.services.twitter.twitter_uid) {
this.model.unfollow_twitter_account(username); NEWSBLUR.assets.unfollow_twitter_account(username);
} }
} }
}, },
@ -512,22 +511,22 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
if ($input.is(':checked')) { if ($input.is(':checked')) {
$button.addClass('NB-active'); $button.addClass('NB-active');
if (feed == 'blog') { if (feed == 'blog') {
this.model.save_add_url(blog_url, "", function() { NEWSBLUR.assets.save_add_url(blog_url, "", function() {
NEWSBLUR.app.feed_list.fetch(); NEWSBLUR.app.feed_list.fetch();
}, {auto_active: false}); }, {auto_active: false});
} else if (feed == 'popular') { } else if (feed == 'popular') {
this.model.follow_user(popular_username, function() { NEWSBLUR.assets.follow_user(popular_username, function() {
NEWSBLUR.reader.make_social_feeds(); NEWSBLUR.reader.make_social_feeds();
}); });
} }
} else { } else {
$button.removeClass('NB-active'); $button.removeClass('NB-active');
if (feed == 'blog') { if (feed == 'blog') {
this.model.delete_feed_by_url(blog_url, "", function() { NEWSBLUR.assets.delete_feed_by_url(blog_url, "", function() {
NEWSBLUR.app.feed_list.fetch(); NEWSBLUR.app.feed_list.fetch();
}); });
} else if (feed == 'popular') { } else if (feed == 'popular') {
this.model.unfollow_user(popular_username, function() { NEWSBLUR.assets.unfollow_user(popular_username, function() {
NEWSBLUR.app.feed_list.make_social_feeds(); NEWSBLUR.app.feed_list.make_social_feeds();
}); });
} }

View file

@ -30,8 +30,10 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
// Binding directly instead of using event delegation. Need for speed. // Binding directly instead of using event delegation. Need for speed.
this.$el.bind('mouseenter', this.mouseenter); this.$el.bind('mouseenter', this.mouseenter);
this.$el.bind('mouseleave', this.mouseleave); this.$el.bind('mouseleave', this.mouseleave);
this.model.story_view = this; if (!this.options.feed_floater) {
this.model.story_view = this;
}
}, },
// ============= // =============
@ -178,6 +180,11 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
} }
}, },
destroy: function() {
this.model.unbind(null, null, this);
this.remove();
},
// ============ // ============
// = Bindings = // = Bindings =
// ============ // ============

View file

@ -105,14 +105,20 @@ NEWSBLUR.Views.StoryListView = Backbone.View.extend({
var $story = story.story_view.$el; var $story = story.story_view.$el;
$header = $('.NB-feed-story-header-feed', $story); $header = $('.NB-feed-story-header-feed', $story);
var $new_header = $header.clone(); var $new_header = $header.clone();
if (this.feed_title_floater) this.feed_title_floater.destroy();
this.feed_title_floater = new NEWSBLUR.Views.StoryDetailView({
feed_floater: true,
model: story,
el: $new_header
});
$feed_floater.html($new_header); $feed_floater.html($new_header);
this.cache.feed_title_floater_feed_id = story.get('story_feed_id'); this.cache.feed_title_floater_feed_id = story.get('story_feed_id');
var feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id')); var feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
$feed_floater.toggleClass('NB-inverse', feed.is_light()); $feed_floater.toggleClass('NB-inverse', feed.is_light());
$feed_floater.width($header.outerWidth()); $feed_floater.width($header.outerWidth());
} else if (!story) { } else if (!story) {
$feed_floater.empty(); if (this.feed_title_floater) this.feed_title_floater.destroy();
this.cache.feed_title_floater_feed_id = null; this.cache.feed_title_floater_feed_id = null;
} }