From 2a99f1b15e54f89085261c72e7af1ff8585e53ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 5 Mar 2014 16:08:45 +0100 Subject: [PATCH] BUGFIX: HOME/END keyboard shortcuts on non-topic pages This make sure both HOME/END keyboard shortcuts are only applied when viewing a topic --- .../components/keyboard_shortcuts_component.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js index 494196131ec..6db20f7e6c8 100644 --- a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js +++ b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js @@ -59,11 +59,17 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ }, goToFirstPost: function() { - Discourse.__container__.lookup('controller:topic').send('jumpTop'); + this._jumpTo('jumpTop'); }, goToLastPost: function() { - Discourse.__container__.lookup('controller:topic').send('jumpBottom'); + this._jumpTo('jumpBottom'); + }, + + _jumpTo: function(direction) { + if ($('#topic-title').length) { + Discourse.__container__.lookup('controller:topic').send(direction); + } }, selectDown: function() {