From bb887964b16ea9cf0e1ced8005dfd990069c7400 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 29 May 2014 15:38:06 +1000 Subject: [PATCH 1/4] BUGFIX: j/k now goes to the suggested topic list correctly. --- .../components/keyboard_shortcuts_component.js | 16 ++++++++++++---- .../components/keyboard_shortcuts.css.scss | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js index 789538f04ec..7d9210be0b3 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 @@ -141,17 +141,25 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 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 +168,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/stylesheets/common/components/keyboard_shortcuts.css.scss b/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss index aa93d5fe182..7825a799b5d 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; } From 2d9db9ebc9471ad7760329241bbc84d2a8e460d3 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 29 May 2014 15:58:05 +1000 Subject: [PATCH 2/4] BUGFIX: j/k navigation was scrolling stuff in insane ways on first press --- .../keyboard_shortcuts_component.js | 22 ++++++++++++++++++- 1 file changed, 21 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 7d9210be0b3..0f89df1d6e8 100644 --- a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js +++ b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js @@ -133,11 +133,31 @@ 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') { From 4b4d775ad9696947cefe78f409a638360f38694c Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 29 May 2014 16:09:31 +1000 Subject: [PATCH 3/4] Add quote post --- .../components/keyboard_shortcuts_component.js | 11 ++++++++++- .../modal/keyboard_shortcuts_help.js.handlebars | 1 + config/locales/client.en.yml | 1 + 3 files changed, 12 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 0f89df1d6e8..55dd6c76f14 100644 --- a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js +++ b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js @@ -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'); }, 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 faf41abf574..b2e64bdddbf 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 @@
  • {{{i18n keyboard_shortcuts_help.actions.share_post}}}
  • {{{i18n keyboard_shortcuts_help.actions.reply_topic}}}
  • {{{i18n keyboard_shortcuts_help.actions.reply_post}}}
  • +
  • {{{i18n keyboard_shortcuts_help.actions.quote_post}}}
  • {{{i18n keyboard_shortcuts_help.actions.like}}}
  • {{{i18n keyboard_shortcuts_help.actions.flag}}}
  • {{{i18n keyboard_shortcuts_help.actions.bookmark}}}
  • diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2a9b57bbc70..49ae7ee3de7 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1837,6 +1837,7 @@ en: share_post: 's Share post' reply_topic: 'shift r Reply to topic' reply_post: 'r Reply to post' + quote_post: 'q Quote post' like: 'l Like post' flag: '! Flag post' bookmark: 'b Bookmark post' From 4d6ca00e2bdc6f69a8cf1c565795e38ef2cd8b2d Mon Sep 17 00:00:00 2001 From: Jeff Atwood Date: Wed, 28 May 2014 23:21:21 -0700 Subject: [PATCH 4/4] remove user page mini-avatar wrappers --- app/assets/stylesheets/common/base/discourse.scss | 5 ----- app/assets/stylesheets/common/base/user.scss | 4 ---- app/assets/stylesheets/desktop/user.scss | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scss index 98fda631472..e27ab13c2db 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 02e43471050..4d09ac6180f 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/desktop/user.scss b/app/assets/stylesheets/desktop/user.scss index 5d61972389f..8a141db558f 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;