diff --git a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js index 789538f04..55dd6c76f 100644 --- a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js +++ b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js @@ -31,7 +31,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'm t': 'div.notification-options li[data-id="2"] a', // mark topic as tracking 'm w': 'div.notification-options li[data-id="3"] a', // mark topic as watching 'n': '#user-notifications', // open notifictions menu - 'o,enter': '#topic-list tr.topic-list-item.selected a.title', // open selected topic + 'o,enter': '#topic-list tr.selected a.title', // open selected topic 'shift+r': '#topic-footer-buttons button.create', // reply to topic 'r': '.topic-post.selected button.create', // reply to selected post 'shift+s': '#topic-footer-buttons button.share', // share topic @@ -48,7 +48,8 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ '`': 'nextSection', '~': 'prevSection', '/': 'showSearch', - '?': 'showHelpModal' // open keyboard shortcut help + '?': 'showHelpModal', // open keyboard shortcut help + 'q': 'quoteReply' }, bindEvents: function(keyTrapper) { @@ -58,6 +59,14 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ _.each(this.FUNCTION_BINDINGS, this._bindToFunction, this); }, + quoteReply: function(){ + $('.topic-post.selected button.create').click(); + // lazy but should work for now + setTimeout(function(){ + $('#wmd-quote-post').click(); + }, 500); + }, + goToFirstPost: function() { this._jumpTo('jumpTop'); }, @@ -133,25 +142,53 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ // loop is not allowed if (direction === -1 && index === 0) { return; } + // if nothing is selected go to the first post on screen + if ($selected.length === 0) { + var scrollTop = $('body').scrollTop(); + + index = 0; + $articles.each(function(){ + var top = $(this).position().top; + if(top > scrollTop) { + return false; + } + index += 1; + }); + + if(index >= $articles.length){ + index = $articles.length - 1; + } + } + var $article = $articles.eq(index + direction); if ($article.size() > 0) { $articles.removeClass('selected'); - $article.addClass('selected'); + Em.run.next(function(){ + $article.addClass('selected'); + }); var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id); if (rgx === null || typeof rgx[1] === 'undefined') { - this._scrollList($article); + this._scrollList($article, direction); } else { Discourse.TopicView.jumpToPost(rgx[1]); } } }, - _scrollList: function($article) { + _scrollList: function($article, direction) { var $body = $('body'), distToElement = $article.position().top + $article.height() - $(window).height() - $body.scrollTop(); + // cut some bottom slack + distToElement += 40; + + // don't scroll backwards, its silly + if((direction > 0 && distToElement < 0) || (direction < 0 && distToElement > 0)) { + return; + } + $('html, body').scrollTop($body.scrollTop() + distToElement); }, @@ -160,7 +197,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ $topicArea = $('.posts-wrapper'); if ($topicArea.size() > 0) { - return $topicArea.find('.topic-post'); + return $('.posts-wrapper .topic-post, #topic-list tbody tr'); } else if ($topicList.size() > 0) { return $topicList.find('.topic-list-item'); diff --git a/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.js.handlebars b/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.js.handlebars index faf41abf5..b2e64bddd 100644 --- a/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/keyboard_shortcuts_help.js.handlebars @@ -35,6 +35,7 @@ <li>{{{i18n keyboard_shortcuts_help.actions.share_post}}}</li> <li>{{{i18n keyboard_shortcuts_help.actions.reply_topic}}}</li> <li>{{{i18n keyboard_shortcuts_help.actions.reply_post}}}</li> + <li>{{{i18n keyboard_shortcuts_help.actions.quote_post}}}</li> <li>{{{i18n keyboard_shortcuts_help.actions.like}}}</li> <li>{{{i18n keyboard_shortcuts_help.actions.flag}}}</li> <li>{{{i18n keyboard_shortcuts_help.actions.bookmark}}}</li> diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scss index 98fda6314..e27ab13c2 100644 --- a/app/assets/stylesheets/common/base/discourse.scss +++ b/app/assets/stylesheets/common/base/discourse.scss @@ -166,11 +166,6 @@ body { .avatar-wrapper { background-color: $secondary; display: inline-block; - border: 1px solid scale-color-diff(); - @include border-radius-all(5px); - img { - @include border-radius-all(4px); - } } .profiler-results.profiler-left { diff --git a/app/assets/stylesheets/common/base/user.scss b/app/assets/stylesheets/common/base/user.scss index 02e434710..4d09ac618 100644 --- a/app/assets/stylesheets/common/base/user.scss +++ b/app/assets/stylesheets/common/base/user.scss @@ -10,12 +10,8 @@ display: inline-block; color: $primary; } - .avatar-wrapper { - border: none; - } .avatar-link { margin-right: 3px; - } } diff --git a/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss b/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss index aa93d5fe1..7825a799b 100644 --- a/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss +++ b/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss @@ -2,7 +2,7 @@ border-left: 1px solid transparent; } -.topic-list-item.selected td:first-child, .topic-post.selected { +#topic-list tr.selected td:first-child, .topic-list-item.selected td:first-child, .topic-post.selected { border-left: 1px solid $danger; } diff --git a/app/assets/stylesheets/desktop/user.scss b/app/assets/stylesheets/desktop/user.scss index 5d6197238..8a141db55 100644 --- a/app/assets/stylesheets/desktop/user.scss +++ b/app/assets/stylesheets/desktop/user.scss @@ -331,7 +331,7 @@ } .avatar-link { float: left; - margin-right: 10px; + margin-right: 4px; } .title { display: block; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2a9b57bbc..49ae7ee3d 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1837,6 +1837,7 @@ en: share_post: '<b>s</b> Share post' reply_topic: '<b>shift r</b> Reply to topic' reply_post: '<b>r</b> Reply to post' + quote_post: '<b>q</b> Quote post' like: '<b>l</b> Like post' flag: '<b>!</b> Flag post' bookmark: '<b>b</b> Bookmark post'