From ebb001c24acfb11335dc25c26d9bb35dd29b3551 Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 17 Feb 2014 15:21:35 -0800 Subject: [PATCH 1/2] When entering a topic, place the desired post in the middle of the page --- app/assets/javascripts/discourse/views/topic_view.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/views/topic_view.js b/app/assets/javascripts/discourse/views/topic_view.js index 2659d0139e1..eb2d4d720ca 100644 --- a/app/assets/javascripts/discourse/views/topic_view.js +++ b/app/assets/javascripts/discourse/views/topic_view.js @@ -235,7 +235,8 @@ Discourse.TopicView.reopenClass({ new LockOn(holderId, {offsetCalculator: function() { var $header = $('header'), $title = $('#topic-title'), - expectedOffset = $title.height() - $header.find('.contents').height(); + windowHeight = $(window).height() - $title.height(), + expectedOffset = $title.height() - $header.find('.contents').height() + (windowHeight / 5); return $header.outerHeight(true) + ((expectedOffset < 0) ? 0 : expectedOffset); }}).lock(); From 19922ff17471160d097760009fde61b80e33efbe Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 17 Feb 2014 16:33:55 -0800 Subject: [PATCH 2/2] Have keyboard_shortcuts use Discourse.TopicView.jumpToPost Instead of _scrollList, which is more appropriate on the topic list. --- .../discourse/components/keyboard_shortcuts_component.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js index 7569b00faa0..494196131ec 100644 --- a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js +++ b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js @@ -127,7 +127,13 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ if ($article.size() > 0) { $articles.removeClass('selected'); $article.addClass('selected'); - this._scrollList($article); + + var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id); + if (rgx === null || typeof rgx[1] === 'undefined') { + this._scrollList($article); + } else { + Discourse.TopicView.jumpToPost(rgx[1]); + } } },