diff options
| author | Hunternif | 2019-04-13 19:08:14 +0700 |
|---|---|---|
| committer | Hunternif | 2019-04-13 19:28:32 +0700 |
| commit | 55a7a96305dd9923f86f913ed4dea48b746685a1 (patch) | |
| tree | 0eac4a43aad495d6eccd7cb51399823754f04663 | |
| parent | 9a8f4e31046f197326cacbdd141b6abf07b2a078 (diff) | |
Add keyboard shortcuts for random post, focus tags input and save post
| -rw-r--r-- | client/html/help_keyboard.tpl | 21 | ||||
| -rw-r--r-- | client/js/controls/post_edit_sidebar_control.js | 11 | ||||
| -rw-r--r-- | client/js/views/post_main_view.js | 11 |
3 files changed, 38 insertions, 5 deletions
diff --git a/client/html/help_keyboard.tpl b/client/html/help_keyboard.tpl index f200ce0..5fe53b9 100644 --- a/client/html/help_keyboard.tpl +++ b/client/html/help_keyboard.tpl @@ -15,11 +15,21 @@ shortcuts:</p> </tr> <tr> + <td><kbd>P</kbd></td> + <td>Focus first post in post list</td> + </tr> + + <tr> <td><kbd>A</kbd> and <kbd>D</kbd>, <kbd>←</kbd> and <kbd>→</kbd></td> <td>Go to newer/older page or post</td> </tr> <tr> + <td><kbd>R</kbd></td> + <td>Go to random post</td> + </tr> + + <tr> <td><kbd>F</kbd></td> <td>Cycle post fit mode</td> </tr> @@ -30,13 +40,18 @@ shortcuts:</p> </tr> <tr> - <td><kbd>P</kbd></td> - <td>Focus first post in post list</td> + <td><kbd>T</kbd></td> + <td>(In edit mode) Focus tag input</td> + </tr> + + <tr> + <td><kbd>Command/Ctrl+S</kbd></td> + <td>(In edit mode) Save post</td> </tr> <tr> <td><kbd>Delete</kbd></td> - <td>Delete post (while in edit mode)</td> + <td>(In edit mode) delete post</td> </tr> </tbody> </table> diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index b920896..dd62355 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -67,7 +67,7 @@ class PostEditSidebarControl extends events.EventTarget { this._syncExpanderTitles(); if (this._formNode) { - this._formNode.addEventListener('submit', e => this._evtSubmit(e)); + this._formNode.addEventListener('submit', e => this.submit(e)); } if (this._tagInputNode) { @@ -319,7 +319,7 @@ class PostEditSidebarControl extends events.EventTarget { this._postNotesOverlayControl.switchToPassiveEdit(); } - _evtSubmit(e) { + submit(e) { e.preventDefault(); this.dispatchEvent(new CustomEvent('submit', { detail: { @@ -465,6 +465,13 @@ class PostEditSidebarControl extends events.EventTarget { showError(message) { views.showError(this._hostNode, message); } + + focusTagInput() { + const realTagInput = this._formNode.querySelector('.tag-input input'); + if (realTagInput) { + realTagInput.focus(); + } + } }; module.exports = PostEditSidebarControl; diff --git a/client/js/views/post_main_view.js b/client/js/views/post_main_view.js index 55b57cc..7718dea 100644 --- a/client/js/views/post_main_view.js +++ b/client/js/views/post_main_view.js @@ -81,11 +81,22 @@ class PostMainView { }); keyboard.bind(['a', 'left'], showPreviousImage); keyboard.bind(['d', 'right'], showNextImage); + keyboard.bind('r', showRandomImage); keyboard.bind('del', (e) => { if (ctx.editMode) { this.sidebarControl._evtDeleteClick(e); } }); + keyboard.bind('t', () => { + if (ctx.editMode) { + this.sidebarControl.focusTagInput(); + } + }); + keyboard.bind(['command+s', 'ctrl+s'], (e) => { + if (ctx.editMode) { + this.sidebarControl.submit(e); + } + }); new Touch( postContainerNode, |