From ed8d828ff129d65bb227ecdb61b7d0072b46e040 Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 08:04:57 -0400 Subject: [PATCH 1/8] FIX: Added keyboard bindings for dismiss buttons --- .../javascripts/discourse/lib/keyboard_shortcuts.js | 3 +++ .../templates/discovery/topics.js.handlebars | 12 ++++++------ .../templates/mobile/discovery/topics.js.handlebars | 6 +++--- .../modal/keyboard_shortcuts_help.js.handlebars | 7 +++++-- config/locales/client.en.yml | 3 +++ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index 991879ba00e..d1b7cdca070 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -35,6 +35,9 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular '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 + 'd n': '#dismiss-new', // dismiss new + 'd t': '#dismiss-topics', // dismiss topics + 'd p': '#dismiss-posts', // dismiss posts 'n': '#user-notifications', // open notifications menu 'o,enter': '.topic-list tr.selected a.title', // open selected topic 'shift+r': '#topic-footer-buttons button.create', // reply to topic diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars index 92e101e158c..d88a9976c8c 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars @@ -1,11 +1,11 @@ {{#if showDismissAtTop}}
{{#if showDismissRead}} - - + + {{/if}} {{#if showResetNew}} - + {{/if}}
{{/if}} @@ -83,11 +83,11 @@ {{/if}} {{#if allLoaded}} {{#if showDismissRead}} - - + + {{/if}} {{#if showResetNew}} - + {{/if}} {{#if latest}} diff --git a/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars b/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars index a76edca8621..2dcbabe56f8 100644 --- a/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/mobile/discovery/topics.js.handlebars @@ -29,11 +29,11 @@ {{/if}} {{#if allLoaded}} {{#if showDismissRead}} - - + + {{/if}} {{#if showResetNew}} - + {{/if}} {{#if latest}} 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 76617712dce..44d08a74ce2 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 @@ -10,8 +10,6 @@
  • {{{i18n keyboard_shortcuts_help.jump_to.starred}}}
  • {{{i18n keyboard_shortcuts_help.jump_to.categories}}}
  • - -

    {{i18n keyboard_shortcuts_help.navigation.title}}

    +
    +

    {{i18n keyboard_shortcuts_help.application.title}}

    diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7fe3c5299ce..2aab846cdd7 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2058,6 +2058,9 @@ en: user_profile_menu: 'p Open user profile menu' search: '/ Search' help: '? Open keyboard shortcuts help' + dismiss_new: 'd, n Dismiss New' + dismiss_topics: 'd, t Dismiss Topics' + dismiss_posts: 'd, p Dismiss Posts' actions: title: 'Actions' star: 'f Star topic' From e4ce995369a8cacc7c8b4d57e713c15524eba17d Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 08:11:23 -0400 Subject: [PATCH 2/8] FIX: Changed Dismiss New and Dismiss Posts to use d + r because p is reserved for the profile menu and n is reserved for the notifications menu --- app/assets/javascripts/discourse/lib/keyboard_shortcuts.js | 3 +-- .../templates/modal/keyboard_shortcuts_help.js.handlebars | 3 +-- config/locales/client.en.yml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index d1b7cdca070..fd7194730a7 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -35,9 +35,8 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular '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 - 'd n': '#dismiss-new', // dismiss new + 'd r': '#dismiss-new, #dismiss-posts', // dismiss new/posts 'd t': '#dismiss-topics', // dismiss topics - 'd p': '#dismiss-posts', // dismiss posts 'n': '#user-notifications', // open notifications menu 'o,enter': '.topic-list tr.selected a.title', // open selected topic 'shift+r': '#topic-footer-buttons button.create', // reply to topic 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 44d08a74ce2..7077f227c80 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 @@ -28,9 +28,8 @@
  • {{{i18n keyboard_shortcuts_help.application.user_profile_menu}}}
  • {{{i18n keyboard_shortcuts_help.application.search}}}
  • {{{i18n keyboard_shortcuts_help.application.help}}}
  • -
  • {{{i18n keyboard_shortcuts_help.application.dismiss_new}}}
  • +
  • {{{i18n keyboard_shortcuts_help.application.dismiss_new_posts}}}
  • {{{i18n keyboard_shortcuts_help.application.dismiss_topics}}}
  • -
  • {{{i18n keyboard_shortcuts_help.application.dismiss_posts}}}
  • diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2aab846cdd7..f53ec58ffe4 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2058,9 +2058,8 @@ en: user_profile_menu: 'p Open user profile menu' search: '/ Search' help: '? Open keyboard shortcuts help' - dismiss_new: 'd, n Dismiss New' + dismiss_new_posts: 'd, r Dismiss New/Posts' dismiss_topics: 'd, t Dismiss Topics' - dismiss_posts: 'd, p Dismiss Posts' actions: title: 'Actions' star: 'f Star topic' From 9e72b97a7563b07f1a16387e44aee0f7e4d48231 Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 08:33:45 -0400 Subject: [PATCH 3/8] Corrected an issue with using the same ID for the header/footer of the buttons --- .../discourse/lib/keyboard_shortcuts.js | 22 +++++++++---------- .../templates/discovery/topics.js.handlebars | 6 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index fd7194730a7..2bb38350e4a 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -31,17 +31,17 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ // star topic 'f': '#topic-footer-buttons button.star, .topic-list tr.topic-list-item.selected a.star', - 'm m': 'div.notification-options li[data-id="0"] a', // mark topic as muted - 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular - '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 - 'd r': '#dismiss-new, #dismiss-posts', // dismiss new/posts - 'd t': '#dismiss-topics', // dismiss topics - 'n': '#user-notifications', // open notifications menu - 'o,enter': '.topic-list tr.selected a.title', // open selected topic - 'shift+r': '#topic-footer-buttons button.create', // reply to topic - 'shift+s': '#topic-footer-buttons button.share', // share topic - 's': '.topic-post.selected a.post-date' // share post + 'm m': 'div.notification-options li[data-id="0"] a', // mark topic as muted + 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular + '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 + 'd r': '#dismiss-new,#dismiss-new-top,#dismiss-posts,#dismiss-posts-top', // dismiss new/posts + 'd t': '#dismiss-topics,#dismiss-topics-top', // dismiss topics + 'n': '#user-notifications', // open notifications menu + 'o,enter': '.topic-list tr.selected a.title', // open selected topic + 'shift+r': '#topic-footer-buttons button.create', // reply to topic + 'shift+s': '#topic-footer-buttons button.share', // share topic + 's': '.topic-post.selected a.post-date' // share post }, FUNCTION_BINDINGS: { diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars index d88a9976c8c..134c7699e2a 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/topics.js.handlebars @@ -1,11 +1,11 @@ {{#if showDismissAtTop}}
    {{#if showDismissRead}} - - + + {{/if}} {{#if showResetNew}} - + {{/if}}
    {{/if}} From ede9d1e057fa495eb2f7bb6c7dac77b1a4120249 Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 08:46:35 -0400 Subject: [PATCH 4/8] Change the Dismiss keybindings to use 'x' instead of 'd' --- app/assets/javascripts/discourse/lib/keyboard_shortcuts.js | 4 ++-- config/locales/client.en.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index 2bb38350e4a..22b02f42b86 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -35,8 +35,8 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular '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 - 'd r': '#dismiss-new,#dismiss-new-top,#dismiss-posts,#dismiss-posts-top', // dismiss new/posts - 'd t': '#dismiss-topics,#dismiss-topics-top', // dismiss topics + 'x r': '#dismiss-new,#dismiss-new-top,#dismiss-posts,#dismiss-posts-top', // dismiss new/posts + 'x t': '#dismiss-topics,#dismiss-topics-top', // dismiss topics 'n': '#user-notifications', // open notifications menu 'o,enter': '.topic-list tr.selected a.title', // open selected topic 'shift+r': '#topic-footer-buttons button.create', // reply to topic diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index f53ec58ffe4..b805cb4b98c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2058,8 +2058,8 @@ en: user_profile_menu: 'p Open user profile menu' search: '/ Search' help: '? Open keyboard shortcuts help' - dismiss_new_posts: 'd, r Dismiss New/Posts' - dismiss_topics: 'd, t Dismiss Topics' + dismiss_new_posts: 'x, r Dismiss New/Posts' + dismiss_topics: 'x, t Dismiss Topics' actions: title: 'Actions' star: 'f Star topic' From 3f085c3fd3242b8d7b2ee48111d290f1bf64960f Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 09:22:47 -0400 Subject: [PATCH 5/8] Change the Dismiss keybindings to use 'x' instead of 'd' --- app/assets/javascripts/discourse/lib/keyboard_shortcuts.js | 1 + .../templates/modal/keyboard_shortcuts_help.js.handlebars | 1 + config/locales/client.en.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index 473f9d14e57..a4321fe55d2 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -35,6 +35,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular '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 + '.': '.alert .alert-info .clickable', // show incoming topics 'n': '#user-notifications', // open notifications menu '=': '#site-map', // open site map menu 'p': '#current-user', // open current user menu 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 76617712dce..2ac870f2cac 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 @@ -27,6 +27,7 @@
  • {{{i18n keyboard_shortcuts_help.application.site_map_menu}}}
  • {{{i18n keyboard_shortcuts_help.application.user_profile_menu}}}
  • {{{i18n keyboard_shortcuts_help.application.search}}}
  • +
  • {{{i18n keyboard_shortcuts_help.application.show_incoming_updated}}}
  • {{{i18n keyboard_shortcuts_help.application.help}}}
  • diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7fe3c5299ce..1edf950b220 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2056,6 +2056,7 @@ en: notifications: 'n Open notifications' site_map_menu: '= Open site map menu' user_profile_menu: 'p Open user profile menu' + show_incoming_updated: '. Show incoming/updated topics' search: '/ Search' help: '? Open keyboard shortcuts help' actions: From cde64580b14ea2e69f782004cede231d2530906c Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 09:35:38 -0400 Subject: [PATCH 6/8] Change the Dismiss keybindings to use 'x' instead of 'd' - moved it to a function binding --- app/assets/javascripts/discourse/lib/keyboard_shortcuts.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index a4321fe55d2..79e5d71b64a 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -35,7 +35,6 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'm r': 'div.notification-options li[data-id="1"] a', // mark topic as regular '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 - '.': '.alert .alert-info .clickable', // show incoming topics 'n': '#user-notifications', // open notifications menu '=': '#site-map', // open site map menu 'p': '#current-user', // open current user menu @@ -55,6 +54,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ '`': 'nextSection', '~': 'prevSection', '/': 'showSearch', + '.': 'showIncomingUpdatedTopics', // show incoming topics 'ctrl+f': 'showBuiltinSearch', 'command+f': 'showBuiltinSearch', '?': 'showHelpModal', // open keyboard shortcut help @@ -134,6 +134,11 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ } }, + showIncomingUpdatedTopics: function() { + $('.alert .alert-info .clickable').click(); + return false; + }, + toggleProgress: function() { Discourse.__container__.lookup('controller:topic-progress').send('toggleExpansion', {highlight: true}); }, From 80cb8f3a96251c934d299fa3fb16e7e4d10ef6b9 Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 17:54:50 -0400 Subject: [PATCH 7/8] Fixed qunit test assertion --- test/javascripts/components/keyboard-shortcuts-test.js.es6 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/javascripts/components/keyboard-shortcuts-test.js.es6 b/test/javascripts/components/keyboard-shortcuts-test.js.es6 index cb290355c95..e08e582cfc9 100644 --- a/test/javascripts/components/keyboard-shortcuts-test.js.es6 +++ b/test/javascripts/components/keyboard-shortcuts-test.js.es6 @@ -46,6 +46,8 @@ module("Discourse.KeyboardShortcuts", { " ", " ", " ", + " ", + " ", "", "", "
    ", From bc07bc481925946fc4e7ef8310bf811d37323023 Mon Sep 17 00:00:00 2001 From: cpradio Date: Fri, 29 Aug 2014 18:19:06 -0400 Subject: [PATCH 8/8] Remove incoming/updated topics logic (not sure how that got in here, but it is causing a conflict) --- app/assets/javascripts/discourse/lib/keyboard_shortcuts.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index 79e5d71b64a..473f9d14e57 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -54,7 +54,6 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ '`': 'nextSection', '~': 'prevSection', '/': 'showSearch', - '.': 'showIncomingUpdatedTopics', // show incoming topics 'ctrl+f': 'showBuiltinSearch', 'command+f': 'showBuiltinSearch', '?': 'showHelpModal', // open keyboard shortcut help @@ -134,11 +133,6 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ } }, - showIncomingUpdatedTopics: function() { - $('.alert .alert-info .clickable').click(); - return false; - }, - toggleProgress: function() { Discourse.__container__.lookup('controller:topic-progress').send('toggleExpansion', {highlight: true}); },