From 869027b0fc65d7449659769f8619e8106063f75e Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Thu, 16 Jan 2014 12:55:44 -0800 Subject: [PATCH] Fixing an infinite loop (!!) and focusing in on the comment textbox when sharing a story. --- media/js/newsblur/views/story_save_view.js | 4 ++-- media/js/newsblur/views/story_share_view.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/media/js/newsblur/views/story_save_view.js b/media/js/newsblur/views/story_save_view.js index 0cc579163..c365861da 100644 --- a/media/js/newsblur/views/story_save_view.js +++ b/media/js/newsblur/views/story_save_view.js @@ -213,8 +213,8 @@ NEWSBLUR.Views.StorySaveView = Backbone.View.extend({ } } }); - } else if (this.sideoptions_view.share_view.is_open) { - this.sideoptions_view.share_view.resize(); + } else if (this.sideoptions_view.share_view.is_open && !options.from_share_view) { + this.sideoptions_view.share_view.resize({from_save_view: true}); } } diff --git a/media/js/newsblur/views/story_share_view.js b/media/js/newsblur/views/story_share_view.js index 52114dc87..e5b357b07 100644 --- a/media/js/newsblur/views/story_share_view.js +++ b/media/js/newsblur/views/story_share_view.js @@ -70,6 +70,7 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ // Close this.is_open = false; this.resize({close: true}); + NEWSBLUR.reader.blur_to_page(); } else { // Open/resize this.is_open = true; @@ -104,12 +105,18 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ this.mark_story_as_shared({'source': 'sideoption'}); }, this); var $comments = $('.NB-sideoption-share-comments', $share); - $comments.unbind('keydown.story_share') + $comments.unbind('keydown.story_share').unbind('keypress.story_share') .bind('keydown.story_share', 'ctrl+return', share) - .bind('keydown.story_share', 'meta+return', share); + .bind('keydown.story_share', 'meta+return', share) + .bind('keypress.story_share', 'esc', blur); + $comments.focus(); } }, + blur: function() { + NEWSBLUR.reader.blur_to_page(); + }, + resize: function(options) { options = options || {}; var $sideoption_container = this.$('.NB-feed-story-sideoptions-container'); @@ -193,8 +200,9 @@ NEWSBLUR.Views.StoryShareView = Backbone.View.extend({ }); } else if (this.sideoptions_view && this.sideoptions_view.save_view && - this.sideoptions_view.save_view.is_open) { - this.sideoptions_view.save_view.resize(); + this.sideoptions_view.save_view.is_open && + !options.from_save_view) { + this.sideoptions_view.save_view.resize({from_share_view: true}); } }